public void Add(FixedIncomeIntraDayTimeBarCollection value) { if (value == null) { this._logger.LogInformation("UniverseFixedIncomeIntraDayCache was asked to add null. returning"); return; } this._logger.LogInformation( $"UniverseFixedIncomeIntraDayCache adding {value.Epoch} - {value.Exchange?.MarketIdentifierCode}"); if (this._latestExchangeFrameBook.ContainsKey(value.Exchange.MarketIdentifierCode)) { this._latestExchangeFrameBook.Remove(value.Exchange.MarketIdentifierCode); this._latestExchangeFrameBook.Add(value.Exchange.MarketIdentifierCode, value); } else { this._latestExchangeFrameBook.Add(value.Exchange.MarketIdentifierCode, value); } if (!this._marketHistory.ContainsKey(value.Exchange.MarketIdentifierCode)) { var history = new FixedIncomeIntraDayHistoryStack(this._windowSize); history.Add(value, value.Epoch); this._marketHistory.TryAdd(value.Exchange.MarketIdentifierCode, history); } else { this._marketHistory.TryGetValue(value.Exchange.MarketIdentifierCode, out var history); history?.Add(value, value.Epoch); history?.ArchiveExpiredActiveItems(value.Epoch); } }
public void Add(FixedIncomeIntraDayTimeBarCollection frame, DateTime currentTime) { if (frame == null) { return; } lock (this._lock) { if (currentTime.Subtract(frame.Epoch) <= this._activeTradeDuration) { this._activeStack.Push(frame); } } }
private IUniverseEvent MapRowToFixedIncomeIntradayMarketDataEvent(IntradayMarketDataParameters marketDataParam) { if (marketDataParam == null) { return(null); } if (string.IsNullOrWhiteSpace(marketDataParam.SecurityName) || !this._securitySelection.Securities.ContainsKey(marketDataParam.SecurityName)) { this._scenarioContext.Pending(); return(null); } if (marketDataParam.Bid == null || marketDataParam.Ask == null || marketDataParam.Price == null) { this._scenarioContext.Pending(); return(null); } var security = this._securitySelection.Securities[marketDataParam.SecurityName]; var bid = this.MapToMoney(marketDataParam.Bid, marketDataParam.Currency); var ask = this.MapToMoney(marketDataParam.Ask, marketDataParam.Currency); var price = this.MapToMoney(marketDataParam.Price, marketDataParam.Currency); var volume = new Volume(marketDataParam.Volume.GetValueOrDefault(0)); var intradayPrices = new SpreadTimeBar(bid.Value, ask.Value, price.Value, volume); var marketData = new FixedIncomeInstrumentIntraDayTimeBar( security.Instrument, intradayPrices, null, marketDataParam.Epoch, security.Market); var timeBarCollection = new FixedIncomeIntraDayTimeBarCollection( security.Market, marketDataParam.Epoch, new[] { marketData }); var universeEvent = new UniverseEvent( UniverseStateEvent.FixedIncomeIntraDayTick, marketDataParam.Epoch, timeBarCollection); return(universeEvent); }