Пример #1
0
        /// <summary>
        /// 建立連線
        /// </summary>
        /// <param name="Account"></param>
        public string ApiInit(Account Account, string sExchangeType)
        {
            Exchange Exchange        = Account.Exchange;
            var      ExchangeTypeVal = "";
            var      MC = "";
            var      DC = "";
            var      ExchangeTypelist = Account.Exchange.ExchangeTypes.Where(x => x.Text == sExchangeType);

            if (ExchangeTypelist.Any())
            {
                ExchangeTypeVal = ExchangeTypelist.FirstOrDefault().ExchangeType1;
                MC = ExchangeTypelist.FirstOrDefault().MainCurrency;
                DC = ExchangeTypelist.FirstOrDefault().DeputyCurrency;
            }
            else
            {
                return(Exchange.Name + ":交易所沒有設定對應幣別");
            }

            switch (Exchange.Name.ToLower())
            {
            case "binance":
                ExchangeList.Add(Exchange, new ExchangeData(Exchange.Name, Account.Exchange.ProcessingFee, ExchangeTypeVal, MC, DC, Account.APIKey, Account.Secret));
                binance = new BinanceApi.Binance(Account.APIKey, Account.Secret);
                break;

            case "bittrex":
                ExchangeList.Add(Exchange, new ExchangeData(Exchange.Name, Account.Exchange.ProcessingFee, ExchangeTypeVal, MC, DC, Account.APIKey, Account.Secret));
                bittrex = new BittrexApi.Bittrex(Account.APIKey, Account.Secret);
                break;

            case "hitbtc":
                ExchangeList.Add(Exchange, new ExchangeData(Exchange.Name, Account.Exchange.ProcessingFee, ExchangeTypeVal, MC, DC, Account.APIKey, Account.Secret));
                hitbtc = new HitbtcApi.Hitbtc(Account.APIKey, Account.Secret);
                break;

            case "huobi":
                ExchangeList.Add(Exchange, new ExchangeData(Exchange.Name, Account.Exchange.ProcessingFee, ExchangeTypeVal, MC, DC, Account.APIKey, Account.Secret));
                huobi = new HuobiApi.Huobi(Account.APIKey, Account.Secret);
                break;

            case "poloniex":
                ExchangeList.Add(Exchange, new ExchangeData(Exchange.Name, Account.Exchange.ProcessingFee, ExchangeTypeVal, MC, DC, Account.APIKey, Account.Secret));
                Poloniex = new PoloniexApi.Poloniex(Account.APIKey, Account.Secret);
                break;

            case "okex":
                ExchangeList.Add(Exchange, new ExchangeData(Exchange.Name, Account.Exchange.ProcessingFee, ExchangeTypeVal, MC, DC, Account.APIKey, Account.Secret));
                OKEx = new OKExApi.OKExAPI(Account.APIKey, Account.Secret);
                break;
            }
            return("");
        }
Пример #2
0
 private void Api_Init()
 {
     binance = new BinanceApi.Binance();
     bittrex = new BittrexApi.Bittrex();
 }