forked from jasonweiyi/xapi_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallbacks.py
More file actions
192 lines (172 loc) · 6.47 KB
/
callbacks.py
File metadata and controls
192 lines (172 loc) · 6.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# -*- coding: utf-8 -*-
__author__ = 'Chunyou<snowtigersoft@126.com>'
class CallBacks:
"""
The class for all callbacks for both market and trading APIs.
Sub-class should redefine needed callbacks to implement customized behavior.
Note:
1. that some callbacks from the market API and trading API have the same name,
but we put them into different callbacks. See on_market_connected and on_trading_connected
as an example.
"""
def __init__(self):
pass
def on_market_connected(self, p_api, rsp_user_login, status):
"""
callback on market server connect status change
:param p_api: c_void_p
:param rsp_user_login: RspUserLoginField
:param status: ConnectionStatus int
:return:
"""
pass
def on_market_rsp_error(self, p_api, rsp_info, b_is_last):
"""
callback on market server when error occurred
:param p_api: c_void_p
:param rsp_info: ErrorField
:param b_is_last: boolean, True if it is the last response for this request
:return:
"""
pass
def on_market_rtn_depth_market_data_n(self, p_api, p_depth_market_data_n):
"""
callback on market server when receive market data
:param p_api: c_void_p
:param p_depth_market_data_n: DepthMarketDataNField
:return:
"""
pass
def on_trading_connected(self, p_api, rsp_user_login, status):
"""
callback on trading server connect status change
:param p_api: c_void_p
:param rsp_user_login: CThostFtdcRspUserLoginField
:param status: ConnectionStatus int
:return:
"""
pass
def on_trading_rsp_error(self, p_api, rsp_info, b_is_last):
"""
callback on trading server when error occurred
:param p_api: c_void_p
:param rsp_info: CThostFtdcRspInfoField
:param b_is_last: boolean, True if it is the last response for this request
:return:
"""
pass
def on_trading_rsp_qry_depth_market_data(self, p_api, depth_market_data, rsp_info, b_is_last):
"""
请求查询行情响应。当客户端发出请求查询行情指令后,交易托管系统返回响应时,该方法会被调用。
:param p_api: c_void_p
:param depth_market_data: CThostFtdcDepthMarketDataField
:param rsp_info: CThostFtdcRspInfoField
:param b_is_last: boolean, True if it is the last response for this request
:return:
"""
pass
def on_trading_rsp_qry_instrument(self, p_api, instrument, b_is_last):
"""
请求查询合约响应。当客户端发出请求查询合约指令后,交易托管系统返回响应时,该方法会被调用。
:param p_api: c_void_p
:param instrument: InstrumentField
:param b_is_last: boolean, True if it is the last response for this request
:return:
"""
pass
def on_trading_rsp_qry_investor_position(self, p_api, investor_position, b_is_last):
"""
投资者持仓查询应答。当客户端发出投资者持仓查询指令后,后交易托管系统返回响应时,该方法会被调用。
:param p_api: c_void_p
:param investor_position: PositionField
:param b_is_last: boolean, True if it is the last response for this request
:return:
"""
pass
def on_trading_rsp_qry_trading_account(self, p_api, trading_account, b_is_last):
"""
请求查询资金账户响应。当客户端发出请求查询资金账户指令后,交易托管系统返回响应时,该方法会被调用。
:param p_api: c_void_p
:param trading_account: AccountField
:param b_is_last: boolean, True if it is the last response for this request
:return:
"""
pass
def on_trading_rsp_qry_settlement_info(self, p_api, settlement_info, b_is_last):
"""
请求查询结算信息响应。当客户端发出请求查询结算信息指令后,交易托管系统返回响应时,该方法会被调用。
:param p_api: c_void_p
:param settlement_info: SettlementInfoField
:param b_is_last: boolean, True if it is the last response for this request
:return:
"""
pass
def on_trading_rtn_order(self, p_api, order):
"""
报单回报。当客户端进行报单录入、报单操作及其它原因(如部分成交)导致报单状态发生变化时,交易托管系统会主动通知客户端,该方法会被调用。
:param p_api: c_void_p
:param order: OrderField
"""
pass
def on_trading_rtn_trade(self, p_api, trade):
"""
成交回报。当发生成交时交易托管系统会通知客户端,该方法会被调用。
:param p_api: c_void_p
:param trade:TradeField
:return:
"""
pass
def on_trading_rtn_quote(self, p_api, quote):
"""
Quote
:param p_api: c_void_p
:param quote: QuoteField
"""
pass
def on_trading_rtn_quote_request(self, p_api, quote_request):
"""
Quote Request
:param p_api: c_void_p
:param quote_request: QuoteRequestField
"""
pass
def on_trading_rsp_qry_historical_ticks(self, p_api, tick, historical_data_request, b_is_last):
"""
Historical Data
:param p_api:
:param tick: TickField
:param historical_data_request: HistoricalDataRequestField
:param b_is_last:
:return:
"""
pass
def on_trading_rsp_qry_historical_bars(self, p_api, bar, historical_data_request, b_is_last):
"""
Historical Data
:param p_api:
:param bar: BarField
:param historical_data_request: HistoricalDataRequestField
:param b_is_last:
:return:
"""
pass
def on_trading_rsp_qry_investor(self, p_api, investor):
"""
Qry investor
:param p_api:
:param investor:
:return:
"""
pass
def on_trading_filter_subscribe(self, p_api, exchange, instrument_part1, instrument_part2, instrument_part3, pInstrument):
"""
Filter Subscribe
:param p_api:
:param exchange:
:param instrument_part1:
:param instrument_part2:
:param instrument_part3:
:param pInstrument:
:return:
"""
pass