Skip to content

Commit

Permalink
[#99] Fix to update sub-accounts list+assets from wapi to sapi.
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomanuel committed Nov 22, 2021
1 parent 42178ae commit 15c1f49
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tasks/do-account-info.gs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function BinDoAccountInfo() {
* Gets the list of ALL sub-accounts
*/
function listSubAccounts() {
const data = new BinRequest().get("wapi/v3/sub-account/list.html");
const data = new BinRequest().get("sapi/v1/sub-account/list");
return data && data.subAccounts ? data.subAccounts : [];
}

Expand All @@ -82,7 +82,8 @@ function BinDoAccountInfo() {

function execute(type, options) {
Logger.log("[BinDoAccountInfo]["+type.toUpperCase()+"] Running..");
if (!BinWallet().isEnabled(type)) { // The "overview" case will always be true
const wallet_type = type === "futures/positions" ? "futures" : type;
if (!BinWallet().isEnabled(wallet_type)) { // The "overview" case will always be true
Logger.log("[BinDoAccountInfo]["+type.toUpperCase()+"] The wallet is disabled!");
return [["The "+type.toUpperCase()+" wallet is disabled! Enable it from 'Binance->Wallets' main menu."]];
}
Expand All @@ -107,7 +108,8 @@ function BinDoAccountInfo() {
refresh();
return; // We don't return any data here!
}
if (!BinWallet().isEnabled(type)) { // The wallet is disabled..
const wallet_type = type === "futures/positions" ? "futures" : type;
if (!BinWallet().isEnabled(wallet_type)) { // The wallet is disabled..
return; // ..so we don't return any data here!
}

Expand Down Expand Up @@ -137,7 +139,7 @@ function BinDoAccountInfo() {

return Object.keys(subaccs).reduce(function(assets, email) {
const qs = "email="+email;
const data = new BinRequest(opts).get("wapi/v3/sub-account/assets.html", qs);
const data = new BinRequest(opts).get("sapi/v3/sub-account/assets", qs);
assets[email] = (data||{}).balances || [];
return assets;
}, {});
Expand All @@ -148,7 +150,8 @@ function BinDoAccountInfo() {
if (type === "overview") {
return parseOverview(show_headers);
}
if (!BinWallet().isEnabled(type)) { // The wallet is disabled..
const wallet_type = type === "futures/positions" ? "futures" : type;
if (!BinWallet().isEnabled(wallet_type)) { // The wallet is disabled..
return []; // ..so we return empty data here!
}

Expand Down

0 comments on commit 15c1f49

Please sign in to comment.