策略里常用的BUY,SELL,SHORT,COVER函数分别有什么作用,其参数DIRECTION和offset是什么含义
策略里常用的BUY,SELL,SHORT,COVER函数分别有什么作用,其参数DIRECTION和offset是什么含义
开多开空平多平空。DIRECTION是多空方向,offset是开平。
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吗
开多平多开空平空,抱歉看错顺序了