KO-9 / node-trading212

NodeJS Trading212 Unofficial API
19 stars 3 forks source link

Portfolio data #6

Closed zRelux closed 1 year ago

zRelux commented 3 years ago

Hello I was trying to make an api for trading212 and came across this. Is it possible to get user portfolio data with this? Like pies and overall profits

KO-9 commented 3 years ago

You can get overall return, I suspect you can get pie data too but I don't use pies. I can look into that though

You can get overall return by subscribing to t he "account" event

trading212.on('account', (data) => {

the data object has a property cash which has a property "result", this is the overall profit/loss for the account

trading212.on('account', (data) => {
console.log(data.cash);
});

you also have "cash" which is the current cash value of the account, "free", the free amount, "commission" how much you have paid/lost in commission fees, "free" cash free in the account, "freeForStocks" - free cash minus any cash reserved for buys, 2pieCash" - not sure what this does

zRelux commented 3 years ago

Oh nice how do I go on to get like the percentage increase or something like that?

mrgithub commented 3 years ago

You can get overall return, I suspect you can get pie data too but I don't use pies. I can look into that though

You can get overall return by subscribing to t he "account" event

trading212.on('account', (data) => {

the data object has a property cash which has a property "result", this is the overall profit/loss for the account

trading212.on('account', (data) => {
console.log(data.cash);
});

you also have "cash" which is the current cash value of the account, "free", the free amount, "commission" how much you have paid/lost in commission fees, "free" cash free in the account, "freeForStocks" - free cash minus any cash reserved for buys, 2pieCash" - not sure what this does

How do you scan the API for all this info? E.g. how did you find out all this info?