|
|
|
using Binance.Net.Clients;
|
|
|
|
using Binance.Net.Objects;
|
|
|
|
using Binance.TradeRobot.Model.Base;
|
|
|
|
using CryptoExchange.Net.Authentication;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using SDKAdapter.APIClient;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace SDKTestConsole
|
|
|
|
{
|
|
|
|
internal class Program
|
|
|
|
{
|
|
|
|
static void Main(string[] args)
|
|
|
|
{
|
|
|
|
var apiKey = "NnLXgcdUAZ8FAye4Qge3zrrdg5o7ufoWbgtYsKzgfIXz0OMz27G1Kx4SykMzw7YS";
|
|
|
|
var secret = "lpJ3t50osPx6lEUerVFMdoKsZ6uHPc769OFPGtfhcoPANpv97CEcvR3pz3Bezhhv";
|
|
|
|
var client = BaseAPIClient.Create(Enums.Exchange.Binance, 0, apiKey, secret);
|
|
|
|
|
|
|
|
//逐仓杠杆账户资产
|
|
|
|
//var marginList = client.GetIsolatedMarginAccountAssets();
|
|
|
|
//var s = JsonConvert.SerializeObject(marginList);
|
|
|
|
|
|
|
|
//查询最大借币额度
|
|
|
|
//var maxLoan = client.QueryMaxLoanAmount("ETHUSDT");
|
|
|
|
//Console.WriteLine(maxLoan);
|
|
|
|
|
|
|
|
//借币
|
|
|
|
//var r1 = client.IsolatedMarginLoan("ETHUSDT", 10M);
|
|
|
|
//var r2 = client.IsolatedMarginLoan("ETHUSDT", 10M);
|
|
|
|
//Console.WriteLine(r2.AccountLoanAmount);
|
|
|
|
|
|
|
|
//还币
|
|
|
|
//var r3 = client.IsolatedMarginRepay("ETHUSDT", 20M);
|
|
|
|
//Console.WriteLine(r3);
|
|
|
|
|
|
|
|
|
|
|
|
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 = binanceClient.SpotApi.Trading.PlaceMarginOrderAsync("ETHUSDT",
|
|
|
|
// Binance.Net.Enums.OrderSide.Buy,
|
|
|
|
// Binance.Net.Enums.SpotOrderType.Market,
|
|
|
|
// quoteQuantity: 20M, //报价币金额
|
|
|
|
// //quantity: 100M,
|
|
|
|
// //timeInForce: Binance.Net.Enums.TimeInForce.GoodTillCanceled,
|
|
|
|
// //stopPrice: 1899M,
|
|
|
|
// isIsolated: true,
|
|
|
|
// orderResponseType: Binance.Net.Enums.OrderResponseType.Full).Result;
|
|
|
|
//var s = JsonConvert.SerializeObject(r);
|
|
|
|
|
|
|
|
//市价卖币
|
|
|
|
//var r = binanceClient.SpotApi.Trading.PlaceMarginOrderAsync("ETHUSDT",
|
|
|
|
// Binance.Net.Enums.OrderSide.Sell,
|
|
|
|
// Binance.Net.Enums.SpotOrderType.Market,
|
|
|
|
// quantity: 0.0098M,
|
|
|
|
// //quoteQuantity: 20M, //报价币金额
|
|
|
|
// //quantity: 100M,
|
|
|
|
// //timeInForce: Binance.Net.Enums.TimeInForce.GoodTillCanceled,
|
|
|
|
// //stopPrice: 1899M,
|
|
|
|
// isIsolated: true,
|
|
|
|
// orderResponseType: Binance.Net.Enums.OrderResponseType.Full).Result;
|
|
|
|
//var s = JsonConvert.SerializeObject(r);
|
|
|
|
|
|
|
|
|
|
|
|
//止损卖币
|
|
|
|
//var r = binanceClient.SpotApi.Trading.PlaceMarginOrderAsync("ETHUSDT",
|
|
|
|
// Binance.Net.Enums.OrderSide.Sell,
|
|
|
|
// Binance.Net.Enums.SpotOrderType.StopLossLimit,
|
|
|
|
// quantity: 0.00008040M,
|
|
|
|
// price: 1899M,
|
|
|
|
// //quoteQuantity: 20M, //报价币金额
|
|
|
|
// //quantity: 100M,
|
|
|
|
// timeInForce: Binance.Net.Enums.TimeInForce.GoodTillCanceled,
|
|
|
|
// stopPrice: 1899M,
|
|
|
|
// isIsolated: true,
|
|
|
|
// orderResponseType: Binance.Net.Enums.OrderResponseType.Full).Result;
|
|
|
|
//var s = JsonConvert.SerializeObject(r);
|
|
|
|
//Console.WriteLine(s);
|
|
|
|
Console.ReadKey();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|