public async Task UpdateLimitOrdersAsync(string indexName) { IndexPrice indexPrice = await _indexPriceService.GetByIndexAsync(indexName); if (indexPrice == null) { throw new InvalidOperationException("Index price not found"); } IndexSettings indexSettings = await _indexSettingsService.GetByIndexAsync(indexName); if (indexSettings == null) { throw new InvalidOperationException("Index settings not found"); } AssetPairSettings assetPairSettings = await _instrumentService.GetAssetPairAsync(indexSettings.AssetPairId, Exchange); if (assetPairSettings == null) { throw new InvalidOperationException("Asset pair settings not found"); } AssetSettings baseAssetSettings = await _instrumentService.GetAssetAsync(assetPairSettings.BaseAsset, ExchangeNames.Lykke); if (baseAssetSettings == null) { throw new InvalidOperationException("Base asset settings not found"); } AssetSettings quoteAssetSettings = await _instrumentService.GetAssetAsync(assetPairSettings.QuoteAsset, ExchangeNames.Lykke); if (quoteAssetSettings == null) { throw new InvalidOperationException("Quote asset settings not found"); } decimal sellPrice = (indexPrice.Price + indexSettings.SellMarkup) .TruncateDecimalPlaces(assetPairSettings.PriceAccuracy, true); decimal buyPrice = indexPrice.Price.TruncateDecimalPlaces(assetPairSettings.PriceAccuracy); IReadOnlyCollection <LimitOrder> limitOrders = CreateLimitOrders(indexSettings, assetPairSettings, sellPrice, buyPrice); ValidateBalance(limitOrders, baseAssetSettings, quoteAssetSettings); ValidateMinVolume(limitOrders, assetPairSettings.MinVolume); LimitOrder[] allowedLimitOrders = limitOrders .Where(o => o.Error == LimitOrderError.None) .ToArray(); _log.InfoWithDetails("Limit orders created", limitOrders); _limitOrderService.Update(indexSettings.AssetPairId, limitOrders); await _lykkeExchangeService.ApplyAsync(indexSettings.AssetPairId, allowedLimitOrders); _traceWriter.LimitOrders(indexSettings.AssetPairId, limitOrders); }