Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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
            });
        }
Ejemplo n.º 4
0
 public PortfolioChangedLineEvent(PortfolioLineItem li)
 {
     Item = li;
 }