@@ -40,14 +40,14 @@ def __init__(self):
4040 self ._client = Client (self ._logger , ** dict (self ._config .items ('ShiPanE' )))
4141
4242 def start (self ):
43- self .__add_job ( self . __create_new_stock_purchase_job ())
44- self .__add_job ( self . __create_repo_job ())
45- self . __add_job ( self . __create_batch_job ())
46- self .__add_job ( self . __create_join_quant_following_job () )
47- self . __add_job ( self . __create_rice_quant_following_job ())
48- self .__add_job (self . __create_uqer_following_job () )
49- self . __add_job ( self . __create_guorn_sync_job ())
50- self .__add_job ( self . __create_join_quant_sync_job () )
43+ for section in self ._config . sections ():
44+ if not self .__is_job ( section ):
45+ continue
46+ job = self .__create_job ( section )
47+ if job is not None :
48+ self .__add_job (job )
49+ else :
50+ self ._logger . warning ( "[{}] is not a valid job" , section )
5151
5252 self ._scheduler .start ()
5353 print ('Press Ctrl+{0} to exit' .format ('Break' if os .name == 'nt' else 'C' ))
@@ -64,64 +64,80 @@ def __add_job(self, job):
6464 else :
6565 self ._logger .warning ('{} is not enabled' .format (job .name ))
6666
67- def __create_new_stock_purchase_job (self ):
68- section = 'NewStocks'
67+ def __create_job (self , section ):
68+ job_type = self ._config .get (section , 'type' )
69+ job = None
70+ if job_type == 'NewStocks' :
71+ job = self .__create_new_stock_purchase_job (section )
72+ elif job_type == 'Repo' :
73+ job = self .__create_repo_job (section )
74+ elif job_type == 'Batch' :
75+ job = self .__create_batch_job (section )
76+ elif job_type == 'JoinQuant' :
77+ job = self .__create_join_quant_following_job (section )
78+ elif job_type == 'RiceQuant' :
79+ job = self .__create_rice_quant_following_job (section )
80+ elif job_type == 'Uqer' :
81+ job = self .__create_uqer_following_job (section )
82+ elif job_type == 'Guorn' :
83+ job = self .__create_guorn_sync_job (section )
84+ elif job_type == 'JoinQuantArena' :
85+ job = self .__create_join_quant_sync_job (section )
86+ return job
87+
88+ def __create_new_stock_purchase_job (self , section ):
6989 options = self .__build_options (section )
7090 client_aliases = self .__filter_client_aliases (section )
71- return NewStockPurchaseJob (self ._client , client_aliases , '{}Job' .format (section ), ** options )
91+ return NewStockPurchaseJob (self ._client , client_aliases , '{}- Job' .format (section ), ** options )
7292
73- def __create_repo_job (self ):
74- section = 'Repo'
93+ def __create_repo_job (self , section ):
7594 options = self .__build_options (section )
7695 client_aliases = self .__filter_client_aliases (section )
77- return RepoJob (self ._client , client_aliases , '{}Job' .format (section ), ** options )
96+ return RepoJob (self ._client , client_aliases , '{}- Job' .format (section ), ** options )
7897
79- def __create_batch_job (self ):
80- section = 'Batch'
98+ def __create_batch_job (self , section ):
8199 options = self .__build_options (section )
82100 client_aliases = self .__filter_client_aliases (section )
83- return BatchJob (self ._client , client_aliases , '{}Job' .format (section ), ** options )
101+ return BatchJob (self ._client , client_aliases , '{}- Job' .format (section ), ** options )
84102
85- def __create_join_quant_following_job (self ):
86- section = 'JoinQuant'
103+ def __create_join_quant_following_job (self , section ):
87104 options = self .__build_options (section )
88105 client_aliases = self .__filter_client_aliases (section )
89106 quant_client = JoinQuantClient (** options )
90- return OnlineQuantFollowingJob (self ._client , quant_client , client_aliases , '{}FollowingJob' .format (section ),
107+ return OnlineQuantFollowingJob (self ._client , quant_client , client_aliases , '{}- FollowingJob' .format (section ),
91108 ** options )
92109
93- def __create_rice_quant_following_job (self ):
94- section = 'RiceQuant'
110+ def __create_rice_quant_following_job (self , section ):
95111 options = self .__build_options (section )
96112 client_aliases = self .__filter_client_aliases (section )
97113 quant_client = RiceQuantClient (** options )
98- return OnlineQuantFollowingJob (self ._client , quant_client , client_aliases , '{}FollowingJob' .format (section ),
114+ return OnlineQuantFollowingJob (self ._client , quant_client , client_aliases , '{}- FollowingJob' .format (section ),
99115 ** options )
100116
101- def __create_uqer_following_job (self ):
102- section = 'Uqer'
117+ def __create_uqer_following_job (self , section ):
103118 options = self .__build_options (section )
104119 client_aliases = self .__filter_client_aliases (section )
105120 quant_client = UqerClient (** options )
106- return OnlineQuantFollowingJob (self ._client , quant_client , client_aliases , '{}FollowingJob' .format (section ),
121+ return OnlineQuantFollowingJob (self ._client , quant_client , client_aliases , '{}- FollowingJob' .format (section ),
107122 ** options )
108123
109- def __create_guorn_sync_job (self ):
110- section = 'Guorn'
124+ def __create_guorn_sync_job (self , section ):
111125 options = self .__build_options (section )
112126 client_aliases = self .__filter_client_aliases (section )
113127 quant_client = GuornClient (** options )
114- return OnlineQuantSyncJob (self ._client , quant_client , client_aliases , '{}SyncJob' .format (section ),
128+ return OnlineQuantSyncJob (self ._client , quant_client , client_aliases , '{}- SyncJob' .format (section ),
115129 ** options )
116130
117- def __create_join_quant_sync_job (self ):
118- section = 'JoinQuantArena'
131+ def __create_join_quant_sync_job (self , section ):
119132 options = self .__build_options (section )
120133 client_aliases = self .__filter_client_aliases (section )
121134 quant_client = JoinQuantClient (** options )
122- return OnlineQuantSyncJob (self ._client , quant_client , client_aliases , '{}SyncJob' .format (section ),
135+ return OnlineQuantSyncJob (self ._client , quant_client , client_aliases , '{}- SyncJob' .format (section ),
123136 ** options )
124137
138+ def __is_job (self , section ):
139+ return self ._config .has_option (section , 'type' )
140+
125141 def __build_options (self , section ):
126142 if not self ._config .has_section (section ):
127143 return dict ()
0 commit comments