public async Task <IActionResult> GetAssetPairRates() { var allAssetPairs = await _assetsHelper.GetAllAssetPairsAsync(); var allNondisabledAssetPairs = allAssetPairs.Where(x => !x.IsDisabled); var allAssets = await _assetsHelper.GetAllAssetsAsync(); var allTradableNondisabledAssets = new HashSet <string>( allAssets .Where(x => !x.IsDisabled && x.IsTradable) .Select(x => x.Id)); var assetPairsDict = allNondisabledAssetPairs.Where(x => allTradableNondisabledAssets.Contains(x.BaseAssetId) && allTradableNondisabledAssets.Contains(x.QuotingAssetId)) .ToDictionary(x => x.Id); var marketProfile = await _marketProfileService.ApiMarketProfileGetAsync(); var relevantMarketProfile = marketProfile.Where(itm => assetPairsDict.ContainsKey(itm.AssetPair)); return(Ok(AssetPairRatesResponseModel.Create( relevantMarketProfile.Select(x => x.ToApiModel()).OrderBy(x => x.AssetPair).ToArray()))); }
public async Task <IActionResult> GetAssetPairRates() { var assetPairs = await _assetsService.AssetPairGetAllAsync(); //var assetPairs = await _assetsService.GetAssetsPairsForClient(new Lykke.Service.Assets.Client.Models.GetAssetPairsForClientRequestModel //{ // ClientId = _requestContext.ClientId, // IsIosDevice = _requestContext.IsIosDevice, // PartnerId = _requestContext.PartnerId //}); var assetPairsDict = assetPairs.ToDictionary(itm => itm.Id); var marketProfile = await _marketProfileService.ApiMarketProfileGetAsync(); marketProfile = marketProfile.Where(itm => assetPairsDict.ContainsKey(itm.AssetPair)).ToList(); return(Ok(AssetPairRatesResponseModel.Create(marketProfile.Select(m => m.ConvertToApiModel()).ToArray()))); }
public async Task <IActionResult> GetAssetPairRatesById([FromRoute] AssetPairRequestModel request) { if (string.IsNullOrWhiteSpace(request.AssetPairId)) { return(BadRequest()); } var assetPair = await _assetsHelper.GetAssetPairAsync(request.AssetPairId); if (assetPair == null || assetPair.IsDisabled) { return(NotFound()); } var allAssets = await _assetsHelper.GetAllAssetsAsync(); var allTradableNondisabledAssets = new HashSet <string>( allAssets .Where(x => !x.IsDisabled && x.IsTradable) .Select(x => x.Id)); if (!allTradableNondisabledAssets.Contains(assetPair.BaseAssetId) || !allTradableNondisabledAssets.Contains(assetPair.QuotingAssetId)) { return(NotFound()); } var marketProfile = await _marketProfileService.ApiMarketProfileGetAsync(); var feedData = marketProfile.FirstOrDefault(itm => itm.AssetPair == request.AssetPairId); if (feedData == null) { return(NotFound()); } return(Ok(AssetPairRatesResponseModel.Create(new List <AssetPairRateModel> { feedData.ToApiModel() }))); }
public async Task <IActionResult> GetAssetPairRatesById([FromRoute] AssetPairRequestModel request) { var asset = (await _assetPairs.Values()).FirstOrDefault(x => x.Id == request.AssetPairId); if (asset == null) { return(NotFound($"AssetPair {request.AssetPairId} does not exist")); } var marketProfile = await _marketProfileService.ApiMarketProfileGetAsync(); var feedData = marketProfile.FirstOrDefault(itm => itm.AssetPair == request.AssetPairId); if (feedData == null) { return(NotFound($"No data exist for {request.AssetPairId}")); } return(Ok(AssetPairRatesResponseModel.Create(new List <AssetPairRateModel> { feedData.ConvertToApiModel() }))); }