public override void Destory() { base.Destory(); IStorageManager storageManager = ApiFactory.Get <IStorageManager>(this); storageManager.ClearCache(); }
// Display all balances for the specified exchange // where T like KrakenRestApi and exchange like "KRAKEN" and symbolId like "btcusd" static void DisplayBalances(string exchange, string symbolId) { try { Console.WriteLine("{0}", new string('=', 80)); var api = m_factory.Get(exchange); var t = api.GetTicker(symbolId); t.Wait(); t.Result.Print(api.Exchange); var b = api.GetBalances(); b.Wait(); b.Result.PrintNonZero(api.Exchange); } catch (Exception ex) { Console.WriteLine("ERROR ({0}, {1}): {2}", exchange, symbolId, ex.Message); } }
// Display account balances for each exchange static void DisplayAllExchangeBalances() { DisplayBalances("KRAKEN", "btcusd"); DisplayBalances("BITFINEX", "btcusd"); DisplayBalances("BINANCE", "btcusdt"); DisplayBalances("BITTREX", "btcusdt"); DisplayBalances("POLONIEX", "btcusdt"); DisplayBalances("GDAX", "btcusd"); try { GdaxRestApi api = m_factory.Get("GDAX") as GdaxRestApi; api.PrintCoinbaseAccounts().Wait(); } catch (Exception ex) { Console.WriteLine("\nGDAX Coinbase Error: {0}", ex.Message); } }
static Dictionary <string, List <HitBtcTicker> > m_hitTickers; // HitBTC tickers static void Main(string[] args) { Console.WriteLine("\n*** WECOME TO CRYPTO CONSOLE ***\n"); Console.WriteLine("********** GATOR " + new string('*', 103)); //CryptoTools.Cryptography.Cryptography.EncryptFile("X:/Users/Trader/Documents/hat_apis.json", "/Users/michael/Documents/hat_apis.enc", pw); // encrypt api key file var api = m_factory.Get("HITBTC") as CryptoRestApis.Exchange.HitBtc.HitBtcRestApi; /*//var symbols = api.GetSymbols(); * m_factory = new ApiFactory(m_credentialsFile, m_pw);*/ //string password = "******"; //var apiXS = new ExchangeSharpRestApi("/Users/michael/Documents/hat_apis.csv.enc", password); var apiXS = new ExchangeSharpRestApi(); //apiXS.Gator("ETH-USD", amountRequested:200, bips:125); if (args.Length < 3) { Console.WriteLine("usage: dotnet CryptoConsole.dll <symbol> <amount> <bips> (#display)"); Console.WriteLine(); Console.WriteLine(" ex: dotnet CryptoConsole.dll ETH-USD 200 125"); Console.WriteLine(" dotnet CryptoConsole.dll BTC-USD 90 125 20"); Console.WriteLine(" dotnet CryptoConsole.dll BTC-USDT 75 150"); return; } string symbol = args[0]; decimal amount = decimal.Parse(args[1]); int bips = int.Parse(args[2]); int displayBook = 0; if (args.Length > 3) { displayBook = int.Parse(args[3]); } apiXS.Gator(symbol, amount, bips, displayBook); //DisplayBinanceTotals(); //BinanceSellAllCurrency(1.0M); /*//var api = m_factory.Get("HITBTC") as CryptoRestApis.Exchange.HitBtc.HitBtcRestApi; * //var symbols = api.GetSymbols(); * * //symbols.ForEach(s => Console.WriteLine(s)); * var t1 = api.GetOneTicker("DASHBTC"); * Console.WriteLine(t1); * var c1 = api.GetCandles("DASHBTC"); * c1.ForEach(cc => Console.WriteLine(cc));*/ /*Console.Write("\n\nPress any key to exit... "); * Console.ReadKey(); * return; * * string pathname = Path.Combine(GetExeDirectory(), "data.hitbtc_tickers.txt"); * bool writeHeaders = !File.Exists(pathname); * var writer = new StreamWriter(pathname, true); * if (writeHeaders) * { * writer.WriteLine(HitBtcTicker.CsvHeaders); * writer.Flush(); * } * * while (true) * { * var tickers = api.GetAllTickers(); * if (m_hitTickers == null) // first time through, create the dictionary to store HitBtc data * { * m_hitTickers = new Dictionary<string, List<HitBtcTicker>>(); * foreach (var t in tickers) * { * m_hitTickers[t.symbol] = new List<HitBtcTicker>(); * m_hitTickers[t.symbol].Add(t); * } * } * else * { * Console.WriteLine(new string('=', 120)); * int count = 0; * foreach (var t in tickers) * { * if (!m_hitTickers.ContainsKey(t.symbol)) // if we have not yet stored this symbol... * { * m_hitTickers[t.symbol] = new List<HitBtcTicker>(); // create a new list for this symbol's tickers * m_hitTickers[t.symbol].Add(t); * } * else * { * var last = m_hitTickers[t.symbol].Last(); // check the last ticker we added to the list for this symbol * if (true) //last.timestamp != t.timestamp) // only add to our stored tickers if the "last_updated" field has changed * { * m_hitTickers[t.symbol].Add(t); * //Console.WriteLine(t); * writer.WriteLine(t.ToCsv()); * writer.Flush(); * count++; * } * } * } * Console.WriteLine("{0} ({1} updates)", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), count); * } * Thread.Sleep(20000); // sleep for 20 seconds * } * * * //BinanceTotals(); * //var mgr = new CryptoTools.SymbolManager(); * //SellBinance(0.50M, "bnb"); * * * Console.Write("\n\nPress any key to exit... "); * Console.ReadKey(); * return; */ }