From c197d08d67d48a3acc159a33793031d79ce3781f Mon Sep 17 00:00:00 2001 From: Tommaso Verzegnassi Date: Mon, 29 May 2023 12:00:54 +0200 Subject: [PATCH] new charts --- stockingly-frontend/src/api/index.ts | 10 ++++++++++ stockingly-frontend/src/views/Comparison.vue | 4 ++++ stockingly.py | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/stockingly-frontend/src/api/index.ts b/stockingly-frontend/src/api/index.ts index 146e14a..364cad3 100644 --- a/stockingly-frontend/src/api/index.ts +++ b/stockingly-frontend/src/api/index.ts @@ -38,6 +38,12 @@ export interface BalanceSheet { total_debt: number; } +export interface Eps { + [ticker: string]: string | number; // really just number + quarter: string; + +} + export const getCompanies = (tickers?: string[]): Promise => fetch(BACKEND_URL + '/companies' + (tickers ? ('/' + tickers.join('/')) : '')) .then(r => r.json()) @@ -54,3 +60,7 @@ export const getPriceHistory = (tickers: string[]): Promise => export const getBalanceSheet = (tickers: string[]): Promise => fetch(BACKEND_URL + '/assets_debts/' + tickers.join('/')).then(r=>r.json()) + + +export const getEps = (tickers: string[]): Promise => + fetch(BACKEND_URL + '/eps/' + tickers.join('/').toUpperCase()).then(r => r.json()) \ No newline at end of file diff --git a/stockingly-frontend/src/views/Comparison.vue b/stockingly-frontend/src/views/Comparison.vue index 425802a..84d2615 100644 --- a/stockingly-frontend/src/views/Comparison.vue +++ b/stockingly-frontend/src/views/Comparison.vue @@ -51,6 +51,9 @@ + + + @@ -84,6 +87,7 @@ import { defineLoader } from '@/api/loader'; import CompanyCard from '@/components/CompanyCard.vue'; import EmployeesChart from '@/components/EmployeesChart.vue'; import BalanceSheet from '@/components/BalanceSheet.vue'; +import EpsChart from '@/components/EpsChart.vue'; const route = useRoute(); const router = useRouter(); diff --git a/stockingly.py b/stockingly.py index bebb8b7..500f6ce 100644 --- a/stockingly.py +++ b/stockingly.py @@ -9,6 +9,7 @@ import os import sys import subprocess from typing import Optional +from backend.api.eps import get_eps ROOT_DIR: str = os.path.dirname(__file__) @@ -57,6 +58,11 @@ def get_company_logo(ticker: str): return send_from_directory(ROOT_DIR, 'company_generic.svg') +@app.route('/eps/', methods=['GET']) +def eps(tickers: Optional[str]) -> object: + return jsonify(get_eps(tickers.split('/'))) + + if __name__ == '__main__': if len(sys.argv) < 2 or sys.argv[1] != 'no-frontend': build_frontend()