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

查询持仓总是返回none #268

Open
beardao opened this issue Mar 15, 2024 · 5 comments
Open

查询持仓总是返回none #268

beardao opened this issue Mar 15, 2024 · 5 comments

Comments

@beardao
Copy link

beardao commented Mar 15, 2024

在连simnow测试时,明明有持仓,但是在on_tick下用self.app.center.get_position(self.local_symbol) 总是返回None,请问怎么解决?thx

@somewheve
Copy link
Member

麻烦提供下代码

@beardao
Copy link
Author

beardao commented Mar 18, 2024

非常感谢您的回复,用的就是您gitbook上范例类似的代码,主要是测试下单,查询持仓然后止损测试。

结果今天测试一切又正常了。周五测试时大部分时候一直是持仓返回None,有时返回的数据打印出来发现持仓手数有时还出现-1。。。。。

BTW:因为是初次使用CTP,想乘机请教您几个初级问题:
1.接下来我找期货公司申请穿透式认证测试,只是需要替换ctpbee_api的文件(我是linux,只需替换.so文件?),以及info的账户信息吗?还需要别的操作么?
2. 测试完了后,需要换回原来的ctpbee_api,还是继续用期货公司提供的?
非常感谢!!

@beardao
Copy link
Author

beardao commented Mar 18, 2024

比如会打印出这样的持仓,short那部分肯定不对,这是发生在我平空头仓位,然后又开了多头仓位后,打印position,出来这样:
{'exchange': 'SHFE', 'long_float_pnl': -10.0, 'long_frozen': 0, 'local_symbol': 'rb2405.SHFE', 'long_open_price': 3499.0000000000005, 'long_pnl': -10, 'long_price': 3499.0000000000005, 'symbol': 'rb2405', 'long_volume': 1, 'long_yd_volume': 0, 'short_float_pnl': 34980.00000000001, 'short_frozen': 0, 'short_open_price': 0, 'short_pnl': 34980, 'short_price': 0, 'short_volume': -1, 'short_yd_volume': -1}

@somewheve
Copy link
Member

somewheve commented Mar 18, 2024

对的替换so文件,以及账户信息啥的 测试完需要切回原来的ctpbee

这个可能是simnow的问题 。

@beardao
Copy link
Author

beardao commented Mar 18, 2024

好的,了解,非常感谢您的回复。
有可能是simnow的问题,不过我同时在无限易模拟终端查看时,那里显示持仓却很正常(主要是用这个终端来查看ctpbee报单,撤单,成交是否正常,互相验证)。
anyway,等换到期货公司的前置后看看是否有问题再看,再次感谢!

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