def test_000778_spo_detial(): result = get_spo_detail(session=session, provider='eastmoney', return_type='domain', codes=['000778'], end_timestamp='2018-09-30', order=SpoDetail.timestamp.desc()) assert len(result) == 4 latest: SpoDetail = result[0] assert latest.timestamp == to_pd_timestamp('2017-04-01') assert latest.spo_issues == 347600000 assert latest.spo_price == 5.15 assert latest.spo_raising_fund == 1766000000
def on_finish(self): last_year = str(now_pd_timestamp().year) codes = [item.code for item in self.entities] need_filleds = get_dividend_financing( provider=self.provider, codes=codes, return_type='domain', session=self.session, filters=[DividendFinancing.spo_raising_fund.is_(None)], end_timestamp=last_year) for item in need_filleds: df = get_spo_detail( provider=self.provider, entity_id=item.entity_id, columns=[SpoDetail.timestamp, SpoDetail.spo_raising_fund], start_timestamp=item.timestamp, end_timestamp="{}-12-31".format(item.timestamp.year)) if df_is_not_null(df): item.spo_raising_fund = df['spo_raising_fund'].sum() self.session.commit() super().on_finish()