huggingface112 commited on
Commit
687ad2b
1 Parent(s): 2899e7b

add schema for stocks_price table

Browse files
appComponents.py CHANGED
@@ -38,7 +38,7 @@ def create_portfolio_overview(df_list):
38
  ip_eval_df = p_eval_df.interactive()
39
  isector_eval_df = sector_eval_df.interactive()
40
 
41
- # TODO convert below to a class
42
  ranged_ip_eval_df = ip_eval_df[ip_eval_df.date.between(
43
  range_slider.param.value_start, range_slider.param.value_end)]
44
  ranged_isector_eval_df = isector_eval_df[isector_eval_df.date.between(
@@ -425,7 +425,6 @@ class DrawDownCard(Viewer):
425
  def calculate_drawdown(self):
426
  df = self.eval_df.copy()
427
  # rolling max return
428
- # TODO: consider adding this to the processing code
429
  df['rolling_max_return_p'] = df['portfolio_return_p'].rolling(
430
  window=len(df), min_periods=1).max()
431
  # calculate drawdown
 
38
  ip_eval_df = p_eval_df.interactive()
39
  isector_eval_df = sector_eval_df.interactive()
40
 
41
+
42
  ranged_ip_eval_df = ip_eval_df[ip_eval_df.date.between(
43
  range_slider.param.value_start, range_slider.param.value_end)]
44
  ranged_isector_eval_df = isector_eval_df[isector_eval_df.date.between(
 
425
  def calculate_drawdown(self):
426
  df = self.eval_df.copy()
427
  # rolling max return
 
428
  df['rolling_max_return_p'] = df['portfolio_return_p'].rolling(
429
  window=len(df), min_periods=1).max()
430
  # calculate drawdown
portfolioEditingPage.py CHANGED
@@ -3,8 +3,6 @@
3
  import panel as pn
4
  from utils import create_stocks_entry_from_excel, style_number, create_share_changes_report
5
  import datetime as dt
6
- import pytz
7
- import io
8
  from bokeh.models.widgets.tables import CheckboxEditor, NumberEditor, SelectEditor
9
  from utils import time_in_beijing
10
  import api
@@ -307,10 +305,9 @@ def app():
307
  floating_windows.append(floatpanel)
308
 
309
  def handle_sync_to_db(e):
310
- # TODO: change to use profile df instead, because tabulator might not contain all entry
311
  '''sync selected entry to db'''
312
  new_portfolio = portfolio_tabulator.value
313
- # TODO when initially df is empty, there is a 0 row in df as place holder
314
  # only update selected row to db
315
  selected_portfolio = new_portfolio[new_portfolio['sync_to_db']]
316
  successed = update_portfolio_profile_to_db(selected_portfolio)
 
3
  import panel as pn
4
  from utils import create_stocks_entry_from_excel, style_number, create_share_changes_report
5
  import datetime as dt
 
 
6
  from bokeh.models.widgets.tables import CheckboxEditor, NumberEditor, SelectEditor
7
  from utils import time_in_beijing
8
  import api
 
305
  floating_windows.append(floatpanel)
306
 
307
  def handle_sync_to_db(e):
308
+ # TODO: change to use profile df instead, because tabulator might not contain all entry (currently have no problem)
309
  '''sync selected entry to db'''
310
  new_portfolio = portfolio_tabulator.value
 
311
  # only update selected row to db
312
  selected_portfolio = new_portfolio[new_portfolio['sync_to_db']]
313
  successed = update_portfolio_profile_to_db(selected_portfolio)
script/processing.py CHANGED
@@ -151,7 +151,7 @@ def get_portfolio_evaluation(portfolio_stock, benchmark_stock, profile_df):
151
  return merged_df
152
 
153
 
154
- # TODO convert below to funciton
155
 
156
  def get_portfolio_sector_evaluation(portfolio_stock, benchmark_df):
157
  # aggregate on sector and day
 
151
  return merged_df
152
 
153
 
154
+
155
 
156
  def get_portfolio_sector_evaluation(portfolio_stock, benchmark_df):
157
  # aggregate on sector and day
table_schema.py CHANGED
@@ -26,3 +26,15 @@ STOCKS_DETAILS_TABLE_SCHEMA = {
26
  'sector': str,
27
  'aggregate_sector': str
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  'sector': str,
27
  'aggregate_sector': str
28
  }
29
+
30
+ STOCKS_PRICE_TABLE = 'stocks_price'
31
+ STOCKS_PRICE_TABLE = {
32
+ 'time': 'datetime64[ns]',
33
+ 'ticker': str,
34
+ 'open': float,
35
+ 'close': float,
36
+ 'high': float,
37
+ 'low': float,
38
+ 'volume': int,
39
+ 'money': float,
40
+ }