Inheritance: Tick
Esempio n. 1
0
        public override void OnTrade(Trade trade)
        {
            if (Bars.Count > length)
            {
                if (trade.Price > highestHigh + Bars[Bars.Count - 1].Range)
                {
                    count++;

                    if (count >= 10)
                    {
                        Signal(+1);

                        return;
                    }
                }
                else
                    count = 0;

                if (trade.Price < lowestLow - Bars[Bars.Count - 1].Range)
                {
                    Signal(-1);

                    return;
                }
            }

            Signal(0);
        }
Esempio n. 2
0
 internal void OnTrade(Trade trade)
 {
     if (TraceOnTrade)
     {
         this.fillPrice = this.trailPrice = this.currPrice = GetPrice(trade.Price);
         this.method_1();
     }
 }
Esempio n. 3
0
        public override void EmitTrade(Trade trade)
        {
            // Emit trade to BuySide strategy.
            base.EmitTrade(trade);

            System.Collections.Generic.LinkedListNode<OrderProcessor> processorNode = processors.First;

            // Send trade to order processors.
            while (processorNode != null)
            {
                OrderProcessor processor = processorNode.Value;
                processor.OnTrade(trade);
                processorNode = processorNode.Next;
            }
        }
Esempio n. 4
0
        protected override void OnTrade(Instrument instrument, Trade trade)
        {
            if (instrument == spread)
                return;

            if (!isTradeReady)
            {
                isTradeReady = true;

                foreach (Leg leg in spread.Legs)
                {
                    if (leg.Instrument.Trade == null)
                    {
                        isTradeReady = false;

                        return;
                    }
                }
            }

            //
            double tradePrice = 0;
            int tradeSize = Int32.MaxValue;

            foreach (Leg leg in spread.Legs)
            {
                tradePrice += leg.Instrument.Trade.Price * leg.Weight;
                tradeSize = Math.Min(tradeSize, leg.Instrument.Trade.Size);
            }

            // Create new trade for spread instrument.
            EmitTrade(new Trade(trade.DateTime, 0, spread.Id, tradePrice, tradeSize));
        }
Esempio n. 5
0
        public void OnTrade(Trade trade)
        {
            // Check conditions for send leg orders.
            switch (order.Type)
            {
                case OrderType.Limit:
                    switch (order.Side)
                    {
                        case OrderSide.Buy:
                            if (trade.Price <= order.Price)
                                SendLegOrders();
                            break;

                        case OrderSide.Sell:
                            if (trade.Price >= order.Price)
                                SendLegOrders();
                            break;
                    }
                    break;

                case OrderType.Stop:
                    switch (order.Side)
                    {
                        case OrderSide.Buy:
                            if (trade.Price >= order.StopPx)
                                SendLegOrders();
                            break;

                        case OrderSide.Sell:
                            if (trade.Price <= order.StopPx)
                                SendLegOrders();
                            break;
                    }
                    break;
            }
        }
Esempio n. 6
0
 public Trade(Trade trade) : base(trade)
 {
     Direction = trade.Direction;
 }
Esempio n. 7
0
        public void OnTrade(Trade trade)
        {
            var orders = GetOrdersBy(trade.InstrumentId);
            if (orders == null)
                return;

            if (FillOnTrade)
            {
                foreach (var order in orders)
                    FillWithTrade(order, trade);
                ClearOrders();
            }
        }
 protected internal override void OnStrategyStart()
 {
     var data = new Trade();
     this.stopwatch.Start();
     (DataProvider as PerformanceProvider).EmitData(data, true);
 }
Esempio n. 9
0
 internal virtual void vmethod_12(Trade trade)
 {
     if (this.IsInstance)
     {
         this.OnTrade(trade);
         List<Stop> list = this.idArray_0[trade.instrumentId];
         if (list != null)
         {
             for (int i = 0; i < list.Count; i++)
             {
                 Stop stop_ = list[i];
                 if (stop_.Connected)
                 {
                     stop_.method_5(trade);
                 }
             }
         }
     }
 }
Esempio n. 10
0
 internal void OnTrade(Trade trade)
 {
     if (Strategy?.Status == StrategyStatus.Running)
         Strategy.EmitTrade(trade);
 }
