public async Task <IActionResult> GetVolatility(string assetPairId) { if (string.IsNullOrWhiteSpace(assetPairId)) { return(BadRequest(ErrorResponse.Create($"{nameof(assetPairId)} has invalid value"))); } try { VolatilityModel volatility = await _payVolatilityClient.Volatility.GetDailyVolatilityAsync(assetPairId); return(Ok(Mapper.Map <VolatilityResponseModel>(volatility))); } catch (Exception ex) { _log.Error(ex, null, assetPairId); if (ex is Refit.ApiException refitEx) { if (refitEx.StatusCode == HttpStatusCode.NotFound) { return(NotFound(ErrorResponse.Create("Asset pair volatility not found"))); } if (refitEx.StatusCode == HttpStatusCode.BadRequest) { return(BadRequest(ErrorResponse.Create(refitEx.Message))); } } } return(StatusCode((int)HttpStatusCode.InternalServerError)); }
private void SetDeltaSpread(IMarkup markup, VolatilityModel volatilityModel, bool isDeltaSpreadFixed) { markup.DeltaSpread = isDeltaSpreadFixed ? Math.Max(markup.DeltaSpread, volatilityModel.HighPriceVolatilityShield) : volatilityModel.HighPriceVolatilityShield; }