コード例 #1
0
        private static void GetStableCoin()
        {
            var stableCoinClient = new StableCointClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var result = stableCoinClient.GetStableCoinAsync("tusd", "1000", "sell").Result;

            _logger.StopAndLog();

            if (result != null)
            {
                switch (result.status)
                {
                case "ok":
                {
                    var d = result.data;
                    AppLogger.Info($"Get stable coin successfully, quoteId: {d.quoteId}, currency: {d.currency}, amount: {d.amount}, fee: {d.exchangeFee}");
                    break;
                }

                case "error":
                {
                    AppLogger.Info($"Get stable coin fail, error code: {result.errorCode}, error message: {result.errorMessage}");
                    break;
                }
                }
            }
        }
コード例 #2
0
        private static void GetStableCoin()
        {
            var stableCoinClient = new StableCointClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var response = stableCoinClient.GetStableCoinAsync("usdt", "10", "sell").Result;

            _logger.StopAndLog();

            if (response != null)
            {
                switch (response.status)
                {
                case "ok":
                {
                    AppLogger.Info($"Get stable coin successfully");
                    break;
                }

                case "error":
                {
                    AppLogger.Info($"Get stable coin fail, error code: {response.errorCode}, error message: {response.errorMessage}");
                    break;
                }
                }
            }
        }
コード例 #3
0
        private static void PlaceOrder()
        {
            var tradeClient = new AlgoOrderClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var request = new PlaceOrderRequest
            {
                accountId     = 11136102,
                orderSide     = "buy",
                orderType     = "limit",
                symbol        = "htusdt",
                orderSize     = "5",
                orderPrice    = "2.1",
                stopPrice     = "2",
                clientOrderId = "0922T1753"
            };

            var response = tradeClient.PlaceOrderAsync(request).Result;

            _logger.StopAndLog();

            if (response.code == (int)ResponseCode.Success)
            {
                AppLogger.Info($"Place algo order successfully, client order id: {response.data.clientOrderId}");
            }
            else
            {
                AppLogger.Info($"Place algo order fail, error code: {response.code}, error message: {response.message}");
            }
        }
コード例 #4
0
        /// <summary>
        /// 获取成交量
        /// </summary>
        private static void GetIndexStatistics()
        {
            _logger.Start();
            var data = _homeClient.GetIndexStatisticsAsync().Result;

            _logger.StopAndLog();

            AppLogger.Info($"get index statistics, data:{JsonConvert.SerializeObject(data)}");
        }
コード例 #5
0
        /// <summary>
        /// 获取用户出入金记录
        /// </summary>
        private static void GetDepositWithdraw()
        {
            _logger.Start();
            var data = _walletClient.GetDepositWithdrawAsync(1, 10).Result;

            _logger.StopAndLog();

            AppLogger.Info($"get deposit withdraw record, data:{JsonConvert.SerializeObject(data)}");
        }
コード例 #6
0
        /// <summary>
        /// 获取K线
        /// </summary>
        private static void GetKline()
        {
            _logger.Start();
            var data = _marketClient.GetKlineAsync("BTCUSDT", DateTimeUtil.GetTimestamps_seconds(DateTime.Now),
                                                   DateTimeUtil.GetTimestamps_seconds(DateTime.Now.AddDays(-1)), CandlestickInterval.HOUR1).Result;

            _logger.StopAndLog();

            AppLogger.Info($"get kline, data:{JsonConvert.SerializeObject(data)}");
        }
コード例 #7
0
        private static void GetSystemStatus()
        {
            var client = new CommonClient();

            _logger.Start();
            string result = client.GetSystemStatus().Result;

            _logger.StopAndLog();

            AppLogger.Info($"Get system status: {result}");
        }
