示例#1
0
 public void Add(Fill fill)
 {
     Fills.Add(fill);
     Qty += fill.Qty;
     Commission += fill.Commission;
     Price = Fills.Sum(f => f.Qty*f.Price)/Qty;
 }
示例#2
0
 public Fill(Fill fill)
 {
     DateTime = fill.DateTime;
     Order = fill.Order;
     Instrument = fill.Instrument;
     OrderId = fill.OrderId;
     InstrumentId = fill.InstrumentId;
     CurrencyId = fill.CurrencyId;
     Side = fill.Side;
     Qty = fill.Qty;
     Price = fill.Price;
     Commission = fill.Commission;
     Text = fill.Text;
 }
示例#3
0
        public void Add(Fill fill)
        {
            Fills.Add(fill);
            if (Amount == 0)
                this.fill = fill;

            if (fill.Side == OrderSide.Buy)
               QtyBought += fill.Qty;
            else
                QtySold += fill.Qty;

            this.method_0(fill);
            Amount = QtyBought - QtySold;
        }
示例#4
0
 public void Add(Fill fill)
 {
     Fill fill2 = this.interface0_0.Peek();
     if (fill2 == null)
     {
         this.instrument_0 = fill.Instrument;
         this.timeSeries_0.Clear();
         this.timeSeries_0.Add(this.portfolio_0.framework.Clock.DateTime, this.method_4(this.instrument_0));
     }
     if (fill2 != null && (!this.method_3(fill2) || !this.method_3(fill)) && (this.method_3(fill2) || this.method_3(fill)))
     {
         if (this.fill_0 != null)
         {
             fill = this.method_1(fill);
         }
         double num = fill.Qty;
         while (num > 0.0 && (fill2 = this.interface0_0.Peek()) != null)
         {
             if (fill2.Qty > num)
             {
                 this.fill_0 = new Fill(fill);
                 return;
             }
             this.BotEqOqmKI(this.method_2(fill2, fill, fill2.Qty));
             this.interface0_0.Pop();
             this.double_0 -= Math.Round(fill2.Qty, 5);
             num -= Math.Round(fill2.Qty, 5);
             if (this.double_0 > 0.0 && num > 0.0)
             {
                 fill = this.method_0(fill, num);
             }
         }
         if (num > 0.0)
         {
             this.double_0 = num;
             Fill fill3 = this.method_0(fill, num);
             this.interface0_0.Push(fill3);
         }
         if (this.fill_0 != null)
         {
             this.fill_0 = null;
         }
         return;
     }
     this.interface0_0.Push(fill);
     this.double_0 += fill.Qty;
 }
示例#5
0
 public OnFill(Portfolio portfolio, Fill fill)
 {
     Portfolio = portfolio;
     Fill = fill;
 }
示例#6
0
 public void Push(Fill fill) => this.queue.Enqueue(fill);
示例#7
0
 protected override void OnFill(Fill fill)
 {
     Log(fill, fillGroup);
 }
示例#8
0
 protected virtual void OnFill(Fill fill)
 {
 }
示例#9
0
 public AccountTransaction(Fill fill) : this(fill.DateTime, fill.CashFlow, fill.CurrencyId, fill.Text)
 {
 }
示例#10
0
 private Fill method_0(Fill fill_1, double double_1)
 {
     Fill fill = new Fill(fill_1);
     fill.Commission *= double_1 / fill.Qty;
     fill.Qty = double_1;
     return fill;
 }
示例#11
0
 protected override void OnFill(Fill fill)
 {
     // Add fill to fill group.
     Log(fill, fillGroups[fill.Instrument]);
 }
示例#12
0
 public override void OnFill(Fill fill)
 {
     Log(fill, fillChartGroup);
 }
示例#13
0
 internal void OnFill(Portfolio portfolio, Fill fill, bool queued)
 {
     var e = new OnFill(portfolio, fill);
     if (queued)
         this.queue.Enqueue(e);
     else
         OnEvent(e);
 }
示例#14
0
 public void Push(Fill fill) => this.stack.Push(fill);
示例#15
0
 private void method_0(Fill fill_1)
 {
     if (Amount == 0)
     {
         this.double_3 = fill_1.Value;
         AvgPx = fill_1.Price;
         return;
     }
     if ((Side == PositionSide.Long && fill_1.Side == OrderSide.Buy) || (this.Side == PositionSide.Short && fill_1.Side == OrderSide.Sell))
     {
         this.double_3 += fill_1.Value;
         if (Instrument.Factor != 0)
         {
             AvgPx = this.double_3 / (this.Qty + fill_1.Qty) / Instrument.Factor;
             return;
         }
         AvgPx = this.double_3 / (this.Qty + fill_1.Qty);
         return;
     }
     else
     {
         if (this.Qty == fill_1.Qty)
         {
             PnL += this.method_2(fill_1.Price, fill_1.Qty);
             this.double_3 = 0.0;
             this.AvgPx = 0.0;
             return;
         }
         if (this.Qty > fill_1.Qty)
         {
             PnL += this.method_2(fill_1.Price, fill_1.Qty);
             this.double_3 -= this.method_1(fill_1.Qty * this.AvgPx);
             return;
         }
         PnL += this.method_2(fill_1.Price, this.Qty);
         double num = fill_1.Qty - this.Qty;
         this.double_3 = this.method_1(num * fill_1.Price);
         if (Instrument.Factor != 0)
         {
             this.AvgPx = this.double_3 / num / Instrument.Factor;
             return;
         }
         this.AvgPx = this.double_3 / num;
         return;
     }
 }
