experiments integrating mwfin
This commit is contained in:
parent
711e24d244
commit
d0aedfc21f
0
src/mw_stockfin/__init__.py
Normal file
0
src/mw_stockfin/__init__.py
Normal file
6
src/mw_stockfin/apps.py
Normal file
6
src/mw_stockfin/apps.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class MwStockfinConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'mw_stockfin'
|
33
src/mw_stockfin/functions.py
Normal file
33
src/mw_stockfin/functions.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from django_stockfin_db.models import FinancialPosition, ReportingPeriod, Company, Figure
|
||||||
|
|
||||||
|
from mwfin import get_balance_sheet
|
||||||
|
from mwfin.functions import ResultDict, RowData
|
||||||
|
|
||||||
|
|
||||||
|
def end_date_to_reporting_period(date_str: str) -> ReportingPeriod:
|
||||||
|
"""Convert an end date string into parameters for a ReportingPeriod, `get_or_create` the object and return it."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def get_or_create_position(name: str, parent_position: FinancialPosition = None) -> FinancialPosition:
|
||||||
|
return FinancialPosition.objects.get_or_create(name=name, parent=parent_position)
|
||||||
|
|
||||||
|
|
||||||
|
def data_row_to_figures(company: Company, position: FinancialPosition, data: RowData):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def save_single_result_dict(fin_stmt: str, symbol: str, result_dict: ResultDict):
|
||||||
|
company = Company.objects.get_or_create(symbol=symbol)
|
||||||
|
|
||||||
|
|
||||||
|
def result_dicts_to_db(fin_stmt: str, **data: ResultDict):
|
||||||
|
for symbol, result_dict in data.items():
|
||||||
|
save_single_result_dict(fin_stmt, symbol, result_dict)
|
||||||
|
|
||||||
|
|
||||||
|
async def main(*symbols: str):
|
||||||
|
data = await get_balance_sheet(*symbols)
|
||||||
|
if len(symbols) == 1:
|
||||||
|
save_single_result_dict('BS', symbols[0], data)
|
||||||
|
result_dicts_to_db('BS', **data)
|
Loading…
Reference in New Issue
Block a user