Hi,
I am trying to connect to my margin account using Matlab, some requests are successful some aren’t.
Below the test code I used for the first test :
%%%%%%%API
timestamp=webread(‘https://api.binance.com/api/v1/time’);timestamp=num2str(timestamp.serverTime); [key,secret]=key_secret('binance'); string=['×tamp=' timestamp]; Signature = char(crypto(string, secret, 'HmacSHA256')); url_ext = [ string '&signature=' Signature]; url=['https://api.binance.com/api/v3/account?' url_ext ]; options = weboptions('HeaderFields',{'X-MBX-APIKEY' key},'ArrayFormat','json'); balances=webread(url,options) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% Max transferable timestamp=webread('https://api.binance.com/api/v1/time'); timestamp=num2str(timestamp.serverTime); [key,secret]=key_secret('binance'); string=['×tamp=' timestamp]; Signature = char(crypto(string, secret, 'HmacSHA256')); url_ext = [ '&asset=BNB' string '&signature=' Signature]; url=['https://api.binance.com/sapi/v1/margin/maxTransferable?' url_ext ]; options = weboptions('HeaderFields',{'X-MBX-APIKEY' key},'ArrayFormat','json'); max=webread(url,options)
There is the response I obtain :
test_api
balances =
struct with fields:
makerCommission: 10 takerCommission: 10 buyerCommission: 0 sellerCommission: 0 canTrade: 1 canWithdraw: 1 canDeposit: 1 updateTime: 1.5962e+12 accountType: 'SPOT' balances: [254×1 struct] permissions: {2×1 cell}
The server returned the status 400 with message “” in response to the request to URL
https://api.binance.com/sapi/v1/margin/maxTransferable?&asset=BNB×tamp=xxxx&signature=xxxx
The first part is OK but I cannot get a reply for the margin account (maybe the string sent is wrong because I am not sure about the parameter ‘asset’.
In the first response the accountType=Spot, is this the issue? How to change that?
Regards.