예제 #1
0
    def placeOrder(self, orderInputParams):
        logging.info('%s: Going to place order with params %s', self.broker,
                     orderInputParams)
        kite = self.brokerHandle
        try:
            orderId = kite.place_order(
                variety=kite.VARIETY_REGULAR,
                exchange=kite.EXCHANGE_NSE,
                tradingsymbol=orderInputParams.tradingSymbol,
                transaction_type=self.convertToBrokerDirection(
                    orderInputParams.direction),
                quantity=orderInputParams.qty,
                price=orderInputParams.price,
                trigger_price=orderInputParams.triggerPrice,
                product=self.convertToBrokerProductType(
                    orderInputParams.productType),
                order_type=self.convertToBrokerOrderType(
                    orderInputParams.orderType))

            logging.info('%s: Order placed successfully, orderId = %s',
                         self.broker, orderId)
            order = Order(orderInputParams)
            order.orderId = orderId
            order.orderPlaceTimestamp = datetime.now()
            order.lastOrderUpdateTimestamp = datetime.now()

        except Exception as e:
            logging.info('%s Order placement failed: %s', self.broker, str(e))
            raise Exception(str(e))
    def placeOrder(self, orderInputParams):
        message = "{0}: Going to place order with params {1}".format(
            self.broker, orderInputParams)
        Utils.sendMessageTelegramBot(message)
        logging.info(message)
        kite = self.brokerHandle
        try:
            orderId = kite.place_order(
                variety=kite.VARIETY_REGULAR,
                exchange=kite.EXCHANGE_NFO
                if orderInputParams.isFnO == True else kite.EXCHANGE_NSE,
                tradingsymbol=orderInputParams.tradingSymbol,
                transaction_type=self.convertToBrokerDirection(
                    orderInputParams.direction),
                quantity=orderInputParams.qty,
                price=orderInputParams.price,
                trigger_price=orderInputParams.triggerPrice,
                product=self.convertToBrokerProductType(
                    orderInputParams.productType),
                order_type=self.convertToBrokerOrderType(
                    orderInputParams.orderType))

            message = "{0}: Order placed successfully, orderId {1}".format(
                self.broker, orderId)
            Utils.sendMessageTelegramBot(message)
            logging.info(message)
            order = Order(orderInputParams)
            order.orderId = orderId
            order.orderPlaceTimestamp = Utils.getEpoch()
            order.lastOrderUpdateTimestamp = Utils.getEpoch()
            return order
        except Exception as e:
            logging.info('%s Order placement failed: %s', self.broker, str(e))
            raise Exception(str(e))
예제 #3
0
 def testMisc():
     orderManager = ZerodhaOrderManager()
     sampleOrder = Order(orderInputParams=None)
     sampleOrder.orderId = '210505200078243'
     orders = []
     orders.append(sampleOrder)
     orderManager.fetchAndUpdateAllOrderDetails(orders)
 def convertJSONToOrder(jsonData):
   if jsonData == None:
     return None
   order = Order()
   order.tradingSymbol = jsonData['tradingSymbol']
   order.exchange = jsonData['exchange']
   order.productType = jsonData['productType']
   order.orderType = jsonData['orderType']
   order.price = jsonData['price']
   order.triggerPrice = jsonData['triggerPrice']
   order.qty = jsonData['qty']
   order.orderId = jsonData['orderId']
   order.orderStatus = jsonData['orderStatus']
   order.averagePrice = jsonData['averagePrice']
   order.filledQty = jsonData['filledQty']
   order.pendingQty = jsonData['pendingQty']
   order.orderPlaceTimestamp = jsonData['orderPlaceTimestamp']
   order.lastOrderUpdateTimestamp = jsonData['lastOrderUpdateTimestamp']
   order.message = jsonData['message']
   return order