datahub_binary 1.7.10__cp312-cp312-win_amd64.whl → 1.7.12__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,50 +33,251 @@ class BaseStrategy:
33
33
  def strategy_id(self): ...
34
34
  @property
35
35
  def subscribed_topic(self): ...
36
- def subscribe(self, instrument_id: str, quote_type: QuoteType): ...
37
- def unsubscribe(self, instrument_id: str, quote_type: QuoteType): ...
38
- def on_init(self) -> None: ...
39
- def on_start(self) -> None: ...
40
- def on_stop(self) -> None: ...
41
- def on_order(self, event: client_msg.OrderEvent): ...
42
- def qry_instrument_req(self, instrument_id: str = None, basket_instrument_id: str = None, market_list: list[str] = ()) -> str: ...
43
- def on_qry_instrument_rsp(self, rsp: client_msg.QryInstrumentRsp): ...
44
- def qry_strategy_info_req(self, strategy_id: int) -> str: ...
45
- def on_qry_strategy_info_rsp(self, rsp: client_msg.QryStrategyInfoRsp): ...
46
- def qry_trade_req(self) -> str: ...
47
- def on_qry_trade_rsp(self, rsp: client_msg.QryTradesRsp): ...
48
- def qry_order_req(self, cl_order_id: str = None, order_id: str = None, is_active: int = 0) -> str: ...
49
- def on_qry_order_rsp(self, rsp: client_msg.QryOrdersRsp): ...
50
- def qry_strategy_posi_req(self) -> str: ...
51
- def on_qry_strategy_posi_rsp(self, rsp: client_msg.QryStrategyPositionRsp): ...
52
- def qry_book_stat_req(self, book_id: str = None) -> str: ...
53
- def on_qry_book_stat_rsp(self, rsp: client_msg.QryBookStatRsp): ...
54
- def qry_signal_kline_req(self, signal_id: int, start_date: datetime.date = None) -> str: ...
55
- def on_qry_signal_kline_rsp(self, rsp: client_msg.QrySignalKlineRsp): ...
56
- def qry_quote_req(self, instrument_id: str | None = None) -> str: ...
57
- def on_qry_quote_rsp(self, qry_quote_rsp: client_msg.QryQuoteRsp): ...
36
+ def subscribe(self, instrument_id: str, quote_type: QuoteType):
37
+ """
38
+ 订阅行情
39
+
40
+ :param instrument_id: 600519.XSHG
41
+ :param quote_type: 行情类型
42
+ :return:
43
+ """
44
+ def unsubscribe(self, instrument_id: str, quote_type: QuoteType):
45
+ """
46
+ 取消订阅行情
47
+
48
+ :param instrument_id: 600519.XSHG
49
+ :param quote_type: 行情类型
50
+ :return:
51
+ """
52
+ def on_init(self) -> None:
53
+ """
54
+ 回调函数, 收到初始化指令时调用
55
+
56
+ :return: None
57
+ """
58
+ def on_start(self) -> None:
59
+ """
60
+ 回调函数, 收到运行指令时调用
61
+
62
+ :return: None
63
+ """
64
+ def on_stop(self) -> None:
65
+ """
66
+ 回调函数, 收到停止指令时调用
67
+
68
+ :return: None
69
+ """
70
+ def on_order(self, event: client_msg.OrderEvent):
71
+ """
72
+ 回调函数, 收到订单事件时调用
73
+
74
+ :param event: OrderEvent消息
75
+ :return: None
76
+ """
77
+ def qry_instrument_req(self, instrument_id: str = None, basket_instrument_id: str = None, market_list: list[str] = ()) -> str:
78
+ """
79
+ 查询标的请求
80
+
81
+ :param instrument_id: 标的ID
82
+ :param basket_instrument_id: 篮子标的ID, 如: ETF标的id, 返回篮子成分
83
+ :param market_list: 市场标的列表,为空表示所有标的
84
+ :return: 请求ID
85
+ """
86
+ def on_qry_instrument_rsp(self, rsp: client_msg.QryInstrumentRsp):
87
+ """
88
+ 回调函数, 收到标的结果时调用
89
+
90
+ :param rsp: QryInstrumentRsp
91
+ :return: None
92
+ """
93
+ def qry_strategy_info_req(self, strategy_id: int) -> str:
94
+ """
95
+ 查询订单请求
96
+
97
+ :param strategy_id: 策略ID
98
+ :return: 请求ID
99
+ """
100
+ def on_qry_strategy_info_rsp(self, rsp: client_msg.QryStrategyInfoRsp):
101
+ """
102
+ 回调函数, 收到策略查询结果时调用
103
+
104
+ :param rsp: QryStrategyInfoRsp
105
+ :return: None
106
+ """
107
+ def qry_trade_req(self) -> str:
108
+ """
109
+ 查询成交请求
110
+
111
+ :return: 请求ID
112
+ """
113
+ def on_qry_trade_rsp(self, rsp: client_msg.QryTradesRsp):
114
+ """
115
+ 回调函数, 收到成交查询结果时调用
116
+
117
+ :param rsp: QryTradesRsp
118
+ :return: None
119
+ """
120
+ def qry_order_req(self, cl_order_id: str = None, order_id: str = None, is_active: int = 0) -> str:
121
+ """
122
+ 查询策略订单请求
123
+ // cl_order_id和order_id空时查全部
124
+ // cl_order_id或order_id不为空时不为空的做为查询条件
125
+ // cl_order_id和order_id都不为空时cl_order_id做为查询条件
126
+
127
+ :param cl_order_id: 本地委托号
128
+ :param order_id: 委托号
129
+ :param is_active: 是否仅查询在途委托,0已完成+在途;1仅在途
130
+ :return: 请求ID
131
+ """
132
+ def on_qry_order_rsp(self, rsp: client_msg.QryOrdersRsp):
133
+ """
134
+ 回调函数, 收到订单查询结果时调用
135
+
136
+ :param rsp: QryOrdersRsp
137
+ :return: None
138
+ """
139
+ def qry_strategy_posi_req(self) -> str:
140
+ """
141
+ 查询策略持仓请求
142
+
143
+ :return: 请求ID
144
+ """
145
+ def on_qry_strategy_posi_rsp(self, rsp: client_msg.QryStrategyPositionRsp):
146
+ """
147
+ 回调函数, 收到持仓查询结果时调用
148
+
149
+ :param rsp: QryPosiRsp
150
+ :return: None
151
+ """
152
+ def qry_book_stat_req(self, book_id: str = None) -> str:
153
+ """
154
+ 查询Book统计信息请求
155
+
156
+ :param book_id: book id
157
+ :return: 请求ID
158
+ """
159
+ def on_qry_book_stat_rsp(self, rsp: client_msg.QryBookStatRsp):
160
+ """
161
+ 回调函数, 收到Book统计信息结果时调用
162
+
163
+ :param rsp: QryBookStatRsp
164
+ :return: None
165
+ """
166
+ def qry_signal_kline_req(self, signal_id: int, start_date: datetime.date = None) -> str:
167
+ """
168
+ 查询信号K线请求
169
+
170
+ :param signal_id: 信号ID
171
+ :param start_date: 开始日期, 默认为当天
172
+ :return: 请求ID
173
+ """
174
+ def on_qry_signal_kline_rsp(self, rsp: client_msg.QrySignalKlineRsp):
175
+ """
176
+ 回调函数, 收到信号K线查询结果时调用
177
+
178
+ :param rsp: QrySignalKlineRsp
179
+ :return: None
180
+ """
181
+ def qry_quote_req(self, instrument_id: str | None = None) -> str:
182
+ """
183
+ 查询最新行情信息
184
+
185
+ :param instrument_id: 标的
186
+ :return: 请求ID
187
+ """
188
+ def on_qry_quote_rsp(self, qry_quote_rsp: client_msg.QryQuoteRsp):
189
+ """
190
+ 查询最新行情信息返回
191
+
192
+ :param qry_quote_rsp: 行情
193
+ :return:
194
+ """
58
195
  def qry_broker_posi_req(self) -> str: ...
