Ejemplo n.º 1
0
        /// <remarks> 返回数据示例
        /// {
        ///     "result":"success",
        ///     "data":
        ///     {
        ///         "Login":"******",
        ///         "Index":"561759",
        ///         "Id":"7e476c78-377e-4773-8321-41df0bc63a6c",
        ///         "Link":"M33561759X",
        ///         "Rights":["deposit","get_info","merchant","trade","withdraw"],
        ///         "Language":"en_US",
        ///         "Created":"2013-06-20 02:13:41",
        ///         "Last_Login":"******",
        ///         "Wallets":
        ///         {
        ///             "BTC":
        ///             {
        ///                 "Balance":
        ///                 {
        ///                     "value":"0.00500000","value_int":"500000","display":"0.00500000\u00a0BTC","display_short":"0.01\u00a0BTC","currency":"BTC"
        ///                 },
        ///                 "Operations":1,
        ///                 "Daily_Withdraw_Limit":
        ///                 {
        ///                     "value":"100.00000000","value_int":"10000000000","display":"100.00000000\u00a0BTC","display_short":"100.00\u00a0BTC","currency":"BTC"
        ///                 },
        ///                 "Monthly_Withdraw_Limit":null,
        ///                 "Max_Withdraw":
        ///                 {
        ///                     "value":"100.00000000","value_int":"10000000000","display":"100.00000000\u00a0BTC","display_short":"100.00\u00a0BTC","currency":"BTC"
        ///                 },
        ///                 "Open_Orders":
        ///                 {
        ///                     "value":"0.00000000","value_int":"0","display":"0.00000000\u00a0BTC","display_short":"0.00\u00a0BTC","currency":"BTC"
        ///                 }
        ///             },
        ///             "USD":
        ///             {
        ///                 "Balance":
        ///                 {
        ///                     "value":"0.00000","value_int":"0","display":"$0.00000","display_short":"$0.00","currency":"USD"
        ///                 },
        ///                 "Operations":0,
        ///                 "Daily_Withdraw_Limit":
        ///                 {
        ///                     "value":"1000.00000","value_int":"100000000","display":"$1,000.00000","display_short":"$1,000.00","currency":"USD"
        ///                 },
        ///                 "Monthly_Withdraw_Limit":
        ///                 {
        ///                     "value":"10000.00000","value_int":"1000000000","display":"$10,000.00000","display_short":"$10,000.00","currency":"USD"
        ///                 },
        ///                 "Max_Withdraw":
        ///                 {
        ///                     "value":"1000.00000","value_int":"100000000","display":"$1,000.00000","display_short":"$1,000.00","currency":"USD"
        ///                 },
        ///                 "Open_Orders":
        ///                 {
        ///                     "value":"0.00000","value_int":"0","display":"$0.00000","display_short":"$0.00","currency":"USD"
        ///                 }
        ///             }
        ///         },
        ///         "Monthly_Volume":
        ///         {
        ///             "value":"0.00000000","value_int":"0","display":"0.00000000\u00a0BTC","display_short":"0.00\u00a0BTC","currency":"BTC"
        ///         },
        ///         "Trade_Fee":0.6
        ///     }
        /// }
        /// </remarks>
        private ExchangeFund GetFund(string result)
        {
            JObject jObject = JObject.Parse(result);

            var available = new Dictionary <Currency, decimal>();
            var frozen    = new Dictionary <Currency, decimal>();

            string  btcAvailableText = jObject["data"]["Wallets"]["BTC"]["Balance"]["value"].ToString();
            decimal btcAvailable     = Convert.ToDecimal(btcAvailableText);

            available.Add(Currency.All["BTC"], btcAvailable);

            string  btcLockedText = jObject["data"]["Wallets"]["BTC"]["Open_Orders"]["value"].ToString();
            decimal btcLocked     = Convert.ToDecimal(btcLockedText);

            frozen.Add(Currency.All["BTC"], btcLocked);

            string  usdAvailableText = jObject["data"]["Wallets"]["USD"]["Balance"]["value"].ToString();
            decimal usdAvailable     = Convert.ToDecimal(usdAvailableText);

            available.Add(Currency.All["USD"], usdAvailable);

            string  usdLockedText = jObject["data"]["Wallets"]["USD"]["Open_Orders"]["value"].ToString();
            decimal usdLocked     = Convert.ToDecimal(usdLockedText);

            frozen.Add(Currency.All["USD"], btcLocked);
            ExchangeFund exchangeFund = new ExchangeFund(Exchange);

            exchangeFund.Available = available;
            exchangeFund.Frozen    = frozen;
            return(exchangeFund);
        }
