コード例 #1
0
ファイル: OrderFactory.cs プロジェクト: ForTrade/CSharp
 public Order OnExecutionCommand(ExecutionCommand command)
 {
     Order order = this.orders[command.Id];
     if (order == null)
     {
         order = new Order();
         this.orders[command.Id] = order;
         order.dateTime = command.dateTime;
         order.id = command.id;
         order.providerId = command.providerId;
         order.portfolioId = command.portfolioId;
         order.transactTime = command.transactTime;
         order.instrument = command.instrument;
         order.provider = command.provider;
         order.portfolio = command.portfolio;
         order.side = command.side;
         order.type = command.orderType;
         order.timeInForce = command.timeInForce;
         order.price = command.price;
         order.stopPx = command.stopPx;
         order.qty = command.qty;
         order.oCA = command.oCA;
         order.text = command.text;
     }
     command.order = order;
     order.OnExecutionCommand(command);
     return order;
 }
コード例 #2
0
ファイル: SellSideStrategy.cs プロジェクト: ForTrade/CSharp
 public virtual void Send(ExecutionCommand command)
 {
     switch (command.Type)
     {
     case ExecutionCommandType.Send:
         this.OnSendCommand(command);
         return;
     case ExecutionCommandType.Cancel:
         this.OnCancelCommand(command);
         return;
     case ExecutionCommandType.Replace:
         this.OnReplaceCommand(command);
         return;
     default:
         return;
     }
 }
コード例 #3
0
 public override void Send(ExecutionCommand command)
 {
     SellSideStrategy sellSideStrategy = this.strategyBySynthInstrument[command.order.instrument.Id];
     switch (command.Type)
     {
     case ExecutionCommandType.Send:
         sellSideStrategy.OnSendCommand(command);
         return;
     case ExecutionCommandType.Cancel:
         sellSideStrategy.OnCancelCommand(command);
         return;
     case ExecutionCommandType.Replace:
         sellSideStrategy.OnReplaceCommand(command);
         return;
     default:
         return;
     }
 }
コード例 #4
0
        public override void Write(BinaryWriter writer, object obj)
        {
            byte value = 0;

            writer.Write(value);
            ExecutionCommand executionCommand = obj as ExecutionCommand;

            writer.Write(executionCommand.id);
            writer.Write(executionCommand.providerId);
            writer.Write(executionCommand.portfolioId);
            writer.Write(executionCommand.transactTime.Ticks);
            writer.Write((byte)executionCommand.Type);
            writer.Write(executionCommand.instrumentId);
            writer.Write((int)executionCommand.Side);
            writer.Write((int)executionCommand.orderType);
            writer.Write((int)executionCommand.timeInForce);
            writer.Write(executionCommand.Price);
            writer.Write(executionCommand.StopPx);
            writer.Write(executionCommand.Qty);
            writer.Write(executionCommand.OCA);
            writer.Write(executionCommand.Text);
        }
コード例 #5
0
ファイル: OrderManager.cs プロジェクト: ForTrade/CSharp
 public void Cancel(Order order)
 {
     ExecutionCommand executionCommand = new ExecutionCommand(ExecutionCommandType.Cancel, order);
     executionCommand.dateTime = this.framework.Clock.DateTime;
     executionCommand.providerId = order.providerId;
     executionCommand.portfolioId = order.portfolioId;
     executionCommand.transactTime = order.transactTime;
     executionCommand.instrument = order.instrument;
     executionCommand.provider = order.provider;
     executionCommand.portfolio = order.portfolio;
     executionCommand.side = order.side;
     executionCommand.orderType = order.Type;
     executionCommand.timeInForce = order.timeInForce;
     executionCommand.price = order.price;
     executionCommand.stopPx = order.stopPx;
     executionCommand.qty = order.qty;
     executionCommand.oCA = order.oCA;
     executionCommand.text = order.text;
     order.OnExecutionCommand(executionCommand);
     this.framework.eventServer.OnExecutionCommand(executionCommand);
     order.Provider.Send(executionCommand);
 }
        public override void Send(ExecutionCommand command)
        {
            SellSideStrategy sellSideStrategy = this.strategyBySynthInstrument[command.order.instrument.Id];

            switch (command.Type)
            {
            case ExecutionCommandType.Send:
                sellSideStrategy.OnSendCommand(command);
                return;

            case ExecutionCommandType.Cancel:
                sellSideStrategy.OnCancelCommand(command);
                return;

            case ExecutionCommandType.Replace:
                sellSideStrategy.OnReplaceCommand(command);
                return;

            default:
                return;
            }
        }
コード例 #7
0
ファイル: OrderManager.cs プロジェクト: ForTrade/CSharp
        public void Cancel(Order order)
        {
            ExecutionCommand executionCommand = new ExecutionCommand(ExecutionCommandType.Cancel, order);

            executionCommand.dateTime     = this.framework.Clock.DateTime;
            executionCommand.providerId   = order.providerId;
            executionCommand.portfolioId  = order.portfolioId;
            executionCommand.transactTime = order.transactTime;
            executionCommand.instrument   = order.instrument;
            executionCommand.provider     = order.provider;
            executionCommand.portfolio    = order.portfolio;
            executionCommand.side         = order.side;
            executionCommand.orderType    = order.Type;
            executionCommand.timeInForce  = order.timeInForce;
            executionCommand.price        = order.price;
            executionCommand.stopPx       = order.stopPx;
            executionCommand.qty          = order.qty;
            executionCommand.oCA          = order.oCA;
            executionCommand.text         = order.text;
            order.OnExecutionCommand(executionCommand);
            this.framework.eventServer.OnExecutionCommand(executionCommand);
            order.Provider.Send(executionCommand);
        }
コード例 #8
0
        public override void Send(ExecutionCommand command)
        {
            if (base.IsDisconnected)
            {
                this.Connect();
            }
            switch (command.Type)
            {
            case ExecutionCommandType.Send:
                this.Send(command.Order);
                return;

            case ExecutionCommandType.Cancel:
                this.Cancel(command.Order);
                return;

            case ExecutionCommandType.Replace:
                this.Replace(command);
                return;

            default:
                return;
            }
        }
コード例 #9
0
ファイル: Order.cs プロジェクト: ForTrade/CSharp
 public void OnExecutionCommand(ExecutionCommand command)
 {
     this.commands.Add(command);
     this.messages.Add(command);
 }
コード例 #10
0
        public override void Send(ExecutionCommand command)
        {
            if(command.RouteId == id)
                return;

            IExecutionProvider provider;
            if (command.RouteId != 0)
            {
                provider = framework.ProviderManager.GetExecutionProvider(command.RouteId);
            }
            else
            {
                provider = ExecutionProvider;
            }
            provider.Send(command);
        }
コード例 #11
0
ファイル: ExecutionCommand.cs プロジェクト: ForTrade/CSharp
		public ExecutionCommand(ExecutionCommand command)
		{
			this.id = command.id;
			this.providerId = command.providerId;
			this.portfolioId = command.portfolioId;
			this.transactTime = command.transactTime;
			this.dateTime = command.dateTime;
			this.instrument = command.instrument;
			this.provider = command.provider;
			this.portfolio = command.portfolio;
			this.side = command.side;
			this.orderType = command.OrdType;
			this.timeInForce = command.timeInForce;
			this.price = command.price;
			this.stopPx = command.stopPx;
			this.qty = command.qty;
			this.oCA = command.oCA;
			this.text = command.text;
		}
コード例 #12
0
 public void Send(ExecutionCommand command)
 {
     throw new NotImplementedException();
 }
コード例 #13
0
ファイル: SellSideStrategy.cs プロジェクト: ForTrade/CSharp
 public virtual void OnReplaceCommand(ExecutionCommand command)
 {
 }
コード例 #14
0
ファイル: OnExecutionCommand.cs プロジェクト: ForTrade/CSharp
 public OnExecutionCommand(ExecutionCommand command)
 {
     this.command = command;
 }
