Closed jurgenBE closed 2 years ago
Hi jurgenBE.
I would do something like the code bellow.
The additional value in the repay order is for interest payment.
Best regards.
// Get all isolated margin account balances
var balanceResult = client.SpotApi.Account.GetIsolatedMarginAccountAsync().Result;
// Select balances of a specific symbol
var assetBalance = balanceResult.Data.Assets.First(x => x.Symbol == "WTCUSDT");
// Get quote (USDT) free balance for that symbol
var usdtBalance = assetBalance.QuoteAsset.Free;
// Check if it is greater than some value. If not, transfer the missing value.
if (usdtBalance < 100M)
{
var amount = 100M - usdtBalance;
var transferResult = client.SpotApi.Account.IsolatedMarginAccountTransferAsync("USDT", "WTCUSDT", IsolatedMarginTransferDirection.Spot, IsolatedMarginTransferDirection.IsolatedMargin, amount).Result;
}
// Open a short position
var sellResult = client.SpotApi.Trading.PlaceMarginOrderAsync("WTCUSDT", OrderSide.Sell, SpotOrderType.Market, null, 100M, null, null, null, null, null, SideEffectType.MarginBuy, true);
// At a later time, close the short position and repay the borrow value and the interest
var buyResult = client.SpotApi.Trading.PlaceMarginOrderAsync("WTCUSDT", OrderSide.Buy, SpotOrderType.Market, null, 101M, null, null, null, null, null, SideEffectType.AutoRepay, true);
Hi Eduardo,
I am not doing anything anymore with binance.net. I am doing web3/solidity now. Are you experienced in these languages too? Can you send me a PM at @.**@.> if you are?
Verzonden vanuit Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 voor Windows
Van: @.> Verzonden: 29 May 2022 02:42 Aan: @.> CC: @.>; @.> Onderwerp: Re: [JKorf/Binance.Net] Isolated Margin (#850)
Hi jurgenBE.
I would do something like the code bellow.
The additional value in the repay order is for interest payment.
Best regards.
// Get all isolated margin account balances
var balanceResult = client.SpotApi.Account.GetIsolatedMarginAccountAsync().Result;
// Select balances of a specific symbol
var assetBalance = balanceResult.Data.Assets.First(x => x.Symbol == "WTCUSDT");
// Get quote (USDT) free balance for that symbol
var usdtBalance = assetBalance.QuoteAsset.Free;
// Check if it is greater than some value. If not, transfer the missing value.
if (usdtBalance < 100M)
{
var amount = 100M - usdtBalance;
var transferResult = client.SpotApi.Account.IsolatedMarginAccountTransferAsync("USDT", "WTCUSDT", IsolatedMarginTransferDirection.Spot, IsolatedMarginTransferDirection.IsolatedMargin, amount).Result;
}
// Open a short position
var sellResult = client.SpotApi.Trading.PlaceMarginOrderAsync("WTCUSDT", OrderSide.Sell, SpotOrderType.Market, null, 100M, null, null, null, null, null, SideEffectType.MarginBuy, true);
// At a later time, close the short position and repay the borrow value and the interest
var buyResult = client.SpotApi.Trading.PlaceMarginOrderAsync("WTCUSDT", OrderSide.Buy, SpotOrderType.Market, null, 101M, null, null, null, null, null, SideEffectType.AutoRepay, true);
— Reply to this email directly, view it on GitHubhttps://github.com/JKorf/Binance.Net/issues/850#issuecomment-1140350642, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACOZWZ76FONTJSMISSV344DVMK4OHANCNFSM5DF4BNQA. You are receiving this because you authored the thread.Message ID: @.***>
Hi jurgenBE.
I just know a little bit of C#.
Best regards.
Hey,
Let's say this example WTCUSDT => this is 'isolated' margin x3
How would someone do that with your binance.net program ?? Many thanx,