Пример #1
0
        public void TriggerStopOrder(string instrument, EnmOrderTypes ordType, decimal amount)
        {
            if (EnmOrderTypes.BuyStop == ordType)
            {
                AddMarketOrder(instrument, /*Plaza2Connector.OrderDirection.Buy*/ EnmOrderDir.Buy, amount);
            }

            if (EnmOrderTypes.SellStop == ordType)
            {
                AddMarketOrder(instrument, /*Plaza2Connector.OrderDirection.Sell*/ EnmOrderDir.Sell, amount);
            }
        }
Пример #2
0
        /// <summary>
        /// Set TakePofit, StopLoss, StopLossInvert, BuyStop or SellStop
        ///
        ///
        ///
        /// Call from  TradersDispatcher.ProcessTypeOrder
        /// </summary>
        /// <param name="instrument"></param>
        /// <param name="orderType"></param>
        /// <param name="price"></param>
        /// <param name="amount"></param>
        public void SetTypeOrderByTrader(string instrument, EnmOrderTypes orderType, decimal price, decimal amount = 0)
        {
            if (!_subBots.ContainsKey(instrument))
            {
                return;
            }


            if (!IsAllowTraderActions(instrument))
            {
                return;
            }



            //TODO check bid ask here also
            //echoing respons for a while
            if (EnmOrderTypes.TakePofit == orderType)
            {
                //_traderInstrumentData[instrument].TakeProfit = price;

                _subBots[instrument].TakeProfitPrice = price;
                _subBots[instrument].Log("TakeProfitPrice=" + price);
                _tradersDispatcher.EnqueueAcceptStopLossTakeProfit(BotId, instrument, orderType, price);
            }
            if ((EnmOrderTypes.StopLoss == orderType))
            {
                _subBots[instrument].StopLossPrice = price;
                _subBots[instrument].Log("StopLossPrice=" + price);
                _tradersDispatcher.EnqueueAcceptStopLossTakeProfit(BotId, instrument, orderType, price);
            }
            if ((EnmOrderTypes.StopLossInvert == orderType))
            {
                _subBots[instrument].StopLossInvertPrice = price;
                _subBots[instrument].Log("StopLossInvertPrice=" + price);
                _tradersDispatcher.EnqueueAcceptStopLossTakeProfit(BotId, instrument, orderType, price);
            }
            if (EnmOrderTypes.BuyStop == orderType)
            {
                _subBots[instrument].BuyStopPrice  = price;
                _subBots[instrument].BuyStopAmount = amount;
                _subBots[instrument].Log("BuyStopPrice=" + price);
                _tradersDispatcher.EnqueueAcceptStopLossTakeProfit(BotId, instrument, orderType, price, amount);
            }
            if (EnmOrderTypes.SellStop == orderType)
            {
                _subBots[instrument].SellStopPrice  = price;
                _subBots[instrument].SellStopAmount = amount;
                _subBots[instrument].Log("SellStopPrice=" + price);
                _tradersDispatcher.EnqueueAcceptStopLossTakeProfit(BotId, instrument, orderType, price, amount);
            }
        }
Пример #3
0
        public void SendOrderType(int conId, string instrument, EnmOrderTypes stopLossTakeProfit, decimal price, decimal amount = 0)
        {
            enmTradingEvent ev  = enmTradingEvent.SetStoplossTakeProfit;
            CSetOrder       ssp = new CSetOrder
            {
                Instrument = instrument,
                Price      = price,
                OrderType  = stopLossTakeProfit,
                Amount     = amount
            };

            SendDataToServer(conId, ssp, ev);
        }
        public void EnqueueAcceptStopLossTakeProfit(int botID, string instrument, EnmOrderTypes stoplossTakeProfit, decimal price, decimal amount = 0)
        {
            if (IsConnected(botID))
            {
                int connId = _dictBotIdConnId[botID];

                _bqTraderData.Add(new CTradingData
                {
                    Data = (object)new CSetOrder {
                        Instrument = instrument, OrderType = stoplossTakeProfit, Price = price, Amount = amount
                    },
                    Event  = enmTradingEvent.StopLossTakeProfitAccepted,
                    ConnId = connId
                }
                                  );
            }
        }
 private void SendOrderType(EnmOrderTypes orderType, decimal price, decimal amount = 0)
 {
     _kernelTerminal.Communicator.SendOrderType(ConnId, TickerName, orderType, price, amount);
     Log("SendOrderType. TcikerName=" + TickerName + " orderType=" + orderType + " price=" + price + " amount=" + amount);
 }