Esempio n. 1
0
        public OwnedOptionView(OwnedOption o)
        {
            Id                = o.State.Id;
            Ticker            = o.State.Ticker;
            OptionType        = o.State.OptionType.ToString();
            StrikePrice       = o.State.StrikePrice;
            ExpirationDate    = o.State.Expiration.ToString("yyyy-MM-dd");
            NumberOfContracts = Math.Abs(o.State.NumberOfContracts);
            BoughtOrSold      = o.State.SoldToOpen.Value ? "Sold" : "Bought";
            Filled            = o.State.FirstFill.Value;
            Days              = o.State.Days;
            DaysHeld          = o.State.DaysHeld;
            Transactions      = o.State.Transactions.Where(t => !t.IsPL).ToList();
            ExpiresSoon       = o.State.ExpiresSoon;
            IsExpired         = o.State.IsExpired;
            Closed            = o.State.Closed;
            Assigned          = o.State.Assigned;
            Notes             = o.State.Notes;

            var credits = o.State.Transactions.Where(t => !t.IsPL && t.Profit >= 0);
            var debits  = o.State.Transactions.Where(t => !t.IsPL && t.Profit < 0);

            if (credits.Any())
            {
                PremiumReceived = credits.Sum(t => t.Credit);
            }
            if (debits.Any())
            {
                PremiumPaid = debits.Sum(t => t.Debit);
            }
        }
Esempio n. 2
0
 public OwnedOptionView(OwnedOption option, decimal currentPrice)
     : this(option)
 {
     ApplyPrice(currentPrice);
 }