Ejemplo n.º 1
0
        /// <summary>
        /// 撤销订单
        /// </summary>
        /// <param name="symbol">btc_usd: 比特币 ltc_usd: 莱特币</param>
        /// <param name="order_id">订单ID(多个订单ID中间以","分隔,一次最多允许撤消3个订单)</param>
        /// <returns></returns>
        public String cancel_order(String symbol, String order_id)
        {
            String result = "";

            try
            {// 构造参数签名
                Dictionary <String, String> paras = new Dictionary <String, String>();
                paras.Add("api_key", api_key);
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(order_id))
                {
                    paras.Add("order_id", order_id);
                }

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

                // 发送post请求
                HttpUtilManager httpUtil = HttpUtilManager.getInstance();
                result = httpUtil.requestHttpPost(url_prex, CANCEL_ORDER_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 用户还全款
        /// </summary>
        /// <param name="borrow_id">借款单ID</param>
        /// <returns></returns>
        public String repayment(String borrow_id)
        {
            String result = "";

            try
            {
                HttpUtilManager             httpUtil = HttpUtilManager.getInstance();
                Dictionary <String, String> paras    = new Dictionary <String, String>();
                paras.Add("api_key", api_key);
                if (!StringUtil.isEmpty(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, REPAYMENT_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 3
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
            {
                HttpUtilManager             httpUtil = HttpUtilManager.getInstance();
                Dictionary <String, String> paras    = new Dictionary <String, String>();
                paras.Add("api_key", api_key);
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(since))
                {
                    paras.Add("since", since);
                }
                String sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);
                //发送post请求
                result = httpUtil.requestHttpPost(url_prex, TRADE_HISTORY_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 4
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 (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(type))
                {
                    paras.Add("type", type);
                }
                if (!StringUtil.isEmpty(orders_data))
                {
                    paras.Add("orders_data", orders_data);
                }
                String sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);

                // 发送post请求
                HttpUtilManager httpUtil = HttpUtilManager.getInstance();
                result = httpUtil.requestHttpPost(url_prex, BATCH_TRADE_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 5
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
            {
                HttpUtilManager             httpUtil = HttpUtilManager.getInstance();
                Dictionary <String, String> paras    = new Dictionary <String, String>();
                paras.Add("api_key", api_key);
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(current_page))
                {
                    paras.Add("current_page", current_page);
                }
                if (!StringUtil.isEmpty(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, UNREPAYMENTS_INFO_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 期货账户信息
        /// </summary>
        /// <returns></returns>
        public String future_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请求

                HttpUtilManager httpUtil = HttpUtilManager.getInstance();
                result = httpUtil.requestHttpPost(url_prex, FUTURE_USERINFO_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 用户逐仓持仓查询
        /// </summary>
        /// <param name="symbol">btc_usd:比特币    ltc_usd :莱特币</param>
        /// <param name="contractType">合约类型: this_week:当周   next_week:下周   month:当月   quarter:季度</param>
        /// <returns></returns>
        public String future_position_4fix(String symbol, String contractType)
        {
            String result = "";

            try
            {
                // 构造参数签名
                Dictionary <String, String> paras = new Dictionary <String, String>();
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(contractType))
                {
                    paras.Add("contract_type", contractType);
                }
                paras.Add("api_key", api_key);
                String sign = MD5Util.buildMysignV1(paras, secret_key);
                paras.Add("sign", sign);
                // 发送post请求
                HttpUtilManager httpUtil = HttpUtilManager.getInstance();
                result = httpUtil.requestHttpPost(url_prex, FUTURE_POSITION_4FIX_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(result);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///  查询用户借款信息
        /// </summary>
        /// <param name="symbol">btc_usd: 比特币 ltc_usd: 莱特币 usd: 美元 </param>
        /// <returns></returns>
        public String borrows_info(String symbol)
        {
            String result = "";

            try
            {
                HttpUtilManager             httpUtil = HttpUtilManager.getInstance();
                Dictionary <String, String> paras    = new Dictionary <String, String>();
                paras.Add("api_key", api_key);
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                String sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);
                //发送post请求
                result = httpUtil.requestHttpPost(url_prex, BORROWS_INFO_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 9
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
            {
                HttpUtilManager             httpUtil = HttpUtilManager.getInstance();
                Dictionary <String, String> paras    = new Dictionary <String, String>();
                paras.Add("api_key", api_key);
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(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, CANCEL_WITHDRAW_RUL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 期货下单
        /// </summary>
        /// <param name="symbol">btc_usd:比特币    ltc_usd :莱特币</param>
        /// <param name="contractType">合约类型: this_week:当周   next_week:下周   month:当月   quarter:季度</param>
        /// <param name="price">价格</param>
        /// <param name="amount">委托数量</param>
        /// <param name="type">1:开多   2:开空   3:平多   4:平空</param>
        /// <param name="matchPrice">是否为对手价 0:不是    1:是   ,当取值为1时,price无效</param>
        /// <param name="leverRate">杠杆率,10或20</param>
        /// <returns></returns>
        public String future_trade_ex(String symbol, String contractType,
                                      String price, String amount, String type, String matchPrice, String leverRate)
        {
            String result = "";

            try
            {  // 构造参数签名
                Dictionary <String, String> paras = new Dictionary <String, String>();
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(contractType))
                {
                    paras.Add("contract_type", contractType);
                }
                if (!StringUtil.isEmpty(api_key))
                {
                    paras.Add("api_key", api_key);
                }
                if (!StringUtil.isEmpty(price))
                {
                    paras.Add("price", price);
                }
                if (!StringUtil.isEmpty(amount))
                {
                    paras.Add("amount", amount);
                }
                if (!StringUtil.isEmpty(type))
                {
                    paras.Add("type", type);
                }
                if (!StringUtil.isEmpty(matchPrice))
                {
                    paras.Add("match_price", matchPrice);
                }
                if (!StringUtil.isEmpty(leverRate))
                {
                    paras.Add("lever_rate", leverRate);
                }
                String sign = MD5Util.buildMysignV1(paras, secret_key);
                paras.Add("sign", sign);
                // 发送post请求

                HttpUtilManager httpUtil = HttpUtilManager.getInstance();
                result = httpUtil.requestHttpPost(url_prex, FUTURE_TRADE_URL, paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 获取用户订单信息
        /// </summary>
        /// <param name="symbol">btc_usd:比特币    ltc_usd :莱特币</param>
        /// <param name="contractType">合约类型: this_week:当周   next_week:下周   month:当月   quarter:季度</param>
        /// <param name="orderId">订单ID(-1查询全部未成交订单,否则查询相应单号的订单)</param>
        /// <param name="status">查询状态:1:未完成(最近七天的数据)  2:已完成(最近七天的数据)</param>
        /// <param name="currentPage">当前页数</param>
        /// <param name="pageLength">每页获取条数,最多不超过50</param>
        /// <returns></returns>
        public String future_order_info(String symbol, String contractType,
                                        String orderId, String status, String currentPage = null, String pageLength = null)
        {
            String result = "";

            try
            {
                // 构造参数签名
                Dictionary <String, String> paras = new Dictionary <String, String>();
                if (!StringUtil.isEmpty(contractType))
                {
                    paras.Add("contract_type", contractType);
                }
                if (!StringUtil.isEmpty(currentPage))
                {
                    paras.Add("current_page", currentPage);
                }
                if (!StringUtil.isEmpty(orderId))
                {
                    paras.Add("order_id", orderId);
                }
                if (!StringUtil.isEmpty(api_key))
                {
                    paras.Add("api_key", api_key);
                }
                if (!StringUtil.isEmpty(pageLength))
                {
                    paras.Add("page_length", pageLength);
                }
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(status))
                {
                    paras.Add("status", status);
                }
                String sign = MD5Util.buildMysignV1(paras, secret_key);
                paras.Add("sign", sign);
                // 发送post请求

                HttpUtilManager httpUtil = HttpUtilManager.getInstance();
                result = httpUtil.requestHttpPost(url_prex, FUTURE_ORDER_INFO_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 12
0
        string IOKLinkClient.refund(Dictionary <string, Object> param)
        {
            String result = "";

            try
            {
                HttpUtilManager httpUtil = HttpUtilManager.getInstance(api_key, secret_key);
                result = httpUtil.requestHttpPost(url_prex, refund, param);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(result);
        }
Ejemplo n.º 13
0
        public String ticker(Dictionary <string, Object> param)
        {
            String result = "";

            try
            {
                HttpUtilManager httpUtil = HttpUtilManager.getInstance(api_key, secret_key);
                result = httpUtil.requestHttpPost(url_prex, ticker_url, param);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(result);
        }
Ejemplo n.º 14
0
        public string getCountryList()
        {
            String result = "";

            try
            {
                HttpUtilManager httpUtil = HttpUtilManager.getInstance(api_key, secret_key);
                result = httpUtil.requestHttpPost(url_prex, country_url, null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(result);
        }
Ejemplo n.º 15
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 (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(status))
                {
                    paras.Add("status", status);
                }
                if (!StringUtil.isEmpty(current_page))
                {
                    paras.Add("current_page", current_page);
                }
                if (!StringUtil.isEmpty(page_length))
                {
                    paras.Add("page_length", page_length);
                }

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

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

            return(result);
        }
Ejemplo n.º 16
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 (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(chargefee))
                {
                    paras.Add("chargefee", chargefee);
                }
                if (!StringUtil.isEmpty(trade_pwd))
                {
                    paras.Add("trade_pwd", trade_pwd);
                }
                if (!StringUtil.isEmpty(withdraw_address))
                {
                    paras.Add("withdraw_address", withdraw_address);
                }
                if (!StringUtil.isEmpty(withdraw_amount))
                {
                    paras.Add("withdraw_amount", withdraw_amount);
                }
                String sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);

                // 发送post请求
                HttpUtilManager httpUtil = HttpUtilManager.getInstance();
                result = httpUtil.requestHttpPost(url_prex, WITHDRAW_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 批量下单
        /// </summary>
        /// <param name="symbol">btc_usd:比特币    ltc_usd :莱特币</param>
        /// <param name="contract_type">合约类型: this_week:当周   next_week:下周   quarter:季度</param>
        /// <param name="orders_data">JSON类型的字符串 例:[{price:5,amount:2,type:1,match_price:1},{price:2,amount:3,type:1,match_price:1}] 最大下单量为5,price,amount,type,match_price参数参考future_trade接口中的说明 </param>
        ///<param name="lever_rate">杠杆倍数 value:10\20 默认10</param>
        /// <returns></returns>
        public String future_batch_trade(String symbol, String contract_type, String orders_data, String lever_rate)
        {
            String result = "";

            try
            {
                // 构造参数签名
                Dictionary <String, String> paras = new Dictionary <String, String>();
                paras.Add("api_key", api_key);
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(contract_type))
                {
                    paras.Add("contract_type", contract_type);
                }
                if (!StringUtil.isEmpty(orders_data))
                {
                    paras.Add("orders_data", orders_data);
                }
                if (!StringUtil.isEmpty(lever_rate))
                {
                    paras.Add("lever_rate", lever_rate);
                }
                String sign = MD5Util.buildMysignV1(paras, secret_key);

                paras.Add("sign", sign);
                // 发送post请求

                HttpUtilManager httpUtil = HttpUtilManager.getInstance();
                result = httpUtil.requestHttpPost(url_prex, FUTURE_BATCH_TRADE_URL, paras);
            }
            catch (Exception e)
            {
                Console.WriteLine("重新连接");
                future_batch_trade(symbol, contract_type, orders_data, lever_rate);
            }
            return(result);
        }
Ejemplo n.º 18
0
        /// <summary>
        ///  获取期货交易历史
        /// </summary>
        /// <param name="symbol">btc_usd:比特币    ltc_usd :莱特币</param>
        /// <param name="date">合约交割时间,格式yyyy-MM-dd</param>
        /// <param name="since">交易Id起始位置</param>
        /// <returns></returns>
        public String future_trades_history(String symbol, String date, String since)
        {
            String result = "";

            try
            {
                // 构造参数签名
                Dictionary <String, String> paras = new Dictionary <String, String>();
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(date))
                {
                    paras.Add("date", date);
                }
                if (!StringUtil.isEmpty(since))
                {
                    paras.Add("since", since);
                }
                if (!StringUtil.isEmpty(api_key))
                {
                    paras.Add("api_key", api_key);
                }
                String sign = MD5Util.buildMysignV1(paras, secret_key);
                paras.Add("sign", sign);
                // 发送post请求

                HttpUtilManager httpUtil = HttpUtilManager.getInstance();
                result = httpUtil.requestHttpPost(url_prex, FUTURE_TRADES_HISTORY_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 获取用户提现/充值记录
        /// </summary>
        /// <param name="symbol">btc_usd: 比特币 ltc_usd: 莱特币 usd: 美元</param>
        /// <param name="type">0:充值 1 :提现 </param>
        /// <param name="current_page">当前页数</param>
        /// <param name="page_length">每页数据条数,最多不超过50条</param>
        /// <returns></returns>
        public String account_records(String symbol, String type, String current_page, String page_length)
        {
            String result = "";

            try
            {
                HttpUtilManager             httpUtil = HttpUtilManager.getInstance();
                Dictionary <String, String> paras    = new Dictionary <String, String>();
                paras.Add("api_key", api_key);
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(type))
                {
                    paras.Add("type", type);
                }
                if (!StringUtil.isEmpty(current_page))
                {
                    paras.Add("current_page", current_page);
                }
                if (!StringUtil.isEmpty(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, ACCOUNT_RECORDS_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Ejemplo n.º 20
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
            {
                HttpUtilManager             httpUtil = HttpUtilManager.getInstance();
                Dictionary <String, String> paras    = new Dictionary <String, String>();
                paras.Add("api_key", api_key);
                if (!StringUtil.isEmpty(symbol))
                {
                    paras.Add("symbol", symbol);
                }
                if (!StringUtil.isEmpty(days))
                {
                    paras.Add("days", days);
                }
                if (!StringUtil.isEmpty(amount))
                {
                    paras.Add("amount", amount);
                }
                if (!StringUtil.isEmpty(rate))
                {
                    paras.Add("rate", rate);
                }
                String sign = MD5Util.buildMysignV1(paras, this.secret_key);
                paras.Add("sign", sign);
                //发送post请求
                result = httpUtil.requestHttpPost(url_prex, BORROW_MONEY_URL,
                                                  paras);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }