vn.py官网
开源量化社区
Member
avatar
加入于:
帖子: 68
声望: 0

OKEX,策略下单后POS一直是0导致策略无法自动平仓,只能手动平仓,火币里同样策略却正常运行

Member
avatar
加入于:
帖子: 470
声望: 25

请问是什么交易品种和手数?提供一下具体的报错截图。

Member
avatar
加入于:
帖子: 68
声望: 0

ETH-USDT-SWAP,1.0张换算成手是0.1手,没有报错信息,就是POS一直为零

Member
avatar
加入于:
帖子: 470
声望: 25

请问pos为0是指策略里的pos为0吗,还是主界面显示为0?请贴一下具体截图。

Member
avatar
加入于:
帖子: 68
声望: 0

青青子荆 wrote:

请问pos为0是指策略里的pos为0吗,还是主界面显示为0?请贴一下具体截图。

description

description
为了快速有订单用的系统的教学策略双均线,界面和策略里都是为0

Member
avatar
加入于:
帖子: 68
声望: 0

if cross_over:
if self.pos == 0:
self.buy(bar.close_price, 1)
elif self.pos < 0:
self.cover(bar.close_price, 1)
self.buy(bar.close_price, 1)

    elif cross_below:
        if self.pos == 0:
            self.short(bar.close_price, 1)
        elif self.pos > 0:
            self.sell(bar.close_price, 1)
            self.short(bar.close_price, 1)


无法进入,POS>0里面进行逻辑判断平仓,只能在反交叉时候反向开新仓才把原来的仓位平了,然后这个单向持仓,SELL跟SHORT是一样的效果吗

Member
avatar
加入于:
帖子: 470
声望: 25

请问是模拟账户还是实盘账户?如果是模拟盘可能是模拟环境抽风了,如果是实盘账户请打印一下on_position传过来的数据。

Member
avatar
加入于:
帖子: 3115
声望: 181

下次请贴截图不要贴照片,从你图上看,主界面【持仓】栏应该是有数的是“x.0”,但是显示看不全只看到".0"。
description
如果策略的self.pos没有及时更新,请去vnpy.app.cta_strategy.engine下的process_trade_event函数逐行打印进行排查看看卡在哪了

Member
avatar
加入于:
帖子: 68
声望: 0

xiaohe wrote:

下次请贴截图不要贴照片,从你图上看,主界面【持仓】栏应该是有数的是“x.0”,但是显示看不全只看到".0"。
description
如果策略的self.pos没有及时更新,请去vnpy.app.cta_strategy.engine下的process_tradeevent函数逐行打印进行排查看看卡在哪了
打印具体的属性会的,这个函数的逐行打印不知道怎么打,见谅 -
-||

Member
avatar
加入于:
帖子: 68
声望: 0

青青子荆 wrote:

请问是模拟账户还是实盘账户?如果是模拟盘可能是模拟环境抽风了,如果是实盘账户请打印一下on_position传过来的数据。

description
是实盘的打印是这样的
Microsoft Windows [版本 10.0.14393]
(c) 2016 Microsoft Corporation。保留所有权利。

C:\Windows\system32>python -m vnstation
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_ciphersuites
qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.009509426550585
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.0568118814128866
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.1015705912563135
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.2372442207813037
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.1142657314179815
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.1727921873356991
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.0922007352942728
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.0420102328411758
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.0334123266924962
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.1620255023807204
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.1670917319842374
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.1667854991858349
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.1884984011924189
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.2216083641648311
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.1147328058845687
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.1201557929181035
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.0633695511539827
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl -0.0924609971762038
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.2676880951689327
symbol ETH-USDT-SWAP
exchange Exchange.OKEX
direction Direction.NET
volume 1.0
price 3965.95
pnl 0.441385845615605

Member
avatar
加入于:
帖子: 470
声望: 25

打印出来的结果volume是1.0,不是0,说明推送过来的没有错误。
建议去process_trade_event里进行打印排查。

Member
avatar
加入于:
帖子: 68
声望: 0

青青子荆 wrote:

打印出来的结果volume是1.0,不是0,说明推送过来的没有错误。
建议去process_trade_event里进行打印排查。
请问打印哪个变量

Member
avatar
加入于:
帖子: 50
声望: 0

description
我也遇到了这个问题,OKEX的策略发单且成交了,但是CTA界面的Pos还是0在,这个要怎么改

Member
avatar
加入于:
帖子: 470
声望: 25

石头2021 wrote:

青青子荆 wrote:

打印出来的结果volume是1.0,不是0,说明推送过来的没有错误。
建议去process_trade_event里进行打印排查。
请问打印哪个变量

打印trade.volume和strategy.pos。

© 2015-2019 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3

沪公网安备 31011502017034号