public void Add(Fill fill) { Fills.Add(fill); Qty += fill.Qty; Commission += fill.Commission; Price = Fills.Sum(f => f.Qty*f.Price)/Qty; }
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; }
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; }
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; }
public OnFill(Portfolio portfolio, Fill fill) { Portfolio = portfolio; Fill = fill; }
public void Push(Fill fill) => this.queue.Enqueue(fill);
protected override void OnFill(Fill fill) { Log(fill, fillGroup); }
protected virtual void OnFill(Fill fill) { }
public AccountTransaction(Fill fill) : this(fill.DateTime, fill.CashFlow, fill.CurrencyId, fill.Text) { }
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; }
protected override void OnFill(Fill fill) { // Add fill to fill group. Log(fill, fillGroups[fill.Instrument]); }
public override void OnFill(Fill fill) { Log(fill, fillChartGroup); }
internal void OnFill(Portfolio portfolio, Fill fill, bool queued) { var e = new OnFill(portfolio, fill); if (queued) this.queue.Enqueue(e); else OnEvent(e); }
public void Push(Fill fill) => this.stack.Push(fill);
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; } }
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; }
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; }
public void Add(Fill fill, bool updateParent = true) { Add(new AccountTransaction(fill), updateParent); }
private bool method_3(Fill fill_1) { return fill_1.Side == OrderSide.Buy; }
public Transaction(Fill fill) { Add(fill); }
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]); }
protected override void OnFill(Fill fill) { // Add fill to group. Log(fill, fillGroup); }
private bool method_3(Fill fill_1) { return(fill_1.Side == OrderSide.Buy); }