vn.py量化社区
By Traders, For Traders.
Member
avatar
加入于:
帖子: 12
声望: 0

策略里常用的BUY,SELL,SHORT,COVER函数分别有什么作用,其参数DIRECTION和offset是什么含义

Member
avatar
加入于:
帖子: 520
声望: 24

开多开空平多平空。DIRECTION是多空方向,offset是开平。
基础架构和策略编写在【vn.py全实战进阶 - CTA策略】中有详细讲解,可以通过【vnpy-community】微信公众号订阅。

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

Offset的OPEN是开,CLOSE是平?
def buy(self, price: float, volume: float, stop: bool = False, lock: bool = False):
"""
Send buy order to open a long position.
"""
return self.send_order(Direction.LONG, Offset.OPEN, price, volume, stop, lock)

def sell(self, price: float, volume: float, stop: bool = False, lock: bool = False):
    """
    Send sell order to close a long position.
    """
    return self.send_order(Direction.SHORT, Offset.CLOSE, price, volume, stop, lock)

def short(self, price: float, volume: float, stop: bool = False, lock: bool = False):
    """
    Send short order to open as short position.
    """
    return self.send_order(Direction.SHORT, Offset.OPEN, price, volume, stop, lock)

def cover(self, price: float, volume: float, stop: bool = False, lock: bool = False):
    """
    Send cover order to close a short position.
    """
    return self.send_order(Direction.LONG, Offset.CLOSE, price, volume, stop, lock)

那为什么SELL函数里Offset参数值为CLOSE,不应该是OPEN吗

Member
avatar
加入于:
帖子: 520
声望: 24

开多平多开空平空,抱歉看错顺序了

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