|
|
@ -4,7 +4,9 @@ using Binance.TradeRobot.Model.Base; |
|
|
|
using CryptoExchange.Net.Authentication; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using SDKAdapter.APIClient; |
|
|
|
using SDKAdapter.WebSockets.Order.Spot; |
|
|
|
using System; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
namespace SDKTestConsole |
|
|
|
{ |
|
|
@ -12,34 +14,68 @@ namespace SDKTestConsole |
|
|
|
{ |
|
|
|
private static System.Threading.Timer timer; |
|
|
|
|
|
|
|
private static SpotOrderWebSocketClient orderWebSocketClient; |
|
|
|
static void Main(string[] args) |
|
|
|
{ |
|
|
|
var apiKey = "RsQ5RuhYbNRXCTGAQXhwb5Dt3jgPnwKXfR1OXz0qWmf3IsAC7zPQd14WGIr18rDA"; |
|
|
|
var secret = "yxW4PPb65rVpdo7fMt2mZcbNOtjOe3J4fMSRVtX5YJfj7kRzHW3dY6xfoW4jje1I"; |
|
|
|
var apiKey = "pXKdUPbGN4DNar2f2HRoL2qxHoCWcLNf9V5uHTL2lBVCxz66eE8PMPwBw9h8RbKf"; |
|
|
|
var secret = "c14tJd7kpMnePKRDoo4nzZk4bIn9bDO8ZCYo69amB4uspLgO5s4GlzYvTwD2zYav"; |
|
|
|
var client = BaseAPIClient.Create(Enums.Exchange.Binance, 0, apiKey, secret); |
|
|
|
|
|
|
|
//逐仓杠杆账户资产
|
|
|
|
var marginList = client.GetIsolatedMarginAccountAssets(); |
|
|
|
var s = JsonConvert.SerializeObject(marginList); |
|
|
|
//var marginList = client.GetIsolatedMarginAccountAssets();
|
|
|
|
//var s = JsonConvert.SerializeObject(marginList);
|
|
|
|
|
|
|
|
var spotClientOption = new BinanceApiClientOptions() |
|
|
|
{ |
|
|
|
BaseAddress = "https://api.binance.com", |
|
|
|
ApiCredentials = new ApiCredentials(apiKey, secret) |
|
|
|
}; |
|
|
|
var usdFuturesClientOption = new BinanceApiClientOptions() |
|
|
|
{ |
|
|
|
BaseAddress = "https://fapi.binance.com", |
|
|
|
ApiCredentials = new ApiCredentials(apiKey, secret) |
|
|
|
}; |
|
|
|
var binanceClient = new BinanceClient(new BinanceClientOptions() |
|
|
|
{ |
|
|
|
UsdFuturesApiOptions = usdFuturesClientOption, |
|
|
|
SpotApiOptions = spotClientOption |
|
|
|
}); |
|
|
|
//var spotClientOption = new BinanceApiClientOptions()
|
|
|
|
//{
|
|
|
|
// BaseAddress = "https://api.binance.com",
|
|
|
|
// ApiCredentials = new ApiCredentials(apiKey, secret)
|
|
|
|
//};
|
|
|
|
//var usdFuturesClientOption = new BinanceApiClientOptions()
|
|
|
|
//{
|
|
|
|
// BaseAddress = "https://fapi.binance.com",
|
|
|
|
// ApiCredentials = new ApiCredentials(apiKey, secret)
|
|
|
|
//};
|
|
|
|
//var binanceClient = new BinanceClient(new BinanceClientOptions()
|
|
|
|
//{
|
|
|
|
// UsdFuturesApiOptions = usdFuturesClientOption,
|
|
|
|
// SpotApiOptions = spotClientOption
|
|
|
|
//});
|
|
|
|
|
|
|
|
var binanceSocketClient = new BinanceSocketClient(); |
|
|
|
//var newClientOrderId = "abcd_286129845448773_1";
|
|
|
|
//var orderId = client.IsolatedMarginPlaceOrder("ETHUSDT", Enums.TradeDirection.Buy, Enums.OrderType.MARKET, quoteAmount: 20M, newClientOrderId: newClientOrderId);
|
|
|
|
|
|
|
|
var logger = NLog.LogManager.GetLogger("test"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var stopLossClientOrderId = "stoploss2_286129845448773_1"; |
|
|
|
long stopLossOrderId = 0; |
|
|
|
|
|
|
|
while (true) |
|
|
|
{ |
|
|
|
var input = Console.ReadLine(); |
|
|
|
if (input == "start") |
|
|
|
{ |
|
|
|
orderWebSocketClient = SpotOrderWebSocketClient.Create(Enums.BusinessType.IsolateMargin, |
|
|
|
Enums.Exchange.Binance, |
|
|
|
0, |
|
|
|
apiKey, |
|
|
|
secret, |
|
|
|
logger, |
|
|
|
null); |
|
|
|
orderWebSocketClient.Start("ETHUSDT"); |
|
|
|
} |
|
|
|
if (input == "down") |
|
|
|
{ |
|
|
|
stopLossOrderId = client.IsolatedMarginPlaceOrder("ETHUSDT", Enums.TradeDirection.Sell, Enums.OrderType.STOP_LOSS_LIMIT, quantity: 0.0101M, price: 1876M, stopPrice: 1876M, newClientOrderId: stopLossClientOrderId); |
|
|
|
} |
|
|
|
if (input == "cancel") |
|
|
|
{ |
|
|
|
client.CancelIsolateMarginOrder("ETHUSDT", stopLossOrderId, stopLossClientOrderId); |
|
|
|
} |
|
|
|
} |
|
|
|
Console.ReadKey(); |
|
|
|
} |
|
|
|
} |
|
|
|