以下代码的目的是获取我的余额使用binance.net但在控制台,只有"真实"。发出。
我如何通过c#获得我的余额?
namespace BinanceAPI
{
class Program
{
static async Task Main(string[] args)
{
BinanceClient.SetDefaultOptions(new BinanceClientOptions()
{
ApiCredentials = new ApiCredentials("my_API", "my_secret"),
});
using (var client = new BinanceClient())
{
var balanceData = await client.UsdFuturesApi.Account.GetBalancesAsync();
Console.WriteLine(balanceData);
}
}
}
}
数据在balanceData中返回。数据
你的代码应该是这样的:
using (var client = new BinanceClient())
{
var balanceData = await client.UsdFuturesApi.Account.GetBalancesAsync();
if(!balanceData.Success){
Console.WriteLine(balanceData.Error.Message);
}
else
{
foreach(var asset in balanceData.Data)
{
Console.WriteLine(string.Format("Asset: {0} | Balance: {1}", asset.Asset, asset.AvailableBalance));
// more info available in obj asset, just pick the ones you need
}
}
}