You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.4 KiB
84 lines
3.4 KiB
using Binance.Net.Clients;
|
|
using Binance.Net.Objects;
|
|
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
|
|
{
|
|
internal class Program
|
|
{
|
|
private static System.Threading.Timer timer;
|
|
|
|
private static SpotOrderWebSocketClient orderWebSocketClient;
|
|
static void Main(string[] args)
|
|
{
|
|
var apiKey = "2HiU7O8v3JmADiIRNjfUHQIFwgJS2WQGOB8SW1e9BmCDppTDHpLZnt950JxIfn8Q";
|
|
var secret = "T3pvxSnutmPpWIh3VI3t8rrTOfbrruJxHzHs5Lp7pXAFlN723z73mcPnct1qaf0g";
|
|
var client = BaseAPIClient.Create(Enums.Exchange.Binance, 0, apiKey, secret);
|
|
|
|
//逐仓杠杆账户资产
|
|
//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 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 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 r = client.GetIsolatedMarginAccountAssets();
|
|
|
|
//var clientOrder = CreateClientOrder(288617629646917,Enums.TradePolicy.D21);
|
|
//client.IsolatedMarginPlaceOrder("APEUSDT", Enums.TradeDirection.Sell, Enums.OrderType.MARKET, quantity: 3.08M, newClientOrderId: clientOrder);
|
|
|
|
//client.IsolatedMarginRepay("APEUSDT", 8.29717105M);
|
|
Console.ReadKey();
|
|
}
|
|
|
|
private static string CreateClientOrder(long robotId, Enums.TradePolicy tradePolicy)
|
|
{
|
|
var guid = Guid.NewGuid();
|
|
var random = new Random(guid.GetHashCode());
|
|
return $"{Convert.ToChar(random.Next(97, 123))}{guid.ToString().Substring(0, 4)}_{robotId}_{(int)tradePolicy}";
|
|
}
|
|
}
|
|
}
|
|
|