59
196
  def on_qry_broker_posi_rsp(self, rsp: client_msg.QryBrokerPosiRsp): ...
60
197
  def qry_broker_fund_req(self) -> str: ...
61
198
  def on_qry_broker_fund_rsp(self, rsp: client_msg.QryBrokerFundRsp): ...
62
- def on_snapshot(self, snapshot: client_msg.MDSnapshot): ...
63
- def place_order(self, order: client_msg.PlaceOrder): ...
64
- def book_trade_req(self, trade: client_msg.BookTradeReq): ...
199
+ def on_snapshot(self, snapshot: client_msg.MDSnapshot):
200
+ """
201
+ 回调函数, 收到行情快照时调用
202
+
203
+ :param snapshot: MDSnapshot
204
+ :return: None
205
+ """
206
+ def place_order(self, order: client_msg.PlaceOrder):
207
+ """
208
+ 下单请求
209
+
210
+ :param order: 下单请求
211
+ :return: None
212
+ """
213
+ def book_trade_req(self, trade: client_msg.BookTradeReq):
214
+ """
215
+ 簿记成交
216
+
217
+ :param trade: 簿记
218
+ :return: None
219
+ """
65
220
  def on_book_trade_rsp(self, rsp: client_msg.BookTradeRsp): ...
66
- def on_trade_confirm(self, trade: client_msg.TradeConfirm): ...
67
- def on_order_reject(self, order: client_msg.OrderReject): ...
68
- def cancel_order(self, order: client_msg.CancelOrder): ...
69
- def cancel_all_order(self) -> None: ...
70
- def on_cancel_confirm(self, order: client_msg.CancelConfirm): ...
71
- def on_cancel_pending_confirm(self, order: client_msg.CancelPendingConfirm): ...
72
- def on_cancel_reject(self, order: client_msg.CancelReject): ...
221
+ def on_trade_confirm(self, trade: client_msg.TradeConfirm):
222
+ """
223
+ 回调函数, 收到成交确认时调用
224
+
225
+ :param trade: TradeConfirm
226
+ :return: None
227
+ """
228
+ def on_order_reject(self, order: client_msg.OrderReject):
229
+ """
230
+ 回调函数, 收到订单拒绝时调用
231
+
232
+ :param order: OrderReject
233
+ :return: None
234
+ """
235
+ def cancel_order(self, order: client_msg.CancelOrder):
236
+ """
237
+ 撤单请求
238
+
239
+ :param order: 撤单请求
240
+ :return: None
241
+ """
242
+ def cancel_all_order(self) -> None:
243
+ """
244
+ 全部撤单请求
245
+
246
+ :return: None
247
+ """
248
+ def on_cancel_confirm(self, order: client_msg.CancelConfirm):
249
+ """
250
+ 回调函数, 收到撤单确认时调用
251
+
252
+ :param order: 撤单确认
253
+ :return: None
254
+ """
255
+ def on_cancel_pending_confirm(self, order: client_msg.CancelPendingConfirm):
256
+ """
257
+ 回调函数, 收到正撤时调用
258
+
259
+ :param order: 正撤
260
+ :return: None
261
+ """
262
+ def on_cancel_reject(self, order: client_msg.CancelReject):
263
+ """
264
+ 回调函数, 收到撤单拒绝时调用
265
+
266
+ :param order: 撤单拒绝
267
+ :return: None
268
+ """
73
269
  def on_qry_sbl_list_rsp(self, rsp: client_msg.QrySblListRsp): ...
