Example #1
0
        internal static void CancelOrder(SingleOrder order)
        {
            if (order.Provider == null)
            {
                throw new ApplicationException("Provider is null");
            }
            OrderCancelRequest request = new OrderCancelRequest();

            request.OrigClOrdID      = order.ClOrdID;
            request.ClOrdID          = OrderManager.GetOrdId();
            request.Side             = order.Side;
            request.TransactTime     = Clock.Now;
            request.Symbol           = order.Symbol;
            request.SecurityType     = order.SecurityType;
            request.SecurityID       = order.SecurityID;
            request.SecurityExchange = order.SecurityExchange;
            if (order.ContainsField(37))
            {
                request.OrderID = order.OrderID;
            }
            request.Account  = order.Account;
            request.OrderQty = order.OrderQty;
            request.SetStringValue(109, order.GetStringValue(109));
            order.Provider.SendOrderCancelRequest(request);
        }
Example #2
0
 public virtual SingleOrder Execute(Signal signal)
 {
   SingleOrder singleOrder = new SingleOrder();
   singleOrder.Instrument = signal.Instrument;
   singleOrder.Strategy = signal.Strategy.Name;
   singleOrder.StrategyComponent = ((object) signal.Sender).ToString();
   singleOrder.StrategyFill = signal.StrategyFill;
   singleOrder.StrategyPrice = signal.StrategyPrice;
   singleOrder.ForceMarketOrder = signal.QvSj2cjRxv;
   if (signal.Fuwj5CvMiW)
     singleOrder.FillOnBarMode = (int) signal.R2djQy947W;
   switch (signal.Side)
   {
     case SignalSide.Buy:
       singleOrder.Side = Side.Buy;
       break;
     case SignalSide.BuyCover:
       singleOrder.Side = Side.Buy;
       break;
     case SignalSide.Sell:
       singleOrder.Side = Side.Sell;
       break;
     case SignalSide.SellShort:
       singleOrder.Side = Side.SellShort;
       break;
     default:
       throw new NotSupportedException();
   }
   switch (signal.Type)
   {
     case SignalType.Market:
       singleOrder.OrdType = OrdType.Market;
       break;
     case SignalType.Limit:
       singleOrder.OrdType = OrdType.Limit;
       singleOrder.Price = signal.LimitPrice;
       break;
     case SignalType.Stop:
       singleOrder.OrdType = OrdType.Stop;
       singleOrder.StopPx = signal.StopPrice;
       break;
     case SignalType.StopLimit:
       singleOrder.OrdType = OrdType.StopLimit;
       singleOrder.StopPx = signal.StopPrice;
       singleOrder.Price = signal.LimitPrice;
       break;
     case SignalType.TrailingStop:
       singleOrder.OrdType = OrdType.TrailingStop;
       singleOrder.TrailingAmt = signal.StopPrice;
       break;
     default:
       throw new NotSupportedException();
   }
   singleOrder.OrderQty = signal.Qty;
   singleOrder.TimeInForce = signal.TimeInForce;
   singleOrder.Text = signal.Text;
   this.MetaStrategyBase.cWMWqoTObJ((StrategyBase) signal.Strategy, singleOrder);
   singleOrder.Send();
   return singleOrder;
 }
Example #3
0
		public OrderRecord(SingleOrder order)
		{
			this.order = order;
			this.avgPx = 0.0;
			this.leavesQty = (int)((FIXNewOrderSingle)order).OrderQty;
			this.cumQty = 0;
		}
Example #4
0
 private void EmitNewOrder(SingleOrder order)
 {
     if (this.NewOrder != null)
     {
         this.NewOrder(new OrderEventArgs(order));
     }
 }
Example #5
0
        public static void RemoveOrders(int tag, object value)
        {
            int count = OrderManager.orders.Count;
            int index = 0;

            while (index < OrderManager.orders.Count)
            {
                SingleOrder order = OrderManager.orders.All[index] as SingleOrder;
                object      obj   = order.GetValue(tag);
                if (obj != null && obj.ToString() == value.ToString())
                {
                    if (order.OrdStatus != OrdStatus.Cancelled && order.OrdStatus != OrdStatus.PendingCancel && order.OrdStatus != OrdStatus.Filled)
                    {
                        order.Cancel();
                    }
                    OrderManager.orders.Remove(order);
                    if (order.Persistent)
                    {
                        OrderManager.server.Remove((IOrder)order);
                    }
                }
                else
                {
                    ++index;
                }
            }
            if (count == OrderManager.orders.Count || OrderManager.OrderListUpdated == null)
            {
                return;
            }
            OrderManager.OrderListUpdated(typeof(OrderManager), EventArgs.Empty);
        }
Example #6
0
            public void RemoveOrders(int tag, object value)
            {
                int count = this.orders.Count;
                int index = 0;

                while (index < this.orders.Count)
                {
                    SingleOrder singleOrder = this.orders[index];
                    if (singleOrder.ContainsField(tag))
                    {
                        object obj = singleOrder.GetValue(tag);
                        if (obj != null && obj.ToString() == value.ToString())
                        {
                            this.orders.Remove(index);
                            continue;
                        }
                    }
                    ++index;
                }
                if (count <= this.orders.Count)
                {
                    return;
                }
                this.EmitOrderListUpdated();
            }
Example #7
0
 private static void EmitOrderDone(SingleOrder order)
 {
     if (OrderManager.OrderDone != null)
     {
         OrderManager.OrderDone(new OrderEventArgs(order));
     }
 }
Example #8
0
 private static void EmitOrderRemoved(SingleOrder order)
 {
     if (OrderManager.OrderRemoved != null)
     {
         OrderManager.OrderRemoved(new OrderEventArgs(order));
     }
 }
Example #9
0
 private static void EmitNewOrder(SingleOrder order)
 {
     if (OrderManager.NewOrder != null)
     {
         OrderManager.NewOrder(new OrderEventArgs(order));
     }
 }
Example #10
0
 internal static void SendOrder(SingleOrder order)
 {
     if (order.Provider == null)
     {
         throw new ApplicationException("order.Provider == null");
     }
     if (order.Persistent)
     {
         OrderManager.server.AddOrder(order);
     }
     OrderManager.orders.Add(order);
     OrderManager.EmitNewOrder(order);
     if (order.OCAGroup != "" && (int)order.Provider.Id != 4 && OrderManager.oca.Contains((object)order.OCAGroup))
     {
         ExecutionReport report = new ExecutionReport();
         report.TransactTime = DateTime.Now;
         report.ClOrdID      = order.ClOrdID;
         report.OrigClOrdID  = order.ClOrdID;
         report.ExecType     = ExecType.Rejected;
         report.OrdStatus    = OrdStatus.Rejected;
         report.Symbol       = order.Symbol;
         report.Side         = order.Side;
         report.OrdType      = order.OrdType;
         report.Currency     = order.Currency;
         report.Text         = "" + order.OCAGroup;
         OrderManager.ExecutionReport(null, new ExecutionReportEventArgs(report));
     }
     else
     {
         order.Provider.SendNewOrderSingle((NewOrderSingle)order);
     }
 }
Example #11
0
 private static void EmitOrderStatusChanged(SingleOrder order)
 {
     if (OrderManager.OrderStatusChanged == null)
     {
         return;
     }
     OrderManager.OrderStatusChanged(new OrderEventArgs(order));
 }
Example #12
0
 public virtual void Update(SingleOrder order)
 {
     this.newOrders       = null;
     this.pendingOrders   = null;
     this.cancelledOrders = null;
     this.rejectedOrders  = null;
     this.filledOrders    = null;
 }
Example #13
0
 public virtual void Remove(SingleOrder order)
 {
     this.allOrders.Remove(order);
     this.newOrders       = null;
     this.pendingOrders   = null;
     this.cancelledOrders = null;
     this.rejectedOrders  = null;
     this.filledOrders    = null;
 }
Example #14
0
 private static void YUArMfFNj(SingleOrder order)
 {
     OrderManager.EmitOrderDone(order);
     if (!OrderManager.RemoveDoneOrders)
     {
         return;
     }
     OrderManager.orders.Remove(order);
     OrderManager.EmitOrderRemoved(order);
 }
Example #15
0
            private void EmitNewOrderSingle(object sender, NewOrderSingleEventArgs e)
            {
                SingleOrder singleOrder = e.Order as SingleOrder;

                if (singleOrder.OrderID == string.Empty)
                {
                    singleOrder.OrderID = this.GetNextOrderID();
                }
                this.orders.Add(singleOrder);
                this.EmitNewOrder(singleOrder);
            }
Example #16
0
        private static void OnOrderCancelReject(object sender, OrderCancelRejectEventArgs e)
        {
            OrderCancelReject orderCancelReject = e.OrderCancelReject;
            SingleOrder       order             = OrderManager.orders.All[orderCancelReject.OrigClOrdID] as SingleOrder;

            if (orderCancelReject.OrdStatus == OrdStatus.Undefined)
            {
                orderCancelReject.OrdStatus = OrdStatus.New;
                ArrayList arrayList = new ArrayList((ICollection)order.Reports);
                arrayList.Reverse();
                foreach (ExecutionReport executionReport in arrayList)
                {
                    switch (executionReport.OrdStatus)
                    {
                    case OrdStatus.PendingCancel:
                    case OrdStatus.PendingNew:
                    case OrdStatus.PendingReplace:
                        continue;

                    default:
                        orderCancelReject.OrdStatus = executionReport.OrdStatus;
                        goto label_10;
                    }
                }
            }
label_10:
            OrdStatus ordStatus = order.OrdStatus;

            order.EmitCancelReject(orderCancelReject);
            if (OrderManager.OrderCancelReject != null)
            {
                OrderManager.OrderCancelReject(sender, new OrderCancelRejectEventArgs(order, orderCancelReject));
            }
            if (order.IsDone)
            {
                if (!OrderManager.EnablePartialTransactions)
                {
                    OrderManager.nf3XP7Xf3(order, orderCancelReject.TransactTime, order.AvgPx, order.CumQty);
                }
                OrderManager.YUArMfFNj(order);
            }
            else
            {
                if (ordStatus == order.OrdStatus)
                {
                    return;
                }
                OrderManager.orders.Update(order);
                order.EmitStatusChanged();
                OrderManager.EmitOrderStatusChanged(order);
            }
        }
Example #17
0
		public void Add(Instrument instrument, string name, SingleOrder order)
		{
			NamedOrderTable namedOrderTable;
			if (this.orders.ContainsKey(instrument))
			{
				namedOrderTable = this.orders[instrument] as NamedOrderTable;
			}
			else
			{
				namedOrderTable = new NamedOrderTable();
				this.orders.Add(instrument, namedOrderTable);
			}
			namedOrderTable.vxbiSOygU5(name, order);
		}
Example #18
0
		public OrderView(SingleOrder order, Pad pad) : base()
		{
			this.hO3wgSeHU8 = true;
			this.aoOwHWbfJ4 = Color.Gold;
			this.vfIwYklUGT = Color.SpringGreen;
			this.VEIwC98m6Z = Color.Crimson;
			this.GM4wmd54o9 = Color.Crimson;
			this.BuyColor = Color.Blue;
			this.SellColor = Color.Red;
			this.SellShortColor = Color.Yellow;
			this.TextEnabled = true;
			this.ToolTipEnabled = true;
			this.ToolTipFormat = "";

			this.order = order;
			this.pad = pad;
		}
Example #19
0
        internal void EmitExecutionReport(ExecutionReport report)
        {
            if ((report.OrdStatus == OrdStatus.New || report.OrdStatus == OrdStatus.PendingNew) && report.ContainsField(37))
            {
                this.OrderID = report.OrderID;
            }
            if (report.Text == "")
            {
                report.Text = this.Text;
            }
            this.CumQty    = report.CumQty;
            this.LeavesQty = report.LeavesQty;
            this.AvgPx     = report.AvgPx;
            this.OrdStatus = report.OrdStatus;
            if (report.ExecType == ExecType.PartialFill || report.ExecType == ExecType.Fill || report.ExecType == ExecType.Trade)
            {
                this.LastPx  = report.LastPx;
                this.LastQty = report.LastQty;
                if (report.ContainsField(13))
                {
                    double num1 = 0.0;
//         switch (report.CommType)
//          {
//            case CommType.PerShare:
//              num1 = report.Commission * report.LastQty;
//              break;
//            case CommType.Percent:
//              num1 = report.Commission * (report.LastPx * report.LastQty);
//              break;
//            case CommType.Absolute:
//              num1 = report.Commission;
//              break;
//          }
                    SingleOrder singleOrder = this;
                    double      num2        = singleOrder.Commission + num1;
                    singleOrder.Commission = num2;
                }
            }
            this.reports.Add(report);
            if (this.ExecutionReport != null)
            {
                this.ExecutionReport((object)this, new ExecutionReportEventArgs(report));
            }
        }
Example #20
0
        private static void nf3XP7Xf3(SingleOrder obj0, DateTime obj1, double obj2, double obj3)
        {
            if (obj0.LastQty <= 0.0 || obj0.Portfolio == null)
            {
                return;
            }
            Transaction transaction = new Transaction();

            transaction.DateTime   = obj1;
            transaction.ClOrdID    = obj0.ClOrdID;
            transaction.Instrument = obj0.Instrument;
            transaction.Side       = obj0.Side;
            transaction.Price      = obj2;
            transaction.Qty        = obj3;
            transaction.Strategy   = obj0.Strategy;
            transaction.Text       = obj0.Text;
            FreeQuant.Instruments.Currency currency = (CurrencyManager.Currencies[obj0.Currency] ?? CurrencyManager.Currencies[obj0.Instrument.Currency]) ?? CurrencyManager.DefaultCurrency;
            transaction.Currency = currency;
            transaction.TransactionCost.Set(CommType.Absolute, obj0.Commission);
            obj0.Portfolio.Add(transaction);
        }
Example #21
0
		protected override void OnOrderDone(SingleOrder order)
		{
			this.klBiFcxZsD.OnOrderDone(order);
			this.csNiLdTRqH[order.Instrument].OnOrderDone(order);
		}
Example #22
0
		protected override void OnOrderStatusChanged(SingleOrder order)
		{
			this.klBiFcxZsD.OnOrderStatusChanged(order);
			this.csNiLdTRqH[order.Instrument].OnOrderStatusChanged(order);
		}
Example #23
0
		protected override void OnOrderPartiallyFilled(SingleOrder order)
		{
			this.klBiFcxZsD.OnOrderPartiallyFilled(order);
			this.csNiLdTRqH[order.Instrument].OnOrderPartiallyFilled(order);
		}
Example #24
0
		protected override void OnExecutionReport(SingleOrder order, ExecutionReport report)
		{
			this.klBiFcxZsD.OnExecutionReport(order, report);
			this.csNiLdTRqH[order.Instrument].OnExecutionReport(order, report);
		}
Example #25
0
		internal void EB2iXBUSFK(SingleOrder order)
		{
			order.Strategy = this.Name;
			order.StrategyComponent = ((object)ComponentType.ATSComponent).ToString();
			this.MetaStrategyBase.cWMWqoTObJ(this, order);
		}
Example #26
0
 internal void Add(SingleOrder order)
 {
     this.ordersById.Add(order.OrderID, order);
     this.ordersByIndex.Add(order);
 }
Example #27
0
		internal void cWMWqoTObJ(StrategyBase obj0, SingleOrder obj1)
		{
			obj1.Portfolio = this.portfolio;
			switch (this.metaStrategyMode)
			{
				case MetaStrategyMode.Simulation:
					obj1.Provider = ProviderManager.ExecutionSimulator;
					break;
				case MetaStrategyMode.Live:
					obj1.Provider = obj0.MarketManager.UyiAAd6ITD[obj1.Instrument];
					if (this.saveOrders)
					{
						obj1.Persistent = true;
						break;
					}
					else
						break;
			}
			obj1.StrategyMode = MetaStrategyBase.FIX_MODES[this.metaStrategyMode];
			this.DKMWNa8OX5.Add(obj1, obj0);
		}
Example #28
0
 internal void h8htoZ5ih(SingleOrder obj0)
 {
   switch (obj0.OrdStatus)
   {
     case OrdStatus.Filled:
       this.OnOrderFilled(obj0);
       break;
     case OrdStatus.Cancelled:
       this.OnOrderCancelled(obj0);
       break;
     case OrdStatus.Rejected:
       this.OnOrderRejected(obj0);
       break;
   }
   this.OnOrderDone(obj0);
 }
Example #29
0
 internal void zQxocsRCM(SingleOrder obj0)
 {
   this.OnOrderPartiallyFilled(obj0);
 }
Example #30
0
 internal void fuDu5XiFd(SingleOrder obj0)
 {
   Instrument instrument = obj0.Instrument;
   if (obj0.Text != "")
     this.orders.Add(instrument, obj0.Text, obj0);
   this.OnNewOrder(obj0);
 }
Example #31
0
 protected virtual void OnNewOrder(SingleOrder order)
 {
 }
		private void j7FeG7ltt3(OrderEntry entry)
		{
			SingleOrder order = new SingleOrder();
			order.TransactTime = DateTime.Now;
			order.Instrument = entry.Instrument;
			order.Side = entry.Side;
			order.OrdType = entry.OrdType;
			order.Price = entry.Price;
			order.StopPx = entry.StopPx;
			order.OrderQty = entry.OrderQty;
			order.Text = entry.Text;
      if (this.NewOrderSingle != null)
      	this.NewOrderSingle(this, new FIXNewOrderSingleEventArgs(order));
		}
Example #33
0
		protected override void OnNewClientOrder(SingleOrder order)
		{
			this.klBiFcxZsD.mfbpeU3YGv(order);
		}
Example #34
0
 protected virtual void OnOrderPartiallyFilled(SingleOrder order)
 {
 }
Example #35
0
 protected virtual void OnOrderFilled(SingleOrder order)
 {
 }
Example #36
0
 internal void acOvnqFOo(SingleOrder obj0)
 {
   if (!this.isActive)
     return;
   this.OnNewClientOrder(obj0);
 }
Example #37
0
 protected virtual void OnOrderRejected(SingleOrder order)
 {
 }
Example #38
0
 protected virtual void OnExecutionReport(SingleOrder order, ExecutionReport report)
 {
 }
Example #39
0
        internal static void ReplaceOrder(SingleOrder order)
        {
            if (order.Provider == null)
            {
                throw new ApplicationException("null");
            }
            OrderCancelReplaceRequest request = new OrderCancelReplaceRequest();

            request.ClOrdID     = OrderManager.GetOrdId();
            request.OrigClOrdID = order.ClOrdID;
            if (order.ContainsField(37))
            {
                request.OrderID = order.OrderID;
            }
            request.Side        = order.Side;
            request.OrdType     = !order.ReplaceOrder.ContainsField(40) ? order.OrdType : order.ReplaceOrder.OrdType;
            request.TimeInForce = !order.ReplaceOrder.ContainsField(59) ? order.TimeInForce : order.ReplaceOrder.TimeInForce;
            if (order.ReplaceOrder.ContainsField(126))
            {
                request.ExpireTime = order.ReplaceOrder.ExpireTime;
            }
            if (order.ReplaceOrder.ContainsField(44))
            {
                request.Price = order.ReplaceOrder.Price;
            }
            else
            {
                request.Price = order.Price;
            }
            if (order.ReplaceOrder.ContainsField(99))
            {
                request.StopPx = order.ReplaceOrder.StopPx;
            }
            else
            {
                request.StopPx = order.StopPx;
            }
            if (order.ReplaceOrder.ContainsField(10701))
            {
                request.TrailingAmt = order.ReplaceOrder.TrailingAmt;
            }
            else
            {
                request.TrailingAmt = order.TrailingAmt;
            }
            if (order.ReplaceOrder.ContainsField(38))
            {
                request.OrderQty = order.ReplaceOrder.OrderQty;
            }
            else
            {
                request.OrderQty = order.OrderQty;
            }
            request.TransactTime     = Clock.Now;
            request.Account          = order.Account;
            request.HandlInst        = order.HandlInst;
            request.Symbol           = order.Symbol;
            request.SecurityType     = order.SecurityType;
            request.SecurityExchange = order.SecurityExchange;
            request.SecurityID       = order.SecurityID;
            request.Currency         = order.Currency;
            request.SetStringValue(109, order.GetStringValue(109));
            order.Provider.SendOrderCancelReplaceRequest(request);
        }
Example #40
0
 protected virtual void OnOrderStatusChanged(SingleOrder order)
 {
 }
Example #41
0
 public override void Add(SingleOrder order)
 {
     base.Add(order);
     this[order.Instrument].Add(order);
 }
Example #42
0
 protected virtual void OnOrderCancelled(SingleOrder order)
 {
 }
Example #43
0
 public override void Remove(SingleOrder order)
 {
     base.Remove(order);
     this[order.Instrument].Remove(order);
 }
Example #44
0
 protected virtual void OnOrderDone(SingleOrder order)
 {
 }
Example #45
0
 public override void Update(SingleOrder order)
 {
     base.Update(order);
     this[order.Instrument].Update(order);
 }
Example #46
0
 internal void a9XY5Muph(SingleOrder obj0, ExecutionReport obj1)
 {
   this.OnExecutionReport(obj0, obj1);
 }
Example #47
0
 protected override void OnExecutionReport(SingleOrder order, ExecutionReport report)
 {
   Instrument instrument = order.Instrument;
   this.HeHpDewVKD.OnExecutionReport(order, report);
   this.A6MpF2380O.OnExecutionReport(order, report);
   this.entries[instrument].OnExecutionReport(order, report);
   this.exits[instrument].OnExecutionReport(order, report);
 }
Example #48
0
 internal void VLka0XAdb(SingleOrder obj0)
 {
   this.OnOrderStatusChanged(obj0);
 }
Example #49
0
 protected override void OnOrderDone(SingleOrder order)
 {
   Instrument instrument = order.Instrument;
   this.HeHpDewVKD.OnOrderDone(order);
   this.A6MpF2380O.OnOrderDone(order);
   this.entries[instrument].OnOrderDone(order);
   this.exits[instrument].OnOrderDone(order);
 }
Example #50
0
		public void DrawOrder(SingleOrder order, int padNumber)
		{
		}
Example #51
0
		private double VirF0ddUxQ(SingleOrder obj0, Quote obj1, Trade obj2, Bar obj3)
		{
			bool flag = !obj0.IsStopLimitReady && (obj0.OrdType == OrdType.TrailingStop || obj0.OrdType == OrdType.TrailingStopLimit || obj0.OrdType == OrdType.StopLimit);
			if (obj1 != null && this.A8bFJItyyx.PartialFills && (this.A8bFJItyyx.FillOnQuote && !flag || this.A8bFJItyyx.TriggerOnQuote && flag))
			{
				if (!this.A8bFJItyyx.FillAtWorstQuoteRate || obj1.Bid <= obj1.Ask)
				{
					switch (obj0.Side)
					{
						case Side.Buy:
							if (obj1.AskSize > 0)
								return (double) obj1.AskSize;
							else
								break;
						case Side.Sell:
						case Side.SellShort:
							if (obj1.BidSize > 0)
								return (double) obj1.BidSize;
							else
								break;
						default:
							return obj0.OrderQty;
					}
				}
				else
				{
					switch (obj0.Side)
					{
						case Side.Buy:
							if (obj1.BidSize > 0)
								return (double) obj1.BidSize;
							else
								break;
						case Side.Sell:
						case Side.SellShort:
							if (obj1.Ask > 0.0)
								return (double) obj1.AskSize;
							else
								break;
						default:
							return obj0.OrderQty;
					}
				}
			}
			if ((this.A8bFJItyyx.FillOnTrade && !flag || this.A8bFJItyyx.TriggerOnTrade && flag) && obj2 != null)
			{
				if ((obj0.OrdType == OrdType.Limit || (obj0.OrdType == OrdType.StopLimit || obj0.OrdType == OrdType.TrailingStopLimit) && obj0.IsStopLimitReady) && (obj0.CumQty == 0.0 && Math.Abs(obj2.Price - obj0.Price) < 0.001 && (obj0.TradeVolumeDelay != 0 && !this.gxTF8gufMx)))
				{
					this.w02FZf7vnP += obj2.Size;
					if (this.w02FZf7vnP <= obj0.TradeVolumeDelay)
						return 0.0;
					this.gxTF8gufMx = true;
					if (this.A8bFJItyyx.PartialFills)
						return (double) (this.w02FZf7vnP - obj0.TradeVolumeDelay);
					else
						return obj0.OrderQty;
				}
				else if (this.A8bFJItyyx.PartialFills)
					return (double) obj2.Size;
			}
			return obj0.OrderQty;
		}