Skip to content

Commit

Permalink
improve jq meta recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
foolcage committed Jan 15, 2020
1 parent 189f45b commit 9422bd6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion zvt/recorders/joinquant/meta/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from zvt.recorders.joinquant.meta.china_stock_meta_recorder import *
from zvt.recorders.joinquant.meta.stock_trade_day_recorder import *
19 changes: 14 additions & 5 deletions zvt/recorders/joinquant/meta/china_stock_meta_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
from zvt.recorders.joinquant.common import to_entity_id


class JqChinaStockMetaRecorder(Recorder):
class BaseJqChinaMetaRecorder(Recorder):
provider = 'joinquant'
data_schema = Etf

def __init__(self, batch_size=10, force_update=False, sleeping_time=10) -> None:
super().__init__(batch_size, force_update, sleeping_time)
Expand Down Expand Up @@ -41,6 +40,10 @@ def to_zvt_entity(self, df, entity_type, category=None):

return df


class JqChinaStockRecorder(BaseJqChinaMetaRecorder):
data_schema = Stock

def run(self):
# 抓取股票列表
df_stock = self.to_zvt_entity(get_all_securities(['stock']), entity_type='stock')
Expand All @@ -49,13 +52,19 @@ def run(self):
self.logger.info(df_stock)
self.logger.info("persist stock list success")

logout()


class JqChinaEtfRecorder(BaseJqChinaMetaRecorder):
data_schema = Etf

def run(self):
# 抓取etf列表
df_index = self.to_zvt_entity(get_all_securities(['etf']), entity_type='etf', category='etf')
df_to_db(df_index, data_schema=Etf, provider=self.provider)

self.logger.info(df_index)
self.logger.info("persist etf list success")

logout()


Expand Down Expand Up @@ -110,8 +119,8 @@ def record(self, entity, start, end, size, timestamps):
return None


__all__ = ['JqChinaStockMetaRecorder', 'JqChinaStockEtfPortfolioRecorder']
__all__ = ['JqChinaStockRecorder', 'JqChinaEtfRecorder', 'JqChinaStockEtfPortfolioRecorder']

if __name__ == '__main__':
JqChinaStockMetaRecorder().run()
JqChinaStockRecorder().run()
# JqChinaStockEtfPortfolioRecorder(codes=SAMPLE_ETF_CODES).run()
2 changes: 2 additions & 0 deletions zvt/recorders/joinquant/meta/stock_trade_day_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def record(self, entity, start, end, size, timestamps):
df_to_db(df=df, data_schema=self.data_schema, provider=self.provider, force_update=self.force_update)


__all__ = ['StockTradeDayRecorder']

if __name__ == '__main__':
r = StockTradeDayRecorder()
r.run()

0 comments on commit 9422bd6

Please sign in to comment.