Exemplo n.º 1
0
        //PRIVATE:

        static SortedSet <string> GetAddedPairs(List <string> resp_pairs)
        {
            SortedSet <string> added_pairs = new SortedSet <string>();

            foreach (string s_pair in resp_pairs)
            {
                WexPair wex_pair = WexPairHelper.FromString(s_pair);
                if (wex_pair == WexPair.Unknown)
                {
                    added_pairs.Add(s_pair.ToLowerInvariant());
                }
            }

            return(added_pairs);
        }
Exemplo n.º 2
0
        public static Trade ReadFromJObject(JObject o)
        {
            if (o == null)
            {
                return(null);
            }

            return(new Trade()
            {
                Pair = WexPairHelper.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")
            });
        }
Exemplo n.º 3
0
        public static Order ReadFromJObject(JObject o)
        {
            if (o == null)
            {
                return(null);
            }

            return(new Order()
            {
                Pair = WexPairHelper.FromString(o.Value <string>("pair")),
                Type = TradeTypeHelper.FromString(o.Value <string>("type")),
                Amount = o.Value <decimal>("amount"),
                StartAmount = o.Value <decimal>("start_amount"),
                Rate = o.Value <decimal>("rate"),
                TimestampCreated = UnixTime.ConvertToDateTime(
                    o.Value <UInt32>("timestamp_created")),
                Status = o.Value <int>("status"),
            });
        }
Exemplo n.º 4
0
        static SortedSet <string> GetDeletedPairs(IEnumerable <string> resp_pairs)
        {
            var our_pairs = WexPairHelper.GetAllPairs();

            foreach (string s_pair in resp_pairs)
            {
                WexPair wex_pair = WexPairHelper.FromString(s_pair);
                if (wex_pair != WexPair.Unknown)
                {
                    our_pairs.Remove(wex_pair);
                }
            }

            SortedSet <string> deleted_pairs = new SortedSet <string>();

            foreach (WexPair pair in our_pairs)
            {
                deleted_pairs.Add(WexPairHelper.ToString(pair));
            }
            return(deleted_pairs);
        }
Exemplo n.º 5
0
/*
 *      private static string QueryIgnoreInvalid(string method, IEnumerable<BtcePair> pairlist, Dictionary<string, string> args = null)
 *      {
 *          var newargs = new Dictionary<string,string> { {"ignore_invalid", "1"} };
 *              if (args != null)
 *              {
 *                      foreach (var arg in args)
 *                      {
 *                              newargs.Add(arg.Key, arg.Value);
 *                      }
 *              }
 *              return Query(method, pairlist, newargs);
 *      }
 */

        private static Dictionary <WexPair, T> ReadPairDict <T>(JObject o, Func <JContainer, T> valueReader)
        {
            return(o.OfType <JProperty>().Select(x => new KeyValuePair <WexPair, T>(WexPairHelper.FromString(x.Name), valueReader(x.Value as JContainer))).ToDictionary(x => x.Key, x => x.Value));
        }