public decimal PercentageDifference(MarketPrice secondPrice) { if (secondPrice.Reversed.Pair.Id == this.Pair.Id) { secondPrice = secondPrice.Reversed; } if (secondPrice.Pair.Id != Pair.Id) { throw new Exception($"Can't calculate percentage difference for {nameof(MarketPrice)}, as pairs don't match: {secondPrice.Pair} - {Pair}"); } return(Price.PercentageProfit(secondPrice.Price)); }
public void Add(MarketPrice price) { lock (_lock) { if (!_prices.ContainsKey(price.Pair.Id)) { _prices.Add(price.Pair.Id, new List <MarketPrice>()); } var col = _prices[price.Pair.Id]; var dt = DateTime.UtcNow.Add(-FlushSpan); col.RemoveAll(x => x.UtcCreated < dt); col.Add(price); } }
private void SendResults(MarketPrice response) { var resultMsg = new LatestPriceResultMessage(Provider, response); _messenger.SendAsync(resultMsg); }