コード例 #15
0
ファイル: ExecutionSimulator.cs プロジェクト: ForTrade/CSharp
		public override void Send(ExecutionCommand command)
		{
			if (base.IsDisconnected)
			{
				this.Connect();
			}
			switch (command.Type)
			{
			case ExecutionCommandType.Send:
				this.Send(command.Order);
				return;
			case ExecutionCommandType.Cancel:
				this.Cancel(command.Order);
				return;
			case ExecutionCommandType.Replace:
				this.Replace(command);
				return;
			default:
				return;
			}
		}
コード例 #16
0
ファイル: Provider.cs プロジェクト: ForTrade/CSharp
 public virtual void Send(ExecutionCommand command)
 {
     Console.WriteLine("Provider::Send is not implemented in the base class");
 }
コード例 #17
0
ファイル: OnExecutionCommand.cs プロジェクト: ForTrade/CSharp
 public OnExecutionCommand(ExecutionCommand command)
 {
     this.command = command;
 }
コード例 #18
0
ファイル: SellSideStrategy.cs プロジェクト: ForTrade/CSharp
 public virtual void OnCancelCommand(ExecutionCommand command)
 {
 }
コード例 #19
0
ファイル: SellSideStrategy.cs プロジェクト: ForTrade/CSharp
 public virtual void OnReplaceCommand(ExecutionCommand command)
 {
 }
コード例 #20
0
ファイル: SellSideStrategy.cs プロジェクト: ForTrade/CSharp
 public virtual void OnSendCommand(ExecutionCommand command)
 {
 }
コード例 #21
0
ファイル: MatchingEngine.cs プロジェクト: ForTrade/CSharp
		public override void Send(ExecutionCommand command)
		{
			switch (command.Type)
			{
			case ExecutionCommandType.Send:
				this.Send(command.Order);
				return;
			case ExecutionCommandType.Cancel:
				this.Cancel(command.Order);
				return;
			case ExecutionCommandType.Replace:
				this.Replace(command);
				return;
			default:
				return;
			}
		}
コード例 #22
0
ファイル: SellSideStrategy.cs プロジェクト: ForTrade/CSharp
 public virtual void OnSendCommand(ExecutionCommand command)
 {
 }
コード例 #23
0
ファイル: Order.cs プロジェクト: ForTrade/CSharp
 public void OnExecutionCommand(ExecutionCommand command)
 {
     this.commands.Add(command);
     this.messages.Add(command);
 }
コード例 #24
0
        private void CmdNewOrderList(ExecutionCommand command)
        {
            // 先查出所有的单子
            List<Order> orders = command.Order.GetSameTimeOrderList();

            OrderField[] fields = new OrderField[orders.Count];
            for (int i = 0; i < orders.Count; ++i)
            {
                string altSymbol;
                string altExchange;
                string apiSymbol;
                string apiExchange;
                double apiTickSize;

                GetApi_Symbol_Exchange_TickSize(orders[i].Instrument,
                    out altSymbol, out altExchange,
                    out apiSymbol, out apiExchange,
                    out apiTickSize);

                ToOrderStruct(ref fields[i], orders[i], apiSymbol, apiExchange);
            }

            orderMap.DoOrderSend(ref fields, orders);
        }
コード例 #25
0
 public virtual void Send(ExecutionCommand command)
 {
     Console.WriteLine("Provider::Send is not implemented in the base class");
 }
コード例 #26
0
ファイル: OrderManager.cs プロジェクト: ForTrade/CSharp
 public void Send(Order order)
 {
     if (order.id == -1)
     {
         this.Register(order);
     }
     if (order.IsOCA)
     {
         List<Order> list;
         this.oCAGroups.TryGetValue(order.oCA, out list);
         if (list == null)
         {
             list = new List<Order>();
             this.oCAGroups[order.oCA] = list;
         }
         list.Add(order);
     }
     this.orders.Add(order);
     order.dateTime = this.framework.Clock.DateTime;
     ExecutionCommand executionCommand = new ExecutionCommand(ExecutionCommandType.Send, order);
     executionCommand.dateTime = order.dateTime;
     executionCommand.id = order.id;
     executionCommand.providerId = order.providerId;
     executionCommand.portfolioId = order.portfolioId;
     executionCommand.transactTime = order.transactTime;
     executionCommand.instrument = order.instrument;
     executionCommand.provider = order.provider;
     executionCommand.portfolio = order.portfolio;
     executionCommand.side = order.side;
     executionCommand.orderType = order.Type;
     executionCommand.timeInForce = order.timeInForce;
     executionCommand.price = order.price;
     executionCommand.stopPx = order.stopPx;
     executionCommand.qty = order.qty;
     executionCommand.oCA = order.oCA;
     executionCommand.text = order.text;
     order.OnExecutionCommand(executionCommand);
     this.framework.eventServer.OnExecutionCommand(executionCommand);
     order.Provider.Send(executionCommand);
 }
コード例 #27
0
ファイル: EventServer.cs プロジェクト: ForTrade/CSharp
		internal void OnExecutionCommand(ExecutionCommand command)
		{
			this.OnEvent(command);
		}
コード例 #28
0
        private void CmdNewOrderSingle(ExecutionCommand command)
        {
            string altSymbol;
            string altExchange;
            string apiSymbol;
            string apiExchange;
            double apiTickSize;

            GetApi_Symbol_Exchange_TickSize(command.Instrument,
                out altSymbol, out altExchange,
                out apiSymbol, out apiExchange,
                out apiTickSize);

            OrderField[] fields = new OrderField[1];

            ToOrderStruct(ref fields[0], command.Order, apiSymbol, apiExchange);
            double price = fields[0].Price;

            //市价修正,如果不连接行情,此修正不执行,得策略层处理
            MarketDataRecord record;
            if (marketDataRecords.TryGetValue(command.Instrument.Symbol, out record))
            {
                switch(command.OrdType)
                {
                    case SQ.OrderType.Market:
                    case SQ.OrderType.MarketOnClose:
                    case SQ.OrderType.Stop:
                    case SQ.OrderType.TrailingStop:
                        {
                            if (command.Side == SQ.OrderSide.Buy)
                            {
                                price = record.DepthMarket.LastPrice + LastPricePlusNTicks * apiTickSize;
                            }
                            else
                            {
                                price = record.DepthMarket.LastPrice - LastPricePlusNTicks * apiTickSize;
                            }

                            // 市价单使用限价单模拟
                            if(SwitchMakertOrderToLimitOrder)
                            {
                                fields[0].Type = XAPI.OrderType.Limit;
                            }
                        }
                        break;
                }
                if (HasPriceLimit)
                {
                    //price = FixPrice(price, command.Side, apiTickSize, record.DepthMarket.LowerLimitPrice, record.DepthMarket.UpperLimitPrice);
                    price = FixPrice(record,price, command.Side, apiTickSize);
                }
                
                fields[0].Price = price;
            }

            orderMap.DoOrderSend(ref fields, command.Order);
        }
コード例 #29
0
ファイル: ExecutionSimulator.cs プロジェクト: ForTrade/CSharp
		private void Replace(ExecutionCommand command)
		{
			Order order = command.order;
			base.EmitExecutionReport(new ExecutionReport
			{
				dateTime = this.framework.Clock.DateTime,
				order = order,
				commandID = order.id,
				instrument = order.instrument,
				ordQty = order.Qty,
				execType = ExecType.ExecReplace,
				ordStatus = OrderStatus.Replaced,
				currencyId = order.instrument.currencyId,
				ordType = order.type,
				side = order.side,
				cumQty = order.cumQty,
				lastQty = 0.0,
				leavesQty = order.leavesQty,
				lastPx = 0.0,
				avgPx = 0.0,
				//ordType = order.type,
				price = command.price,
				stopPx = order.stopPx,
				//ordQty = order.qty,
				timeInForce = order.timeInForce,
				text = order.text
			});
		}
コード例 #30
0
 private void CmdCancelOrder(ExecutionCommand command)
 {
     orderMap.DoOrderCancel(command.Order);
 }
コード例 #31
0
ファイル: EventServer.cs プロジェクト: ForTrade/CSharp
 internal void OnExecutionCommand(ExecutionCommand command)
 {
     this.OnEvent(command);
 }
コード例 #32
0
ファイル: SellSideStrategy.cs プロジェクト: ForTrade/CSharp
 public virtual void OnCancelCommand(ExecutionCommand command)
 {
 }