• 大小: 21KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-25
  • 语言: C#
  • 标签: 火币网API  

资源简介

火币网REST交易API,C#代码示例,VS2010。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Collections;
using System.Collections.Specialized;
using System.Net;

namespace HuobiAPI
{
    /// 
    ///Huobibase 的摘要说明
    /// 

    public class Huobibase
    {
        //火币现货配置信息
        public static String HUOBI_ACCESS_KEY = “xxxxxxxxxxxxxxxxxxx“;
        public static String HUOBI_SECRET_KEY = “xxxxxxxxxxxxxxxxxxx“;
        public static String HUOBI_API_URL = “https://api.huobi.com/apiv3“;
        protected static int success = 200;

        //火币网请求信息
        public static String BUY = “buy“;
        public static String BUY_MARKET = “buy_market“;
        public static String CANCEL_ORDER = “cancel_order“;
        public static String ACCOUNT_INFO = “get_account_info“;
        public static String NEW_DEAL_ORDERS = “get_new_deal_orders“;
        public static String ORDER_ID_BY_TRADE_ID = “get_order_id_by_trade_id“;
        public static String GET_ORDERS = “get_orders“;
        public static String ORDER_INFO = “order_info“;
        public static String SELL = “sell“;
        public static String SELL_MARKET = “sell_market“;

        /// 
        /// 加密
        /// 

        /// 
        /// 
        public static string Sign(NameValueCollection PostVars)
        {
            Dictionary dicMap = new Dictionary();
            foreach (var m in PostVars.AllKeys)
            {
                dicMap.Add(m PostVars[m]);
            }
            var dicMapOrder = dicMap.OrderBy(d => d.Key);

            StringBuilder inputStr = new StringBuilder();
            foreach (var d in dicMapOrder)
            {
                inputStr.Append(d.Key).Append(“=“).Append(d.Value).Append(“&“);
            }
            string str = inputStr.ToString();
            string md5Str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str.Substring(0 str.Length - 1) “MD5“).ToLower();
            return md5Str;
        }

        /// 
        /// 请求
        /// 

        /// 
        /// 
        public static string Post(NameValueCollection PostVars)
        {
            WebClient WebClientObj = new WebClient();
            WebClientObj.Headers.Add(“Content-Type“ “application/x-www-form-urlencoded“);
            byte[] byRemoteInfo = WebClientObj.UploadValues(Huobibase.HUOBI_API_URL “POST“ PostVars);
            string sRemoteInfo = System.Text.Encoding.UTF8.GetString(byRemoteInfo);
            return sRemoteInfo;
        }

        /// 
        /// 获得10位时间戳
        /// 

        /// 
        public static string GetTimestamp()
        {
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        144  2016-12-06 10:51  HuobiAPI\app.config

     文件       9728  2016-12-06 11:18  HuobiAPI\bin\Debug\HuobiAPI.dll

     文件        144  2016-12-06 10:51  HuobiAPI\bin\Debug\HuobiAPI.dll.config

     文件      22016  2016-12-06 11:18  HuobiAPI\bin\Debug\HuobiAPI.pdb

     文件       2749  2016-12-06 11:00  HuobiAPI\HuobiAPI.csproj

     文件        227  2016-12-06 10:51  HuobiAPI\HuobiAPI.csproj.user

     文件       3269  2016-12-06 11:23  HuobiAPI\Huobibase.cs

     文件      10493  2016-12-06 11:16  HuobiAPI\HuobiService.cs

     文件        174  2016-12-06 10:47  HuobiAPI\NameValueCollection.cs

     文件       6017  2016-12-06 11:18  HuobiAPI\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        440  2016-12-06 11:05  HuobiAPI\obj\x86\Debug\HuobiAPI.csproj.FileListAbsolute.txt

     文件       9728  2016-12-06 11:18  HuobiAPI\obj\x86\Debug\HuobiAPI.dll

     文件      22016  2016-12-06 11:18  HuobiAPI\obj\x86\Debug\HuobiAPI.pdb

     文件       1348  2016-12-06 10:46  HuobiAPI\Properties\AssemblyInfo.cs

     目录          0  2016-12-06 10:46  HuobiAPI\obj\x86\Debug\TempPE

     目录          0  2016-12-06 11:18  HuobiAPI\obj\x86\Debug

     目录          0  2016-12-06 11:05  HuobiAPI\bin\Debug

     目录          0  2016-12-06 10:59  HuobiAPI\bin\Release

     目录          0  2016-12-06 10:46  HuobiAPI\obj\x86

     目录          0  2016-12-06 10:59  HuobiAPI\bin

     目录          0  2016-12-06 10:46  HuobiAPI\obj

     目录          0  2016-12-06 10:46  HuobiAPI\Properties

     目录          0  2016-12-06 10:59  HuobiAPI

----------- ---------  ---------- -----  ----

                88493                    23


评论

共有 条评论

相关资源