Thank you for this project! I'm glad that at least someone decided to use API and not as a full web motor.
I fixed the live/demo modes, implemented functions to get buckets info and emit a bucket fund. Also, reduced the constructor and did beautify with VScode.
A working example to fund a bucket:
const trading212Handler = require('trading212');
const LIVE_SESSION = "12341234-abcd-abcd-56785678";
const DEMO_SESSION = "12341234-abcd-abcd-56785678";
//Create handle and client
const trading212 = new trading212Handler('demo', DEMO_SESSION);
async function run() {
return new Promise((resolve, reject) =>
trading212
.on('platform-subscribed', async () => {
// trading212.getBuckets();
let bucketID = await trading212.getBucketId("My xd AAA");
trading212.fundBucket(bucketID, 15, "BY_TARGETS");
})
.on('bucket-funded', (output) => {
console.log('Funded!:', output)
resolve(output)
})
)
}
(async () => {
await run();
console.log("Bye Bye")
// This is were you put your code
})();
Missing stuff (in my opinion):
API call in the constructor to refresh cookies
Use more enums instead strings (like the events names)
Hello,
Thank you for this project! I'm glad that at least someone decided to use API and not as a full web motor.
I fixed the live/demo modes, implemented functions to get buckets info and emit a bucket fund. Also, reduced the constructor and did beautify with VScode.
A working example to fund a bucket:
Missing stuff (in my opinion):
Hope it will be usueful :)