private void OnMessageReceived(InstrumentPrice bestBidAsk) { IBoxSize assetCfg = null; // Lock Asset Configuration lock (AssetConfigurationLock) { assetCfg = _assetConfiguration.FirstOrDefault(a => a.AssetPair == bestBidAsk.Instrument); } if (assetCfg == null) { return; } // If asset configured to save history, add it to history if (assetCfg.SaveHistory) { _history?.AddToAssetHistory(new BestBidAsk() { Asset = bestBidAsk.Instrument, BestAsk = bestBidAsk.Ask, BestBid = bestBidAsk.Bid, Source = bestBidAsk.Source, Timestamp = bestBidAsk.Date, ReceiveDate = DateTime.UtcNow }); } // If asset allowed in game, raise event if (assetCfg.GameAllowed) { MessageReceived?.Invoke(this, (InstrumentPrice)bestBidAsk.ClonePrice()); } }
public static BoxSize ToDto(this IBoxSize src) { return(new BoxSize { AssetPair = src.AssetPair, BoxesPerRow = src.BoxesPerRow, BoxHeight = src.BoxHeight, BoxWidth = src.BoxWidth, TimeToFirstBox = src.TimeToFirstBox, SaveHistory = src.SaveHistory, GameAllowed = src.GameAllowed, ScaleK = src.ScaleK }); }
public static BoxSizeEntity CreateEntity(IBoxSize src) { return(new BoxSizeEntity { PartitionKey = GetPartitionKey(), RowKey = src.AssetPair, AssetPair = src.AssetPair, BoxesPerRow = src.BoxesPerRow, BoxHeight = src.BoxHeight, BoxWidth = src.BoxWidth, TimeToFirstBox = src.TimeToFirstBox, SaveHistory = src.SaveHistory, GameAllowed = src.GameAllowed, ScaleK = src.ScaleK }); }
public async Task InsertAsync(IBoxSize olapEntity) { await _storage.InsertOrMergeAsync(BoxSizeEntity.CreateEntity(olapEntity)); }