From fdd6fc3d72aeb6f09526ed1731e88219ca32c2c3 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Wed, 17 May 2023 12:20:19 +0200 Subject: [PATCH] Integrated metrics without color ranges --- backend/api/companies.py | 12 ++++++++ stockingly-frontend/package.json | 1 + stockingly-frontend/src/api/index.ts | 8 ++++-- stockingly-frontend/src/views/Home.vue | 39 ++++++++++++++++++-------- stockingly-frontend/yarn.lock | 5 ++++ 5 files changed, 52 insertions(+), 13 deletions(-) diff --git a/backend/api/companies.py b/backend/api/companies.py index a690b50..07da8a1 100644 --- a/backend/api/companies.py +++ b/backend/api/companies.py @@ -2,7 +2,10 @@ import os import pandas as pd import numpy as np from scraper.top100_extractor import programming_crime_list + COMPANIES_CSV_PATH: str = 'scraper/companies.csv' +COMPANY_DATA_CSV_PATH: str = 'Elaborated_Data/normalized_data.csv' + def non_nan(a: list[any]) -> list[any]: return list(filter(lambda a: type(a) == str or not np.isnan(a), a)) @@ -21,4 +24,13 @@ def get_companies(root_dir: str) -> list[dict]: del df['tag 1'] del df['tag 2'] del df['tag 3'] + + # Include company metrics + df_data = pd.read_csv(os.path.join(root_dir, COMPANY_DATA_CSV_PATH), index_col='Ticker') \ + .loc[:, ['Valuation', 'Financial Health', 'Estimated Growth', 'Past Performance']] + + # Compute limits of metrics + # print(df_data.agg([min, max]).to_dict('records')) + + df = df.join(df_data) return df.reset_index().replace({ np.nan: None }).to_dict('records') \ No newline at end of file diff --git a/stockingly-frontend/package.json b/stockingly-frontend/package.json index 2f9a9e3..7ce9d2e 100644 --- a/stockingly-frontend/package.json +++ b/stockingly-frontend/package.json @@ -14,6 +14,7 @@ "debounce": "^1.2.1", "fuse.js": "^6.6.2", "roboto-fontface": "*", + "round-to": "^6.0.0", "vue": "^3.2.0", "vue-router": "^4.0.0", "vuetify": "^3.2.3", diff --git a/stockingly-frontend/src/api/index.ts b/stockingly-frontend/src/api/index.ts index 61298e2..27a3c15 100644 --- a/stockingly-frontend/src/api/index.ts +++ b/stockingly-frontend/src/api/index.ts @@ -13,10 +13,14 @@ export interface Company { tags: string[]; ticker: string; website: string; - logoSrc: string + logoSrc: string; + 'Valuation': number; + 'Financial Health': number; + 'Estimated Growth': number; + 'Past Performance': number; } -export const getCompanies = (): Promise => +export const getCompanies = (): Promise => fetch(BACKEND_URL + '/companies').then(r => r.json()).then(list => list.map((e: Company) => ({ ...e, logoSrc: `${BACKEND_URL}/companies/logos/${e.ticker}` diff --git a/stockingly-frontend/src/views/Home.vue b/stockingly-frontend/src/views/Home.vue index 4e2132c..97dd4f4 100644 --- a/stockingly-frontend/src/views/Home.vue +++ b/stockingly-frontend/src/views/Home.vue @@ -88,6 +88,7 @@