74
270
  def on_qry_lock_record_rsp(self, rsp: client_msg.QryLockRecordRsp): ...
75
271
  def on_lock_sbl_rsp(self, rsp: client_msg.LockSblRsp): ...
76
272
  def on_qry_lock_position_rsp(self, rsp: client_msg.QryLockPositionRsp): ...
77
273
  def update_strategy_param_req(self, req: client_msg.UpdateStrategyParamsReq): ...
78
274
  def on_update_strategy_params_rsp(self, rsp: client_msg.UpdateStrategyParamsRsp): ...
79
- def calc(self) -> None: ...
275
+ def calc(self) -> None:
276
+ """
277
+ 策略计算, 会按照 self.interval 设置的间隔定时调用
278
+
279
+ :return:
280
+ """
80
281
  def qry_sbl_list_req(self, sbl_ids: list[str]) -> str: ...
81
282
  def lock_sbl_req(self, instrument_id: str, sbl_id: str, lock_qty: int) -> str: ...
82
283
  def qry_lock_position_req(self) -> None: ...
datahub/datacache.pyi CHANGED
@@ -13,14 +13,22 @@ class UpdateLevel(Enum):
13
13
 
14
14
  class KVJsonDB:
15
15
  db_path: Incomplete
16
- def __init__(self, db_path: str) -> None: ...
17
- def set(self, key: str, value: Any): ...
18
- def get(self, key: str, default: Any | None = None) -> Any | None: ...
19
- def delete(self, key: str) -> bool: ...
20
- def all(self) -> dict[str, Any]: ...
21
- def all_keys(self) -> list[str]: ...
22
- def clear(self) -> None: ...
23
- def close(self) -> None: ...
16
+ def __init__(self, db_path: str) -> None:
17
+ """初始化基于文件系统的数据库"""
18
+ def set(self, key: str, value: Any):
19
+ """设置键值对"""
20
+ def get(self, key: str, default: Any | None = None) -> Any | None:
21
+ """获取指定键的值"""
22
+ def delete(self, key: str) -> bool:
23
+ """删除指定键"""
24
+ def all(self) -> dict[str, Any]:
25
+ """返回所有键值对"""
26
+ def all_keys(self) -> list[str]:
27
+ """返回所有键"""
28
+ def clear(self) -> None:
29
+ """清空数据库"""
30
+ def close(self) -> None:
31
+ """关闭数据库(在文件系统实现中不需要特别操作)"""
24
32
 
25
33
  class DataCache:
26
34
  prefix: Incomplete
@@ -30,33 +38,68 @@ class DataCache:
30
38
  datahub: Incomplete
