public decimal CalculatePrice( decimal askPrice, decimal bidPrice, int pairAccuracy, int assetAccuracy, decimal markupPercent, int markupPips, PriceCalculationMethod priceValueType, IMarkup merchantMarkup) { _log.Info($"Rate calculation, askPrice = {askPrice}, bidPrice = {bidPrice}"); decimal originalPrice = GetOriginalPriceByMethod(bidPrice, askPrice, priceValueType); decimal spread = GetSpread(originalPrice, merchantMarkup.DeltaSpread); decimal priceWithSpread = GetPriceWithSpread(originalPrice, spread, priceValueType); decimal lpFee = GetMerchantFee(priceWithSpread, merchantMarkup.Percent); decimal lpPips = GetMerchantPips(merchantMarkup.Pips); decimal fee = GetMarkupFeePerRequest(priceWithSpread, markupPercent); decimal delta = GetDelta(spread, lpFee, fee, lpPips, markupPips, pairAccuracy); decimal result = GetPriceWithDelta(originalPrice, delta, priceValueType); return(GetRoundedPrice(result, pairAccuracy, assetAccuracy, priceValueType)); }
public static ExtentTest CreateTestwrap(string description) { test = extent.CreateTest(description, ""); IMarkup m = MarkupHelper.CreateLabel(description, ExtentColor.Red); return(test); }
private async Task SetDeltaSpreadAsync(IMarkup markup, bool isDeltaSpreadFixed) { string assetPairId = GetVolatilityAssetPairId(markup); if (string.IsNullOrEmpty(assetPairId) || !_volatilityAssetPairs.Contains(assetPairId, StringComparer.OrdinalIgnoreCase)) { return; } VolatilityModel volatilityModel; try { volatilityModel = await _payVolatilityClient.Volatility.GetDailyVolatilityAsync(assetPairId); } catch (Refit.ApiException ex) when(ex.StatusCode == HttpStatusCode.NotFound) { _log.Critical(ex, $"There are no volatility of {assetPairId} for last days."); return; } if (volatilityModel != null) { SetDeltaSpread(markup, volatilityModel, isDeltaSpreadFixed); } }
public async Task <IActionResult> ResolveMarkupByMerchant(string merchantId, string assetPairId) { merchantId = Uri.UnescapeDataString(merchantId); assetPairId = Uri.UnescapeDataString(assetPairId); try { IMarkup markup = await _markupService.ResolveAsync(merchantId, assetPairId); return(Ok(Mapper.Map <MarkupResponse>(markup))); } catch (InvalidRowKeyValueException e) { _log.ErrorWithDetails(e, new { e.Variable, e.Value }); return(BadRequest(ErrorResponse.Create(e.Message))); } catch (MarkupNotFoundException e) { _log.ErrorWithDetails(e, new { e.MerchantId, e.AssetPairId }); return(NotFound(ErrorResponse.Create(e.Message))); } }
public void AddMarkup(IMarkup markup) { if (markup != null) { Markups.Add(markup); } }
public async Task <ContactMessage> SendContact(string chatId, string phoneNumber, string firstName, string lastName = null, bool disableNotification = false, int?replyToMessageId = null, IMarkup replyMarkup = null) { chatId.NullInspect(nameof(chatId)); phoneNumber.NullInspect(nameof(phoneNumber)); firstName.NullInspect(nameof(firstName)); var content = new Content { Json = true }; SendMethodsDefaultContent(content, chatId, disableNotification, replyToMessageId, replyMarkup); content.Add("phone_number", phoneNumber); content.Add("first_name", firstName); if (lastName != null) { content.Add("last_name", lastName); } var json = JsonConvert.SerializeObject(content.JsonData); using (var httpContent = new StringContent(json, Encoding.UTF8, "application/json")) { return(await UploadFormData <ContactMessage>(httpContent).ConfigureAwait(false)); } }
public async Task <IActionResult> GetForMerchant(string merchantId, string assetPairId) { merchantId = Uri.UnescapeDataString(merchantId); assetPairId = Uri.UnescapeDataString(assetPairId); try { IMarkup markup = await _markupService.GetForMerchantAsync(merchantId, assetPairId); if (markup == null) { return(NotFound(ErrorResponse.Create("Markup has not been set"))); } return(Ok(Mapper.Map <MarkupResponse>(markup))); } catch (InvalidRowKeyValueException e) { _log.ErrorWithDetails(e, new { e.Variable, e.Value }); return(NotFound(ErrorResponse.Create("Merchant or asset pair not found"))); } }
public async Task <IMarkup> ResolveAsync(string merchantId, string assetPairId) { IMarkup markup = await GetForMerchantAsync(merchantId, assetPairId); return(markup ?? await GetDefaultAsync(assetPairId) ?? throw new MarkupNotFoundException(merchantId, assetPairId)); }
public async Task <IActionResult> GetForMerchant(string merchantId, string assetPairId) { IMerchant merchant = await _merchantService.GetAsync(merchantId); if (merchant == null) { return(NotFound(ErrorResponse.Create("Merchant not found"))); } try { IMarkup markup = await _markupService.GetForMerchantAsync(merchantId, assetPairId); if (markup == null) { return(NotFound(ErrorResponse.Create("Markup has not been set"))); } return(Ok(Mapper.Map <MarkupResponse>(markup))); } catch (Exception ex) { await _log.WriteErrorAsync(nameof(MarkupsController), nameof(GetForMerchant), ex); throw; } }
public decimal CalculatePrice( double askPrice, double bidPrice, int pairAccuracy, int assetAccuracy, double markupPercent, int markupPips, PriceCalculationMethod priceValueType, IMarkup merchantMarkup) { _log.WriteInfoAsync(nameof(CalculationService), nameof(CalculatePrice), new { askPrice, bidPrice }.ToJson(), "Rate calculation").GetAwaiter().GetResult(); double originalPrice = GetOriginalPriceByMethod(bidPrice, askPrice, priceValueType); double spread = GetSpread(originalPrice, merchantMarkup.DeltaSpread); double priceWithSpread = GetPriceWithSpread(originalPrice, spread, priceValueType); double lpFee = GetMerchantFee(priceWithSpread, merchantMarkup.Percent); double lpPips = GetMerchantPips(merchantMarkup.Pips); double fee = GetMarkupFeePerRequest(priceWithSpread, markupPercent); decimal delta = GetDelta(spread, lpFee, fee, lpPips, markupPips, pairAccuracy); decimal result = GetPriceWithDelta(originalPrice, delta, priceValueType); return(GetRoundedPrice(result, pairAccuracy, assetAccuracy, priceValueType)); }
public static void InfoTestMarkup(string text) { String code = " \n\t \n\t\t" + text + "\n\t \n "; IMarkup p = MarkupHelper.CreateCodeBlock(code); scenario.Log(Status.Info, p); }
public static void markupCodeblock(string text, Status status) { String code = "\n\t\n\t\t" + text + "\n\t\n"; IMarkup m = MarkupHelper.CreateCodeBlock(code); test.Log(status, m); }
private string GetVolatilityAssetPairId(IMarkup markup) { if (!string.IsNullOrEmpty(markup?.PriceAssetPairId)) { return(markup.PriceAssetPairId); } return(markup?.AssetPairId); }
public async Task <IMarkup> SetAsync(IMarkup markup) { MarkupEntity entity = MarkupEntity.ByAssetPair.Create(markup); await _tableStorage.InsertOrReplaceAsync(entity); AzureIndex index = MarkupEntity.IndexByIdentity.Create(entity); await _indexByIdentity.InsertOrReplaceAsync(index); return(Mapper.Map <Core.Domain.Markup.Markup>(entity)); }
public void SendMessageAll(string text, IMarkup markup = null) { if (!requestResponseMode) { foreach (var item in chats) { API.SendMessage(item.Id.ToString(), text, reply_markup: markup); } } else { throw new InvalidOperationException("В режиме запрос-ответ невозможн отправить сообщение клиентам!"); } }
public static void FailTestMarkup(String text) { string txt = text; IMarkup Amber = MarkupHelper.CreateLabel(text, ExtentColor.Amber); scenario.Log(Status.Fail, Amber); IMarkup Black = MarkupHelper.CreateLabel(text, ExtentColor.Black); scenario.Log(Status.Fail, Black); IMarkup Blue = MarkupHelper.CreateLabel(text, ExtentColor.Blue); scenario.Log(Status.Fail, Blue); IMarkup Brown = MarkupHelper.CreateLabel(text, ExtentColor.Brown); scenario.Log(Status.Fail, Brown); IMarkup Cyan = MarkupHelper.CreateLabel(text, ExtentColor.Cyan); scenario.Log(Status.Fail, Cyan); IMarkup Green = MarkupHelper.CreateLabel(text, ExtentColor.Green); scenario.Log(Status.Fail, Green); IMarkup Grey = MarkupHelper.CreateLabel(text, ExtentColor.Grey); scenario.Log(Status.Fail, Grey); IMarkup Indigo = MarkupHelper.CreateLabel(text, ExtentColor.Indigo); scenario.Log(Status.Fail, Indigo); IMarkup Lime = MarkupHelper.CreateLabel(text, ExtentColor.Lime); scenario.Log(Status.Fail, Lime); IMarkup Orange = MarkupHelper.CreateLabel(text, ExtentColor.Orange); scenario.Log(Status.Fail, Orange); }
public void inapplication() { Console.WriteLine("Time " + String.Format("{0:MM}_{0:D}", DateTime.Now)); String datetoday = String.Format("{0:D}", DateTime.Now).Replace(",", "_").Replace(" ", "").Replace("Wednesday", "Wed"); Console.WriteLine(datetoday); excelFile.getrowcount(""); string Spec_CustName = excelFile.GetTestInputValue("SPECIFICATION", "Create_Specification", "Create_RSC_makeBoard", "SPECCUSTNAME"); excelFile.getrowcount(""); Console.WriteLine(Spec_CustName.ToLower()); htmlreporter = new ExtentHtmlReporter("D:\\Nunit_Workspace\\NUnitSamplec\\NUnitSample\\Reports\\" + datetoday + ".html"); htmlreporter.AppendExisting = true; extent = new ExtentReports(); extent.AttachReporter(htmlreporter); Console.WriteLine("Started the test test 1 "); extent.AddSystemInfo("Host Name", "Manoj"); extent.AddSystemInfo("Environment", "QA"); extent.AddSystemInfo("User Name", "Manoj"); Console.WriteLine("Started the test test 2 "); test = extent.CreateTest("Create test wrap", ""); test2 = extent.CreateTest("Second test", ""); IMarkup m = MarkupHelper.CreateLabel("Create test wrap", ExtentColor.Red); test.Log(Status.Warning, "This is the final Log"); test.Log(Status.Pass, MarkupHelper.CreateLabel("Manoj" + " Test Case PASSED", ExtentColor.Green)); Console.WriteLine("Output1 : " + Property.ProductMenu_ID); driver.Url = PropertyReader.GetProperty(Property.ProductMenu_ID, Locators.Specification.Default); driver.Manage().Window.Maximize(); PropertyReader.GetProperty(Property.BASEURL, Locators.Specification.Default); Console.WriteLine("Output : " + PropertyReader.GetProperty(Property.ProductMenu_ID, Locators.Specification.Default)); extent.AddTestRunnerLogs("Navigated to Gogle "); driver.FindElement(By.XPath(PropertyReader.GetProperty(Property.Product_Management, Locators.Specification.Default))).Click(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); Thread.Sleep(1000); // wait.Until(ExpectedConditions.ElementToBeClickable(By.Id(PropertyReader.GetProperty(Property.Specifications, Specification.Default)))); // var coomon = new Commonfunctions(); driver.FindElement(By.Id(PropertyReader.GetProperty(Property.Specifications, Locators.Specification.Default))).Click(); // coomon.findelement(driver, "id", "Specifications").Click(); // driver.FindElement(By.Id(PropertyReader.GetProperty(Property.Specifications, Specification.Default))).Click(); extent.AddTestRunnerLogs("Launched the application"); test.Info("Now i am in the test"); extent.Flush(); }
private void SendMethodsDefaultContent(MultipartFormDataContent form, string chatId, bool disableNotification, int?replyToMessageId, IMarkup replyMarkup, string caption = null) { form.Add(new StringContent(chatId, Encoding.UTF8), "chat_id"); form.Add(new StringContent(disableNotification.ToString(), Encoding.UTF8), "disable_notification"); if (caption != null) { form.Add(new StringContent(caption, Encoding.UTF8), "caption"); } if (replyToMessageId != null) { form.Add(new StringContent(replyToMessageId.ToString(), Encoding.UTF8), "reply_to_message_id"); } if (replyMarkup != null) { form.Add(new StringContent( JsonConvert.SerializeObject(replyMarkup, Formatting.None, Settings), Encoding.UTF8, "application/json"), "reply_markup"); } }
public async Task <IActionResult> GetDefault(string assetPairId) { try { IMarkup markup = await _markupService.GetDefaultAsync(assetPairId); if (markup == null) { return(NotFound(ErrorResponse.Create("Default markup has not been set"))); } return(Ok(Mapper.Map <MarkupResponse>(markup))); } catch (Exception ex) { await _log.WriteErrorAsync(nameof(MarkupsController), nameof(GetDefault), ex); throw; } }
public void LogRequest(System.Uri url, String Method) { try { string[,] a = new string[6, 2] { { "Full URL", url.AbsoluteUri }, { "Protocol", url.Scheme }, { "Port", url.Port.ToString() }, { "Host", url.DnsSafeHost }, { "Local Path", url.LocalPath }, { "Method", Method } }; IMarkup m = MarkupHelper.CreateTable(a); test.Log(Status.Info, "Request Details:"); test.Log(Status.Info, m); } catch (Exception e) { test.Log(Status.Error, e.Message); } }
public async Task <decimal> GetAmountAsync(string baseAssetId, string quotingAssetId, decimal amount, IRequestMarkup requestMarkup, IMarkup merchantMarkup) { var rate = await GetRateAsync(baseAssetId, quotingAssetId, requestMarkup.Percent, requestMarkup.Pips, merchantMarkup); _log.Info("Rate calculation", $"Calculation details: {new {baseAssetId, quotingAssetId, amount, requestMarkup, merchantMarkup, rate}.ToJson()}"); if (rate == decimal.Zero) { throw new ZeroRateException(); } decimal result = (amount + requestMarkup.FixedFee + merchantMarkup.FixedFee) / rate; Asset baseAsset = await _assetsLocalCache.GetAssetByIdAsync(baseAssetId); decimal roundedResult = decimal.Round(result, baseAsset.Accuracy, MidpointRounding.AwayFromZero); return(roundedResult); }
public void LogResponse(IRestResponse response) { try { string[,] a = new string[6, 2] { { "Response Uri", response.ResponseUri.OriginalString }, { "Status Code", ((int)response.StatusCode).ToString() }, { "Status", response.StatusDescription }, { "Error Message", response.ErrorMessage }, { "Server", response.Server }, { "Protocol", response.ProtocolVersion.ToString() } }; IMarkup m = MarkupHelper.CreateTable(a); test.Log(Status.Info, "Response Details:"); test.Log(Status.Info, m); } catch (Exception e) { test.Log(Status.Error, e.Message); } }
public async Task <decimal> GetAmountAsync(string baseAssetId, string quotingAssetId, decimal amount, IRequestMarkup requestMarkup, IMarkup merchantMarkup) { var rate = await GetRateAsync(baseAssetId, quotingAssetId, requestMarkup.Percent, requestMarkup.Pips, merchantMarkup); await _log.WriteInfoAsync(nameof(CalculationService), nameof(GetAmountAsync), new { baseAssetId, quotingAssetId, amount, requestMarkup, merchantMarkup, rate }.ToJson(), "Rate calculation"); decimal result = (amount + (decimal)requestMarkup.FixedFee + merchantMarkup.FixedFee) / rate; Asset baseAsset = await _assetsLocalCache.GetAssetByIdAsync(baseAssetId); decimal roundedResult = decimal.Round(result, baseAsset.Accuracy, MidpointRounding.AwayFromZero); return(roundedResult); }
private void SendMethodsDefaultContent(Content content, string chatId, bool disableNotification, int?replyToMessageId, IMarkup replyMarkup, string caption = null) { content.Add("disable_notification", disableNotification.ToString()); if (chatId != null) { content.Add("chat_id", chatId); } if (caption != null) { content.Add("caption", caption); } if (replyToMessageId != null) { content.Add("reply_to_message_id", replyToMessageId.ToString()); } if (replyMarkup != null) { content.Add("reply_markup", JsonConvert.SerializeObject(replyMarkup, Formatting.None, Settings)); } }
public async Task <IActionResult> ResolveMarkupByMerchant(string merchantId, string assetPairId) { IMerchant merchant = await _merchantService.GetAsync(merchantId); if (merchant == null) { return(NotFound(ErrorResponse.Create("Couldn't find merchant"))); } try { IMarkup markup = await _markupService.ResolveAsync(merchantId, assetPairId); return(Ok(Mapper.Map <MarkupResponse>(markup))); } catch (MarkupNotFoundException markupNotFoundEx) { await _log.WriteErrorAsync(nameof(MerchantsController), nameof(ResolveMarkupByMerchant), new { markupNotFoundEx.MerchantId, markupNotFoundEx.AssetPairId }.ToJson(), markupNotFoundEx); return(NotFound(ErrorResponse.Create(markupNotFoundEx.Message))); } catch (Exception ex) { await _log.WriteErrorAsync(nameof(MerchantsController), nameof(ResolveMarkupByMerchant), new { merchantId, assetPairId }.ToJson(), ex); throw; } }
public CalculationData(double input, IMarkup markupData) { InputAmount = input; Markup = markupData; }
// Retrieves SOP Instance UID and Referenced Frame Number from the coordinate private static void SetMarkupImageReference(IMarkup markup, aim4_dotnet.TwoDimensionGeometricShapeEntity geoShape) { if (geoShape != null) { Debug.Assert(geoShape.ReferencedFrameNumber > 0, "Referenced Frame Number must be positive"); markup.PresentationImageUid = geoShape.ImageReferenceUid.Uid; markup.FrameNumber = geoShape.ReferencedFrameNumber.HasValue ? geoShape.ReferencedFrameNumber.Value : 1; } }
/// <summary> /// Logs an <see cref="Status.Debug"/> event with <see cref="IMarkup"/> /// </summary> /// <param name="m"><see cref="IMarkup"/></param> /// <returns>A <see cref="ExtentTest"/> object</returns> public ExtentTest Debug(IMarkup m) { return(Log(Status.Debug, m)); }
/// <summary> /// Logs an <see cref="Status.Skip"/> event with <see cref="IMarkup"/> /// </summary> /// <param name="m"><see cref="IMarkup"/></param> /// <returns>A <see cref="ExtentTest"/> object</returns> public ExtentTest Skip(IMarkup m) { return(Log(Status.Skip, m)); }
/// <summary> /// Logs an <see cref="Status.Error"/> event with <see cref="IMarkup"/> /// </summary> /// <param name="m"><see cref="IMarkup"/></param> /// <returns>A <see cref="ExtentTest"/> object</returns> public ExtentTest Error(IMarkup m) { return(Log(Status.Error, m)); }
/// <summary> /// Logs an <see cref="Status.Warning"/> event with <see cref="IMarkup"/> /// </summary> /// <param name="m"><see cref="IMarkup"/></param> /// <returns>A <see cref="ExtentTest"/> object</returns> public ExtentTest Warning(IMarkup m) { return(Log(Status.Warning, m)); }
public MarkupListViewItem(IMarkup markup) { Markup = markup; }