예제 #1
0
        void BreakoutStopLogic(object sender, OrderFilledEventArgs e)
        {
            Instrument inst = ((InstrumentTradeSubscription)sender).Instrument;

            tickerDB = TA.TickerConverters.ConvertFromTTAPIFields2DB(inst.Product.ToString(), inst.Name.ToString());

            if (e.Fill.BuySell == BuySell.Buy)
            {
                BreakoutPosition.OrderFill(tickerDB, e.Fill.Quantity);
            }

            else if (e.Fill.BuySell == BuySell.Sell)
            {
                BreakoutPosition.OrderFill(tickerDB, -e.Fill.Quantity);
            }

            if (e.FillType == FillType.Full)
            {
                Console.WriteLine("Order was fully filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);
            }
            else
            {
                Console.WriteLine("Order was partially filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);
            }

            //Console.WriteLine("Average Buy Price = {0} : Net Position = {1} : P&L = {2}", m_ts.ProfitLossStatistics.BuyAveragePrice,
            //   m_ts.ProfitLossStatistics.NetPosition, m_ts.ProfitLoss.AsPrimaryCurrency);
        }
        private void OnOrderFilled(object sender, OrderFilledEventArgs e)
        {
            var row = GetContractRow(e.Fill.Instrument);

            if (row != null)
            {
                row.ProcessMessage(e);
            }
        }
예제 #3
0
        void OrderFilledLogic(object sender, OrderFilledEventArgs e)
        {
            Instrument Inst = ((InstrumentTradeSubscription)sender).Instrument;

            TickerDB = TA.TickerConverters.ConvertFromTTAPIFields2DB(Inst.Product.ToString(), Inst.Name.ToString());
            string  TickerHead    = TA.TickerheadConverters.ConvertFromTT2DB(Inst.Product.ToString());
            decimal TradeQuantity = 0;

            if (e.Fill.BuySell == BuySell.Buy)
            {
                ScalperPosition.OrderFill(TickerDB, e.Fill.Quantity);
                TradeQuantity = e.Fill.Quantity;
            }


            else if (e.Fill.BuySell == BuySell.Sell)
            {
                ScalperPosition.OrderFill(TickerDB, -e.Fill.Quantity);
                TradeQuantity = -e.Fill.Quantity;
            }


            if (e.FillType == FillType.Full)
            {
                Console.WriteLine("Order was fully filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);

                if (e.Fill.SiteOrderKey == WorkingLongEntryOrderKey[TickerDB])
                {
                    WorkingLongEntryOrderKey[TickerDB] = "";
                }

                else if (e.Fill.SiteOrderKey == WorkingLongExitOrderKey[TickerDB])
                {
                    WorkingLongExitOrderKey[TickerDB] = "";
                }

                else if (e.Fill.SiteOrderKey == WorkingShortEntryOrderKey[TickerDB])
                {
                    WorkingShortEntryOrderKey[TickerDB] = "";
                }

                else if (e.Fill.SiteOrderKey == WorkingShortExitOrderKey[TickerDB])
                {
                    WorkingShortExitOrderKey[TickerDB] = "";
                }
            }
            else
            {
                Console.WriteLine("Order was partially filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);
            }

            TA.Strategy.LoadTrade2Strategy(ticker: TickerDB, trade_price: (decimal)TA.PriceConverters.FromTT2DB(ttPrice: Convert.ToDecimal(e.Fill.MatchPrice.ToString()),
                                                                                                                tickerHead: TickerHead), trade_quantity: TradeQuantity, instrument: "F", alias: "TS_Jan_2017", conn: conn);

            //Console.WriteLine("Average Buy Price = {0} : Net Position = {1} : P&L = {2}", m_ts.ProfitLossStatistics.BuyAveragePrice,
            //   m_ts.ProfitLossStatistics.NetPosition, m_ts.ProfitLoss.AsPrimaryCurrency);
        }
예제 #4
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>   Event notification for order fills. </summary>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 void m_instrumentTradeSubscription_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     if (e.FillType == tt_net_sdk.FillType.Full)
     {
         Console.WriteLine("\nOrderFullyFilled [{0}]: {1}@{2}", e.Fill.SiteOrderKey, e.Fill.Quantity, e.Fill.MatchPrice);
     }
     else
     {
         Console.WriteLine("\nOrderPartiallyFilled [{0}]: {1}@{2}", e.Fill.SiteOrderKey, e.Fill.Quantity, e.Fill.MatchPrice);
     }
 }
예제 #5
0
 private void OrderFilledEvent(OrderFilledEventArgs args)
 {
     if (args.OldOrder.Id == _limitOrderId)
     {
         _fillPrice.Add(args.NewOrder.LastFillPrice);
         _fillVolume.Add(args.NewOrder.LastFillVolume);
         Print($"Volume: {args.NewOrder.LastFillVolume}, price: {args.NewOrder.LastFillPrice}");
         if (args.NewOrder.RemainingVolume == 0)
         {
             Exit();
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Event notification for order filled
        /// </summary>
        void m_trd_OrderFilled(object sender, OrderFilledEventArgs e)
        {
            if (e.FillType == FillType.Full)
            {
                Console.WriteLine("Order was fully filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);
            }
            else
            {
                Console.WriteLine("Order was partially filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);
            }

            //e.Fill.InstrumentKey
            //Console.WriteLine("Average Buy Price = {0} : Net Position = {1} : P&L = {2}", m_ts.ProfitLossStatistics.BuyAveragePrice, m_ts.ProfitLossStatistics.NetPosition, m_ts.ProfitLoss.AsPrimaryCurrency);
        }
예제 #7
0
        /// <summary>
        /// Event notification for order filled
        /// </summary>
        void m_ts_OrderFilled(object sender, OrderFilledEventArgs e)
        {
            if (e.Fill.SiteOrderKey == m_orderKey)
            {
                // Our parent order has been filled
                Console.WriteLine("Our parent order has been " + (e.Fill.FillType == FillType.Full ? "fully" : "partially") + " filled");
            }
            else if (e.Fill.ParentKey == m_orderKey)
            {
                // A child order of our parent order has been filled
                Console.WriteLine("A child order of our parent order has been " + (e.Fill.FillType == FillType.Full ? "fully" : "partially") + " filled");
            }

            Console.WriteLine("Average Buy Price = {0} : Net Position = {1} : P&L = {2}", m_ts.ProfitLossStatistics.BuyAveragePrice,
                              m_ts.ProfitLossStatistics.NetPosition, m_ts.ProfitLoss.AsPrimaryCurrency);
        }
예제 #8
0
 /// <summary>
 /// OrderFilledEventArgs InstrumentTradeSubscription callback.
 /// </summary>
 /// <param name="sender">Sender (InstrumentTradeSubscription)</param>
 /// <param name="e">OrderFilledEventArgs</param>
 void m_instrumentTradeSubscription_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     if (e.NewOrder.SiteOrderKey == m_LastOrderSiteOrderKey)
     {
         if (e.FillType == FillType.Full)
         {
             txtSiteOrderKey.Text     = String.Empty;
             m_lastOrder              = null;
             gboModifyOrder.Enabled   = false;
             buttonDeleteLast.Enabled = false;
         }
         else
         {
             m_lastOrder = e.NewOrder;
         }
     }
 }
예제 #9
0
        public void OrderFilled()
        {
            var sec = new Security()
            {
                Id = 1, Type = SecurityType.Future, Group = "GC", Product = "GC", Contract = "GCZ6"
            };
            var book = new OrderBook(sec);

            book.SetStatus(SecurityTradingStatus.Open);

            OrderFilledEventArgs order1FilledArgs = null;
            OrderFilledEventArgs order2FilledArgs = null;

            book.OrderFilled += (sender, e) => { if (e.Order.Id == 1)
                                                 {
                                                     order1FilledArgs = e;
                                                 }
            };
            book.OrderFilled += (sender, e) => { if (e.Order.Id == 2)
                                                 {
                                                     order2FilledArgs = e;
                                                 }
            };

            book.CreateLimitOrder(1, TimeInForce.Day, null, Side.Buy, 100, 3);
            book.CreateLimitOrder(2, TimeInForce.Day, null, Side.Sell, 100, 5);

            Debug.Assert(order1FilledArgs != null);
            Debug.Assert(order1FilledArgs.Price == 100);
            Debug.Assert(order1FilledArgs.IsAggressor == false);
            Debug.Assert(order1FilledArgs.Quantity == 3);
            Debug.Assert(order1FilledArgs.Order.Id == 1);
            Debug.Assert(order1FilledArgs.Order.Status == OrderStatus.Filled);
            Debug.Assert(order1FilledArgs.Order.FilledQuantity == 3);
            Debug.Assert(order1FilledArgs.Order.RemainingQuantity == 0);

            Debug.Assert(order2FilledArgs != null);
            Debug.Assert(order2FilledArgs.Price == 100);
            Debug.Assert(order2FilledArgs.IsAggressor == true);
            Debug.Assert(order2FilledArgs.Quantity == 3);
            Debug.Assert(order2FilledArgs.Order.Id == 2);
            Debug.Assert(order2FilledArgs.Order.Status == OrderStatus.PartiallyFilled);
            Debug.Assert(order2FilledArgs.Order.FilledQuantity == 3);
            Debug.Assert(order2FilledArgs.Order.RemainingQuantity == 2);
        }
예제 #10
0
        void m_ts_OrderFilled(object sender, OrderFilledEventArgs e)
        {
            string  Tag         = e.Fill.OrderTag;
            int     RowIndex    = TagList.IndexOf(Tag);
            DataRow RelevantRow = SummaryTable.Rows[RowIndex];

            string Alias = RelevantRow.Field <string>("Alias");

            if (!TA.Strategy.CheckIfStrategyExist(alias: Alias, conn: conn))
            {
                TA.Strategy.GenerateDbStrategyFromAlias(alias: Alias, descriptionString: RelevantRow.Field <string>("DescriptionString"), conn: conn);
            }

            int TradeQuantity;

            if (e.Fill.BuySell == BuySell.Buy)
            {
                TradeQuantity = e.Fill.Quantity;
            }
            else
            {
                TradeQuantity = -e.Fill.Quantity;
            }

            if (e.Fill.IsAutospreaderSyntheticFill)
            {
                RelevantRow["Position"]        = RelevantRow.Field <int>("Position") + TradeQuantity;
                RelevantRow["WorkingOrders"]   = RelevantRow.Field <int>("WorkingOrders") - TradeQuantity;
                RelevantRow["WorkingOrderKey"] = "";
                return;
            }

            Instrument Inst = AutoSpreaderList[RowIndex].InstrumentDictionary[e.Fill.InstrumentKey];

            string TickerDB   = TA.TickerConverters.ConvertFromTTAPIFields2DB(Inst.Product.ToString(), Inst.Name.ToString());
            string TickerHead = TA.TickerheadConverters.ConvertFromTT2DB(Inst.Product.ToString());

            TA.Strategy.LoadTrade2Strategy(ticker: TickerDB, trade_price: (decimal)TA.PriceConverters.FromTT2DB(ttPrice: Convert.ToDecimal(e.Fill.MatchPrice.ToString()),
                                                                                                                tickerHead: TickerHead), trade_quantity: TradeQuantity, instrument: "F", alias: Alias, conn: conn);

            IFSLogger.Log(Alias + ": " + TradeQuantity.ToString() + " " + TickerDB + " for " + TA.PriceConverters.FromTT2DB(ttPrice: Convert.ToDecimal(e.Fill.MatchPrice.ToString()),
                                                                                                                            tickerHead: TickerHead).ToString());
        }
예제 #11
0
        void m_ts_OrderFilled(object sender, OrderFilledEventArgs e)
        {
            string Tag      = e.Fill.OrderTag;
            int    RowIndex = TagList.IndexOf(Tag);
            string Alias    = SummaryTable.Rows[RowIndex].Field <string>("Alias");

            //ASENameList[RowIndex].

            if (!TA.Strategy.CheckIfStrategyExist(alias: Alias, conn: conn))
            {
                TA.Strategy.GenerateDbStrategyFromAlias(alias: Alias, descriptionString: SummaryTable.Rows[RowIndex].Field <string>("DescriptionString"), conn: conn);
            }

            // ProducttKey and SeriesKey are seperately accesible

            if (e.Fill.IsAutospreaderSyntheticFill)
            {
                return;
            }

            Instrument Inst = AutoSpreaderList[RowIndex].InstrumentDictionary[e.Fill.InstrumentKey];

            string  TickerDB   = TA.TickerConverters.ConvertFromTTAPIFields2DB(Inst.Product.ToString(), Inst.Name.ToString());
            string  TickerHead = TA.TickerheadConverters.ConvertFromTT2DB(Inst.Product.ToString());
            decimal TradeQuantity;

            if (e.Fill.BuySell == BuySell.Buy)
            {
                TradeQuantity = e.Fill.Quantity;
            }
            else
            {
                TradeQuantity = -e.Fill.Quantity;
            }

            TA.Strategy.LoadTrade2Strategy(ticker: TickerDB, trade_price: (decimal)TA.PriceConverters.FromTT2DB(ttPrice: Convert.ToDecimal(e.Fill.MatchPrice.ToString()),
                                                                                                                tickerHead: TickerHead), trade_quantity: TradeQuantity, instrument: "F", alias: Alias, conn: conn);

            IFSLogger.Log(Alias + ": " + TradeQuantity.ToString() + " " + TickerDB + " for " + TA.PriceConverters.FromTT2DB(ttPrice: Convert.ToDecimal(e.Fill.MatchPrice.ToString()),
                                                                                                                            tickerHead: TickerHead).ToString());
        }
예제 #12
0
 /// <summary>
 /// Triggered when a new Order in the trade subscription gets filled
 /// </summary>
 void tradeSubscription_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     UpdateAuditLog("OrderFilled", e.NewOrder);
 }
예제 #13
0
 private void HandleOrderFilled(object sender, OrderFilledEventArgs args)
 {
     ordersToClients[args.Order.Id].Send(new Fill(args.Order, orderInfos[args.Order.Id], args.Time, args.Price, args.Quantity,
                                                  args.IsAggressor, args.Order.Status.HasFlag(Common.OrderStatus.Completed)));
 }
 void m_ts_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     string emre = "merve";
 }
예제 #15
0
        void BreakoutStopLogic(object sender, OrderFilledEventArgs e)
        {

            Instrument inst = ((InstrumentTradeSubscription)sender).Instrument;
            tickerDB = TA.TickerConverters.ConvertFromTTAPIFields2DB(inst.Product.ToString(), inst.Name.ToString());

            if (e.Fill.BuySell==BuySell.Buy)
                BreakoutPosition.OrderFill(tickerDB, e.Fill.Quantity);
              
            else if (e.Fill.BuySell == BuySell.Sell)
                BreakoutPosition.OrderFill(tickerDB, -e.Fill.Quantity);

            if (e.FillType == FillType.Full)
            {
                Console.WriteLine("Order was fully filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);
            }
            else
            {
                Console.WriteLine("Order was partially filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);
            }

            //Console.WriteLine("Average Buy Price = {0} : Net Position = {1} : P&L = {2}", m_ts.ProfitLossStatistics.BuyAveragePrice,
            //   m_ts.ProfitLossStatistics.NetPosition, m_ts.ProfitLoss.AsPrimaryCurrency);
        }
        /// <summary>
        /// Event notification for order filled
        /// </summary>
        void m_ts_OrderFilled(object sender, OrderFilledEventArgs e)
        {
            if (e.Fill.SiteOrderKey == m_orderKey)
            {
                // Our parent order has been filled
                Console.WriteLine("Our parent order has been " + (e.Fill.FillType == FillType.Full ? "fully" : "partially") + " filled");
            }
            else if (e.Fill.ParentKey == m_orderKey)
            {
                // A child order of our parent order has been filled
                Console.WriteLine("A child order of our parent order has been " + (e.Fill.FillType == FillType.Full ? "fully" : "partially") + " filled");
            }

            Console.WriteLine("Average Buy Price = {0} : Net Position = {1} : P&L = {2}", m_ts.ProfitLossStatistics.BuyAveragePrice,
                m_ts.ProfitLossStatistics.NetPosition, m_ts.ProfitLoss.AsPrimaryCurrency);
        }
 void m_ts_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     string emre = "merve";
 }
예제 #18
0
 private void PositionManager_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     string message = "Filled " + e.Trade.Size + " @" + e.Trade.Price + " for order " + e.Trade.Order.ToString();
     _systemLogger.Log(OutputSeverityLevel.Informational, "ActivityLogger", e.Position.Symbol, message);
 }
 /// <summary>
 /// OrderFilledEventArgs InstrumentTradeSubscription callback.
 /// </summary>
 /// <param name="sender">Sender (InstrumentTradeSubscription)</param>
 /// <param name="e">OrderFilledEventArgs</param>
 void m_instrumentTradeSubscription_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     if (e.NewOrder.SiteOrderKey == m_LastOrderSiteOrderKey)
     {
         if (e.FillType == FillType.Full)
         {
             txtSiteOrderKey.Text = String.Empty;
             m_lastOrder = null;
             gboModifyOrder.Enabled = false;
             buttonDeleteLast.Enabled = false;
         }
         else
         {
             m_lastOrder = e.NewOrder;
         }
     }
 }
예제 #20
0
        void m_ts_OrderFilled(object sender, OrderFilledEventArgs e)
        {

            string Tag = e.Fill.OrderTag;
            int RowIndex = TagList.IndexOf(Tag);
            string Alias = MarketPriceTable.Rows[RowIndex].Field<string>("Alias");

            //ASENameList[RowIndex].

            if (!TA.Strategy.CheckIfStrategyExist(alias:Alias,conn:conn))
            {
                TA.Strategy.GenerateDbStrategyFromAlias(alias: Alias, descriptionString: MarketPriceTable.Rows[RowIndex].Field<string>("DescriptionString"), conn: conn);
            }

            // ProducttKey and SeriesKey are seperately accesible

            if (e.Fill.IsAutospreaderSyntheticFill)  
            {
                return;
            }

            Instrument Inst = AutoSpreaderList[RowIndex].InstrumentDictionary[e.Fill.InstrumentKey];

            string TickerDB = TA.TickerConverters.ConvertFromTTAPIFields2DB(Inst.Product.ToString(), Inst.Name.ToString());
            string TickerHead = TA.TickerheadConverters.ConvertFromTT2DB(Inst.Product.ToString());
            decimal TradeQuantity;

            if (e.Fill.BuySell==BuySell.Buy)
            {
                TradeQuantity = e.Fill.Quantity;
            }
            else
            {
                TradeQuantity = -e.Fill.Quantity;
            }

            TA.Strategy.LoadTrade2Strategy(ticker: TickerDB, trade_price: (decimal)TA.PriceConverters.FromTT2DB(ttPrice: Convert.ToDecimal(e.Fill.MatchPrice.ToString()),
                tickerHead: TickerHead), trade_quantity: TradeQuantity, instrument: "F", alias: Alias, conn: conn);

            IFSLogger.Log(Alias + ": " + TradeQuantity.ToString() + " " + TickerDB + " for " + TA.PriceConverters.FromTT2DB(ttPrice: Convert.ToDecimal(e.Fill.MatchPrice.ToString()),
                tickerHead: TickerHead).ToString());



            //e.Fill.Quantity

            //e.Fill.BuySell

            //e.Fill.MatchPrice

                






            //tickerDB = TA.TickerConverters.ConvertFromTTAPIFields2DB(inst.Product.ToString(), inst.Name.ToString());
            /*
            if (e.Fill.SiteOrderKey == OrderKey)
            {
                // Our parent order has been filled
                Console.WriteLine("Our parent order has been " + (e.Fill.FillType == FillType.Full ? "fully" : "partially") + " filled");
            }
            else if (e.Fill.ParentKey == OrderKey)
            {
                // A child order of our parent order has been filled
                Console.WriteLine("A child order of our parent order has been " + (e.Fill.FillType == FillType.Full ? "fully" : "partially") + " filled");
            }

            Console.WriteLine("Average Buy Price = {0} : Net Position = {1} : P&L = {2}", ts.ProfitLossStatistics.BuyAveragePrice,
                ts.ProfitLossStatistics.NetPosition, ts.ProfitLoss.AsPrimaryCurrency);
             * */
        }
        /// <summary>
        /// Event notification for order filled
        /// </summary>
        void m_ts_OrderFilled(object sender, OrderFilledEventArgs e)
        {
            if (e.FillType == FillType.Full)
            {
                Console.WriteLine("Order was fully filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);
            }
            else
            {
                Console.WriteLine("Order was partially filled for {0} at {1}.", e.Fill.Quantity, e.Fill.MatchPrice);
            }

            Console.WriteLine("Average Buy Price = {0} : Net Position = {1} : P&L = {2}", m_ts.ProfitLossStatistics.BuyAveragePrice,
                m_ts.ProfitLossStatistics.NetPosition, m_ts.ProfitLoss.AsPrimaryCurrency);
        }
        public void ts_OrderFilled(object sender, OrderFilledEventArgs e)
        {
            if (e.Fill.SiteOrderKey == orderKey)
            {
                // Our parent order has been filled
                Console.WriteLine("Our parent order has been " + (e.Fill.FillType == FillType.Full ? "fully" : "partially") + " filled");

                if (e.Fill.FillType == FillType.Full)
                {
                    Dispose();
                }
            }
            else if (e.Fill.ParentKey == orderKey)
            {
                // A child order of our parent order has been filled
                Console.WriteLine("A child order of our parent order has been " + (e.Fill.FillType == FillType.Full ? "fully" : "partially") + " filled");
            }
        }
 /// <summary>
 /// Triggered when a new Order in the trade subscription gets filled 
 /// </summary>
 void tradeSubscription_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     UpdateAuditLog("OrderFilled", e.NewOrder);
 }
예제 #24
0
 void ts_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     processOrder(TTOrderStatus.Filled, e.OldOrder);
 }
예제 #25
0
 void ts_OrderFilled(object sender, OrderFilledEventArgs e)
 {
     //Console.WriteLine("OrderFilled");
 }
 public void ProcessMessage(OrderFilledEventArgs e)
 {
     Volume += e.Fill.Quantity.Value;
 }