Mida
Mida copied to clipboard
Adding a custom id to a MidaTradingAccount
Is there a way to add a custom id to a MidaTradingAccount when using Mida.login()?
The MidaTradingAccount class does have an id property but it's set as read only so I can't assign any value to it. Is this intentional?
Hello, the id field of MidaTradingAccount is supposed to contain the trading account id in the trading platform. So it's intentional to be a read only property. If you want to assign an id to your trading account you have plenty of ways to do this with different data structures, for example:
const ids = new WeakMap();
const myAccount = ...
ids.set(myAccount, "id");
What do you think?
Thanks! Never heard of WeakMaps before but it provided the solution for me.
Also one side note I noticed that the MidaTradingAccount id of a Binance/Spot account is empty. Is this because Binance doesn't give back a trading account id?
Also one side note I noticed that the MidaTradingAccount id of a Binance/Spot account is empty. Is this because Binance doesn't give back a trading account id?
Yes, in Binance unfortunately the API will not report the user id so in this specific case it's going to be empty.