internal void ApplyInternal(OptionSold sold) { if (SoldToOpen == null) { ApplyFirstTransactionLogic(true, sold.When); } if (Deleted == true) { Deleted = false; } AddNoteIfNotEmpty(sold.Notes); if (NumberOfContracts == 0) { PremiumReceived = 0; PremiumPaid = 0; } NumberOfContracts -= sold.NumberOfContracts; Sells.Add(sold); var credit = (sold.NumberOfContracts * sold.Premium); PremiumReceived += credit; Transactions.Add( Transaction.CreditTx( Id, sold.Id, Ticker, $"Sold {sold.NumberOfContracts} x ${StrikePrice} {OptionType} {Expiration.ToString("MM/dd")} contract(s) for ${sold.Premium} premium/contract", credit, sold.When, true ) ); ApplyClosedLogicIfApplicable(sold.When, sold.Id); }
private void OpenOrder(BookOpen openOrder) { var offer = new ProductOffer { OrderId = openOrder.OrderId, Price = openOrder.Price, Size = openOrder.RemainingSize }; if (openOrder.Side == SideType.Buy) { Buys.Add(offer); } else { Sells.Add(offer); } if (!RemoveReceiveOrder(openOrder.OrderId)) { Api.Log.Warning($"No receive message for order id {openOrder.OrderId}"); } }
internal void AddSell(TradeActionEvent trade) { Sells.Add(trade); }