Exemple #1
0
        public ORDERLIST GetOrderList(int?from              = null,
                                      int?count             = null,
                                      int?fromId            = null,
                                      int?endId             = null,
                                      bool?orderAsc         = null,
                                      DateTime?since        = null,
                                      DateTime?end          = null,
                                      BTCECURRENCYPAIR?pair = null,
                                      bool?active           = null)
        {
            var args = new Dictionary <string, string>()
            {
                { "method", "OrderList" }
            };

            if (from != null)
            {
                args.Add("from", from.Value.ToString());
            }
            if (count != null)
            {
                args.Add("count", count.Value.ToString());
            }
            if (fromId != null)
            {
                args.Add("from_id", fromId.Value.ToString());
            }
            if (endId != null)
            {
                args.Add("end_id", endId.Value.ToString());
            }
            if (orderAsc != null)
            {
                args.Add("order", orderAsc.Value ? "ASC" : "DESC");
            }
            if (since != null)
            {
                args.Add("since", UNIXTIME.GetFromDateTime(since.Value).ToString());
            }
            if (end != null)
            {
                args.Add("end", UNIXTIME.GetFromDateTime(end.Value).ToString());
            }
            if (pair != null)
            {
                args.Add("pair", BTCECURRENCYPAIRHELPER.ToString(pair.Value));
            }
            if (active != null)
            {
                args.Add("active", active.Value ? "1" : "0");
            }
            var result = JObject.Parse(Query(args));

            if (result.Value <int>("success") == 0)
            {
                throw new Exception(result.Value <string>("error"));
            }
            return(ORDERLIST.ReadFromJObject(result["return"] as JObject));
        }
 public static ORDER ReadFromJObject(JObject o)
 {
     if (o == null)
     {
         return(null);
     }
     return(new ORDER()
     {
         Pair = BTCECURRENCYPAIRHELPER.FromString(o.Value <string>("pair")),
         Type = TRADETYPEHELPER.FromString(o.Value <string>("type")),
         Amount = o.Value <decimal>("amount"),
         Rate = o.Value <decimal>("rate"),
         TimestampCreated = o.Value <UInt32>("timestamp_created"),
         Status = o.Value <int>("status")
     });
 }
Exemple #3
0
 public static TRADE ReadFromJObject(JObject o)
 {
     if (o == null)
     {
         return(null);
     }
     return(new TRADE()
     {
         Pair = BTCECURRENCYPAIRHELPER.FromString(o.Value <string>("pair")),
         Type = TRADETYPEHELPER.FromString(o.Value <string>("type")),
         Amount = o.Value <decimal>("amount"),
         Rate = o.Value <decimal>("rate"),
         Timestamp = o.Value <UInt32>("timestamp"),
         IsYourOrder = o.Value <int>("is_your_order") == 1,
         OrderId = o.Value <int>("order_id")
     });
 }
Exemple #4
0
        public TRADEANSWER Trade(BTCECURRENCYPAIR pair, TRADETYPE type, decimal rate, decimal amount)
        {
            var args = new Dictionary <string, string>()
            {
                { "method", "Trade" },
                { "pair", BTCECURRENCYPAIRHELPER.ToString(pair) },
                { "type", TRADETYPEHELPER.ToString(type) },
                { "rate", DecimalToString(rate) },
                { "amount", DecimalToString(amount) }
            };
            var result = JObject.Parse(Query(args));

            if (result.Value <int>("success") == 0)
            {
                throw new Exception(result.Value <string>("error"));
            }
            return(TRADEANSWER.ReadFromJObject(result["return"] as JObject));
        }
Exemple #5
0
 private static Dictionary <BTCECURRENCYPAIR, T> ReadPairDict <T>(JObject o, Func <JContainer, T> valueReader)
 {
     return(o.OfType <JProperty>().Select(x => new KeyValuePair <BTCECURRENCYPAIR, T>(BTCECURRENCYPAIRHELPER.FromString(x.Name), valueReader(x.Value as JContainer))).ToDictionary(x => x.Key, x => x.Value));
 }
Exemple #6
0
 private static string MakePairListString(BTCECURRENCYPAIR[] pairlist)
 {
     return(string.Join("-", pairlist.Select(x => BTCECURRENCYPAIRHELPER.ToString(x)).ToArray()));
 }
Exemple #7
0
        public static decimal GetFee(BTCECURRENCYPAIR pair)
        {
            string queryStr = string.Format("https://btc-e.com/api/2/{0}/fee", BTCECURRENCYPAIRHELPER.ToString(pair));

            return(JObject.Parse(WEBAPI.Query(queryStr)).Value <decimal>("trade"));
        }
Exemple #8
0
        public static List <TRADEINFORMATIONv2> GetTrades(BTCECURRENCYPAIR pair)
        {
            string queryStr = string.Format("https://btc-e.com/api/2/{0}/trades", BTCECURRENCYPAIRHELPER.ToString(pair));

            return(JArray.Parse(WEBAPI.Query(queryStr)).OfType <JObject>().Select(TRADEINFORMATIONv2.ReadFromJObject).ToList());
        }
Exemple #9
0
        public static TICKER GetTicker(BTCECURRENCYPAIR pair)
        {
            string queryStr = string.Format("https://btc-e.com/api/2/{0}/ticker", BTCECURRENCYPAIRHELPER.ToString(pair));

            return(TICKER.ReadFromJObject(JObject.Parse(WEBAPI.Query(queryStr))["ticker"] as JObject));
        }
Exemple #10
0
        public static DEPTH GetDepth(BTCECURRENCYPAIR pair)
        {
            string queryStr = string.Format("https://btc-e.com/api/2/{0}/depth", BTCECURRENCYPAIRHELPER.ToString(pair));

            return(DEPTH.ReadFromJObject(JObject.Parse(WEBAPI.Query(queryStr))));
        }