ctpwrapper icon indicating copy to clipboard operation
ctpwrapper copied to clipboard

初始化下单数据是出现错误。

Open tianhm opened this issue 5 years ago • 2 comments

错误信息如下: F:>ipython Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] Type 'copyright', 'credits' or 'license' for more information IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import ctpwrapper.ApiStructure as apidata

In [2]: orderdata=apidata.InputOrderField()

TypeError Traceback (most recent call last) in ----> 1 orderdata=apidata.InputOrderField()

d:\miniconda3\lib\site-packages\ctpwrapper\ApiStructure.py in init(self, BrokerID, InvestorID, InstrumentID, OrderRef, UserID, OrderPriceType, Direction, CombOffsetFlag, CombHedgeFlag, LimitPrice, VolumeTotalOriginal, TimeCondition, GTDDate, VolumeCondition, MinVolume, ContingentCondition, StopPrice, ForceCloseReason, IsAutoSuspend, BusinessUnit, RequestID, UserForceClose, IsSwapOrder, ExchangeID, InvestUnitID, AccountID, CurrencyID, ClientID, IPAddress, MacAddress) 1626 self.OrderRef = self._to_bytes(OrderRef) 1627 self.UserID = self._to_bytes(UserID) -> 1628 self.OrderPriceType = self._to_bytes(OrderPriceType) 1629 self.Direction = self._to_bytes(Direction) 1630 self.CombOffsetFlag = self._to_bytes(CombOffsetFlag)

TypeError: one character bytes, bytearray or integer expected

tianhm avatar Jan 23 '21 02:01 tianhm

这里都要给str,看看是不是给了int

jimmylucky avatar Jan 28 '21 07:01 jimmylucky

跟踪了一下, init 里面给的是空字符串, 后来通过将数据类型c_char, 改成了c_char*1, 临时解决了。

tianhm avatar Jan 30 '21 13:01 tianhm