多头有仓位,如果需要平仓(或者减仓)的话,对应的操作应该是多头平仓吧?为什么在vnpy中是空头平仓?
多头有仓位,如果需要平仓(或者减仓)的话,对应的操作应该是多头平仓吧?为什么在vnpy中是空头平仓?
这个日常买卖语言和程序逻辑不搭配,没必要一定mapping 上,只要看看下面代码,注意Direction和Offset就可以
   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)