forked from jasonweiyi/XAPI2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXSpi.py
More file actions
58 lines (43 loc) · 1.49 KB
/
Copy pathXSpi.py
File metadata and controls
58 lines (43 loc) · 1.49 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# import pydevd
from .XStruct import *
class XSpi(object):
def __init__(self):
pass
def OnConnectionStatus(self, status, pUserLogin, size1):
print(u'OnConnectionStatus={0}'.format(ConnectionStatus[status]))
if size1 > 0:
print(pUserLogin)
def OnRtnError(self, pError):
print(pError)
def OnLog(self, pLog):
print(pLog)
def OnRspQryInstrument(self, pInstrument, size1, bIsLast):
if size1 > 0:
print(pInstrument)
def OnRspQryTradingAccount(self, pAccount, size1, bIsLast):
if size1 > 0:
print(pAccount)
def OnRspQryInvestorPosition(self, pPosition, size1, bIsLast):
if size1 > 0:
print(pPosition)
def OnRspQryOrder(self, pOrder, size1, bIsLast):
if size1 > 0:
print(pOrder)
def OnRspQryInvestor(self, pInvestor, size1, bIsLast):
if size1 > 0:
print(pInvestor)
def OnRtnOrder(self, pOrder):
print(pOrder)
def OnRtnTrade(self, pTrade):
print(pTrade)
def OnRtnDepthMarketData(self, ptr1, size1):
# 这是从交易接口拿到的行情
obj = cast(ptr1, POINTER(DepthMarketDataNField)).contents
print(obj)
# 打印N档行情
for i in range(obj.get_ticks_count()):
p = ptr1 + sizeof(DepthMarketDataNField) + sizeof(DepthField) * i
d = cast(p, POINTER(DepthField)).contents
print(d)