コード例 #1
0
        public static CryptsyOrder ReadFromJObject(JObject o, Int64 marketId = -1, CryptsyOrderType orderType = CryptsyOrderType.Na)
        {
            if (o == null)
            {
                return(null);
            }

            var order = new CryptsyOrder
            {
                Price            = o.Value <decimal>("price"),
                Quantity         = o.Value <decimal>("quantity"),
                Total            = o.Value <decimal>("total"),
                OriginalQuantity = o.Value <decimal?>("orig_quantity") ?? -1,
                MarketId         = o.Value <Int64?>("marketid") ?? marketId,

                //If ordertype is present, use it, if not: use the ordertype passed to the method
                OrderType =
                    o.Value <string>("ordertype") == null
                        ? orderType
                        : (o.Value <string>("ordertype").ToLower() == "buy" ? CryptsyOrderType.Buy : CryptsyOrderType.Sell),
                CreatedUtc = o.Value <DateTime?>("created")
            };

            if (order.CreatedUtc != null)
            {
                order.CreatedUtc = TimeZoneInfo.ConvertTime((DateTime)order.CreatedUtc, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"), TimeZoneInfo.Utc); //Convert to UTC
            }
            return(order);
        }
コード例 #2
0
        public static CryptsyOrderBook ReadFromJObject(JObject o, Int64 marketId)
        {
            var ob = new CryptsyOrderBook();

            foreach (var order in o["sellorders"])
            {
                ob.SellOrders.Add(CryptsyOrder.ReadFromJObject(order as JObject, marketId, CryptsyOrderType.Sell));
            }

            foreach (var order in o["buyorders"])
            {
                ob.BuyOrders.Add(CryptsyOrder.ReadFromJObject(order as JObject, marketId, CryptsyOrderType.Buy));
            }

            return(ob);
        }