Ejemplo n.º 1
0
        // 查询cointiger站支持的所有币种
        // 币种是按交易分区来列举的,如:
        //   bitcny-partition
        //   btc-partition
        //   usdt-partition
        //   eth-partition
        public static Currencys GetCurrencys()
        {
            string strResponse = Http.Get(V2.URL + "/currencys");

            if (string.IsNullOrEmpty(strResponse))
            {
                return(null);
            }

            Response response = Response.FromString(strResponse);

            if (response == null || response.code != "0" || response.msg != "suc" || string.IsNullOrEmpty(response.data))
            {
                return(null);
            }

            Currencys currencys = Currencys.FromString(response.data);

            if (currencys == null || currencys.partitions == null)
            {
                return(null);
            }

            return(currencys);
        }
Ejemplo n.º 2
0
        public static Currencys FromString(string strResponseData)
        {
            Json.Dictionary dict = Json.ToDictionary(strResponseData);
            if (dict == null)
            {
                return(null);
            }

            Currencys currencys = new Currencys();

            foreach (var part in dict)
            {
                Partition partition = new Partition();
                partition.name = part.Key;
                Json.Array array = Json.ToArray(part.Value);
                if (array != null)
                {
                    partition.items = new System.Collections.Generic.List <Currency>();
                    foreach (var it in array)
                    {
                        Json.Dictionary dictItem = Json.ToDictionary(it);
                        Currency        item     = new Currency();
                        item.baseCurrency    = Json.GetAt(dictItem, "baseCurrency");
                        item.quoteCurrency   = Json.GetAt(dictItem, "quoteCurrency");
                        item.pricePrecision  = Convert.ToInt32(Json.GetAt(dictItem, "pricePrecision"));
                        item.amountPrecision = Convert.ToInt32(Json.GetAt(dictItem, "amountPrecision"));
                        item.withdrawFeeMin  = Convert.ToDouble(Json.GetAt(dictItem, "withdrawFeeMin"));
                        item.withdrawFeeMax  = Convert.ToDouble(Json.GetAt(dictItem, "withdrawFeeMax"));
                        item.withdrawOneMin  = Convert.ToDouble(Json.GetAt(dictItem, "withdrawOneMin"));
                        item.withdrawOneMax  = Convert.ToDouble(Json.GetAt(dictItem, "withdrawOneMax"));
                        Json.Dictionary dictDS = Json.ToDictionary(Json.GetAt(dictItem, "depthSelect"));
                        item.depthSelect       = new Currency.DepthSelect();
                        item.depthSelect.step0 = Convert.ToDouble(Json.GetAt(dictDS, "step0"));
                        item.depthSelect.step1 = Convert.ToDouble(Json.GetAt(dictDS, "step1"));
                        item.depthSelect.step2 = Convert.ToDouble(Json.GetAt(dictDS, "step2"));
                        partition.items.Add(item);
                    }
                }

                if (currencys.partitions == null)
                {
                    currencys.partitions = new System.Collections.Generic.List <Partition>();
                }

                currencys.partitions.Add(partition);
            }

            return(currencys);
        }