VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 32
声望: 0

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

Member
avatar
加入于:
帖子: 4622
声望: 284

开多开空平多平空。DIRECTION是多空方向,offset是开平。

Member
avatar
加入于:
帖子: 32
声望: 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
加入于:
帖子: 4622
声望: 284

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

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

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】