// Join the inside bid/offer public static ExchangeOrderResult GdaxJoinInside(ExchangeGdaxAPI api, string symbol, OrderSide side, decimal amount) { var t = api.GetTicker(symbol); var order = new ExchangeOrderRequest(); var price = (side == OrderSide.Buy) ? t.Bid : t.Ask; return(GdaxOrder(api, symbol, side, price, amount, postOnly: true)); }
public CGDAX() : base() { API_KEY = Properties.Settings.Default.GDAX_API_KEY; API_SECRET = Properties.Settings.Default.GDAX_API_SECRET; API_PASSPHRASE = Properties.Settings.Default.GDAX_API_PASSPHRASE; api = new ExchangeGdaxAPI(); api.LoadAPIKeysUnsecure(API_KEY, API_SECRET, API_PASSPHRASE); Name = api.Name; getAccounts(); }
public GdaxConnector2() { api = new ExchangeGdaxAPI(); var symbols = api.GetSymbols(); Debug.Print("{0}: ", api.Name); foreach (var s in symbols) { Debug.Print("\t{0}", s); } base.Register(this); }
public IDisposable TestWebsocketsGdax(bool display = false) { IExchangeAPI a = new ExchangeGdaxAPI(); var socket = a.GetCompletedOrderDetailsWebSocket((or) => { if (display) Console.WriteLine("[GDAX {0,-9}] {1} at {2}", or.Symbol, or.AmountFilled, or.Price); //await Task.Run(async () => HandleTickerUpdate( a, tickers)); //HandleTickerUpdate(a, tickers); //m_outputQ.Enqueue(new TickerOutput("GDAX", tickers)); }); return socket; }
public void TestWebsocketsGdax() { // create a web socket connection to the exchange. Note you can Dispose the socket anytime to shut it down. // the web socket will handle disconnects and attempt to re-connect automatically. IExchangeAPI b = new ExchangeGdaxAPI(); using (var socket = b.GetTickersWebSocket((tickers) => { Console.WriteLine("{0} tickers, first: {1}", tickers.Count, tickers.First()); })) { Console.WriteLine("Press ENTER to shutdown."); Console.ReadLine(); } }
// ICEBERG: Join the inside bid/offer public static void GdaxIcebergJoinInside(ExchangeGdaxAPI api, string symbol, OrderSide side, decimal amount, int repeatCount, TimeSpan delayBetweenTrades) { decimal amountPer = amount / repeatCount; int count = 0; while (count < repeatCount) { // Submit new order var or = GdaxJoinInside(api, symbol, side, amountPer); Console.WriteLine("{0}/{1}: {2}", count, repeatCount, or.ToStr()); var eor = api.GetOrderDetails(or.OrderId); count++; Thread.Sleep((int)delayBetweenTrades.TotalMilliseconds); } }
public IDisposable TestWebsocketsGdax(bool display = false) { IExchangeAPI a = new ExchangeGdaxAPI(); var socket = a.GetTickersWebSocket((tickers) => { if (display) { Console.WriteLine("GDAX {0,4} tickers, first: {1}", tickers.Count, tickers.First()); } //await Task.Run(async () => HandleTickerUpdate( a, tickers)); //HandleTickerUpdate(a, tickers); m_outputQ.Enqueue(new TickerOutput("GDAX", tickers)); }); return(socket); }
public static void RunShowExchangeStats(Dictionary <string, string> dict) { string symbol = "BTC-USD"; string symbol2 = "XXBTZUSD"; IExchangeAPI apiGDAX = new ExchangeGdaxAPI(); IExchangeAPI apiGemini = new ExchangeGeminiAPI(); IExchangeAPI apiKraken = new ExchangeKrakenAPI(); IExchangeAPI apiBitfinex = new ExchangeBitfinexAPI(); while (true) { ExchangeTicker ticker = apiGDAX.GetTicker(symbol); ExchangeOrderBook orders = apiGDAX.GetOrderBook(symbol); decimal askAmountSum = orders.Asks.Values.Sum(o => o.Amount); decimal askPriceSum = orders.Asks.Values.Sum(o => o.Price); decimal bidAmountSum = orders.Bids.Values.Sum(o => o.Amount); decimal bidPriceSum = orders.Bids.Values.Sum(o => o.Price); ExchangeTicker ticker2 = apiGemini.GetTicker(symbol); ExchangeOrderBook orders2 = apiGemini.GetOrderBook(symbol); decimal askAmountSum2 = orders2.Asks.Values.Sum(o => o.Amount); decimal askPriceSum2 = orders2.Asks.Values.Sum(o => o.Price); decimal bidAmountSum2 = orders2.Bids.Values.Sum(o => o.Amount); decimal bidPriceSum2 = orders2.Bids.Values.Sum(o => o.Price); ExchangeTicker ticker3 = apiKraken.GetTicker(symbol2); ExchangeOrderBook orders3 = apiKraken.GetOrderBook(symbol2); decimal askAmountSum3 = orders3.Asks.Values.Sum(o => o.Amount); decimal askPriceSum3 = orders3.Asks.Values.Sum(o => o.Price); decimal bidAmountSum3 = orders3.Bids.Values.Sum(o => o.Amount); decimal bidPriceSum3 = orders3.Bids.Values.Sum(o => o.Price); ExchangeTicker ticker4 = apiBitfinex.GetTicker(symbol); ExchangeOrderBook orders4 = apiBitfinex.GetOrderBook(symbol); decimal askAmountSum4 = orders4.Asks.Values.Sum(o => o.Amount); decimal askPriceSum4 = orders4.Asks.Values.Sum(o => o.Price); decimal bidAmountSum4 = orders4.Bids.Values.Sum(o => o.Amount); decimal bidPriceSum4 = orders4.Bids.Values.Sum(o => o.Price); Console.Clear(); Console.WriteLine("GDAX: {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}, {5:0.00}", ticker.Last, ticker.Volume.BaseVolume, askAmountSum, askPriceSum, bidAmountSum, bidPriceSum); Console.WriteLine("GEMI: {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}, {5:0.00}", ticker2.Last, ticker2.Volume.BaseVolume, askAmountSum2, askPriceSum2, bidAmountSum2, bidPriceSum2); Console.WriteLine("KRAK: {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}, {5:0.00}", ticker3.Last, ticker3.Volume.BaseVolume, askAmountSum3, askPriceSum3, bidAmountSum3, bidPriceSum3); Console.WriteLine("BITF: {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}, {5:0.00}", ticker4.Last, ticker4.Volume.BaseVolume, askAmountSum4, askPriceSum4, bidAmountSum4, bidPriceSum4); Thread.Sleep(5000); } }
// where symbol like "ETH-USD" // where side is OrderSide.Buy/OrderSide.Sell // where price like 390.19M // where amount like 0.1M // where postOnly is true/false (true means DO NOT allow "taker" -- "maker" only) public static ExchangeOrderResult GdaxOrder(ExchangeGdaxAPI api, string symbol, OrderSide side, decimal price, decimal amount, bool postOnly = true) { var order = new ExchangeOrderRequest(); order.OrderType = OrderType.Limit; order.Symbol = symbol; order.Price = price; order.Amount = amount; order.IsBuy = side == OrderSide.Buy; //order.ShouldRoundAmount = true; //order.RoundAmount(); //var parameters = order.ExtraParameters; order.ExtraParameters["post_only"] = postOnly; //var api = new ExchangeGdaxAPI(); //api.LoadAPIKeysUnsecure(m_creds["GDAX"].Key, m_creds["GDAX"].Secret, m_creds["GDAX"].Passphrase); //var api = m_apiMap["GDAX"]; return(api.PlaceOrder(order)); }
// TODO: change iceberg orders to require TOTAL amount (and split that amount based on repeatCount) // ICEBERG: Join the inside bid/offer public static void GdaxIcebergJoinInside(ExchangeGdaxAPI api, string symbol, OrderSide side, decimal amount, int repeatCount) { decimal amountPer = amount / repeatCount; int count = 0; while (count < repeatCount) { // Submit new order var or = GdaxJoinInside(api, symbol, side, amountPer); Console.WriteLine(or.ToStr()); var eor = api.GetOrderDetails(or.OrderId); // Wait for fill while (eor.AmountFilled < eor.Amount) { Thread.Sleep(1000); eor = api.GetOrderDetails(or.OrderId); } count++; } }
public IDisposable StartWebsocketsGdax(bool display = false) { IExchangeAPI a = new ExchangeGdaxAPI(); var socket = a.GetTickersWebSocket((tickers) => { if (display) { Console.WriteLine("GDAX {0,4} tickers, first: {1}", tickers.Count, tickers.First()); } HandleTickerUpdate("GDAX", tickers); //m_outputQ.Enqueue(new TickerOutput("GDAX", tickers)); if (tickers.Select(s => s.Key).Contains("BTC-USD")) { //Console.WriteLine("GDAX"); if (TickersExistForAllExchanges) { DisplaySpreads("GDAX"); } } }); return(socket); }