Wealthsimple-Trade-Python

A convenient Python wrapper for the Wealthsimple Trade API. Note that this wrapper is Unofficial and is not in any way affiliated with Wealthsimple. Please use at your own risk.

The Wealthsimple-Trade-Python Project:

Wealthsimple Trade Python

A convenient Python wrapper for the Wealthsimple Trade API. Note that this wrapper is Unofficial and is not in any way affiliated with Wealthsimple. Please use at your own risk.


docs Documentation Status
tests
Travis-CI Build Status Requirements Status
package
Commits since latest release

Installation

pip install wealthsimple-trade-python

You can also install the in-development version with:

pip install https://github.com/seansullivan44/Wealthsimple-Trade-Python/archive/master.zip

Note: node is a dependency of this project. See [here](https://github.com/VeNoMouS/cloudscraper#dependencies) for more information.

Getting Started

Download the Wealthsimple Trade app for iOS or Android and create an account. This API wrapper will use your Wealthsimple Trade login credentials to make successful API calls. After creating an account, use your login credentials to create a WSTrade object:

import wealthsimple
WS = wealthsimple.WSTrade('email', 'password')

If your Wealthsimple Trade account uses two-factor authentication then you must provide the WSTrade object with a callback function as shown in the following example:

import wealthsimple

def my_two_factor_function():
    MFACode = ""
    while not MFACode:
        # Obtain user input and ensure it is not empty
        MFACode = input("Enter 2FA code: ")
    return MFACode

ws = wealthsimple.WSTrade(
    "email",
    "password",
    two_factor_callback=my_two_factor_function,
)

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

Bug reports

When reporting a bug please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Documentation improvements

Wealthsimple-Trade-Python could always use more documentation, whether as part of the official Wealthsimple-Trade-Python docs, in docstrings, or even on the web in blog posts, articles, and such.

Feature requests and feedback

The best way to send feedback is to file an issue at https://github.com/seansullivan44/Wealthsimple-Trade-Python/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that code contributions are welcome :)

Development

To set up Wealthsimple-Trade-Python for local development:

  1. Fork Wealthsimple-Trade-Python (look for the “Fork” button).

  2. Clone your fork locally:

    git clone git@github.com:seansullivan44/Wealthsimple-Trade-Python.git
    
  3. Create a branch for local development:

    git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  4. Commit your changes and push your branch to GitHub:

    git add .
    git commit -m "Your detailed description of your changes."
    git push origin name-of-your-bugfix-or-feature
    
  5. Submit a pull request through the GitHub website.

Pull Request Guidelines

If you need some code review or feedback while you’re developing the code just make the pull request.

For merging, you should:

  1. Update documentation when there’s new API, functionality etc.
  2. Add a note to CHANGELOG.rst about the changes.
  3. Add yourself to AUTHORS.rst.
[1]

If you don’t have all the necessary python versions available locally you can rely on Travis - it will run the tests for each change you add in the pull request.

It will be slower though …

Authors

Sean Sullivan (Project Creator)

Joey Orlando

Changelog

1.1.0 (2021-03-14)

  • Swap out requests.Session with cloudscraper.CloudScraper instance to overcome recent security changes related to Cloudflare

1.0.0 (2020-06-24)

  • First release on PyPI.

Code Documentation

wealthsimple package

Submodules

wealthsimple.requestor module

class wealthsimple.requestor.APIRequestor(session, APIMainURL)

Bases: object

A class to simplify request calls to REST API

session : session
A requests Session object to be associated with the class
APIMainURL : str
Main URL endpoint for API
makeRequest(method, endpoint, params=None, returnValue=None)
Make a request to a given API endpoint
post(URL, params=None)
Make a POST request to a given API endpoint
get(URL, params=None)
Make a GET request to a given API endpoint
get(URL, params=None)

Make a GET request to a given API endpoint

URL : str
Full URL endpoint of API
params : dict
Dictionary of parameters to be passed with request
Response : Response
A requests response object
makeRequest(method, endpoint, params=None, returnValue=None)

Make a request to a given API endpoint

method : str
Specify POST or GET request
endpoint : str
URL endpoint oof API (Does not include base URL)
params : dict
Dictionary of parameters to be passed with request
Response : Response
A requests response object
post(URL, params=None)

Make a POST request to a given API endpoint

URL : str
Full URL endpoint of API
params : dict
Dictionary of parameters to be passed with request
Response : Response
A requests response object

wealthsimple.wealthsimple module

class wealthsimple.wealthsimple.WSTrade(email: str, password: str, two_factor_callback: callable = None)

Bases: object

Wealthsimple Trade API wrapper

session : session
A requests Session object to be associated with the class
APIMainURL : str
Main URL endpoint for API
TradeAPI : APIRequester
APIRequester object to handle API calls
login(email=None, password=None, two_factor_callback=None)
Login to Wealthsimple Trade account
get_accounts()
Get Wealthsimple Trade accounts
get_account_ids()
Get Wealthsimple Trade account ids
get_account(id)
Get a Wealthsimple Trade account given an id
get_account_history(id, time=”all”)
Get Wealthsimple Trade account history
get_activities()
Get Wealthsimple Trade activities
get_orders(symbol=None)
Get Wealthsimple Trade orders
get_security(symbol)
Get information about a security
get_positions(id)
Get positions
get_person()
Get Wealthsimple Trade person object
get_me()
Get Wealthsimple Trade user object
get_bank_accounts():
Get list of bank accounts tied to Wealthsimple Trade account
get_deposits()
Get list of deposits
get_forex()
Get foreign exchange rate
get_account(id: str) → dict

Get a Wealthsimple Trade account given an id

id : str
Wealthsimple Trade account id
dict
A dictionary containing the Wealthsimple Trade account
get_account_history(id: str, time: str = 'all') → dict

Get Wealthsimple Trade account history

id : str
Wealthsimple Trade account id
time : str
String containing time interval for history
dict
A dictionary containing the historical Trade account data
get_account_ids() → list

Get Wealthsimple Trade account ids

list
A list of Wealthsimple Trade account ids
get_accounts() → list

Get Wealthsimple Trade accounts

list
A list of Wealthsimple Trade account dictionary objects
get_activities() → list

Get Wealthsimple Trade activities

list
A list of dictionaries containing Wealthsimple Trade activities
get_bank_accounts() → list

Get list of bank accounts tied to Wealthsimple Trade account

list
A list of dictionaries containing bank account objects
get_deposits() → list

Get list of deposits

list
A list of dictionaries containing deposit objects
get_forex() → dict

Get foreign exchange rate

dict
A dictionary containing foreign exchange rates
get_me() → dict

Get Wealthsimple Trade user object

dict
A dictionary containing a user object
get_orders(symbol: str = None) → list

Get Wealthsimple Trade orders

symbol : str
Symbol for security to filter orders on
list
A list containing Wealthsimple Trade order dictionaries
get_person() → dict

Get Wealthsimple Trade person object

dict
A dictionary containing a person object
get_positions(id: str) → list

Get positions

id : str
Wealthsimple Trade account id
list
A list containing positions
get_securities_from_ticker(symbol: str) → list

Get information about a securitys with matching ticker symbols

symbol : str
Symbol for security to search on
list
A list containing matching securities
get_security(id: str) → dict

Get information about a security

id : str
Wealthsimple Security ID to search on
dict
Dictionary containing information for security
login(email: str = None, password: str = None, two_factor_callback: callable = None) → None

Login to Wealthsimple Trade account

email : str
Wealthsimple Trade account email
password : str
Wealthsimple Trade account password
two_factor_callback: function
Callback function that returns user input for 2FA code

None

Module contents