/// <summary> /// Run every 10 seconds, gets data from the API and puts it into the database. /// </summary> public static void TimerElapsed(object sender, ElapsedEventArgs e) { LastInsert = ApiReader.GetUnixTime(); TickerResult ticker = APR.GetTickerResult(currency); // Gets the ticker for the specified currency TradeHistoryResult history = APR.GetTradeHistoryResult(currency); // Gets the trade history for the specified currency Console.Write("Got price " + ticker.lastPrice + " at time " + LastInsert + "... "); double volAsk = 0; double volBid = 0; foreach (HistoricalTrade trade in history.trades) { if (trade.IsBid) { volBid += trade.Amount; } else { volAsk += trade.Amount; } } //DatabaseRow row = new DatabaseRow( // LastInsert, // ticker.lastPrice, // volBid, // volAsk); //DBC.InsertIntoDatabase(row); //Console.WriteLine("Inserted."); Console.WriteLine("Skipping insertion, no longer implemented in C#. Speak to me if you'd like me to reimplement this, it shouldn't take too long."); }
public void TradingLib_ApiReader_GetPriceTest() { TickerResult TR = APR.GetTickerResult(new CurrencyPair(0, 1)); // Get result for currency pair USD/BTC // Check each variable in TickerResult has a value Assert.AreNotEqual(TR.ask, null); Assert.AreNotEqual(TR.askSize, null); Assert.AreNotEqual(TR.bid, null); Assert.AreNotEqual(TR.bidSize, null); Assert.AreNotEqual(TR.dailyChange, null); Assert.AreNotEqual(TR.dailyChangePerc, null); Assert.AreNotEqual(TR.lastPrice, null); Assert.AreNotEqual(TR.volume, null); Assert.AreNotEqual(TR.high, null); Assert.AreNotEqual(TR.low, null); }