Esempio n. 11
0
 internal void OnTrade(Trade trade)
 {
     var iId = trade.InstrumentId;
     var pId = trade.ProviderId + 1;
     this.latestTrade[iId] = trade;
     this.tradeByIIdAndPId[pId] = this.tradeByIIdAndPId[pId] ?? new IdArray<Trade>(10240);
     this.tradeByIIdAndPId[pId][iId] = trade;
 }
Esempio n. 12
0
 public override void EmitTrade(Trade trade)
 {
     var providerId = GetProviderId();
     this.framework.EventManager.OnEvent(new Trade(trade) { ProviderId = providerId });
 }
Esempio n. 13
0
 public new virtual void EmitTrade(Trade trade)
 {
     this.framework.EventManager.OnEvent(new Trade(trade) { ProviderId = (byte)Id });
 }
Esempio n. 14
0
        protected override void OnTrade(Instrument instrument, Trade trade)
        {
            if (instrument.Id == currentFuturesContract.Id)
            {
                Trade rootTrade = new Trade(trade.DateTime, 0, rootInstrument.Id, trade.Price, trade.Size);

                // Emit trade to to BuySide strategy.
                EmitTrade(rootTrade);
            }
        }
Esempio n. 15
0
 public void OnTrade(Trade trade)
 {
     throw new NotImplementedException();
 }
Esempio n. 16
0
 public virtual void EmitTrade(Trade trade)
 {
     EventManager.OnEvent(new Trade(trade){providerId = (byte)Id});
 }
Esempio n. 17
0
 protected virtual void OnTrade(Trade trade)
 {
     // noop
 }
Esempio n. 18
0
 public override void EmitTrade(Trade trade)
 {
     EventManager.OnEvent(new Trade(trade){providerId = IsInstance ? (byte)Parent.Id : (byte)Id});
 }
 protected override void OnTrade(Instrument instrument, Trade trade)
 {
     this.stopwatch.Stop();
 }
Esempio n. 20
0
 private bool FillWithTrade(Order order, Trade trade)
 {
     while (true)
     {
         switch (order.Type)
         {
             case OrderType.Market:
             case OrderType.Pegged:
                 this.Fill(order, trade.Price, trade.Size);
                 return true;
             case OrderType.Stop:
                 switch (order.Side)
                 {
                     case OrderSide.Buy:
                         if (trade.Price >= order.StopPx)
                         {
                             if (!FillAtStopPrice)
                             {
                                 order.Type = OrderType.Market;
                                 continue;
                             }
                             goto IL_DA;
                         }
                         break;
                     case OrderSide.Sell:
                         if (trade.Price <= order.StopPx)
                         {
                             if (!FillAtStopPrice)
                             {
                                 order.Type = OrderType.Market;
                                 continue;
                             }
                             goto IL_EF;
                         }
                         break;
                 }
                 break;
             case OrderType.Limit:
                 goto IL_104;
             case OrderType.StopLimit:
                 switch (order.Side)
                 {
                     case OrderSide.Buy:
                         if (trade.Price >= order.StopPx)
                         {
                             order.Type = OrderType.Limit;
                             continue;
                         }
                         break;
                     case OrderSide.Sell:
                         if (trade.Price <= order.StopPx)
                         {
                             order.Type = OrderType.Limit;
                             continue;
                         }
                         break;
                 }
                 break;
         }
         break;
     }
     return false;
     IL_DA:
     this.Fill(order, order.StopPx, trade.Size);
     return true;
     IL_EF:
     this.Fill(order, order.StopPx, trade.Size);
     return true;
     IL_104:
     switch (order.Side)
     {
         case OrderSide.Buy:
             if (trade.Price <= order.Price)
             {
                 Fill(order, FillAtLimitPrice ? order.Price : trade.Price, trade.Size);
                 return true;
             }
             break;
         case OrderSide.Sell:
             if (trade.Price >= order.Price)
             {
                 Fill(order, FillAtLimitPrice ? order.Price : trade.Price, trade.Size);
                 return true;
             }
             break;
     }
     return false;
     IL_1A0:
     this.Fill(order, trade.Price, trade.Size);
     return true;
 }