Ejemplo n.º 2
0
        /// {
        ///     "result":"true",
        ///     "available_funds":
        ///     {
        ///         "BTC":"1.52980541",
        ///         "LTC":"0.02",
        ///         "CNY":"495.871",
        ///         "XPM":"50",
        ///         "ZCC":"0"
        ///     },
        ///     "locked_funds":
        ///     {
        ///         "XPM":"50"
        ///     }
        /// }
        /// 有可能没有数据:
        /// { "BTC": "0.52980541", "LTC": "0.02", "CNY": "495.871", "XPM": "100", "ZCC": "0" }

        private ExchangeFund GetFund(string result)
        {
            JObject      jObject      = JObject.Parse(result);
            ExchangeFund exchangeFund = new ExchangeFund(Exchange);

            if (jObject["available_funds"] != null)
            {
                var avalilable = jObject["available_funds"].ToString();
                exchangeFund.Available = GetFundDict(avalilable);
            }
            else
            {
                exchangeFund.Available = new Dictionary <Currency, decimal>();
            }
            if (jObject["locked_funds"] != null)
            {
                var lockFund = jObject["locked_funds"].ToString();
                exchangeFund.Frozen = GetFundDict(lockFund);
            }
            else
            {
                exchangeFund.Frozen = new Dictionary <Currency, decimal>();
            }
            return(exchangeFund);
        }
Ejemplo n.º 3
0
        /// {
        ///     "result":
        ///     {
        ///         "profile":
        ///         {
        ///             "username":"******",
        ///             "trade_password_enabled":true,
        ///             "otp_enabled":false,
        ///             "trade_fee":"0",
        ///             "daily_btc_limit":10,
        ///             "btc_deposit_address":"1PgSu942W13GBpJYAaKyMTEMFQTmsmsdsB",
        ///             "btc_withdrawal_address":""
        ///         },
        ///         "balance":
        ///         {
        ///             "btc":{"currency":"BTC","symbol":"\u0e3f","amount":"0.00100000","amount_integer":"100000","amount_decimal":8},
        ///             "cny":{"currency":"CNY","symbol":"\u00a5","amount":"0.00000","amount_integer":"0","amount_decimal":5}
        ///         },
        ///         "frozen":
        ///         {
        ///             "btc":{"currency":"BTC","symbol":"\u0e3f","amount":null,"amount_integer":"0","amount_decimal":8},
        ///             "cny":{"currency":"CNY","symbol":"\u00a5","amount":null,"amount_integer":"0","amount_decimal":5}
        ///         }
        ///     },
        ///     "id":"1"
        ///  }

        private ExchangeFund GetFund(string result)
        {
            JObject jObject = JObject.Parse(result);

            var     btcAvailableText = jObject["result"]["balance"]["btc"]["amount"].ToString();
            decimal btcAvailable     = Convert.ToDecimal(btcAvailableText);
            var     cnyAvailableText = jObject["result"]["balance"]["cny"]["amount"].ToString();
            decimal cnyAvailable     = Convert.ToDecimal(cnyAvailableText);

            var btcFrozenText = jObject["result"]["frozen"]["btc"]["amount"].ToString();

            decimal btcFrozen     = Convert.ToDecimal(btcFrozenText == "" ? "0" : btcFrozenText);
            var     cnyFrozenText = jObject["result"]["frozen"]["cny"]["amount"].ToString();
            decimal cnyFrozen     = Convert.ToDecimal(cnyFrozenText == "" ? "0" : cnyFrozenText);

            ExchangeFund exchangeFund = new ExchangeFund(Exchange);

            exchangeFund.Available = new Dictionary <Currency, decimal>()
            {
                { Currency.All["BTC"], btcAvailable }, { Currency.All["CNY"], cnyAvailable }
            };
            exchangeFund.Frozen = new Dictionary <Currency, decimal>()
            {
                { Currency.All["BTC"], btcFrozen }, { Currency.All["CNY"], cnyFrozen }
            };
            return(exchangeFund);
        }
