Ejemplo n.º 1
0
        public static CryptsyOrder ReadFromJObject(JObject o, Int64 marketId = -1, ORDER_TYPE orderType = ORDER_TYPE.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" ? ORDER_TYPE.BUY : ORDER_TYPE.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);
        }
Ejemplo n.º 2
0
        public async Task <List <CryptsyOrder> > GetAllMyOrders(CancellationToken token = default(CancellationToken))
        {
            return(await RetryHelper.DoAsync(async() =>
            {
                CryptsyResponse response = await CryptsyPrivateQuery(new Dictionary <string, string> {
                    { "method", "allmyorders" }
                },
                                                                     token, RequestCategory.OpenOrders);

                //Response is an array of markets, with only the requested market
                return response.Success ? CryptsyOrder.ReadMultipleFromJArray(response.Data as JArray) : null;
            }, TimeSpan.FromMilliseconds(Constant.DefaultRetryInterval)));
        }
Ejemplo n.º 3
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, CryptsyOrder.ORDER_TYPE.SELL));
            }

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

            return(ob);
        }