private void PlaceOrder(OrderMode orderMode, decimal price)
        {
            int quantity = _config.LotSize;

            if (_oldOrderMode.HasValue && _oldOrderMode.Value == orderMode)
            {
                return;
            }

            var reversal = _reversalMultiplier.Where(s => s.Key <= _countOfContiniousExecutionInOneDirection).OrderByDescending(s => s.Key).FirstOrDefault();

            if (reversal.Value != 0)
            {
                quantity = (_config.LotSize * reversal.Value) + Math.Abs(_currentOpenPosition);
            }
            else
            {
                quantity = _config.LotSize;
            }

            _countOfContiniousExecutionInOneDirection++;

            _oldOrderMode = orderMode;
            try
            {
                var orderResponse = _kite.PlaceOrder(_config.Exchange, _config.Symbol, orderMode.ToString(), quantity, Product: "MIS", OrderType: "MARKET");
                Events.RaiseStatusChangedEvent(_config.Exchange, _config.Symbol, orderMode + " order executed");
            }
            catch (Exception ex)
            {
            }
        }
        private bool PlaceCoverOrder(RangeBreakOutStockConfig stock, OrderMode mode, int quantity)
        {
            stock.StopLoss = mode == OrderMode.BUY ? stock.SellBreakOutPrice : stock.BuyBreakOutPrice;
            Dictionary <string, dynamic> orderResponse = new Dictionary <string, dynamic>();

            orderResponse = _kite.PlaceOrder(stock.Exchange, stock.Symbol, mode.ToString(), quantity, Product: Constants.PRODUCT_MIS, OrderType: Constants.ORDER_TYPE_MARKET, TriggerPrice: stock.StopLoss, Variety: stock.Variety, Validity: Constants.VALIDITY_DAY);
            if (orderResponse.Any(s => s.Key.ToLower() == "status" && s.Value.ToLower() == "success"))
            {
                stock.TargetPrice = null;
                string orderId = GetOrderId(orderResponse);
                Events.RaiseAskForOrderSubscriptionEvent(orderId, true);
                stock.ParentOrderId       = orderId;
                stock.LastOrderedQuantity = quantity;
                stock.ReversalNumber++;
                stock.OrderedQuantity = quantity;
                return(true);
            }
            else
            {
                return(true);
            }
        }