public async Task <Dictionary <string, TradingDayInfoContract> > GetMarketsInfo([FromBody] string[] marketIds = null,
                                                                                        [FromQuery] DateTime?date     = null)
        {
            var allMarkets = (await _marketSettingsService.GetAllMarketSettingsAsync()).Select(x => x.Id).ToHashSet();

            allMarkets.Add(_platformSettings.PlatformMarketId);
            allMarkets.Add(AssetPairConstants.FxMarketId);
            if (marketIds == null || !marketIds.Any())
            {
                marketIds = allMarkets.ToArray();
            }
            else
            {
                foreach (var marketId in marketIds)
                {
                    if (allMarkets.Contains(marketId))
                    {
                        continue;
                    }

                    throw new ArgumentException($"Market {marketId} does not exist", nameof(marketIds));
                }
            }

            var info = await _marketDayOffService.GetMarketsInfo(marketIds, date);

            return(info.ToDictionary(k => k.Key, v => new TradingDayInfoContract()
            {
                IsTradingEnabled = v.Value.IsTradingEnabled,
                LastTradingDay = v.Value.LastTradingDay,
                NextTradingDayStart = v.Value.NextTradingDayStart,
                IsBusinessDay = v.Value.IsBusinessDay
            }));
        }
示例#2
0
        public async Task <GetAllMarketSettingsResponse> GetAllMarketSettingsAsync()
        {
            var result = await _marketSettingsService.GetAllMarketSettingsAsync();

            return(new GetAllMarketSettingsResponse
            {
                MarketSettingsContracts = result.Select(x => _convertService.Convert <MarketSettings, MarketSettingsContract>(x)).ToList()
            });
        }