コード例 #8
0
        private static void TransferIn()
        {
            var marginClient = new IsolatedMarginClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var response = marginClient.TransferInAsync("eosht", "eos", "0.01").Result;

            _logger.StopAndLog();

            if (response != null)
            {
                switch (response.status)
                {
                case "ok":
                {
                    AppLogger.Info($"Transfer successfully, transfer id: {response.data}");
                    break;
                }

                case "error":
                {
                    AppLogger.Info($"Transfer fail, error code: {response.errorCode}, error message: {response.errorMessage}");
                    break;
                }
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        private static void GetUserInfo()
        {
            _logger.Start();
            var data = _accountClient.GetUserInfoAsync().Result;

            _logger.StopAndLog();

            AppLogger.Info($"get user info, data:{JsonConvert.SerializeObject(data)}");
        }
コード例 #10
0
        private static void GetETFInfo()
        {
            var etfClient = new ETFClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var response = etfClient.GetETFInfoAsync().Result;

            _logger.StopAndLog();

            if (response != null && response.data != null)
            {
                AppLogger.Info($"ETF name: {response.data.etfName}, purchase min amount: {response.data.purchaseMinAmount}");
                if (response.data.unitPrice != null)
                {
                    foreach (var p in response.data.unitPrice)
                    {
                        AppLogger.Info($"Currency: {p.currency}, amount: {p.amount}");
                    }
                }
            }
        }
コード例 #11
0
        private static void GetAccountInfo()
        {
            var accountClient = new AccountClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var result = accountClient.GetAccountInfoAsync().Result;

            _logger.StopAndLog();

            if (result != null && result.data != null)
            {
                AppLogger.Info($"Get account info, count={result.data.Length}");
                foreach (var a in result.data)
                {
                    AppLogger.Info($"account id: {a.id}, type: {a.type}, state: {a.state}");
                }
            }
        }
コード例 #12
0
        private static void LockSubUser()
        {
            var accountClient = new SubUserClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var result = accountClient.LockSubUserAsync(Config.SubUserId).Result;

            _logger.StopAndLog();

            if (result != null)
            {
                if (result.code == (int)ResponseCode.Success && result.data != null)
                {
                    AppLogger.Info($"Lock sub user {result.data.subUid} result: {result.data.userState}");
                }
                else
                {
                    AppLogger.Info($"Lock sub user error: {result.code}");
                }
            }
        }
コード例 #13
0
        private static void GetDepoistAddress()
        {
            var walletClient = new WalletClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var request = new GetRequest()
                          .AddParam("currency", "btc");

            var result = walletClient.GetDepositAddressAsync(request).Result;

            _logger.StopAndLog();

            if (result != null && result.data != null)
            {
                AppLogger.Info($"Get deposit address, id={result.data.Length}");
                foreach (var a in result.data)
                {
                    AppLogger.Info($"currency: {a.currency}, addr: {a.address}, chain: {a.chain}");
                }
            }
        }
コード例 #14
0
        private static void GetCandlestick()
        {
            var marketClient = new MarketClient();

            _logger.Start();
            var request = new GetRequest()
                          .AddParam("symbol", "btcusdt")
                          .AddParam("period", "1min")
                          .AddParam("size", "10");
            var result = marketClient.GetCandlestickAsync(request).Result;

            _logger.StopAndLog();

            if (result != null && result.data != null)
            {
                foreach (var c in result.data)
                {
                    AppLogger.Info($"local time: {Timestamp.SToLocal(c.id)}, count: {c.count}, amount: {c.amount}, volume: {c.vol}");
                }
                AppLogger.Info($"there are total {result.data.Length} candlesticks");
            }
        }
コード例 #15
0
        private static void PlaceOrder()
        {
            var tradeClient = new OrderClient(Config.AccessKey, Config.SecretKey);

            _logger.Start();
            var request = new PlaceOrderRequest
            {
                AccountId = Config.AccountId,
                type      = "buy-limit",
                symbol    = "btcusdt",
                source    = "spot-api",
                amount    = "1",
                price     = "1.1"
            };

            var response = tradeClient.PlaceOrderAsync(request).Result;

            _logger.StopAndLog();

            switch (response.status)
            {
            case "ok":
            {
                AppLogger.Info($"Place order successfully, order id: {response.data}");
                break;
            }

            case "error":
            {
                AppLogger.Info($"Place order fail, error code: {response.errorCode}, error message: {response.errorMessage}");
                break;
            }
            }
        }
コード例 #16
0
        /// <summary>
        /// 获取活跃委托
        /// </summary>
        /// <param name="contractCode"></param>
        private static void GetOpenOrders(string contractCode)
        {
            _logger.Start();
            var data = _tradeClient.GetOpenOrdersAsync(contractCode).Result;

            _logger.StopAndLog();

            AppLogger.Info($"get open orders, data:{JsonConvert.SerializeObject(data)}");
        }