Ejemplo n.º 1
0
        public ActionResult ExchangePairs(string exchange, string baseCurrency)
        {
            var result = new JArray();

            var symbolArray = new JArray();

            IExchangeAPI api           = ExchangeAPI.GetExchangeAPI(exchange);
            var          exchangeCoins = api.GetSymbolsMetadataAsync().Result;

            if (!String.IsNullOrEmpty(baseCurrency))
            {
                exchangeCoins = exchangeCoins.Where(e => e.BaseCurrency.ToLowerInvariant() == baseCurrency.ToLowerInvariant());
            }

            foreach (var coin in exchangeCoins)
            {
                symbolArray.Add(api.ExchangeSymbolToGlobalSymbol(coin.MarketName));
            }

            var baseCurrencyArray      = new JArray();
            var exchangeBaseCurrencies = api.GetSymbolsMetadataAsync().Result.Select(m => m.BaseCurrency).Distinct();

            foreach (var currency in exchangeBaseCurrencies)
            {
                baseCurrencyArray.Add(currency);
            }

            result.Add(symbolArray);
            result.Add(baseCurrencyArray);

            return(new JsonResult(result));
        }
        public static void RunGetOrderHistory(Dictionary <string, string> dict)
        {
            RequireArgs(dict, "exchangeName", "marketSymbol");

            string       exchangeName = dict["exchangeName"];
            IExchangeAPI api          = ExchangeAPI.GetExchangeAPI(exchangeName);
            string       marketSymbol = dict["marketSymbol"];

            Authenticate(api);

            DateTime?startDate = null;

            if (dict.ContainsKey("startDate"))
            {
                startDate = DateTime.Parse(dict["startDate"]).ToUniversalTime();
            }

            var completedOrders = api.GetCompletedOrderDetailsAsync(marketSymbol, startDate).Sync();

            foreach (var completedOrder in completedOrders)
            {
                Console.WriteLine(completedOrder);
            }

            Console.Write("Press enter to exit..");
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        private async void FetchTickers()
        {
            if (!Created || string.IsNullOrWhiteSpace(cmbExchange.SelectedItem as string))
            {
                return;
            }

            this.UseWaitCursor = true;
            try
            {
                var api = ExchangeAPI.GetExchangeAPI(cmbExchange.SelectedItem as string);
                var tickers = await api.GetTickersAsync();
                StringBuilder b = new StringBuilder();
                foreach (var ticker in tickers)
                {
                    b.AppendFormat("{0,-12}{1}\r\n", ticker.Key, ticker.Value);
                }
                textTickersResult.Text = b.ToString();
            }
            catch (Exception ex)
            {
                textTickersResult.Text = ex.ToString();
            }
            finally
            {
                Invoke(new Action(() => this.UseWaitCursor = false));
            }
        }
 private static void RunWebSocketTickers(Dictionary <string, string> dict)
 {
     using (var api = ExchangeAPI.GetExchangeAPI(dict["exchangeName"]))
     {
         if (api == null)
         {
             throw new ArgumentException("Cannot find exchange with name {0}", dict["exchangeName"]);
         }
         try
         {
             using (var socket = api.GetTickersWebSocket(freshTickers =>
             {
                 foreach (KeyValuePair <string, ExchangeTicker> kvp in freshTickers)
                 {
                     Console.WriteLine($"market {kvp.Key}, ticker {kvp.Value}");
                 }
             }))
             {
                 Console.WriteLine("Press any key to quit.");
                 Console.ReadKey();
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("Web socket error: " + ex);
         }
     }
 }
Ejemplo n.º 5
0
        public static void RunGetHistoricalTrades(Dictionary <string, string> dict)
        {
            RequireArgs(dict, "exchangeName", "symbol");

            string       exchangeName = dict["exchangeName"];
            IExchangeAPI api          = ExchangeAPI.GetExchangeAPI(exchangeName);
            string       symbol       = dict["symbol"];

            Console.WriteLine("Showing historical trades for exchange {0}...", exchangeName);
            DateTime?startDate = null;
            DateTime?endDate   = null;

            if (dict.ContainsKey("startDate"))
            {
                startDate = DateTime.Parse(dict["startDate"]).ToUniversalTime();
            }
            if (dict.ContainsKey("endDate"))
            {
                endDate = DateTime.Parse(dict["endDate"]).ToUniversalTime();
            }
            api.GetHistoricalTrades((IEnumerable <ExchangeTrade> trades) =>
            {
                foreach (ExchangeTrade trade in trades)
                {
                    Console.WriteLine("Trade at timestamp {0}: {1}/{2}/{3}", trade.Timestamp.ToLocalTime(), trade.Id, trade.Price, trade.Amount);
                }
                return(true);
            }, symbol, startDate, endDate);
        }
        private static void RunOrderBookWebSocket(Dictionary <string, string> dict)
        {
            RequireArgs(dict, "exchangeName");
            var api = ExchangeAPI.GetExchangeAPI(dict["exchangeName"]);

            if (api == null)
            {
                throw new ArgumentException("Cannot find exchange with name {0}", dict["exchangeName"]);
            }
            var apiSymbols = api.GetSymbols();

            string[] symbols = dict["symbols"].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string symbol in symbols)
            {
                if (!apiSymbols.Contains(symbol))
                {
                    throw new ArgumentException(string.Format("Symbol {0} does not exist in API {1}, valid symbols: {2}", symbol, api.Name, string.Join(",", apiSymbols.OrderBy(s => s))));
                }
            }

            IDisposable socket = api.GetOrderBookWebSocket(message =>
            {
                //print the top bid and ask with amount
                var topBid = message.Bids.FirstOrDefault();
                var topAsk = message.Asks.FirstOrDefault();
                Console.WriteLine($"[{message.Symbol}:{message.SequenceId}] {topBid.Value.Price} ({topBid.Value.Amount}) | {topAsk.Value.Price} ({topAsk.Value.Amount})");
            }, symbols: symbols);

            Console.WriteLine("Press any key to quit.");
            Console.ReadKey();
            socket.Dispose();
        }
 private static async Task RunWebSocket(Dictionary <string, string> dict, Func <IExchangeAPI, Task <IWebSocket> > func)
 {
     RequireArgs(dict, "exchangeName");
     using (var api = ExchangeAPI.GetExchangeAPI(dict["exchangeName"]))
     {
         if (api == null)
         {
             throw new ArgumentException("Cannot find exchange with name {0}", dict["exchangeName"]);
         }
         try
         {
             Logger.Info("Connecting web socket to {0}...", api.Name);
             using (var socket = await func(api))
             {
                 SetWebSocketEvents(socket);
                 Console.WriteLine("Press any key to quit.");
                 Console.ReadKey();
             }
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
     }
 }
        public static void RunGetCandles(Dictionary <string, string> dict)
        {
            RequireArgs(dict, "exchangeName", "marketSymbol");
            using (var api = ExchangeAPI.GetExchangeAPI(dict["exchangeName"]))
            {
                if (api == null)
                {
                    throw new ArgumentException("Cannot find exchange with name {0}", dict["exchangeName"]);
                }

                try
                {
                    var marketSymbol = dict["marketSymbol"];
                    var candles      = api.GetCandlesAsync(marketSymbol, 1800, DateTime.UtcNow.AddDays(-12), DateTime.UtcNow).Sync();

                    foreach (var candle in candles)
                    {
                        Console.WriteLine(candle);
                    }

                    Console.WriteLine("Press any key to quit.");
                    Console.ReadKey();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            }
        }
        public static async Task RunGetCandles(Dictionary <string, string> dict)
        {
            RequireArgs(dict, "exchangeName", "marketSymbol");
            using (var api = ExchangeAPI.GetExchangeAPI(dict["exchangeName"]))
            {
                if (api == null)
                {
                    throw new ArgumentException("Cannot find exchange with name {0}", dict["exchangeName"]);
                }

                try
                {
                    var marketSymbol = dict["marketSymbol"];
                    var candles      = await api.GetCandlesAsync(marketSymbol, 1800, CryptoUtility.UtcNow.AddDays(-12), CryptoUtility.UtcNow);

                    foreach (var candle in candles)
                    {
                        Logger.Info(candle.ToString());
                    }

                    WaitForKey();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            }
        }
        public static void RunGetMarketSymbols(Dictionary <string, string> dict)
        {
            RequireArgs(dict, "exchangeName");
            using (var api = ExchangeAPI.GetExchangeAPI(dict["exchangeName"]))
            {
                if (api == null)
                {
                    throw new ArgumentException("Cannot find exchange with name {0}", dict["exchangeName"]);
                }

                try
                {
                    var marketSymbols = api.GetMarketSymbolsAsync().Sync();

                    foreach (var marketSymbol in marketSymbols)
                    {
                        Console.WriteLine(marketSymbol);
                    }

                    Console.WriteLine("Press any key to quit.");
                    Console.ReadKey();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            }
        }
Ejemplo n.º 11
0
        public static void RunGetHistoricalTrades(Dictionary <string, string> dict)
        {
            RequireArgs(dict, "exchangeName", "marketSymbol");

            string       exchangeName = dict["exchangeName"];
            IExchangeAPI api          = ExchangeAPI.GetExchangeAPI(exchangeName);
            string       marketSymbol = dict["marketSymbol"];

            Console.WriteLine("Showing historical trades for exchange {0}...", exchangeName);
            DateTime?startDate = null;
            DateTime?endDate   = null;

            if (dict.ContainsKey("startDate"))
            {
                startDate = DateTime.Parse(dict["startDate"]).ToUniversalTime();
            }
            if (dict.ContainsKey("endDate"))
            {
                endDate = DateTime.Parse(dict["endDate"]).ToUniversalTime();
            }
            //api.GetHistoricalTradesAsync((List<ExchangeTrade> trades) =>
            //{
            //    foreach (ExchangeTrade trade in trades)
            //    {
            //        Console.WriteLine("Trade at timestamp {0}: {1}/{2}/{3}", trade.DateTime.ToLocalTime(), trade.Id, trade.Price, trade.Amount);
            //    }
            //    return true;
            //}, marketSymbol, startDate, endDate).Sync();
        }
        public static async Task RunGetMarketSymbols(Dictionary <string, string> dict)
        {
            RequireArgs(dict, "exchangeName");
            using (var api = ExchangeAPI.GetExchangeAPI(dict["exchangeName"]))
            {
                if (api == null)
                {
                    throw new ArgumentException("Cannot find exchange with name {0}", dict["exchangeName"]);
                }

                try
                {
                    var marketSymbols = await api.GetMarketSymbolsAsync();

                    foreach (var marketSymbol in marketSymbols)
                    {
                        Logger.Info(marketSymbol);
                    }

                    WaitForKey();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            }
        }
Ejemplo n.º 13
0
        public BaseExchange BaseExchange(string exchange)
        {
            IExchangeAPI   api           = ExchangeAPI.GetExchangeAPI(exchange.ToLower());
            var            builder       = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true);
            IConfiguration configuration = builder.Build();

            ExchangeOptions exchangeOptions = new ExchangeOptions();

            exchangeOptions.Exchange = (Exchange)Enum.Parse(typeof(Exchange), exchange, true);

            string apiKey;
            string apiSecret;

            //Check if there are multiple exchanges in config, else Fallback to single mode
            if (configuration.GetSection("Exchanges").GetSection(exchange) != null)
            {
                apiKey    = configuration.GetSection("Exchanges").GetSection(exchange).GetValue <string>("ApiKey");
                apiSecret = configuration.GetSection("Exchanges").GetSection(exchange).GetValue <string>("ApiSecret");
            }
            else
            {
                apiKey    = configuration.GetValue <string>("ApiKey");
                apiSecret = configuration.GetValue <string>("ApiSecret");
            }

            exchangeOptions.Exchange  = (Exchange)Enum.Parse(typeof(Exchange), exchange, true);
            exchangeOptions.ApiKey    = apiKey;
            exchangeOptions.ApiSecret = apiSecret;

            return(new BaseExchange(exchangeOptions));
        }
Ejemplo n.º 14
0
        public string GlobalToExchangeSymbol(string exchange, string symbol)
        {
            IExchangeAPI api            = ExchangeAPI.GetExchangeAPI(exchange);
            string       exchangeSymbol = api.GlobalMarketSymbolToExchangeMarketSymbolAsync(symbol).Result;

            return(exchangeSymbol);
        }
Ejemplo n.º 15
0
        public string GlobalToExchangeSymbol(string exchange, string symbol)
        {
            IExchangeAPI api            = ExchangeAPI.GetExchangeAPI(exchange.ToLower());
            string       exchangeSymbol = api.GlobalSymbolToExchangeSymbol(symbol);

            return(exchangeSymbol);
        }
Ejemplo n.º 16
0
        public ActionResult BacktesterResults(string exchange, string coinsToBuy, string baseCurrency, string candleSize = "5", string strategy = "all")
        {
            JObject strategies = new JObject();

            List <string> coins = new List <string>();

            if (String.IsNullOrEmpty(coinsToBuy))
            {
                IExchangeAPI api           = ExchangeAPI.GetExchangeAPI(exchange.ToLower());
                var          exchangeCoins = api.GetSymbolsMetadataAsync().Result.Where(m => m.BaseCurrency == baseCurrency);
                foreach (var coin in exchangeCoins)
                {
                    coins.Add(api.ExchangeSymbolToGlobalSymbol(coin.MarketName));
                }
            }
            else
            {
                Char     delimiter       = ',';
                String[] coinsToBuyArray = coinsToBuy.Split(delimiter);
                foreach (var coin in coinsToBuyArray)
                {
                    coins.Add(coin.ToUpper());
                }
            }

            var backtestOptions = new BacktestOptions
            {
                DataFolder   = Global.DataPath,
                Exchange     = (Exchange)Enum.Parse(typeof(Exchange), exchange, true),
                Coins        = coins,
                CandlePeriod = Int32.Parse(candleSize)
            };

            var cts             = new CancellationTokenSource();
            var parallelOptions = new ParallelOptions
            {
                CancellationToken      = cts.Token,
                MaxDegreeOfParallelism = Environment.ProcessorCount
            };

            Parallel.ForEach(BacktestFunctions.GetTradingStrategies(), parallelOptions, async tradingStrategy =>
            {
                if (strategy != "all")
                {
                    var base64EncodedBytes = Convert.FromBase64String(strategy);
                    if (tradingStrategy.Name != Encoding.UTF8.GetString(base64EncodedBytes))
                    {
                        return;
                    }
                }
                var result = await BacktestFunctions.BackTestJson(tradingStrategy, backtestOptions, Global.DataStoreBacktest);
                foreach (var item in result)
                {
                    await Runtime.GlobalHubBacktest.Clients.All.SendAsync("Send", JsonConvert.SerializeObject(item));
                }
            });

            return(new JsonResult(strategies));
        }
Ejemplo n.º 17
0
        public string GlobalToTradingViewSymbol(string exchange, string symbol)
        {
            //Trading view use same format as Binance -> BTC-ETH is ETHBTC
            IExchangeAPI api            = ExchangeAPI.GetExchangeAPI(exchange);
            string       exchangeSymbol = api.GlobalMarketSymbolToExchangeMarketSymbolAsync(symbol).Result;

            return(exchangeSymbol);
        }
Ejemplo n.º 18
0
        public string GlobalToTradingViewSymbol(string exchange, string symbol)
        {
            //Trading view use same format as Binance -> BTC-ETH is ETHBTC
            IExchangeAPI api            = ExchangeAPI.GetExchangeAPI("binance");
            string       exchangeSymbol = api.GlobalSymbolToExchangeSymbol(symbol);

            return(exchangeSymbol);
        }
Ejemplo n.º 19
0
        public async Task <ActionResult> ExchangePairsExchangeSymbols(string exchange)
        {
            JArray       symbolArray   = new JArray();
            IExchangeAPI api           = ExchangeAPI.GetExchangeAPI(exchange);
            var          exchangeCoins = await api.GetMarketSymbolsAsync();

            foreach (var coin in exchangeCoins)
            {
                symbolArray.Add(coin);
            }
            return(new JsonResult(symbolArray));
        }
Ejemplo n.º 20
0
        private static ExchangePoloniexAPI CreatePoloniexAPI(string response = null)
        {
            var requestMaker = new MockAPIRequestMaker();

            if (response != null)
            {
                requestMaker.GlobalResponse = response;
            }
            var api = (ExchangeAPI.GetExchangeAPI(ExchangeName.Poloniex) as ExchangePoloniexAPI) !;

            api.RequestMaker = requestMaker;
            return(api);
        }
Ejemplo n.º 21
0
        private ExchangeBitBankAPI MakeMockRequestMaker(string response = null)
        {
            var requestMaker = new MockAPIRequestMaker();

            if (response != null)
            {
                requestMaker.GlobalResponse = response;
            }
            var api = (ExchangeAPI.GetExchangeAPI(ExchangeName.BitBank) as ExchangeBitBankAPI) !;

            api.RequestMaker = requestMaker;
            return(api);
        }
Ejemplo n.º 22
0
        public static void RunExportData(Dictionary <string, string> dict)
        {
            RequireArgs(dict, "exchange", "symbol", "path", "sinceDateTime");
            string exchange = dict["exchange"];
            long   total    = 0;

            TraderExchangeExport.ExportExchangeTrades(ExchangeAPI.GetExchangeAPI(exchange), dict["symbol"], dict["path"], DateTime.Parse(dict["sinceDateTime"]), (long count) =>
            {
                total = count;
                Console.Write("Exporting {0}: {1}     \r", exchange, total);
            });
            Console.WriteLine("{0}Finished Exporting {1}: {2}     \r", Environment.NewLine, exchange, total);
        }
Ejemplo n.º 23
0
        public async Task <ActionResult> FillCandlesGaps(string exchange, string coinsToBuy, string baseCurrency, DateTime?from = null, DateTime?to = null, string candleSize = "5")
        {
            var coins = new List <string>();

            if (String.IsNullOrEmpty(coinsToBuy))
            {
                IExchangeAPI api           = ExchangeAPI.GetExchangeAPI(exchange);
                var          exchangeCoins = api.GetSymbolsMetadataAsync().Result.Where(m => m.BaseCurrency == baseCurrency);
                foreach (var coin in exchangeCoins)
                {
                    coins.Add(api.ExchangeSymbolToGlobalSymbol(coin.MarketName));
                }
            }
            else
            {
                Char     delimiter       = ',';
                String[] coinsToBuyArray = coinsToBuy.Split(delimiter);
                foreach (var coin in coinsToBuyArray)
                {
                    coins.Add(coin.ToUpper());
                }
            }

            var backtestOptions = new BacktestOptions
            {
                DataFolder   = Global.DataPath,
                Exchange     = (Exchange)Enum.Parse(typeof(Exchange), exchange, true),
                Coins        = coins,
                CandlePeriod = Int32.Parse(candleSize),
                EndDate      = DateTime.Now
            };

            if (from.HasValue)
            {
                backtestOptions.StartDate = from.Value;
            }

            if (to.HasValue)
            {
                backtestOptions.EndDate = to.Value;
                backtestOptions.EndDate = backtestOptions.EndDate.AddDays(1).AddMinutes(-1);
            }

            await DataRefresher.FillCandlesGaps(x => Global.Logger.Information(x), backtestOptions, Global.DataStoreBacktest);

            var result = new JObject {
                ["result"] = "success"
            };

            return(new JsonResult(result));
        }
Ejemplo n.º 24
0
        public override async Task RunCommand()
        {
            using var api = ExchangeAPI.GetExchangeAPI(ExchangeName.Kraken);
            var ticker = await api.GetTickerAsync("XXBTZUSD");

            Console.WriteLine("On the Kraken exchange, 1 bitcoin is worth {0} USD.", ticker.Bid);

            try
            {
                // load API keys created from ExchangeSharpConsole.exe keys mode=create path=keys.bin keylist=public_key,private_key
                api.LoadAPIKeys(KeyPath);
            }
            catch (ArgumentException)
            {
                Console.Error.WriteLine(
                    "Invalid key file.\n" +
                    "Try generating a key file with the \"keys\" utility."
                    );
                Environment.Exit(Program.ExitCodeError);
                return;
            }

            // place limit order for 0.01 bitcoin at ticker.Ask USD
            var result = await api.PlaceOrderAsync(new ExchangeOrderRequest
            {
                Amount       = 0.01m,
                IsBuy        = true,
                Price        = ticker.Ask,
                MarketSymbol = "XXBTZUSD"
            });

            // Kraken is a bit funny in that they don't return the order details in the initial request, so you have to follow up with an order details request
            //  if you want to know more info about the order - most other exchanges don't return until they have the order details for you.
            // I've also found that Kraken tends to fail if you follow up too quickly with an order details request, so sleep a bit to give them time to get
            //  their house in order.
            await Task.Delay(500);

            result = await api.GetOrderDetailsAsync(result.OrderId);

            Console.WriteLine(
                "Placed an order on Kraken for 0.01 bitcoin at {0} USD. Status is {1}. Order id is {2}.",
                ticker.Ask, result.Result, result.OrderId
                );
        }
Ejemplo n.º 25
0
        public ExchangeAPI ConstructClient()
        {
            var data = GetData();

            var result = ExchangeAPI.GetExchangeAPI(data.ExchangeName);

            if (result is ExchangeAPI api)
            {
                if (!string.IsNullOrEmpty(data.OverrideUrl))
                {
                    api.BaseUrl = data.OverrideUrl;
                }

                api.LoadAPIKeysUnsecure(data.PublicKey, data.PrivateKey, data.PassPhrase);
                return(api);
            }

            return(null);
        }
Ejemplo n.º 26
0
        internal void Subscribe(string exch, string instument, string side, int topicId)
        {
            if (!tickers.TryGetValue(GetKey(exch, instument), out ExtTicker extTicker))
            {
                extTicker = new ExtTicker()
                {
                    API    = ExchangeAPI.GetExchangeAPI(exch),
                    Symbol = instument,
                };
                tickers[GetKey(exch, instument)] = extTicker;
            }

            if (topics.ContainsKey(topicId))
            {
                throw new ArgumentException("topicid " + topicId + " already been used");
            }
            topics[topicId] = new Tuple <TickerSide, ExtTicker>(GetSide(side), extTicker);
            Task.Run(() => extTicker.GetTicker());
        }
Ejemplo n.º 27
0
        protected async Task RunWebSocket(string exchangeName, Func <IExchangeAPI, Task <IWebSocket> > getWebSocket)
        {
            using var api = ExchangeAPI.GetExchangeAPI(exchangeName);

            Console.WriteLine("Connecting web socket to {0}...", api.Name);

            IWebSocket socket = null;
            var        tcs    = new TaskCompletionSource <bool>();

            // ReSharper disable once AccessToModifiedClosure
            var disposable = KeepSessionAlive(() =>
            {
                socket?.Dispose();
                tcs.TrySetResult(true);
            });

            try
            {
                socket = await getWebSocket(api);

                socket.Connected += _ =>
                {
                    Console.WriteLine("Web socket connected.");
                    return(Task.CompletedTask);
                };
                socket.Disconnected += _ =>
                {
                    Console.WriteLine("Web socket disconnected.");

                    // ReSharper disable once AccessToDisposedClosure
                    disposable.Dispose();

                    return(Task.CompletedTask);
                };

                await tcs.Task;
            }
            catch
            {
                disposable.Dispose();
                throw;
            }
        }
Ejemplo n.º 28
0
        private static void RunWebSocket(Dictionary <string, string> dict)
        {
            var api = ExchangeAPI.GetExchangeAPI(dict["exchangeName"]);

            if (api == null)
            {
                throw new ArgumentException("Cannot find exchange with name {0}", dict["exchangeName"]);
            }
            IDisposable socket = api.GetTickersWebSocket(freshTickers =>
            {
                foreach (KeyValuePair <string, ExchangeTicker> kvp in freshTickers)
                {
                    Console.WriteLine($"market {kvp.Key}, ticker {kvp.Value}");
                }
            });

            Console.WriteLine("Press any key to quit.");
            Console.ReadKey();
            socket.Dispose();
        }
Ejemplo n.º 29
0
        public override Task RunCommand()
        {
            long total = 0;

            TraderExchangeExport.ExportExchangeTrades(
                ExchangeAPI.GetExchangeAPI(ExchangeName),
                MarketSymbol,
                Path,
                DateTime.Parse(SinceDateString, CultureInfo.InvariantCulture),
                count =>
            {
                total = count;
                Console.WriteLine($"Exporting {ExchangeName}: {total}");
            }
                );

            Console.WriteLine($"Finished Exporting {ExchangeName}: {total}");

            return(Task.CompletedTask);
        }
Ejemplo n.º 30
0
        public void ExchangeGetCreateTest()
        {
            // make sure get exchange api calls serve up the same instance
            var ex1 = ExchangeAPI.GetExchangeAPI <ExchangeGeminiAPI>();
            var ex2 = ExchangeAPI.GetExchangeAPI(ExchangeName.Gemini);

            Assert.AreSame(ex1, ex2);
            Assert.IsInstanceOfType(ex2, typeof(ExchangeGeminiAPI));

            // make sure create exchange serves up new instances
            var ex3 = ExchangeAPI.CreateExchangeAPI <ExchangeGeminiAPI>();

            Assert.AreNotSame(ex3, ex2);

            // make sure a bad exchange name throws correct exception
            Assert.ThrowsException <ApplicationException>(() =>
            {
                ExchangeAPI.GetExchangeAPI("SirExchangeNotAppearingInThisFilm");
            });
        }