Пример #1
0
        /// <summary>
        /// Sends Market Order on the given Order Execution Provider
        /// </summary>
        /// <param name="marketOrder">TradeHub MarketOrder</param>
        public void SendMarketOrder(MarketOrder marketOrder)
        {
            try
            {
                if (Logger.IsInfoEnabled)
                {
                    Logger.Info("Sending Market Order on Blackwood." + marketOrder, _type.FullName, "SendMarketOrder");
                }

                OrderSide tempSide    = BlackwoodTypeConvertor.OrderSideConvertor.GetBlackwoodOrderSide(marketOrder.OrderSide);
                TIMEOUT   tempTimeout = BlackwoodTypeConvertor.OrderTifConvertor.GetBlackwoodOrderTif(marketOrder.OrderTif);

                if (tempSide.Equals(ORDER_SIDE.NONE))
                {
                    Logger.Info("Invalid Order Side", _type.FullName, "SendMarketOrder");
                    return;
                }

                // Create Blackwood Order
                //BWOrder bwOrder = new BWOrder(_session, marketOrder.Security.Symbol, tempSide,
                //                              (uint)marketOrder.OrderSize, 0, 0,
                //                              ORDER_TYPE.MARKET, (int)tempTimeout, FEED_ID.NONE, false,
                //                              (uint)marketOrder.OrderSize);
                BWOrder bwOrder = new BWOrder(_session, marketOrder.Security.Symbol, tempSide,
                                              (uint)marketOrder.OrderSize, 0, OrderType.MARKET, (int)tempTimeout, FeedId.NONE, false,
                                              (uint)marketOrder.OrderSize);
                // Set OPG Venue
                DetermineAndSetTraderDestinationsMarket(bwOrder, marketOrder.Exchange);

                // Send Order to gateway
                bwOrder.Send();

                // Update Local IDs Map
                _localToBlackwoodIdsMap.TryAdd(marketOrder.OrderID, bwOrder.ClientOrderID.ToString());

                // Update BW-Orders Map
                _bwOrders.TryAdd(bwOrder.ClientOrderID.ToString(), bwOrder);

                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("BW-Order ID: " + bwOrder.OrderID + " | BW-ClientOrder ID: " + bwOrder.ClientOrderID,
                                 _type.FullName, "SendMarketOrder");
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "SendMarketOrder");
            }
        }
Пример #2
0
        /// <summary>
        /// Sends Limit Order on the given Order Execution Provider
        /// </summary>
        /// <param name="limitOrder">TradeHub LimitOrder</param>
        public void SendLimitOrder(LimitOrder limitOrder)
        {
            try
            {
                if (Logger.IsInfoEnabled)
                {
                    Logger.Info("Sending Limit Order on Blackwood." + limitOrder, _type.FullName, "SendLimitOrder");
                }

                OrderSide tempSide    = BlackwoodTypeConvertor.OrderSideConvertor.GetBlackwoodOrderSide(limitOrder.OrderSide);
                TIMEOUT   tempTimeout = BlackwoodTypeConvertor.OrderTifConvertor.GetBlackwoodOrderTif(limitOrder.OrderTif);

                if (tempSide.Equals(ORDER_SIDE.NONE))
                {
                    Logger.Info("Invalid Order Side", _type.FullName, "SendLimitOrder");
                    return;
                }

                // NOTE: FFED_ID is fixed to ARCA according to StockTrader code
                // Create Blackwood Order
                //BWOrder bwOrder = new BWOrder(_session, limitOrder.Security.Symbol, tempSide,
                //                              (uint)limitOrder.OrderSize, (double)limitOrder.LimitPrice, 0,
                //                              ORDER_TYPE.LIMIT, (int)tempTimeout, FEED_ID.ARCA, false,
                //                              (uint)limitOrder.OrderSize);
                BWOrder bwOrder = new BWOrder(_session, limitOrder.Security.Symbol, tempSide,
                                              (uint)limitOrder.OrderSize, (double)limitOrder.LimitPrice, 0, OrderType.LIMIT, (int)tempTimeout,
                                              FeedId.ARCA, false, (uint)limitOrder.OrderSize);

                // Send Order to gateway
                bwOrder.Send();

                // Update Local IDs Map
                _localToBlackwoodIdsMap.TryAdd(limitOrder.OrderID, bwOrder.ClientOrderID.ToString());

                // Update BW-Orders Map
                _bwOrders.TryAdd(bwOrder.ClientOrderID.ToString(), bwOrder);

                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("BW-Order ID: " + bwOrder.OrderID + " | BW-ClientOrder ID: " + bwOrder.ClientOrderID,
                                 _type.FullName, "SendLimitOrder");
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "SendLimitOrder");
            }
        }