Exemple #1
0
        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);
        }
Exemple #2
0
        public static SimpleOrderInfo CreateFromJObject(JObject obj, string priceName)
        {
            if (obj == null)
            {
                return null;
            }

            var r = new SimpleOrderInfo()
            {
                Price = obj.Value<decimal>(priceName),
                Amount = obj.Value<decimal>("quantity"),
                Total = obj.Value<decimal>("total"),
            };

            return r;
        }
Exemple #3
0
        public static SimpleOrderInfo CreateFromJObject(JObject obj, string priceName)
        {
            if (obj == null)
            {
                return(null);
            }

            var r = new SimpleOrderInfo()
            {
                Price  = obj.Value <decimal>(priceName),
                Amount = obj.Value <decimal>("quantity"),
                Total  = obj.Value <decimal>("total"),
            };

            return(r);
        }