ahmedsakr / wstrade-api

API Wrapper for Wealthsimple Trade
97 stars 27 forks source link

WealthSimple get stocks routes #58

Open GabrielBottari opened 3 years ago

GabrielBottari commented 3 years ago

Wealthsimple trade app allows to get its available stocks by categories or top lists. It would be nice to have those to know which stock are available to trade.

I started investigating the API spec. Will update once I know more.

ahmedsakr commented 3 years ago

Great, keep me updated. It definitely would be a good addition to wstrade-api. I'm nearly wrapped up with v1.0.0, but it could be a minor version in v1.x.0.

GabrielBottari commented 3 years ago

I'm having a hard time reverse engineering the calls. I tried intercepting them with a vpn middleware, but the Wealthsimple Trade app seems to detect it and block it. How did you achieve this? My next attempt otherwise would be to decompile their apk.

ahmedsakr commented 3 years ago

Yep, i've already tried using motmproxy before and it's protected against MOTM attacks (good news as a customer :) ).

I have used this repo to create the API wrapper on. On top of of that, I just fiddled with the parameters and guessed the interface for some endpoints based on patterns.

GabrielBottari commented 3 years ago

I have found a few interesting endpoints:

The /securities endpoint allows much more specification: example: https://trade-service.wealthsimple.com/securities/top_market_movers?type=gainers&limit=50&offset=150 top_market_movers can be replaced with most_watched and crypto, and gainers can be replaced with losers, most_watched and most_active (type is only available for top_market_movers)

There's also the /security-groups/{securitygroupid}/securities which allows to fetch securities by categories. To get categories just call /security-groups. For example, we wanted to get all ETFs, we can do so with a query like: https://trade-service.wealthsimple.com/security-groups/security-group-c6153b067083/securities?limit=50&offset=50 and just change the offset to paginate over all results.

There's also more things, so let me know if you'd like me to forward it to you somehow (over slack maybe).

Would you want to add those to the library? Otherwise I could add them, but it might take a bit longer as I am not familiar with the codebase.

ahmedsakr commented 3 years ago

Great findings! I personally think all that you listed would be great extensions to wstrade-api in a future version.

For now, I think any work will need to be paused while i wrap up v1.0.0. Version 0 is not as friendly or modular to allow these extensions, and I wouldn’t want your efforts to go to waste. I plan on documentating v1.0.0 extensively with tests and contribution documents to on-board new contributors.

We can sync up on this soon! I plan on having v1.0.0 out the door by the end of the month. On Nov 21, 2020, 6:45 PM -0500, Gabriel Bottari notifications@github.com, wrote:

I have found a few interesting endpoints: The /securities endpoint allows much more specification: example: https://trade-service.wealthsimple.com/securities/top_market_movers?type=gainers&limit=50&offset=150 top_market_movers can be replaced with most_watched, crypto and gainers can be replaced with losers, most_watched and most_active (type is only available for top_market_movers) There's also the /security-groups/{securitygroupid}/securities which allows to fetch securities by categories. To get categories just call /security-groups. For example, we wanted to get all ETFs, we can do so with a query like: https://trade-service.wealthsimple.com/security-groups/security-group-c6153b067083/securities?limit=50&offset=50 and just change the offset to paginate over all results. There's also more things, so let me know if you'd like me to forward it to you somehow (over slack maybe). Would you want to add those to the library? Otherwise I could add them, but it might take a bit longer as I am not familiar with the codebase. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

GabrielBottari commented 3 years ago

Alright let me know :)

ahmedsakr commented 3 years ago

Hey @GabrielBottari ,

I took a bit longer but I pushed v1 in last night. I think work on this can start. I am thinking all of this will belong in the data module perfectly. We can have a discussion about this. Feel free to hit me up on Discord (AhmedSakr#5719)

GabrielBottari commented 3 years ago

Wealthsimple trade is now available on web for everyone, so might be interesting to see whats available from the networks tab

ahmedsakr commented 3 years ago

Wow, this is amazing. This will open up the doors for using a web-socket instead of REST/HTTPS calls.