new charts

This commit is contained in:
Tommaso Verzegnassi 2023-05-29 12:00:54 +02:00
parent 379bf1abcd
commit c197d08d67
3 changed files with 20 additions and 0 deletions

View file

@ -38,6 +38,12 @@ export interface BalanceSheet {
total_debt: number; total_debt: number;
} }
export interface Eps {
[ticker: string]: string | number; // really just number
quarter: string;
}
export const getCompanies = (tickers?: string[]): Promise<Company[]> => export const getCompanies = (tickers?: string[]): Promise<Company[]> =>
fetch(BACKEND_URL + '/companies' + (tickers ? ('/' + tickers.join('/')) : '')) fetch(BACKEND_URL + '/companies' + (tickers ? ('/' + tickers.join('/')) : ''))
.then(r => r.json()) .then(r => r.json())
@ -54,3 +60,7 @@ export const getPriceHistory = (tickers: string[]): Promise<PriceHistory[]> =>
export const getBalanceSheet = (tickers: string[]): Promise<BalanceSheet[]> => export const getBalanceSheet = (tickers: string[]): Promise<BalanceSheet[]> =>
fetch(BACKEND_URL + '/assets_debts/' + tickers.join('/')).then(r=>r.json()) fetch(BACKEND_URL + '/assets_debts/' + tickers.join('/')).then(r=>r.json())
export const getEps = (tickers: string[]): Promise<Eps[]> =>
fetch(BACKEND_URL + '/eps/' + tickers.join('/').toUpperCase()).then(r => r.json())

View file

@ -51,6 +51,9 @@
<v-col cols="12"> <v-col cols="12">
<balance-sheet :colors="colors" :tickers="tickers" /> <balance-sheet :colors="colors" :tickers="tickers" />
</v-col> </v-col>
<v-col cols="12">
<eps-chart :colors="colors" :tickers="tickers" />
</v-col>
</v-row> </v-row>
</v-container> </v-container>
</template> </template>
@ -84,6 +87,7 @@ import { defineLoader } from '@/api/loader';
import CompanyCard from '@/components/CompanyCard.vue'; import CompanyCard from '@/components/CompanyCard.vue';
import EmployeesChart from '@/components/EmployeesChart.vue'; import EmployeesChart from '@/components/EmployeesChart.vue';
import BalanceSheet from '@/components/BalanceSheet.vue'; import BalanceSheet from '@/components/BalanceSheet.vue';
import EpsChart from '@/components/EpsChart.vue';
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();

View file

@ -9,6 +9,7 @@ import os
import sys import sys
import subprocess import subprocess
from typing import Optional from typing import Optional
from backend.api.eps import get_eps
ROOT_DIR: str = os.path.dirname(__file__) 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') return send_from_directory(ROOT_DIR, 'company_generic.svg')
@app.route('/eps/<path:tickers>', methods=['GET'])
def eps(tickers: Optional[str]) -> object:
return jsonify(get_eps(tickers.split('/')))
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2 or sys.argv[1] != 'no-frontend': if len(sys.argv) < 2 or sys.argv[1] != 'no-frontend':
build_frontend() build_frontend()