コード例 #1
0
        /// <summary>
        /// 未还款列表
        /// </summary>
        /// <param name="symbol">btc_usd: 比特币 ltc_usd: 莱特币 usd: 美元 </param>
        /// <param name="current_page">当前页数</param>
        /// <param name="page_length">每页数据条数,最多不超过50条</param>
        /// <returns></returns>
        public string unrepayments_info(string symbol, string current_page, string page_length)
        {
            string result = "";

            try
            {
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                if (!string.IsNullOrWhiteSpace(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!string.IsNullOrWhiteSpace(current_page))
                {
                    paras.Add("current_page", current_page);
                }
                if (!string.IsNullOrWhiteSpace(page_length))
                {
                    paras.Add("page_length", page_length);
                }
                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);
                //发送post请求
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.UNREPAYMENTS_INFO_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        ///  获取历史交易信息
        /// </summary>
        /// <param name="symbol">btc_usd:比特币 ltc_usd :莱特币 </param>
        /// <param name="since">从某一tid开始访问600条数据(必填项) </param>
        /// <returns></returns>
        public string trade_history(string symbol, string since)
        {
            string result = "";

            try
            {
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                if (!string.IsNullOrWhiteSpace(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!string.IsNullOrWhiteSpace(since))
                {
                    paras.Add("since", since);
                }
                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);
                //发送post请求
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.TRADE_HISTORY_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// 查询手续费
        /// </summary>
        /// <param name="order_id">订单ID </param>
        /// <param name="symbol">btc_usd:比特币    ltc_usd :莱特币 </param>
        /// <returns></returns>
        public string order_fee(string order_id, string symbol)
        {
            string result = "";

            try
            {
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                if (!string.IsNullOrWhiteSpace(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!string.IsNullOrWhiteSpace(order_id))
                {
                    paras.Add("order_id", order_id);
                }
                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);
                //发送post请求
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.ORDER_FEE_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
コード例 #4
0
        /// <summary>
        /// 用户还全款
        /// </summary>
        /// <param name="borrow_id">借款单ID</param>
        /// <returns></returns>
        public string repayment(string borrow_id)
        {
            string result = "";

            try
            {
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                if (!string.IsNullOrWhiteSpace(borrow_id))
                {
                    paras.Add("borrow_id", borrow_id);
                }
                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);
                //发送post请求
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.REPAYMENT_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
コード例 #5
0
        /// <summary>
        /// 现货市场深度
        /// </summary>
        /// <param name="symbol">btc_usd:比特币    ltc_usd :莱特币</param>
        /// <param name="size">size:1-200</param>
        /// <returns></returns>
        public string depth(string symbol, string size)
        {
            string result = "";

            try
            {
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                string      param    = "";
                if (!string.IsNullOrWhiteSpace(symbol))
                {
                    if (!param.Equals(""))
                    {
                        param += "&";
                    }
                    param += "symbol=" + symbol;
                }
                if (!string.IsNullOrWhiteSpace(size))
                {
                    if (!param.Equals(""))
                    {
                        param += "&";
                    }
                    param += "size=" + size;
                }
                result = httpUtil.requestHttpGet(url_prex, OKCoinServerUrl.DEPTH_URL, param);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
コード例 #6
0
        /// <summary>
        /// 取消提币BTC/LTC
        /// </summary>
        /// <param name="symbol">btc_usd: 比特币 ltc_usd: 莱特币 </param>
        /// <param name="withdraw_id">提币申请Id </param>
        /// <returns></returns>
        public string cancel_withdraw(string symbol, string withdraw_id)
        {
            string result = "";

            try
            {
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                if (!string.IsNullOrWhiteSpace(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!string.IsNullOrWhiteSpace(withdraw_id))
                {
                    paras.Add("withdraw_id", withdraw_id);
                }
                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);
                //发送post请求
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.CANCEL_WITHDRAW_RUL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
コード例 #7
0
        /// <summary>
        /// 批量下单
        /// </summary>
        /// <param name="symbol">btc_usd: 比特币 ltc_usd: 莱特币</param>
        /// <param name="type">买卖类型: 限价单(buy/sell) 市价单(buy_market/sell_market)</param>
        /// <param name="orders_data">JSON类型的字符串 例:[{price:3,amount:5},{price:3,amount:3}]   最大下单量为5,price和amount参数参考trade接口中的说明</param>
        /// <returns></returns>
        public string batch_trade(string symbol, string type,
                                  string orders_data)
        {
            string result = "";

            try
            { // 构造参数签名
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                if (!string.IsNullOrWhiteSpace(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!string.IsNullOrWhiteSpace(type))
                {
                    paras.Add("type", type);
                }
                if (!string.IsNullOrWhiteSpace(orders_data))
                {
                    paras.Add("orders_data", orders_data);
                }
                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);

                // 发送post请求
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.BATCH_TRADE_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
コード例 #8
0
        /// <summary>
        /// 提币BTC/LTC
        /// </summary>
        /// <param name="symbol">btc_usd: 比特币 ltc_usd: 莱特币 </param>
        /// <param name="chargefee">网络手续费 BTC默认范围 [0.0001,0.01] LTC默认范围 [0.001,0.2],手续费越高,网络确认越快,OKCoin内部提币设置0 </param>
        /// <param name="trade_pwd">交易密码 </param>
        /// <param name="withdraw_address">提币认证地址 </param>
        /// <param name="withdraw_amount">提币数量 BTC>=0.01 LTC>=0.1 </param>
        /// <returns></returns>
        public string withdraw(string symbol, string chargefee, string trade_pwd, string withdraw_address, string withdraw_amount)
        {
            string result = "";

            try
            {
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                if (!string.IsNullOrWhiteSpace(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!string.IsNullOrWhiteSpace(chargefee))
                {
                    paras.Add("chargefee", chargefee);
                }
                if (!string.IsNullOrWhiteSpace(trade_pwd))
                {
                    paras.Add("trade_pwd", trade_pwd);
                }
                if (!string.IsNullOrWhiteSpace(withdraw_address))
                {
                    paras.Add("withdraw_address", withdraw_address);
                }
                if (!string.IsNullOrWhiteSpace(withdraw_amount))
                {
                    paras.Add("withdraw_amount", withdraw_amount);
                }
                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);

                // 发送post请求
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.WITHDRAW_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
コード例 #9
0
        /// <summary>
        /// 获取历史订单信息,只返回最近七天的信息
        /// </summary>
        /// <param name="symbol">btc_usd: 比特币 ltc_usd: 莱特币</param>
        /// <param name="status">委托状态: 0:未成交 1:已完成(最近七天的数据)</param>
        /// <param name="current_page">当前页数</param>
        /// <param name="page_length">每页数据条数,最多不超过200</param>
        /// <returns></returns>
        public string order_history(string symbol, string status,
                                    string current_page, string page_length)
        {
            string result = "";

            try
            {
                // 构造参数签名
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                if (!string.IsNullOrWhiteSpace(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!string.IsNullOrWhiteSpace(status))
                {
                    paras.Add("status", status);
                }
                if (!string.IsNullOrWhiteSpace(current_page))
                {
                    paras.Add("current_page", current_page);
                }
                if (!string.IsNullOrWhiteSpace(page_length))
                {
                    paras.Add("page_length", page_length);
                }

                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);

                // 发送post请求
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.ORDER_HISTORY_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(result);
        }
コード例 #10
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <returns></returns>
        public string userinfo()
        {
            string result = "";

            try
            {
                // 构造参数签名
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);

                // 发送post请求
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.USERINFO_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
コード例 #11
0
        /// <summary>
        /// 申请借款
        /// </summary>
        /// <param name="symbol">btc_usd: 比特币 ltc_usd: 莱特币 usd: 美元 </param>
        /// <param name="days">借款天数, three,seven,fifteen,thirty,sixty,ninety </param>
        /// <param name="amount">借入数量 </param>
        /// <param name="rate">借款利率 [0.0001, 0.01] </param>
        /// <returns></returns>
        public string borrow_money(string symbol, string days, string amount, string rate)
        {
            string result = "";

            try
            {
                HttpUtilMgr httpUtil = HttpUtilMgr.Ins;
                Dictionary <string, string> paras = new Dictionary <string, string>();
                paras.Add("api_key", api_key);
                if (!string.IsNullOrWhiteSpace(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!string.IsNullOrWhiteSpace(days))
                {
                    paras.Add("days", days);
                }
                if (!string.IsNullOrWhiteSpace(amount))
                {
                    paras.Add("amount", amount);
                }
                if (!string.IsNullOrWhiteSpace(rate))
                {
                    paras.Add("rate", rate);
                }
                string sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);
                //发送post请求
                result = httpUtil.requestHttpPost(url_prex, OKCoinServerUrl.BORROW_MONEY_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }