Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tianhm opened this issue Jan 23, 2021 · 2 comments
Open

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

tianhm opened this issue Jan 23, 2021 · 2 comments

Comments

@tianhm
Copy link

tianhm commented Jan 23, 2021

错误信息如下:
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

@jimmylucky
Copy link

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

@tianhm
Copy link
Author

tianhm commented Jan 30, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants