Ejemplo n.º 1
0
            public void PostAssetPairPipsDiffValuesBidRoundingTest(object expectedBid, object roundedBid)
            {
                var assetPairRates = lykkePayApi.assetPairRates.GetAssetPairRates(testAsset).GetResponseObject();

                var bid         = assetPairRates.bid;
                var deltaSpread = new Decimal(new AzureUtils(LocalConfig.GetLocalConfig().AzureDeltaSpread)
                                              .GetCloudTable("Merchants")
                                              .GetSearchResult("ApiKey", "BILETTERTESTKEY")
                                              .GetCellByKnowRowKeyAndKnownCellValue("DeltaSpread", "bitteller.test.1").DoubleValue.Value);

                var newBid  = assetPairRates.bid - assetPairRates.bid * deltaSpread / 100;
                var percent = (-decimal.Parse(expectedBid.ToString()) + newBid - newBid * 0.1m /*lykkays percent*/ - newBid * 0 /*lykkays pips*/) * 100 / newBid;
                var perc    = percent.ToString(CultureInfo.InvariantCulture);

                string markUp = $"{{\"markup\": {{\"percent\":{perc}, \"pips\": 0}}}}";

                var merchant = new MerchantModel(markUp);

                var response = lykkePayApi.assetPairRates.PostAssetsPairRates(testAsset, merchant, markUp);

                Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK), "Unexpected status code");
                var postModel = JsonConvert.DeserializeObject <PostAssetsPairRatesModel>(response.Content);

                Assert.Multiple(() =>
                {
                    Assert.That(postModel.LykkeMerchantSessionId, Is.Not.Null, "LykkeMerchantSessionId not present in response");
                    Assert.That(postModel.bid, Is.EqualTo(decimal.Parse(roundedBid.ToString())), "Actual bid is not equal to expected");
                });
            }
Ejemplo n.º 2
0
        public ConfigBuilder()
        {
            LocalConfig localConfig = LocalConfig.GetLocalConfig();

            Config = new ConfigurationBuilder().AddEnvironmentVariables().Build();
            Config.Providers.First().Set("SettingsUrl", $"{localConfig.SettingsServiceURL}{localConfig.SettingsServiceAccessToken}");

            ReloadingManager = Config.LoadSettings <AppSettings>("SettingsUrl", false);
        }
Ejemplo n.º 3
0
        public static IReloadingManager <AppSettings> InitConfiguration()
        {
            LocalConfig localConfig = LocalConfig.GetLocalConfig();

            var config = new ConfigurationBuilder().AddEnvironmentVariables().Build();

            config.Providers.First().Set("SettingsUrl", $"{localConfig.SettingsServiceURL}{localConfig.SettingsServiceAccessToken}");

            return(config.LoadSettings <AppSettings>("SettingsUrl", false));
        }
Ejemplo n.º 4
0
            public double ExpectedBid(double percent, int pips, string assetPair = "BTCUSD")
            {
                var assetPairRates = lykkePayApi.assetPairRates.GetAssetPairRates(assetPair).GetResponseObject();

                var bid         = assetPairRates.bid;
                var deltaSpread = new Decimal(new AzureUtils(LocalConfig.GetLocalConfig().AzureDeltaSpread)
                                              .GetCloudTable("Merchants")
                                              .GetSearchResult("ApiKey", "BILETTERTESTKEY")
                                              .GetCellByKnowRowKeyAndKnownCellValue("DeltaSpread", "bitteller.test.1").DoubleValue.Value);

                decimal newBid  = bid - deltaSpread * bid / 100;
                var     tempBid = (newBid * (1 - decimal.Parse(percent.ToString(), CultureInfo.InvariantCulture) / 100 - 0.1m) - pips / (decimal)Math.Pow(10, assetPairRates.accuracy));

                var expectedBid = Math.Floor((tempBid) * (decimal)Math.Pow(10, assetPairRates.accuracy)) / (decimal)Math.Pow(10, assetPairRates.accuracy);

                return(expectedBid >= 0 ? (double)expectedBid : 0);
            }
Ejemplo n.º 5
0
            public double ExpectedAsk(double percent, int pips, string assetPair = "BTCUSD")
            {
                var assetPairRates = lykkePayApi.assetPairRates.GetAssetPairRates(assetPair).GetResponseObject();

                var ask         = assetPairRates.ask;
                var deltaSpread = new Decimal(new AzureUtils(LocalConfig.GetLocalConfig().AzureDeltaSpread)
                                              .GetCloudTable("Merchants")
                                              .GetSearchResult("ApiKey", "BILETTERTESTKEY")
                                              .GetCellByKnowRowKeyAndKnownCellValue("DeltaSpread", "bitteller.test.1").DoubleValue.Value);

                decimal newAsk      = ask + (deltaSpread * ask) / 100;
                decimal spread      = newAsk * decimal.Parse(percent.ToString(), CultureInfo.InvariantCulture) / 100;
                decimal lpm         = newAsk * 0.1m;
                var     expectedAsk = newAsk * (1 + decimal.Parse(percent.ToString(), CultureInfo.InvariantCulture) / 100 + 0.1m) + pips / (decimal)Math.Pow(10, assetPairRates.accuracy);
                var     a1          = expectedAsk - Math.Floor(expectedAsk); // fraction
                var     a2          = a1 * 1000 - Math.Floor(a1 * 1000);     // 0.000XXX fraction

                expectedAsk = Math.Floor((Math.Floor(expectedAsk) + a1) * 1000) / 1000;
                if ((a1 - a2 / 1000) > 0)
                {
                    expectedAsk += +0.001m; //move this to 10^curr
                }
                return((double)expectedAsk);
            }