public void OnPrice(IDictionary <string, PriceDto> priceCache, bool wasTraded) { var isLong = _baseTradedAmount >= 0; var isUsdBased = CurrencyPair.StartsWith("USD"); PriceDto monitoredPrice, crossedPrice = null; if (!priceCache.TryGetValue(CurrencyPair, out monitoredPrice) || (!isUsdBased && !priceCache.TryGetValue(CrossedPair, out crossedPrice))) { return; } _baseSpot = isLong ? _counterTradedAmount / monitoredPrice.Bid : _counterTradedAmount / monitoredPrice.Ask; var basePnl = _baseTradedAmount - _baseSpot; decimal usdPnl; if (isUsdBased) { usdPnl = basePnl; } else { usdPnl = isLong ? basePnl * crossedPrice.Bid : basePnl * crossedPrice.Ask; } _currentPosition = new CurrencyPairPositionReport { Symbol = CurrencyPair, BaseTradedAmount = _baseTradedAmount, BasePnl = basePnl, UsdPnl = usdPnl, WasTraded = wasTraded }; }