| | |
| | | |
| | | def subscribe_codes(self, codes_sh, codes_sz): |
| | | # 重新订阅代码 |
| | | print(f"订阅数量:sh-{len(codes_sh)} sz-{len(codes_sz)}") |
| | | if codes_sh: |
| | | ret = self.__api.SubscribeMarketData(codes_sh, xmdapi.TORA_TSTP_EXD_SSE) |
| | | if ret != 0: |
| | | print('SubscribeMarketData fail, ret[%d]' % ret) |
| | | # print('SubscribeMarketData fail, ret[%d]' % ret) |
| | | pass |
| | | else: |
| | | print('SubscribeMarketData success, ret[%d]' % ret) |
| | | # print('SubscribeMarketData success, ret[%d]' % ret) |
| | | pass |
| | | |
| | | if codes_sz: |
| | | ret = self.__api.SubscribeMarketData(codes_sz, xmdapi.TORA_TSTP_EXD_SZSE) |
| | | if ret != 0: |
| | | print('SubscribeMarketData fail, ret[%d]' % ret) |
| | | # print('SubscribeMarketData fail, ret[%d]' % ret) |
| | | pass |
| | | else: |
| | | print('SubscribeMarketData success, ret[%d]' % ret) |
| | | # print('SubscribeMarketData success, ret[%d]' % ret) |
| | | pass |
| | | |
| | | def OnRspUserLogin(self, pRspUserLoginField, pRspInfoField, nRequestID): |
| | | if pRspInfoField.ErrorID == 0: |
| | | print('Login success! [%d]' % nRequestID) |
| | | # print('Login success! [%d]' % nRequestID) |
| | | |
| | | ''' |
| | | 订阅行情 |
| | |
| | | |
| | | |
| | | else: |
| | | print('Login fail!!! [%d] [%d] [%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | pass |
| | | # print('Login fail!!! [%d] [%d] [%s]' |
| | | # % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | |
| | | def OnRspSubMarketData(self, pSpecificSecurityField, pRspInfoField): |
| | | if pRspInfoField.ErrorID == 0: |
| | | print('OnRspSubMarketData: OK!') |
| | | # print('OnRspSubMarketData: OK!') |
| | | pass |
| | | else: |
| | | print('OnRspSubMarketData: Error! [%d] [%s]' |
| | | % (pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | # print('OnRspSubMarketData: Error! [%d] [%s]' |
| | | # % (pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | pass |
| | | |
| | | def OnRspUnSubMarketData(self, pSpecificSecurityField, pRspInfoField): |
| | | if pRspInfoField.ErrorID == 0: |
| | | print('OnRspUnSubMarketData: OK!') |
| | | # print('OnRspUnSubMarketData: OK!') |
| | | pass |
| | | else: |
| | | print('OnRspUnSubMarketData: Error! [%d] [%s]' |
| | | % (pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | pass |
| | | # print('OnRspUnSubMarketData: Error! [%d] [%s]' |
| | | # % (pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | |
| | | def OnRtnMarketData(self, pMarketDataField): |
| | | if pMarketDataField.SecurityName.find("S") == 0: |