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); } }
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); }
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 }); }
public PortfolioChangedLineEvent(PortfolioLineItem li) { Item = li; }