Ejemplo n.º 4
0
        public ExchangeFund QueryFund()
        {
            ExchangeFund exchangeFund = new ExchangeFund(Exchange);;

            string result = AuthQuery("get_balances", new Dictionary <string, string>());

            return(exchangeFund);
        }
Ejemplo n.º 5
0
        public ExchangeFund QueryFund()
        {
            ExchangeFund exchangeFund = new ExchangeFund(Exchange);

            string result = AuthQuery("getInfo");

            JObject jObject = JObject.Parse(result);

            var avalilable = jObject["return"]["funds"].ToString();

            exchangeFund.Available = GetFund(avalilable);

            return(exchangeFund);
        }
Ejemplo n.º 6
0
        /// {"error": "Invalid signature"}
        ///成功: {"btc_reserved": "0", "fee": "0.5000", "btc_available": "0", "usd_reserved": "0", "btc_balance": "0", "usd_balance": "0.00", "usd_available": "0.00"}
        private ExchangeFund GetFund(string json)
        {
            var def    = new { btc_reserved = 0m, fee = 0m, btc_available = 0m, usd_reserved = 0m, usd_available = 0m };
            var result = JsonConvert.DeserializeAnonymousType(json, def);

            ExchangeFund exchangeFund = new ExchangeFund(Exchange);

            exchangeFund.Available = new Dictionary <Currency, decimal>();
            exchangeFund.Available.Add(Currency.All["BTC"], result.btc_available);
            exchangeFund.Available.Add(Currency.All["USD"], result.usd_available);

            exchangeFund.Frozen = new Dictionary <Currency, decimal>();
            exchangeFund.Frozen.Add(Currency.All["BTC"], result.btc_reserved);
            exchangeFund.Frozen.Add(Currency.All["USD"], result.usd_available);
            return(exchangeFund);
        }
Ejemplo n.º 7
0
        public ExchangeFund QueryFund()
        {
            ExchangeFund exchangeFund = new ExchangeFund(Exchange);
            string       result       = AuthQuery("balance", new Dictionary <string, string>());
            JObject      jObject      = JObject.Parse(result);

            var avalilable = jObject["return"]["balances_available"].ToString();

            exchangeFund.Available = GetFund(avalilable);

            var locked = jObject["return"]["balances_hold"].ToString();

            exchangeFund.Locked = GetFund(locked);

            return(exchangeFund);
        }
Ejemplo n.º 8
0
        private void RefreshAll()
        {
            ObservableCollection <ExchangeFund> funds = new ObservableCollection <ExchangeFund>();

            foreach (IFundApi fundApi in apiManager.FundApis)
            {
                ExchangeApi api = fundApi as ExchangeApi;
                string      exchangeAbbrName = api.Exchange.AbbrName;
                string      functionInfo     = Resources.QueryFund;
                if (Setting.Singleton.GetSelectedPairs(exchangeAbbrName).Count == 0)
                {
                    EventSourceLogger.Logger.NoPairSelected(exchangeAbbrName, functionInfo);
                    continue;
                }

                Dictionary <string, AuthKey> authKeyDict = Setting.Singleton.GetAuthKeyDict();
                if (!authKeyDict[exchangeAbbrName].IsExist)
                {
                    EventSourceLogger.Logger.ApiKeyNotExist(exchangeAbbrName, functionInfo);
                    continue;
                }

                try
                {
                    ExchangeFund exchangeFund = fundApi.QueryFund();
                    funds.Add(exchangeFund);
                    ExchangeApi exchangeApi = fundApi as ExchangeApi;
                    EventSourceLogger.Logger.QueryDataSuccess(functionInfo, exchangeApi.Exchange.Name);
                }
                catch (Exception exception)
                {
                    EventSourceLogger.Logger.QueryDataException(functionInfo, exchangeAbbrName, exception.Message);
                }
            }
            Funds = funds;
        }