예제 #1
0
        private void AddOrUpdate(PortfolioLineItem newItem)
        {
            var eli = Items.FirstOrDefault(x => Equals(x.Asset, newItem.Asset));

            if (eli == null)
            {
                Items.Add(newItem);
            }
            else
            {
                eli.Update(newItem);
            }
        }
예제 #2
0
        private PortfolioLineItem CreateLineItem(BalanceResult balance, IBalanceProvider provider)
        {
            try
            {
                var pli = new PortfolioLineItem()
                {
                    Asset            = balance.Asset,
                    Network          = provider.Network,
                    AvailableBalance = balance.Available,
                    PendingBalance   = balance.Reserved,
                    ReservedBalance  = balance.Reserved,
                    Total            = new Money((decimal)balance.Available + (decimal)balance.Reserved, balance.Available.Asset),
                    ChangePercentage = 0
                };

                return(pli);
            }
            catch (Exception e)
            {
                L.Error(e, $"in {GetType()} @ {nameof(CreateLineItem)}");
            }
            return(null);
        }
예제 #3
0
        private void Update(List <PortfolioLineItem> r, bool finished, PortfolioLineItem li = null)
        {
            UtcLastUpdated = DateTime.UtcNow;

            if (li != null)
            {
                AddOrUpdate(li);
            }
            else
            {
                foreach (var i in r)
                {
                    AddOrUpdate(i);
                }
            }

            UpdateInfo();

            OnChanged?.Invoke(this, new PortfolioChangedLineEvent(li)
            {
                Finished = finished
            });
        }
예제 #4
0
 public PortfolioChangedLineEvent(PortfolioLineItem li)
 {
     Item = li;
 }