Skip to main content

A tool to track your TFSA Contribution Room from Questrade

Project description

Contribution-Room-Tracker

A tool to track your TFSA Contribution Room from Questrade,

Installation

  • Use pip:

    pip install CR-tracker

Getting Started

Get the refresh token from Questrade

  1. Familiarise yourself with the Security documentation for the Questrade API.
  2. Generate a manual refresh token
    1. Login to questrade.com
    2. Account Drop Down > Click 'App hub' > Click 'Register a Personal App'
    3. Ensure 'OAuth scopes' retrieve balances, positions, orders and executions is checked
    4. Under Personal apps, Click '+ New Device' > Click 'Generate New token'
    5. Copy this token!

Connect to Questrade

   import CR_Tracker as CR
   
   CR.connect_questrade(token=ikWQKJHLKJdfdjza5a_0EyivzTJk8hfg9b0)

Important: A token will be created at ~/.questrade.json and used for future API calls

  • If the token is valid future initiations will not require a refresh token

If there is already a valid token, you can simply connect to questrade without declaring a token

import CR_Tracker as CR
CR.connect_questrade()

Calulating your Contribution Room

Contribution Room

Accepts: given_year=None, given_contr_room=None, open_year=2009, birth_year=1990, token=None

The method that contribution_room is calculated is determined by which parameters are inputted by the user
FOR BEST RESULTS: Use the Contribution Room from your CRA My Account on January 1 of the given year

given_year is the year from CRA when you login to CRA My Account
given_contr_room is the contribution room from CRA when you login to CRA My Account
open_year is the year that the Account was opened. Default value is 2009- when the TFSA was first introduced birth_year is the year that the user was born. Default value is 1990- those born before 1990 were 18 years old in 2009

Below is the hierarchy of the contribution room. This function will choose the first method above, that is available

  1. If given_year and given_contr_room are both provided, only account activity in the given_year and onwards will be used
  2. If either given_year or given_contr_room are not provided then the search period will be from open_year
  3. If open_year is not provided then the search period will start when the user turned 18 (after 2009)
    based on the birth_year
x=CR.contribution_room(given_contr_room=35500,given_year=2022,token=ikWQKJHLKJdfdjza5a_0EyivzTJk8hfg9b0)
x

=> start_year is 2022
Questrade time is: {'time': '2024-01-03T17:46:46.904000-05:00'}
Successfully Connected to Questrade
TFSA  account list: ['5173xxxx', '5196xxxx', '5205xxxx']
DatetimeIndex(['2022-01-31', '2022-02-28', '2022-03-31', '2022-04-30',
               '2022-05-31', '2022-06-30', '2022-07-31', '2022-08-31',
               '2022-09-30', '2022-10-31', '2022-11-30', '2022-12-31',
               '2023-01-31', '2023-02-28', '2023-03-31', '2023-04-30',
               '2023-05-31', '2023-06-30', '2023-07-31', '2023-08-31',
               '2023-09-30', '2023-10-31', '2023-11-30', '2023-12-31',
               '2024-01-31'],
              dtype='datetime64[ns]', freq='M')
grabbing activity from 2022-01-31 00:00:00 to 2024-01-31 00:00:00 for TFSA: 5173xxxx. Completed 0 % 
Processing 2022 for account 5173xxxx
Processing 2023 for account 5173xxxx
Processing 2024 for account 5173xxxx
grabbing activity from 2022-01-31 00:00:00 to 2024-01-31 00:00:00 for TFSA: 5196xxxx. Completed 33 % 
Processing 2022 for account 5196xxxx
Processing 2023 for account 5196xxxx
Processing 2024 for account 5196xxxx
grabbing activity from 2022-01-31 00:00:00 to 2024-01-31 00:00:00 for TFSA: 5205xxxx. Completed 66 % 
Processing 2022 for account 5205xxxx
Processing 2023 for account 5205xxxx
Processing 2024 for account 5205xxxx
Grabbing Activity Completed-100%
Today's date: 2024-01-03
Your current contribution room is: $ 9xxxxxxx.5xxxxxxx
Next Year's Contribution room on Jan 1 2025 is:  $9xxxxxxxx.5xxxxxxxxx

contribution_room returns a list of 3 items

[current contribution room, Next Year's Contribution, panda's dataframe with the summarized results ]

x[0]
=> 9xxxxxxx.5xxxxxxx
x[1]
=> 9xxxxxxx.5xxxxxxx
x[2]
=> 
| New_Year_Dollar_Limit | Contr_Room_Jan1 | Year | Deposits | Withdrawals | Current_Contr_Room |

create_df

Creates a dataframe containing the activity from questrade

 create_df(start='2023-09-01', end='2024-01-01', account_type='TFSA',token=None):

Accepts: start='2009-01-01', end=str(date.today() + timedelta(days=30)), account_type='TFSA',token=None

start is the beginning of the activity search period
end is the end of the activity search period
account_type can be {'TFSA','RRSP','FHSA'}

max_contr_room_Limit

Calculates the Maximum contribution room based on your birthday in a given year

max_contr_room_Limit(birthyear=2000,end_yr=2024):

Accepts: birthyear=1900, end_yr=date.today().year

birth_year is the year that the user was born. Default value is 1990- those born before 1990 were 18 years old in 2009 end_yr is the given year or the year you want to calculate the max contribution room for

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

CR_Tracker-0.19.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file CR_Tracker-0.19.0-py3-none-any.whl.

File metadata

  • Download URL: CR_Tracker-0.19.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for CR_Tracker-0.19.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09cadf9ddb3b754f2035738ae7ef97f60a11f4fb266dee9def79bf3e557e854a
MD5 d42453aba190a9d4a9564ab23a462b1a
BLAKE2b-256 2a13481cb4833bf304483b88ffb2ca3a58458f452df630d2750df2f4931e7e2d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page