public async void BitMEX() { var _api_key = TestConfig.GetConnectionKey("BitMEX"); var _args = new Dictionary <string, object>(); var _timeframe = "1d"; var _since = 0; //1514764800000; var _limit = 100; if (String.IsNullOrEmpty(_api_key.secret_key) == false || XApiClient.TestXUnitMode == XUnitMode.UseJsonFile) { var _trade_api = new CCXT.NET.BitMEX.Trade.TradeApi(_api_key.connect_key, _api_key.secret_key); #if DEBUG if (XApiClient.TestXUnitMode != XUnitMode.UseExchangeServer) { await _trade_api.publicApi.LoadMarkets(false, GetJsonContent(_trade_api.tradeClient, tRootFolder.Replace(@"\trade", @"\public"), "fetchMarkets", _args)); } #endif var _fetch_my_orders = await _trade_api.FetchMyOrders("BTC", "USD", _timeframe, _since, _limit, GetJsonContent(_trade_api.tradeClient, "fetchMyOrders", _args)); if (_fetch_my_orders.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_trade_api.tradeClient, _fetch_my_orders); Assert.NotNull(_fetch_my_orders); Assert.True(_fetch_my_orders.success, $"fetch my orders return error: {_fetch_my_orders.message}"); Assert.True(_fetch_my_orders.message == "success"); Assert.False(String.IsNullOrEmpty(_fetch_my_orders.marketId)); foreach (var _all_order in _fetch_my_orders.result) { Assert.False(String.IsNullOrEmpty(_all_order.orderId)); Assert.True(_all_order.quantity > 0.0m); Assert.True(_all_order.price > 0.0m); Assert.True(_all_order.amount == _all_order.quantity * _all_order.price); } } var _my_order_id = ""; if (_fetch_my_orders.result.Count <= 0) { _my_order_id = Guid.NewGuid().ToString(); } else { _my_order_id = _fetch_my_orders.result[0].orderId; } var _fetch_my_order = await _trade_api.FetchMyOrder("BTC", "USD", _my_order_id, GetJsonContent(_trade_api.tradeClient, "fetchMyOrder", _args)); if (_fetch_my_order.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_trade_api.tradeClient, _fetch_my_order); Assert.NotNull(_fetch_my_order); Assert.True(_fetch_my_order.success, $"fetch my order return error: {_fetch_my_order.message}"); Assert.True(_fetch_my_order.message == "success"); Assert.False(String.IsNullOrEmpty(_fetch_my_order.marketId)); Assert.False(String.IsNullOrEmpty(_fetch_my_order.result.orderId)); Assert.True(_fetch_my_order.result.quantity > 0.0m); Assert.True(_fetch_my_order.result.price > 0.0m); Assert.True(_fetch_my_order.result.amount == _fetch_my_order.result.quantity * _fetch_my_order.result.price); } var _fetch_open_orders = await _trade_api.FetchOpenOrders("BTC", "USD", GetJsonContent(_trade_api.tradeClient, "fetchOpenOrders", _args)); if (_fetch_open_orders.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_trade_api.tradeClient, _fetch_open_orders); Assert.NotNull(_fetch_open_orders); Assert.True(_fetch_open_orders.success, $"fetch open orders return error: {_fetch_open_orders.message}"); Assert.True(_fetch_open_orders.message == "success"); Assert.False(String.IsNullOrEmpty(_fetch_open_orders.marketId)); foreach (var _o in _fetch_open_orders.result) { Assert.False(String.IsNullOrEmpty(_o.orderId)); Assert.False(String.IsNullOrEmpty(_o.symbol)); Assert.True(_o.quantity > 0.0m); Assert.True(_o.price > 0.0m); Assert.True(_o.amount == _o.quantity * _o.price); } } var _all_open_orders = await _trade_api.FetchAllOpenOrders(GetJsonContent(_trade_api.tradeClient, "fetchAllOpenOrders", _args)); if (_all_open_orders.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_trade_api.tradeClient, _all_open_orders); Assert.NotNull(_all_open_orders); Assert.True(_all_open_orders.success, $"fetch all open orders return error: {_all_open_orders.message}"); Assert.True(_all_open_orders.message == "success"); foreach (var _o in _all_open_orders.result) { Assert.False(String.IsNullOrEmpty(_o.orderId)); Assert.False(String.IsNullOrEmpty(_o.symbol)); Assert.True(_o.quantity > 0.0m); Assert.True(_o.price > 0.0m); Assert.True(_o.amount == _o.quantity * _o.price); } } var _open_positions = await _trade_api.FetchAllOpenPositions(GetJsonContent(_trade_api.tradeClient, "fetchAllOpenPositions", _args)); if (_open_positions.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_trade_api.tradeClient, _open_positions); Assert.NotNull(_open_positions); Assert.True(_open_positions.success, $"fetch all open positions return error: {_open_positions.message}"); Assert.True(_open_positions.message == "success"); foreach (var _p in _open_positions.result) { Assert.False(String.IsNullOrEmpty(_p.positionId)); Assert.False(String.IsNullOrEmpty(_p.symbol)); Assert.True(_p.sideType != SideType.Unknown); Assert.True(Math.Abs(_p.quantity) > 0.0m); Assert.True(_p.price > 0.0m); Assert.True(_p.amount == Math.Abs(_p.quantity) * _p.price); Assert.True(_p.liqPrice >= 0.0m); } } var _fetch_my_trades = await _trade_api.FetchMyTrades("BTC", "USD", _timeframe, _since, _limit, GetJsonContent(_trade_api.tradeClient, "fetchMyTrades", _args)); if (_fetch_my_trades.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_trade_api.tradeClient, _fetch_my_trades); Assert.NotNull(_fetch_my_trades); Assert.True(_fetch_my_trades.success, $"fetch my trades return error: {_fetch_my_trades.message}"); Assert.True(_fetch_my_trades.message == "success"); Assert.False(String.IsNullOrEmpty(_fetch_my_trades.marketId)); foreach (var _closed_order in _fetch_my_trades.result) { Assert.False(String.IsNullOrEmpty(_closed_order.tradeId)); Assert.True(_closed_order.quantity > 0.0m); Assert.True(_closed_order.price > 0.0m); Assert.True(Numerical.CompareDecimal(_closed_order.amount, _closed_order.quantity * _closed_order.price)); Assert.True(_closed_order.timestamp >= 1000000000000 && _closed_order.timestamp <= 9999999999999); } } #if DEBUG if (XApiClient.TestXUnitMode != XUnitMode.UseExchangeServer) { var _limit_order = await _trade_api.CreateLimitOrder("BTC", "USD", 0.1m, 20000m, SideType.Ask, GetJsonContent(_trade_api.tradeClient, "createLimitOrder", _args)); if ((_limit_order.supported == true || TestConfig.SupportedCheck == true) && _limit_order.message.IndexOf("lack of balance") < 0) { this.WriteJson(_trade_api.tradeClient, _limit_order); Assert.NotNull(_limit_order); Assert.True(_limit_order.success, $"create limit order return error: {_limit_order.message}"); Assert.True(_limit_order.message == "success"); Assert.False(String.IsNullOrEmpty(_limit_order.result.orderId)); Assert.False(String.IsNullOrEmpty(_limit_order.marketId)); Assert.True(_limit_order.result.orderType == OrderType.Limit); } var _market_order = await _trade_api.CreateMarketOrder("BTC", "USD", 0.1m, 20000m, SideType.Ask, GetJsonContent(_trade_api.tradeClient, "createMarketOrder", _args)); if ((_market_order.supported == true || TestConfig.SupportedCheck == true) && _market_order.message.IndexOf("lack of balance") < 0) { this.WriteJson(_trade_api.tradeClient, _market_order); Assert.NotNull(_market_order); Assert.True(_market_order.success, $"create market order return error: {_market_order.message}"); Assert.True(_market_order.message == "success"); Assert.False(String.IsNullOrEmpty(_market_order.result.orderId)); Assert.False(String.IsNullOrEmpty(_market_order.marketId)); Assert.True(_market_order.result.orderType == OrderType.Market); } } #endif var _order_id = Guid.NewGuid().ToString(); var _cancel_order = await _trade_api.CancelOrder("BTC", "USD", _order_id, 0.1m, 20000m, SideType.Ask, GetJsonContent(_trade_api.tradeClient, "cancelOrder", _args)); if ((_cancel_order.supported == true || TestConfig.SupportedCheck == true) && _cancel_order.errorCode != ErrorCode.OrderNotFound) { this.WriteJson(_trade_api.tradeClient, _cancel_order); Assert.NotNull(_cancel_order); Assert.True(_cancel_order.success, $"cancel order return error: {_cancel_order.message}"); Assert.True(_cancel_order.message == "success"); Assert.False(String.IsNullOrEmpty(_cancel_order.result.orderId)); Assert.False(String.IsNullOrEmpty(_cancel_order.marketId)); } var _oder_ids = new string[] { _order_id }; var _cancel_orders = await _trade_api.CancelOrders("BTC", "USD", _oder_ids, GetJsonContent(_trade_api.tradeClient, "cancelOrders", _args)); if ((_cancel_orders.supported == true || TestConfig.SupportedCheck == true) && _cancel_orders.errorCode != ErrorCode.OrderNotFound) { this.WriteJson(_trade_api.tradeClient, _cancel_orders); Assert.NotNull(_cancel_orders); Assert.True(_cancel_orders.success, $"cancel orders return error: {_cancel_orders.message}"); Assert.True(_cancel_orders.message == "success"); } var _cancel_all_orders = await _trade_api.CancelAllOrders(GetJsonContent(_trade_api.tradeClient, "cancelAllOrders", _args)); if ((_cancel_all_orders.supported == true || TestConfig.SupportedCheck == true) && _cancel_all_orders.errorCode != ErrorCode.OrderNotFound) { this.WriteJson(_trade_api.tradeClient, _cancel_all_orders); Assert.NotNull(_cancel_all_orders); Assert.True(_cancel_all_orders.success, $"cancel all orders return error: {_cancel_all_orders.message}"); Assert.True(_cancel_all_orders.message == "success"); } } }
public async void Coinone() { var _api_key = TestConfig.GetConnectionKey("Coinone"); var _args = new Dictionary <string, object>(); var _timeframe = "1d"; var _since = 0; //1514764800000; var _limit = 100; if (String.IsNullOrEmpty(_api_key.secret_key) == false || XApiClient.TestXUnitMode == XUnitMode.UseJsonFile) { var _private_api = new CCXT.NET.Coinone.Private.PrivateApi(_api_key.connect_key, _api_key.secret_key); #if DEBUG if (XApiClient.TestXUnitMode != XUnitMode.UseExchangeServer) { await _private_api.publicApi.LoadMarkets(false, GetJsonContent(_private_api.privateClient, tRootFolder.Replace(@"\private", @"\public"), "fetchMarkets", _args)); } #endif var _new_address = await _private_api.CreateAddress("XRP", GetJsonContent(_private_api.privateClient, "createAddress", _args)); if (_new_address.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _new_address); Assert.NotNull(_new_address); Assert.True(_new_address.success, $"create an address return error: {_new_address.message}"); Assert.True(_new_address.message == "success"); Assert.False(String.IsNullOrEmpty(_new_address.result.currency)); Assert.False(String.IsNullOrEmpty(_new_address.result.address)); } var _address = await _private_api.FetchAddress("XRP", GetJsonContent(_private_api.privateClient, "fetchAddress", _args)); if (_address.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _address); Assert.NotNull(_address); Assert.True(_address.success, $"fetch an address return error: {_address.message}"); Assert.True(_address.message == "success"); Assert.False(String.IsNullOrEmpty(_address.result.currency)); Assert.False(String.IsNullOrEmpty(_address.result.address)); } var _addresses = await _private_api.FetchAddresses(GetJsonContent(_private_api.privateClient, "fetchAddresses", _args)); if (_addresses.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _addresses); Assert.NotNull(_addresses); Assert.True(_addresses.success, $"fetch addresses return error: {_addresses.message}"); Assert.True(_addresses.message == "success"); Assert.True(_addresses.result.Count >= 0); foreach (var _d in _addresses.result) { Assert.False(String.IsNullOrEmpty(_d.currency)); Assert.False(String.IsNullOrEmpty(_d.address)); } } #if DEBUG if (XApiClient.TestXUnitMode != XUnitMode.UseExchangeServer) { _args.Clear(); { // auth_number를 SMS로 발송 하지만, 입력해도 작동 하지 않음 // 대신에 google OTP number를 입력하면 동작은 하지만 "request time-out error" 발생 var _auth_number = await _private_api.GetAuthNumber("BTC", _args); _args.Add("auth_number", _auth_number.result); _args.Add("from_address", _addresses.result.Where(a => a.currency == "BTC").SingleOrDefault().address); } var _withdraw = await _private_api.CoinWithdraw("BTC", "3DE2DBYHC6dj2DZSEDamwnXffzyNHuAr6v", "", 0.01m, GetJsonContent(_private_api.privateClient, "coinWithdraw", _args)); if ((_withdraw.supported == true || TestConfig.SupportedCheck == true) && _withdraw.statusCode != 777 && _withdraw.statusCode != 103) { this.WriteJson(_private_api.privateClient, _withdraw); Assert.NotNull(_withdraw); Assert.True(_withdraw.success, $"withdraw return error: {_withdraw.message}"); Assert.True(_withdraw.message == "success"); Assert.False(String.IsNullOrEmpty(_withdraw.result.transferId)); } if (String.IsNullOrEmpty(_withdraw.result.transferId) == true) { _withdraw.result.transferId = _private_api.privateClient.GenerateNonceString(13); } var _cancel_withdraw = await _private_api.CancelCoinWithdraw("XRP", _withdraw.result.transferId, GetJsonContent(_private_api.privateClient, "cancelCoinWithdraw", _args)); if (_cancel_withdraw.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _cancel_withdraw); Assert.NotNull(_cancel_withdraw); Assert.True(_cancel_withdraw.success, $"cancel withdraw return error: {_cancel_withdraw.message}"); Assert.True(_cancel_withdraw.message == "success"); Assert.False(String.IsNullOrEmpty(_cancel_withdraw.result.transferId)); } } #endif var _fetch_transfers = await _private_api.FetchTransfers("XRP", _timeframe, _since, _limit, GetJsonContent(_private_api.privateClient, "fetchTransfers", _args)); if (_fetch_transfers.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _fetch_transfers); Assert.NotNull(_fetch_transfers); Assert.True(_fetch_transfers.success, $"fetch transfers return error: {_fetch_transfers.message}"); Assert.True(_fetch_transfers.message == "success"); foreach (var _d in _fetch_transfers.result) { Assert.False(String.IsNullOrEmpty(_d.transferId)); Assert.False(String.IsNullOrEmpty(_d.transactionId)); Assert.False(String.IsNullOrEmpty(_d.fromAddress) && String.IsNullOrEmpty(_d.toAddress)); Assert.True(_d.timestamp >= 1000000000000 && _d.timestamp <= 9999999999999); } } var _transfer_id = ""; if (_fetch_transfers.result.Count > 0) { _transfer_id = _fetch_transfers.result[0].transferId; } else { _transfer_id = Guid.NewGuid().ToString(); } var _fetch_transfer = await _private_api.FetchTransfer("XRP", _transfer_id, GetJsonContent(_private_api.privateClient, "fetchTransfer", _args)); if (_fetch_transfer.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _fetch_transfer); Assert.NotNull(_fetch_transfer); Assert.True(_fetch_transfer.success, $"fetch transfer return error: {_fetch_transfer.message}"); Assert.True(_fetch_transfer.message == "success"); Assert.False(String.IsNullOrEmpty(_fetch_transfer.result.transferId)); Assert.False(String.IsNullOrEmpty(_fetch_transfer.result.transactionId)); Assert.False(String.IsNullOrEmpty(_fetch_transfer.result.fromAddress) && String.IsNullOrEmpty(_fetch_transfer.result.toAddress)); Assert.True(_fetch_transfer.result.timestamp >= 1000000000000 && _fetch_transfer.result.timestamp <= 9999999999999); } var _fetch_all_transfers = await _private_api.FetchAllTransfers(_timeframe, _since, _limit, GetJsonContent(_private_api.privateClient, "fetchAllTransfers", _args)); if (_fetch_all_transfers.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _fetch_all_transfers); Assert.NotNull(_fetch_all_transfers); Assert.True(_fetch_all_transfers.success, $"fetch all transfers return error: {_fetch_all_transfers.message}"); Assert.True(_fetch_all_transfers.message == "success"); foreach (var _d in _fetch_all_transfers.result) { Assert.False(String.IsNullOrEmpty(_d.transferId)); Assert.False(String.IsNullOrEmpty(_d.transactionId)); Assert.False(String.IsNullOrEmpty(_d.fromAddress) && String.IsNullOrEmpty(_d.toAddress)); Assert.True(_d.timestamp >= 1000000000000 && _d.timestamp <= 9999999999999); } } var _balance = await _private_api.FetchBalance("XRP", "", GetJsonContent(_private_api.privateClient, "fetchBalance", _args)); if (_balance.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _balance); Assert.NotNull(_balance); Assert.True(_balance.success, $"fetch balances return error: {_balance.message}"); Assert.True(_balance.message == "success"); Assert.True(_balance.result.currency == "XRP"); Assert.True(Numerical.CompareDecimal(_balance.result.total, _balance.result.free + _balance.result.used)); } var _balances = await _private_api.FetchBalances(GetJsonContent(_private_api.privateClient, "fetchBalances", _args)); if (_balances.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _balances); Assert.NotNull(_balances); Assert.True(_balances.success, $"fetch all balances return error: {_balances.message}"); Assert.True(_balances.message == "success"); Assert.True(_balances.result.Count >= 0); foreach (var _b in _balances.result) { Assert.True(Numerical.CompareDecimal(_b.total, _b.free + _b.used)); } } var _wallet = await _private_api.FetchWallet("XRP", "USD", GetJsonContent(_private_api.privateClient, "fetchWallet", _args)); if (_wallet.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _wallet); Assert.NotNull(_wallet); Assert.True(_wallet.success, $"fetch wallet return error: {_wallet.message}"); Assert.True(_wallet.message == "success"); Assert.False(String.IsNullOrEmpty(_wallet.result.balance.currency)); Assert.True(Numerical.CompareDecimal(_wallet.result.balance.total, _wallet.result.balance.free + _wallet.result.balance.used)); } var _wallets = await _private_api.FetchWallets(_api_key.user_id, GetJsonContent(_private_api.privateClient, "fetchWallets", _args)); if (_wallets.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _wallets); Assert.NotNull(_wallets); Assert.True(_wallets.success, $"fetch wallets return error: {_wallets.message}"); Assert.True(_wallets.message == "success"); foreach (var _b in _balances.result) { Assert.True(Numerical.CompareDecimal(_b.total, _b.free + _b.used)); } } } }
public async void Bithumb() { var _api_key = TestConfig.GetConnectionKey("Bithumb"); var _args = new Dictionary <string, object>(); var _timeframe = "1d"; var _since = 0; //1514764800000; var _limit = 100; if (String.IsNullOrEmpty(_api_key.secret_key) == false || XApiClient.TestXUnitMode == XUnitMode.UseJsonFile) { var _private_api = new CCXT.NET.Bithumb.Private.PrivateApi(_api_key.connect_key, _api_key.secret_key); #if DEBUG if (XApiClient.TestXUnitMode != XUnitMode.UseExchangeServer) { await _private_api.publicApi.LoadMarkets(false, GetJsonContent(_private_api.privateClient, tRootFolder.Replace(@"\private", @"\public"), "fetchMarkets", _args)); } #endif var _new_address = await _private_api.CreateAddress("XRP", GetJsonContent(_private_api.privateClient, "createAddress", _args)); if (_new_address.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _new_address); Assert.NotNull(_new_address); Assert.True(_new_address.success, $"create an address return error: {_new_address.message}"); Assert.True(_new_address.message == "success"); Assert.False(String.IsNullOrEmpty(_new_address.result.currency)); Assert.False(String.IsNullOrEmpty(_new_address.result.address)); } var _address = await _private_api.FetchAddress("BTC", GetJsonContent(_private_api.privateClient, "fetchAddress", _args)); if (_address.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _address); Assert.NotNull(_address); Assert.True(_address.success, $"fetch an address return error: {_address.message}"); Assert.True(_address.message == "success"); Assert.False(String.IsNullOrEmpty(_address.result.currency)); Assert.False(String.IsNullOrEmpty(_address.result.address)); } var _addresses = await _private_api.FetchAddresses(GetJsonContent(_private_api.privateClient, "fetchAddresses", _args)); if (_addresses.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _addresses); Assert.NotNull(_addresses); Assert.True(_addresses.success, $"fetch addresses return error: {_addresses.message}"); Assert.True(_addresses.message == "success"); Assert.True(_addresses.result.Count >= 0); foreach (var _d in _addresses.result) { Assert.False(String.IsNullOrEmpty(_d.currency)); Assert.False(String.IsNullOrEmpty(_d.address)); } } #if DEBUG if (XApiClient.TestXUnitMode != XUnitMode.UseExchangeServer) { var _withdraw = await _private_api.CoinWithdraw("XRP", "rN9qNpgnBaZwqCg8CvUZRPqCcPPY7wfWep", "3162679978", 10.0m, GetJsonContent(_private_api.privateClient, "coinWithdraw", _args)); if ((_withdraw.supported == true || TestConfig.SupportedCheck == true) && _withdraw.statusCode != 5600) { this.WriteJson(_private_api.privateClient, _withdraw); Assert.NotNull(_withdraw); Assert.True(_withdraw.success, $"withdraw return error: {_withdraw.message}"); Assert.True(_withdraw.message == "success"); Assert.False(String.IsNullOrEmpty(_withdraw.result.transferId)); } if (String.IsNullOrEmpty(_withdraw.result.transferId) == true) { _withdraw.result.transferId = _private_api.privateClient.GenerateNonceString(13); } var _cancel_withdraw = await _private_api.CancelCoinWithdraw("XRP", _withdraw.result.transferId, GetJsonContent(_private_api.privateClient, "cancelCoinWithdraw", _args)); if (_cancel_withdraw.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _cancel_withdraw); Assert.NotNull(_cancel_withdraw); Assert.True(_cancel_withdraw.success, $"cancel withdraw return error: {_cancel_withdraw.message}"); Assert.True(_cancel_withdraw.message == "success"); Assert.False(String.IsNullOrEmpty(_cancel_withdraw.result.transferId)); } } #endif var _fetch_transfers = await _private_api.FetchTransfers("XRP", _timeframe, _since, _limit, GetJsonContent(_private_api.privateClient, "fetchTransfers", _args)); if (_fetch_transfers.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _fetch_transfers); Assert.NotNull(_fetch_transfers); Assert.True(_fetch_transfers.success, $"fetch transfers return error: {_fetch_transfers.message}"); Assert.True(_fetch_transfers.message == "success"); foreach (var _d in _fetch_transfers.result) { Assert.False(String.IsNullOrEmpty(_d.transferId)); Assert.False(String.IsNullOrEmpty(_d.transactionId)); Assert.False(String.IsNullOrEmpty(_d.fromAddress) && String.IsNullOrEmpty(_d.toAddress)); Assert.True(_d.timestamp >= 1000000000000 && _d.timestamp <= 9999999999999); } } var _transfer_id = ""; if (_fetch_transfers.result.Count > 0) { _transfer_id = _fetch_transfers.result[0].transferId; } else { _transfer_id = Guid.NewGuid().ToString(); } var _fetch_transfer = await _private_api.FetchTransfer("XRP", _transfer_id, GetJsonContent(_private_api.privateClient, "fetchTransfer", _args)); if (_fetch_transfer.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _fetch_transfer); Assert.NotNull(_fetch_transfer); Assert.True(_fetch_transfer.success, $"fetch transfer return error: {_fetch_transfer.message}"); Assert.True(_fetch_transfer.message == "success"); Assert.False(String.IsNullOrEmpty(_fetch_transfer.result.transferId)); Assert.False(String.IsNullOrEmpty(_fetch_transfer.result.transactionId)); Assert.False(String.IsNullOrEmpty(_fetch_transfer.result.fromAddress) && String.IsNullOrEmpty(_fetch_transfer.result.toAddress)); Assert.True(_fetch_transfer.result.timestamp >= 1000000000000 && _fetch_transfer.result.timestamp <= 9999999999999); } var _fetch_all_transfers = await _private_api.FetchAllTransfers(_timeframe, _since, _limit, GetJsonContent(_private_api.privateClient, "fetchAllTransfers", _args)); if (_fetch_all_transfers.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _fetch_all_transfers); Assert.NotNull(_fetch_all_transfers); Assert.True(_fetch_all_transfers.success, $"fetch all transfers return error: {_fetch_all_transfers.message}"); Assert.True(_fetch_all_transfers.message == "success"); foreach (var _d in _fetch_all_transfers.result) { Assert.False(String.IsNullOrEmpty(_d.transferId)); Assert.False(String.IsNullOrEmpty(_d.transactionId)); Assert.False(String.IsNullOrEmpty(_d.fromAddress) && String.IsNullOrEmpty(_d.toAddress)); Assert.True(_d.timestamp >= 1000000000000 && _d.timestamp <= 9999999999999); } } var _balance = await _private_api.FetchBalance("BTC", "KRW", GetJsonContent(_private_api.privateClient, "fetchBalance", _args)); if (_balance.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _balance); Assert.NotNull(_balance); Assert.True(_balance.success, $"fetch balances return error: {_balance.message}"); Assert.True(_balance.message == "success"); Assert.True(_balance.result.currency == "BTC"); Assert.True(Numerical.CompareDecimal(_balance.result.total, _balance.result.free + _balance.result.used)); } var _balances = await _private_api.FetchBalances(GetJsonContent(_private_api.privateClient, "fetchBalances", _args)); if (_balances.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _balances); Assert.NotNull(_balances); Assert.True(_balances.success, $"fetch all balances return error: {_balances.message}"); Assert.True(_balances.message == "success"); Assert.True(_balances.result.Count >= 0); foreach (var _b in _balances.result) { Assert.True(Numerical.CompareDecimal(_b.total, _b.free + _b.used)); } } var _wallet = await _private_api.FetchWallet("XRP", "KRW", GetJsonContent(_private_api.privateClient, "fetchWallet", _args)); if (_wallet.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _wallet); Assert.NotNull(_wallet); Assert.True(_wallet.success, $"fetch wallet return error: {_wallet.message}"); Assert.True(_wallet.message == "success"); Assert.False(String.IsNullOrEmpty(_wallet.result.balance.currency)); Assert.True(Numerical.CompareDecimal(_wallet.result.balance.total, _wallet.result.balance.free + _wallet.result.balance.used)); } var _wallets = await _private_api.FetchWallets(_api_key.user_id, GetJsonContent(_private_api.privateClient, "fetchWallets", _args)); if (_wallets.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _wallets); Assert.NotNull(_wallets); Assert.True(_wallets.success, $"fetch wallets return error: {_wallets.message}"); Assert.True(_wallets.message == "success"); foreach (var _b in _balances.result) { Assert.True(Numerical.CompareDecimal(_b.total, _b.free + _b.used)); } } } }
public async void Poloniex() { var _api_key = TestConfig.GetConnectionKey("Poloniex"); var _args = new Dictionary <string, object>(); var _timeframe = "1d"; var _since = 0; //1514764800000; var _limit = 100; if (String.IsNullOrEmpty(_api_key.secret_key) == false || XApiClient.TestXUnitMode == XUnitMode.UseJsonFile) { var _private_api = new CCXT.NET.Poloniex.Private.PrivateApi(_api_key.connect_key, _api_key.secret_key); #if DEBUG if (XApiClient.TestXUnitMode != XUnitMode.UseExchangeServer) { await _private_api.publicApi.LoadMarketsAsync(false, GetJsonContent(_private_api.privateClient, tRootFolder.Replace(@"\private", @"\public"), "fetchMarkets", _args)); } #endif var _new_address = await _private_api.CreateAddressAsync("XRP", GetJsonContent(_private_api.privateClient, "createAddress", _args)); if ((_new_address.supported == true || TestConfig.SupportedCheck == true) && _new_address.message.IndexOf("You may only") < 0) { this.WriteJson(_private_api.privateClient, _new_address); Assert.NotNull(_new_address); Assert.True(_new_address.success, $"create an address return error: {_new_address.message}"); Assert.True(_new_address.message == "success"); Assert.False(String.IsNullOrEmpty(_new_address.result.currency)); Assert.False(String.IsNullOrEmpty(_new_address.result.address)); } var _address = await _private_api.FetchAddressAsync("BTC", GetJsonContent(_private_api.privateClient, "fetchAddress", _args)); if (_address.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _address); Assert.NotNull(_address); Assert.True(_address.success, $"fetch an address return error: {_address.message}"); Assert.True(_address.message == "success"); Assert.False(String.IsNullOrEmpty(_address.result.currency)); Assert.False(String.IsNullOrEmpty(_address.result.address)); } var _addresses = await _private_api.FetchAddressesAsync(GetJsonContent(_private_api.privateClient, "fetchAddresses", _args)); if (_addresses.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _addresses); Assert.NotNull(_addresses); Assert.True(_addresses.success, $"fetch addresses return error: {_addresses.message}"); Assert.True(_addresses.message == "success"); Assert.True(_addresses.result.Count >= 0); foreach (var _d in _addresses.result) { Assert.False(String.IsNullOrEmpty(_d.currency)); Assert.False(String.IsNullOrEmpty(_d.address)); } } #if DEBUG if (XApiClient.TestXUnitMode != XUnitMode.UseExchangeServer) { var _withdraw = await _private_api.CoinWithdrawAsync("ETH", "0xad8f564dcf5cc7e7e60db938b01283a4da208602", "", 0.1m, GetJsonContent(_private_api.privateClient, "coinWithdraw", _args)); if ((_withdraw.supported == true || TestConfig.SupportedCheck == true) && _withdraw.message.IndexOf("Not enough") < 0) { this.WriteJson(_private_api.privateClient, _withdraw); Assert.NotNull(_withdraw); Assert.True(_withdraw.success, $"withdraw return error: {_withdraw.message}"); Assert.True(_withdraw.message == "success"); Assert.False(String.IsNullOrEmpty(_withdraw.result.transferId)); } if (String.IsNullOrEmpty(_withdraw.result.transferId) == true) { _withdraw.result.transferId = _private_api.privateClient.GenerateNonceString(13); } var _cancel_withdraw = await _private_api.CancelCoinWithdrawAsync("BTC", _withdraw.result.transferId, GetJsonContent(_private_api.privateClient, "cancelCoinWithdraw", _args)); if (_cancel_withdraw.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _cancel_withdraw); Assert.NotNull(_cancel_withdraw); Assert.True(_cancel_withdraw.success, $"cancel withdraw return error: {_cancel_withdraw.message}"); Assert.True(_cancel_withdraw.message == "success"); Assert.False(String.IsNullOrEmpty(_cancel_withdraw.result.transferId)); } } #endif var _fetch_transfers = await _private_api.FetchTransfersAsync("BTC", _timeframe, _since, _limit, GetJsonContent(_private_api.privateClient, "fetchTransfers", _args)); if (_fetch_transfers.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _fetch_transfers); Assert.NotNull(_fetch_transfers); Assert.True(_fetch_transfers.success, $"fetch transfers return error: {_fetch_transfers.message}"); Assert.True(_fetch_transfers.message == "success"); foreach (var _d in _fetch_transfers.result) { Assert.False(String.IsNullOrEmpty(_d.transferId)); Assert.False(String.IsNullOrEmpty(_d.transactionId)); Assert.False(String.IsNullOrEmpty(_d.fromAddress) && String.IsNullOrEmpty(_d.toAddress)); Assert.True(_d.timestamp >= 1000000000000 && _d.timestamp <= 9999999999999); } } var _transfer_id = ""; if (_fetch_transfers.result.Count > 0) { _transfer_id = _fetch_transfers.result[0].transferId; } else { _transfer_id = Guid.NewGuid().ToString(); } var _fetch_transfer = await _private_api.FetchTransferAsync("XRP", _transfer_id, GetJsonContent(_private_api.privateClient, "fetchTransfer", _args)); if (_fetch_transfer.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _fetch_transfer); Assert.NotNull(_fetch_transfer); Assert.True(_fetch_transfer.success, $"fetch transfer return error: {_fetch_transfer.message}"); Assert.True(_fetch_transfer.message == "success"); Assert.False(String.IsNullOrEmpty(_fetch_transfer.result.transferId)); Assert.False(String.IsNullOrEmpty(_fetch_transfer.result.transactionId)); Assert.False(String.IsNullOrEmpty(_fetch_transfer.result.fromAddress) && String.IsNullOrEmpty(_fetch_transfer.result.toAddress)); Assert.True(_fetch_transfer.result.timestamp >= 1000000000000 && _fetch_transfer.result.timestamp <= 9999999999999); } var _fetch_all_transfers = await _private_api.FetchAllTransfersAsync(_timeframe, _since, _limit, GetJsonContent(_private_api.privateClient, "fetchAllTransfers", _args)); if (_fetch_all_transfers.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _fetch_all_transfers); Assert.NotNull(_fetch_all_transfers); Assert.True(_fetch_all_transfers.success, $"fetch all transfers return error: {_fetch_all_transfers.message}"); Assert.True(_fetch_all_transfers.message == "success"); foreach (var _d in _fetch_all_transfers.result) { Assert.False(String.IsNullOrEmpty(_d.transferId)); Assert.False(String.IsNullOrEmpty(_d.transactionId)); Assert.False(String.IsNullOrEmpty(_d.fromAddress) && String.IsNullOrEmpty(_d.toAddress)); Assert.True(_d.timestamp >= 1000000000000 && _d.timestamp <= 9999999999999); } } var _balance = await _private_api.FetchBalanceAsync("BTC", "USDT", GetJsonContent(_private_api.privateClient, "fetchBalance", _args)); if (_balance.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _balance); Assert.NotNull(_balance); Assert.True(_balance.success, $"fetch balances return error: {_balance.message}"); Assert.True(_balance.message == "success"); Assert.True(_balance.result.currency == "BTC"); Assert.True(Numerical.CompareDecimal(_balance.result.total, _balance.result.free + _balance.result.used)); } var _balances = await _private_api.FetchBalancesAsync(GetJsonContent(_private_api.privateClient, "fetchBalances", _args)); if (_balances.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _balances); Assert.NotNull(_balances); Assert.True(_balances.success, $"fetch all balances return error: {_balances.message}"); Assert.True(_balances.message == "success"); Assert.True(_balances.result.Count >= 0); foreach (var _b in _balances.result) { Assert.True(Numerical.CompareDecimal(_b.total, _b.free + _b.used)); } } var _wallet = await _private_api.FetchWalletAsync("XRP", "USD", GetJsonContent(_private_api.privateClient, "fetchWallet", _args)); if (_wallet.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _wallet); Assert.NotNull(_wallet); Assert.True(_wallet.success, $"fetch wallet return error: {_wallet.message}"); Assert.True(_wallet.message == "success"); Assert.False(String.IsNullOrEmpty(_wallet.result.balance.currency)); Assert.True(Numerical.CompareDecimal(_wallet.result.balance.total, _wallet.result.balance.free + _wallet.result.balance.used)); } var _wallets = await _private_api.FetchWalletsAsync(_api_key.user_id, GetJsonContent(_private_api.privateClient, "fetchWallets", _args)); if (_wallets.supported == true || TestConfig.SupportedCheck == true) { this.WriteJson(_private_api.privateClient, _wallets); Assert.NotNull(_wallets); Assert.True(_wallets.success, $"fetch wallets return error: {_wallets.message}"); Assert.True(_wallets.message == "success"); foreach (var _b in _balances.result) { Assert.True(Numerical.CompareDecimal(_b.total, _b.free + _b.used)); } } } }