public static OrderBook CreateFromJObject(JObject o, bool isPublic) { var r = new OrderBook(); r.Asks = new List<SimpleOrderInfo>(); r.Bids = new List<SimpleOrderInfo>(); var sellOrders = o["sellorders"] as JArray; if (sellOrders != null) { foreach (var item in sellOrders as JArray) { var order = SimpleOrderInfo.CreateFromJObject(item as JObject, isPublic ? "price" : "sellprice"); r.Asks.Add(order); } } var buyOrders = o["buyorders"] as JArray; if (buyOrders != null) { foreach (var item in buyOrders) { var order = SimpleOrderInfo.CreateFromJObject(item as JObject, isPublic ? "price" : "buyprice"); r.Bids.Add(order); } } return r; }
/// <summary> /// Gets the order book for a given currency pair /// </summary> /// <param name="currencyPair"></param> /// <returns></returns> public CallResult <OrderBook> GetFullOrderBook(CurrencyPair currencyPair) { return(MakePostRequest <OrderBook>("marketorders", result => OrderBook.CreateFromJObject(result as JObject, false), new Dictionary <string, string> { { "marketid", currencyPair.ID } })); }
/// <summary> /// Gets the order book for a given currency pair /// </summary> /// <param name="currencyPair"></param> /// <returns></returns> public CallResult <OrderBook> GetOrderBook(CurrencyPair currencyPair) { return(MakeGetRequest <OrderBook>("?method=singleorderdata&marketid=" + currencyPair.ID, result => OrderBook.CreateFromJObject(result[currencyPair.Item1] as JObject, true))); }