Inheritance: ICommissionProvider
コード例 #1
0
        public void Fill(Order order, double price, int size)
        {
            if (!PartialFills)
            {
                this.orders.Add(order);
                var report = new ExecutionReport
                {
                    DateTime     = this.framework.Clock.DateTime,
                    Order        = order,
                    OrderId      = order.Id,
                    OrdType      = order.Type,
                    Side         = order.Side,
                    Instrument   = order.Instrument,
                    InstrumentId = order.InstrumentId,
                    OrdQty       = order.Qty,
                    Price        = order.Price,
                    StopPx       = order.StopPx,
                    TimeInForce  = order.TimeInForce,
                    ExecType     = ExecType.ExecTrade,
                    OrdStatus    = OrderStatus.Filled,
                    CurrencyId   = order.Instrument.CurrencyId,
                    CumQty       = order.LeavesQty,
                    LastQty      = order.LeavesQty,
                    LeavesQty    = 0.0,
                    LastPx       = price,
                    Text         = order.Text
                };
                report.Commission = CommissionProvider.GetCommission(report);
                report.LastPx     = SlippageProvider.GetPrice(report);
                this.summariesByOrderId[order.Id] = new ReportSummary(report);
                EmitExecutionReport(report, Queued);
                return;
            }
            if (size <= 0)
            {
                Console.WriteLine("ExecutionSimulator::Fill Error - using partial fills, size can not be zero");
                return;
            }
            var report2 = new ExecutionReport
            {
                DateTime     = this.framework.Clock.DateTime,
                Order        = order,
                OrderId      = order.Id,
                OrdType      = order.Type,
                Side         = order.Side,
                Instrument   = order.Instrument,
                InstrumentId = order.InstrumentId,
                OrdQty       = order.Qty,
                Price        = order.Price,
                StopPx       = order.StopPx,
                TimeInForce  = order.TimeInForce,
                ExecType     = ExecType.ExecTrade,
                CurrencyId   = order.Instrument.CurrencyId
            };

            if (size >= order.LeavesQty)
            {
                this.orders.Add(order);
                report2.OrdStatus = OrderStatus.Filled;
                report2.CumQty    = order.CumQty + order.LeavesQty;
                report2.LastQty   = order.LeavesQty;
                report2.LeavesQty = 0.0;
                report2.LastPx    = price;
                report2.Text      = order.Text;
                order.LeavesQty   = report2.LeavesQty;
            }
            else if (size < order.LeavesQty)
            {
                report2.OrdStatus = OrderStatus.PartiallyFilled;
                report2.CumQty    = order.CumQty + size;
                report2.LastQty   = size;
                report2.LeavesQty = order.LeavesQty - size;
                report2.LastPx    = price;
                report2.Text      = order.Text;
                order.LeavesQty   = report2.LeavesQty;
            }
            report2.Commission = CommissionProvider.GetCommission(report2);
            report2.LastPx     = SlippageProvider.GetPrice(report2);
            this.summariesByOrderId[order.Id] = new ReportSummary(report2);
            EmitExecutionReport(report2, Queued);
        }