def placeSLOrder(trade):
   oip = OrderInputParams(trade.tradingSymbol)
   oip.direction = Direction.SHORT if trade.direction == Direction.LONG else Direction.LONG 
   oip.productType = trade.productType
   oip.orderType = OrderType.SL_MARKET
   oip.triggerPrice = trade.stopLoss
   oip.qty = trade.qty
   try:
     trade.slOrder = TradeManager.getOrderManager().placeOrder(oip)
   except Exception as e:
     logging.error('TradeManager: Failed to place SL order for tradeID %s: Error => %s', trade.tradeID, str(e))
     return False
   logging.info('TradeManager: Successfully placed SL order %s for tradeID %s', trade.slOrder.orderId, trade.tradeID)
   return True
Beispiel #2
0
    def placeSLOrder(trade):
        oip = OrderInputParams(trade.tradingSymbol)
        oip.direction = Direction.SHORT if trade.direction == Direction.LONG else Direction.LONG
        oip.productType = trade.productType
        oip.orderType = OrderType.SL_MARKET
        oip.triggerPrice = Utils.roundToNSEPrice(trade.entry + trade.entry *
                                                 trade.slPercentage / 100)
        oip.qty = trade.qty
        if trade.isFutures == True or trade.isOptions == True:
            oip.isFnO = True
        try:
            trade.slOrder = TradeManager.getOrderManager().placeOrder(oip)
        except Exception as e:
            logging.error(
                'TradeManager: Failed to place SL order for tradeID %s: Error => %s',
                trade.tradeID, str(e))
            return False

        message = "TradeManager: Successfully placed SL order {0} for tradeID {1}".format(
            trade.slOrder.orderId, trade.tradeID)
        Utils.sendMessageTelegramBot(message)
        logging.info(message)
        return True