Commit bbbf3b86 authored by 吕先亚's avatar 吕先亚

etf

parent 05c3b6dc
......@@ -251,7 +251,7 @@ class FundNavSync(JDCDataSync):
return None
querys = self._jdc_querys[datum['id']]
query_str = '&'.join([f'{x[0]}={quote(str(x[1]).encode())}' for x in querys.items()])
return f'http://jdcprod.thiztech.com/api/datas/asset-value?page={page}&size=200&startDate={format_date(start_date)}&{query_str}'
return f'http://jdcprod.thiztech.com/api/datas/index-value?page={page}&size=200&startDate={format_date(start_date)}&{query_str}'
def find_jdc_querys(self):
funds = self._datum.get_datums(type=DatumType.FUND, exclude=False)
......@@ -261,28 +261,28 @@ class FundNavSync(JDCDataSync):
} for x in funds if 'ftTicker' not in x and 'bloombergTicker' in x}
ft_tickers = {x['ftTicker']: x for x in funds if 'ftTicker' in x}
response = requests.get('http://jdcprod.thiztech.com/api/subject?busiField=TW&sourceType=TW&subjectType=FUND')
response = requests.get('http://jdcprod.thiztech.com/api/subject?sourceType=THS&subjectType=INDEX')
response = response.json()
if not response['success']:
raise CollectError(f'''find fund subject failed: {response['status']}''')
return {**urls, **{
ft_tickers[x['fundId']]['id']: {
ft_tickers[x['collectCode']]['id']: {
'subjectKeys': x['key'],
'sourceType': 'TW'
} for x in response['body']['content'] if x['fundId'] in ft_tickers
'sourceType': 'THS'
} for x in response['body']['content'] if x['collectCode'] in ft_tickers
}}
def store_date(self, datumid, datas: List[dict]):
save_navs = [{
'fund_id': datumid,
'nav_date': dt.fromtimestamp(x['date'] / 1000, tz=pytz.timezone('Asia/Shanghai')),
'av': x['originValue'],
'av': x['close'],
'div': x['dividend'] if 'dividend' in x else 0,
'split': x['split'] if 'split' in x else 1,
'accrue_split': x['totalSplit'] if 'totalSplit' in x else 1,
'av_p': x['postValue'],
'av_p': x['close'],
'div_p': x['postDividend'] if 'postDividend' in x else 0,
'nav_cal': x['calibrateValue']
'nav_cal': x['close']
} for x in datas if is_workday(dt.fromtimestamp(x['date'] / 1000, tz=pytz.timezone('Asia/Shanghai')))]
if save_navs:
rfn.batch_insert(save_navs)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment