Inheritance: DataObject
Beispiel #1
0
 public Fill(DateTime dateTime, Order order, Instrument instrument, byte currencyId, OrderSide side, double qty, double price, string text = "")
 {
     DateTime = dateTime;
     Order = order;
     Instrument = instrument;
     OrderId = order.Id;
     InstrumentId = instrument.Id;
     CurrencyId = currencyId;
     Side = side;
     Qty = qty;
     Price = price;
     Text = text;
 }
 public ExecutionMessage(ExecutionMessage executionMessage) : base(executionMessage)
 {
     Id = executionMessage.Id;
     this.order = executionMessage.Order;
     OrderId = executionMessage.OrderId;
     ClOrderId = executionMessage.ClOrderId;
     ProviderOrderId = executionMessage.ProviderOrderId;
     this.instrument = executionMessage.Instrument;
     InstrumentId = executionMessage.InstrumentId;
     ClientId = executionMessage.ClientId;
     IsLoaded = executionMessage.IsLoaded;
     CurrencyId = executionMessage.CurrencyId;
     Fields = new ObjectTable(executionMessage.Fields);
 }
        public void Register(Order order)
        {
            if (order.Id != -1)
            {
                Console.WriteLine($"OrderManager::Register Error Order is already registered : id = {order.Id}");
                return;
            }

            lock (this.obj)
                order.Id = this.counter++;

            if (this.framework.Mode == FrameworkMode.Realtime && string.IsNullOrEmpty(order.ClOrderId))
                order.ClOrderId = $"{this.framework.Clock.DateTime} {order.Id}";
        }
Beispiel #4
0
        public override void OnOrder(Order order)
        {
            if (order.Text == "TakeProfit")
                order.OCA = (++OCACount).ToString();

            if (order.Text == "StopLoss")
                order.OCA = OCACount.ToString();

            if (order.Text == "StopLoss")
                stopLossOrder = order;

            if (order.Text == "StopExit" || order.Text == "StopSession")
                framework.OrderManager.Cancel(stopLossOrder);

            base.OnOrder(order);
        }
        public void Cancel(Order order)
        {
            if (order.IsNotSent)
                throw new ArgumentException($"Can not cancel order that is not sent {order}");

            var command = new ExecutionCommand(ExecutionCommandType.Cancel, order)
            {
                DateTime = this.framework.Clock.DateTime,
                OrderId = order.Id,
                ClOrderId = order.ClOrderId,
                ProviderOrderId = order.ProviderOrderId,
                ProviderId = order.ProviderId,
                RouteId = order.RouteId,
                PortfolioId = order.PortfolioId
            };
            command.DateTime = order.DateTime;
            command.Instrument = order.Instrument;
            command.InstrumentId = order.InstrumentId;
            command.Provider = order.Provider;
            command.Portfolio = order.Portfolio;
            command.Side = order.Side;
            command.OrdType = order.Type;
            command.TimeInForce = order.TimeInForce;
            command.Price = order.Price;
            command.StopPx = order.StopPx;
            command.Qty = order.Qty;
            command.OCA = order.OCA;
            command.Text = order.Text;
            command.Account = order.Account;
            command.ClientID = order.ClientID;
            command.ClientId = order.ClientId;
            Messages.Add(command);
            order.OnExecutionCommand(command);
            this.framework.EventServer.OnExecutionCommand(command);
            if (IsPersistent)
                Server?.Save(command, -1);
            order.Provider.Send(command);
        }
Beispiel #6
0
 public void Replace(Order order, double price, double stopPx, double qty)
 {
     OrderManager.Replace(order, price, stopPx, qty);
 }
Beispiel #7
0
 public void Replace(Order order, double price)
 {
     OrderManager.Replace(order, price);
 }
 public ExecutionCommand(ExecutionCommandType type, Order order)
     : this()
 {
     Type = type;
     Order = order;
     OrderId = order.Id;
     ProviderId = order.ProviderId;
     RouteId = order.RouteId;
     AlgoId = order.AlgoId;
     PortfolioId = order.PortfolioId;
     InstrumentId = order.InstrumentId;
     TransactTime = order.TransactTime;
     DateTime = order.DateTime;
     Instrument = order.Instrument;
     Provider = order.Provider;
     Portfolio = order.Portfolio;
     Side = order.Side;
     OrdType = order.Type;
     TimeInForce = order.TimeInForce;
     ExpireTime = order.ExpireTime;
     Price = order.Price;
     StopPx = order.StopPx;
     Qty = order.Qty;
     MinQty = order.MinQty;
     PegDifference = order.PegDifference;
     ExecInst = order.ExecInst;
     OCA = order.OCA;
     Text = order.Text;
     Account = order.Account;
     ClientID = order.ClientID;
     Fields = new ObjectTable(order.Fields);
 }
Beispiel #9
0
 public Order SellOrder(Instrument instrument, double qty, string text = "")
 {
     Order order = new Order(this.method_1(instrument), this.Portfolio, instrument, OrderType.Market, OrderSide.Sell, qty, 0.0, 0.0, TimeInForce.Day, 0, "");
     order.StrategyId = this.Id;
     order.Text = text;
     OrderManager.Register(order);
     return order;
 }
Beispiel #10
0
 public Order SellPegged(IExecutionProvider provider, Instrument instrument, double qty, double offset, string text = "")
 {
     Order order = new Order(provider, this.Portfolio, instrument, OrderType.Pegged, OrderSide.Sell, qty, 0.0, 0.0, TimeInForce.Day, 0, "");
     order.StrategyId = this.Id;
     order.StopPx = offset;
     order.Text = text;
     this.Send(order);
     return order;
 }
Beispiel #11
0
 protected virtual void OnOrderCancelRejected(Order order)
 {
 }
Beispiel #12
0
 protected virtual void OnOrderExpired(Order order)
 {
 }
Beispiel #13
0
 protected virtual void OnOrderPartiallyFilled(Order order)
 {
 }
Beispiel #14
0
 protected virtual void OnOrderFilled(Order order)
 {
 }
Beispiel #15
0
 protected virtual void OnOrderStatusChanged(Order order)
 {
 }
Beispiel #16
0
 protected virtual void OnNewOrder(Order order)
 {
 }
Beispiel #17
0
 protected virtual void OnPendingNewOrder(Order order)
 {
 }
Beispiel #18
0
 public Order Buy(IExecutionProvider provider, Instrument instrument, double qty, string text = "")
 {
     Order order = new Order(provider, this.Portfolio, instrument, OrderType.Market, OrderSide.Buy, qty, 0.0, 0.0, TimeInForce.Day, 0, "");
     order.StrategyId = this.Id;
     order.Text = text;
     this.Send(order);
     return order;
 }
Beispiel #19
0
 public Order Sell(IExecutionProvider provider, Instrument instrument, OrderType type, double qty, double price, double stopPx, string text = "")
 {
     Order order = new Order(provider, this.Portfolio, instrument, type, OrderSide.Sell, qty, price, stopPx, TimeInForce.Day, 0, "");
     order.StrategyId = Id;
     order.Text = text;
     this.Send(order);
     return order;
 }
Beispiel #20
0
 protected virtual void OnOrderReplaceRejected(Order order)
 {
 }
Beispiel #21
0
 public Order SellStopLimit(IExecutionProvider provider, Instrument instrument, double qty, double stopPx, double price, string text = "")
 {
     Order order = new Order(provider, this.Portfolio, instrument, OrderType.StopLimit, OrderSide.Sell, qty, 0.0, 0.0, TimeInForce.Day, 0, "");
     order.StrategyId = this.Id;
     order.Text = text;
     order.StopPx = stopPx;
     order.Price = price;
     this.Send(order);
     return order;
 }
Beispiel #22
0
 protected virtual void OnOrderDone(Order order)
 {
 }
Beispiel #23
0
 public Order BuyStopLimitOrder(Instrument instrument, double qty, double stopPx, double price, string text = "")
 {
     Order order = new Order(this.method_1(instrument), this.Portfolio, instrument, OrderType.StopLimit, OrderSide.Buy, qty, 0.0, 0.0, TimeInForce.Day, 0, "");
     order.StrategyId = this.Id;
     order.Text = text;
     order.StopPx = stopPx;
     order.Price = price;
     OrderManager.Register(order);
     return order;
 }
Beispiel #24
0
        public OrderProcessor(SpreadSellSide strategy, ExecutionCommand command)
        {
            // Add current processor to SellSide processor's list. 
            strategy.processors.AddLast(this);

            // Init OrderProcessor fields.
            this.strategy = strategy;
            this.command = command;
            order = command.Order;
            spreadInstrument = order.Instrument;
            orders = new Dictionary<Order, Leg>();

            // Send leg orders if order type is market.
            if (order.Type == OrderType.Market)
                SendLegOrders();
        }
Beispiel #25
0
 public void Send(Order order)
 {
     OrderManager.Send(order);
 }
 private void method_8(Order order_0, Bid bid_0, Ask ask_0)
 {
 }
 private void method_6(Order order_0)
 {
 }
Beispiel #28
0
 public void Cancel(Order order)
 {
     OrderManager.Cancel(order);
 }
Beispiel #29
0
        private void UpdateExitLimit()
        {
            if (exitOrder != null && !exitOrder.IsDone)
                Cancel(exitOrder);

            if (HasPosition(Instrument))
            {
                if (Position.Side == PositionSide.Long)
                    exitOrder = SellLimitOrder(Instrument, Qty, sma.Last, "Exit");
                else
                    exitOrder = BuyLimitOrder(Instrument, Qty, sma.Last, "Exit");

                Send(exitOrder);
            }
        }
Beispiel #30
0
 public void Reject(Order order)
 {
     OrderManager.Reject(order);
 }