示例#16
0
 private Fill method_1(Fill fill_1)
 {
     Fill fill = new Fill(fill_1);
     if (this.fill_0 != null)
     {
         if (fill.Instrument.Factor != 0.0)
         {
             fill.Price = (fill_1.Value + this.fill_0.Value) / (fill_1.Qty + this.fill_0.Qty) / fill.Instrument.Factor;
         }
         else
         {
             fill.Price = (fill_1.Value + this.fill_0.Value) / (fill_1.Qty + this.fill_0.Qty);
         }
         fill.Qty = fill_1.Qty + this.fill_0.Qty;
         fill.Commission = fill_1.Commission + this.fill_0.Commission;
     }
     this.fill_0 = null;
     return fill;
 }
示例#17
0
 private TradeInfo method_2(Fill fill_1, Fill fill_2, double double_1)
 {
     TradeInfo tradeInfo = new TradeInfo();
     tradeInfo.Instrument = fill_1.Instrument;
     tradeInfo.EntryDate = fill_1.DateTime;
     tradeInfo.EntryPrice = fill_1.Price;
     tradeInfo.EntryCost = fill_1.Commission * double_1 / fill_1.Qty;
     tradeInfo.ExitDate = fill_2.DateTime;
     tradeInfo.ExitPrice = fill_2.Price;
     tradeInfo.ExitCost = fill_2.Commission * double_1 / fill_2.Qty;
     tradeInfo.Qty = double_1;
     tradeInfo.IsLong = this.method_3(fill_1);
     tradeInfo.BaseCurrencyId = this.portfolio_0.Account.CurrencyId;
     double num = (tradeInfo.Instrument.Factor == 0.0) ? 1.0 : tradeInfo.Instrument.Factor;
     double max = this.timeSeries_0.GetMax(tradeInfo.EntryDate, tradeInfo.ExitDate);
     double min = this.timeSeries_0.GetMin(tradeInfo.EntryDate, tradeInfo.ExitDate);
     if (tradeInfo.IsLong)
     {
         tradeInfo.MAE = num * tradeInfo.Qty * (min - tradeInfo.EntryPrice) - (tradeInfo.EntryCost + tradeInfo.ExitCost);
         tradeInfo.MFE = num * tradeInfo.Qty * (max - tradeInfo.EntryPrice) - (tradeInfo.EntryCost + tradeInfo.ExitCost);
         tradeInfo.ETD = tradeInfo.MFE - tradeInfo.NetPnL;
     }
     else
     {
         tradeInfo.MAE = num * tradeInfo.Qty * (max - tradeInfo.EntryPrice) * -1.0 - (tradeInfo.EntryCost + tradeInfo.ExitCost);
         tradeInfo.MFE = num * tradeInfo.Qty * (min - tradeInfo.EntryPrice) * -1.0 - (tradeInfo.EntryCost + tradeInfo.ExitCost);
         tradeInfo.ETD = tradeInfo.MFE - tradeInfo.NetPnL;
     }
     return tradeInfo;
 }
示例#18
0
 public void Add(Fill fill, bool updateParent = true)
 {
     Add(new AccountTransaction(fill), updateParent);
 }
示例#19
0
 private bool method_3(Fill fill_1)
 {
     return fill_1.Side == OrderSide.Buy;
 }
示例#20
0
 public Transaction(Fill fill)
 {
     Add(fill);
 }
示例#21
0
 public void Push(Fill fill) => this.queue.Enqueue(fill);
示例#22
0
        protected override void OnFill(Fill fill)
        {
            Group[] instrumentGroups = null;

            // Add fill to fill group (index 1).
            if (groups.TryGetValue(fill.Instrument, out instrumentGroups))
                Log(fill, instrumentGroups[1]);
        }
示例#23
0
 public void Push(Fill fill) => this.stack.Push(fill);
示例#24
0
 protected override void OnFill(Fill fill)
 {
     // Add fill to group.
     Log(fill, fillGroup);
 }
示例#25
0
 private bool method_3(Fill fill_1)
 {
     return(fill_1.Side == OrderSide.Buy);
 }