vnpy/binding/tests/test.py

83 lines
1.8 KiB
Python
Raw Normal View History

2019-01-21 09:48:00 +00:00
import os
import sys
2019-01-21 09:48:00 +00:00
print(sys.path)
print(os.environ)
import vnctp # noqa
from vnctp import (
CThostFtdcTraderApi,
CThostFtdcTraderSpi,
CThostFtdcRspAuthenticateField,
CThostFtdcRspInfoField,
CThostFtdcRspUserLoginField,
CThostFtdcUserLogoutField,
) # noqa
2019-01-21 09:48:00 +00:00
print(vnctp)
print(dir(vnctp))
for i in dir(vnctp):
print(f"{i} : {vnctp.__dict__[i]}")
print("creating ctp api")
api = CThostFtdcTraderApi.CreateFtdcTraderApi("flow2")
print("creating ctp spi")
# pylint: disable=invalid-name
2019-01-21 09:48:00 +00:00
class Spi(CThostFtdcTraderSpi):
def OnFrontConnected(self) -> None:
print("OnFrontConnected!")
2019-01-21 09:48:00 +00:00
def OnFrontDisconnected(self, nReason: int) -> None:
print("OnFrontDisconnected!")
def OnRspAuthenticate(
self,
pRspAuthenticateField: CThostFtdcRspAuthenticateField,
pRspInfo: CThostFtdcRspInfoField,
nRequestID: int,
bIsLast: bool,
) -> None:
2019-01-21 09:48:00 +00:00
print("OnRspAuthenticate!")
def OnRspUserLogin(
self,
pRspUserLogin: CThostFtdcRspUserLoginField,
pRspInfo: CThostFtdcRspInfoField,
nRequestID: int,
bIsLast: bool,
) -> None:
2019-01-21 09:48:00 +00:00
print("OnRspUserLogin!")
def OnRspUserLogout(
self,
pUserLogout: CThostFtdcUserLogoutField,
pRspInfo: CThostFtdcRspInfoField,
nRequestID: int,
bIsLast: bool,
) -> None:
2019-01-21 09:48:00 +00:00
print("OnRspUserLogout!")
def OnRspError(
self, pRspInfo: CThostFtdcRspInfoField, nRequestID: int, bIsLast: bool
) -> None:
2019-01-21 09:48:00 +00:00
print("OnRspError!")
# pylint: enable=invalid-name
2019-01-21 09:48:00 +00:00
spi = Spi()
print("registering spi")
api.RegisterSpi(spi)
print("registering front")
api.RegisterFront("tcp://180.168.146.187:10030")
print("Init() ...")
api.Init()
print("Join() ...")
while True:
pass