31
39
  meta_db: Incomplete
32
40
  data_files: Incomplete
33
- def __init__(self, datahub: DataHub, data_path: str, prefix: str, update_cache: bool = False, cache_only: bool = False) -> None: ...
34
- def get_data_matrix(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame: ...
35
- def get_cache_filepath(self, trade_time: datetime) -> str: ...
36
- def update_datacache(self, filepath: str, df: pl.DataFrame, update_level: Sequence[UpdateLevel] = ()): ...
37
- def read_from_cache(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame: ...
38
- def sync_all_meta_info(self) -> None: ...
41
+ def __init__(self, datahub: DataHub, data_path: str, prefix: str, update_cache: bool = False, cache_only: bool = False) -> None:
42
+ """
43
+ 初始化数据缓存
44
+
45
+ :param datahub: Datahub实例
46
+ :param data_path: 数据目录
47
+ :param prefix: 数据文件前缀
48
+ :param update_cache: 是否刷新本地缓存
49
+ :param cache_only: 仅使用缓存, 缺失数据时会触发异常
50
+ """
51
+ def get_data_matrix(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame:
52
+ """获取数据矩阵,由子类实现"""
53
+ def get_cache_filepath(self, trade_time: datetime) -> str:
54
+ """生成缓存文件路径"""
55
+ def update_datacache(self, filepath: str, df: pl.DataFrame, update_level: Sequence[UpdateLevel] = ()):
56
+ """
57
+ 更新数据缓存
58
+
59
+ :param filepath: 文件路径
60
+ :param df: 数据
61
+ :param update_level: 更新级别
62
+ """
63
+ def read_from_cache(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame:
64
+ """
65
+ 从缓存读取数据,如果缓存不存在或不完整则从数据源获取
66
+
67
+ :param trade_time: 时间点
68
+ :param factors: 因子列表
69
+ :param instrument_ids: 标的列表
70
+ :return: DataFrame
71
+ """
72
+ def sync_all_meta_info(self) -> None:
73
+ """同步所有文件的元数据信息"""
39
74
  @staticmethod
40
- def f64_to_f32(df: pl.DataFrame) -> pl.DataFrame: ...
75
+ def f64_to_f32(df: pl.DataFrame) -> pl.DataFrame:
76
+ """float64 转 float32"""
41
77
  @staticmethod
42
- def get_missing_times(df: pl.DataFrame, intra_time_list: list[time]) -> list[time]: ...
78
+ def get_missing_times(df: pl.DataFrame, intra_time_list: list[time]) -> list[time]:
79
+ """获取缺失的时间点"""
43
80
  @staticmethod
44
- def get_missing_instruments(df: pl.DataFrame, instruments: list[str]) -> list[str]: ...
81
+ def get_missing_instruments(df: pl.DataFrame, instruments: list[str]) -> list[str]:
82
+ """获取缺失的标的"""
45
83
  @staticmethod
46
- def get_missing_factors(df: pl.DataFrame, factors: list[str]) -> list[str]: ...
84
+ def get_missing_factors(df: pl.DataFrame, factors: list[str]) -> list[str]:
85
+ """获取缺失的因子"""
47
86
 
48
87
  class FactorDataCache(DataCache):
49
- def get_data_matrix(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame: ...
88
+ def get_data_matrix(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame:
89
+ """获取因子数据矩阵"""
50
90
  def read_factor_from_cache(self, trade_time: datetime, factors: list[str], instrument_ids: list[str]) -> pl.DataFrame: ...
51
91
 
52
92
  class RiskFactorDataCache(DataCache):
53
93
  version: Incomplete
54
- def __init__(self, datahub: DataHub, version: str, data_path: str, prefix: str, update_cache: bool = False) -> None: ...
55
- def get_data_matrix(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame: ...
94
+ def __init__(self, datahub: DataHub, version: str, data_path: str, prefix: str, update_cache: bool = False) -> None:
95
+ """初始化风险因子数据缓存"""
96
+ def get_data_matrix(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame:
97
+ """获取风险因子数据矩阵"""
56
98
  def read_risk_factors_from_cache(self, trade_time: datetime, factors: list[str], instrument_ids: list[str]) -> pl.DataFrame: ...
57
99
 
58
100
  class ReturnDataCache(DataCache):
59
- def get_data_matrix(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame: ...
101
+ def get_data_matrix(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], **kwargs) -> pl.DataFrame:
102
+ """获取因子数据矩阵"""
60
103
  def read_return_from_cache(self, trade_time: datetime, factors: list[str], instrument_ids: list[str], adj_method: Literal['forward'] = 'forward') -> pl.DataFrame: ...
61
104
 
62
105
  class HFTFactorDataCache(DataCache):