Пример #1
0
        public async Task Deploy2()
        {
            const string PLATFORM     = "kraken";
            const string PAIR         = "ETHUSD";
            var          krakenClient = new KrakenConfig();
            var          repo         = new ConfigRepository(new List <IExchangeConfig>()
            {
                krakenClient
            }.ToArray());

            await repo.Deploy(PLATFORM, PAIR);

            var config = await repo.Get(PLATFORM);

            Assert.That(config.Pairs[PAIR].PlatformVariables.ContainsKey("short laverage"), Is.True);
        }
Пример #2
0
        public KrakenExchange(KrakenConfig config, TranslatedSignalsRepository translatedSignalsRepository, IHandler <TickPrice> tickPriceHandler, IHandler <ExecutionReport> tradeHandler, ILog log) :
            base(Name, config, translatedSignalsRepository, log)
        {
            this.config       = config;
            _tickPriceHandler = tickPriceHandler;
            _tradeHandler     = tradeHandler;

            var httpClient = new HttpClient()
            {
                Timeout = TimeSpan.FromSeconds(3)
            };                                                                       // TODO: HttpClient have to be Singleton

            publicData  = new PublicData(new ApiClient(httpClient, log));
            privateData = new PrivateData(new ApiClient(new HttpClient()
            {
                Timeout = TimeSpan.FromSeconds(30)
            }, log), config.ApiKey, config.PrivateKey,
                                          new NonceProvider(), Config.SupportedCurrencySymbols);
        }
Пример #3
0
        private static void ContextError(object sender, EventArgs e)
        {
            HttpApplication application = (HttpApplication)sender;
            HttpRequest     request     = application.Context.Request;
            HttpResponse    response    = application.Context.Response;
            Exception       ex          = application.Server.GetLastError();


            string hint = string.Format(
                "User='******' experienced an exception at '{1}'"
                , WebLogic.ClientIdentity
                , request.RawUrl);

            log.Fatal(hint, ex);

            string errorPageUrl = KrakenConfig.GetAppSettingAsString("ExceptionManagementHttpModule.ErrorPageUrl", false);

            // Only continue with the redirect behaviour if ExceptionManagement is turned on
            if (string.IsNullOrEmpty(errorPageUrl))
            {
                log.Warn(m => m("AppSetting 'ExceptionManagementHttpModule.ErrorPageUrl' is not present. {0} will see hard error.", WebLogic.ClientIdentity));
            }
            else
            {
                // Extract the page name from errorPageUrl setting (ignore everything up to final /)
                // This is to ensure that "http://myserver/myapp/Error.aspx" will match with errorPageUrl="~/Error.aspx"
                // in the infinite-redirect-prevention check that follows
                string errorPageName = errorPageUrl;
                int    lastSlashPos  = errorPageUrl.LastIndexOf("/");

                if (lastSlashPos > -1 && lastSlashPos < errorPageUrl.Length - 1)
                {
                    errorPageName = errorPageUrl.Substring(lastSlashPos + 1);
                }

                // Before re-directing to Error page, make sure current request is NOT the error page
                // (avoids infinite redirect loop)
                if (request.Url.PathAndQuery.ToLower().IndexOf(errorPageName.ToLower()) < 0)
                {
                    response.Redirect(errorPageUrl);
                }
            }
        }