CR-Tracker


NameCR-Tracker JSON
Version 0.20.0 PyPI version JSON
download
home_pagehttps://github.com/rodnyf/CR-Tracker
SummaryA tool to track your TFSA Contribution Room from Questrade and Wealthsimple
upload_time2024-08-30 19:16:34
maintainerNone
docs_urlNone
authorRF
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Contribution-Room-Tracker

A tool to track your TFSA Contribution Room from Questrade & Wealthsimple.

## Change log
Version '0.2.0' introduced the functionality to pull data from Wealthsimple via Wsimple api and calculate\
contribution room for Wealthsimple only and combined with Questrade.

## Installation
* Use `pip`:

   `pip install CR-Tracker`

## Getting Started

### Connect To Wealthsimple and get Deposits & Withdrawals
This will ask for OTP if enabled
```
import CR_Tracker as CR
df_ws=Wsimple_data(email, password)
```

### Calculate Contribution Room from Wealthsimple only

[contribution_room_ws]()

Accepts: ```df_ws,given_year=None, given_contr_room=None, open_year=2009, birth_year=1990```

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](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html) on January 1 of the given year**


`given_year` is the year from CRA when you login to [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html)\
`given_contr_room` is the contribution room from CRA when you login to [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html)\
```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_ws(df_ws,given_year=2024, given_contr_room=20000)
x[2]
```
### Get the refresh token from Questrade

1. Familiarise yourself with the [Security documentation](https://www.questrade.com/api/documentation/security) for the Questrade API.
2. [Generate](https://apphub.questrade.com/UI/UserApps.aspx) a manual refresh token 
   1. Login to [questrade.com](https://www.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!\
      ![](https://github.com/rodnyf/CR-Tracker/blob/8163a8611680bb1d0935c4d2a622d953328942a5/CR-Tracker/Capture1%20Apphub.PNG)
   
### 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 for both Questrade and Wealthsimple Combined
#### [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](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html) on January 1 of the given year**


`given_year` is the year from CRA when you login to [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html)\
`given_contr_room` is the contribution room from CRA when you login to [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html)\
```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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rodnyf/CR-Tracker",
    "name": "CR-Tracker",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "RF",
    "author_email": "me@gmail.com",
    "download_url": null,
    "platform": null,
    "description": "# Contribution-Room-Tracker\r\n\r\nA tool to track your TFSA Contribution Room from Questrade & Wealthsimple.\r\n\r\n## Change log\r\nVersion '0.2.0' introduced the functionality to pull data from Wealthsimple via Wsimple api and calculate\\\r\ncontribution room for Wealthsimple only and combined with Questrade.\r\n\r\n## Installation\r\n* Use `pip`:\r\n\r\n   `pip install CR-Tracker`\r\n\r\n## Getting Started\r\n\r\n### Connect To Wealthsimple and get Deposits & Withdrawals\r\nThis will ask for OTP if enabled\r\n```\r\nimport CR_Tracker as CR\r\ndf_ws=Wsimple_data(email, password)\r\n```\r\n\r\n### Calculate Contribution Room from Wealthsimple only\r\n\r\n[contribution_room_ws]()\r\n\r\nAccepts: ```df_ws,given_year=None, given_contr_room=None, open_year=2009, birth_year=1990```\r\n\r\nThe method that contribution_room is calculated is determined by which parameters are inputted by the user\\\r\n**FOR BEST RESULTS: Use the Contribution Room from your [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html) on January 1 of the given year**\r\n\r\n\r\n`given_year` is the year from CRA when you login to [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html)\\\r\n`given_contr_room` is the contribution room from CRA when you login to [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html)\\\r\n```open_year``` is the year that the Account was opened. Default value is 2009- when the TFSA was first introduced\r\n```birth_year```  is the year that the user was born. Default value is 1990- those born before 1990 were 18 years old in 2009\r\n\r\nBelow is the hierarchy of the contribution room. This function will choose the **first** method above, that is available \r\n\r\n1. If ```given_year``` and ```given_contr_room``` are both provided,\r\nonly account activity in the given_year and onwards will be used  \r\n2. If either ```given_year``` or ```given_contr_room``` are not provided then the search period will be from ```open_year```\r\n3. If ```open_year``` is not provided then the search period will start when the user turned 18 (after 2009) \\\r\nbased on the ```birth_year``` \r\n```\r\nx=CR.contribution_room_ws(df_ws,given_year=2024, given_contr_room=20000)\r\nx[2]\r\n```\r\n### Get the refresh token from Questrade\r\n\r\n1. Familiarise yourself with the [Security documentation](https://www.questrade.com/api/documentation/security) for the Questrade API.\r\n2. [Generate](https://apphub.questrade.com/UI/UserApps.aspx) a manual refresh token \r\n   1. Login to [questrade.com](https://www.questrade.com/)\r\n   2. Account Drop Down > Click 'App hub' > Click 'Register a Personal App' \r\n   3. Ensure 'OAuth scopes' retrieve balances, positions, orders and executions is checked \r\n   4. Under Personal apps, Click '+ New Device' > Click 'Generate New token' \r\n   5. Copy this token!\\\r\n      ![](https://github.com/rodnyf/CR-Tracker/blob/8163a8611680bb1d0935c4d2a622d953328942a5/CR-Tracker/Capture1%20Apphub.PNG)\r\n   \r\n### Connect to Questrade\r\n```\r\n   import CR_Tracker as CR\r\n   \r\n   CR.connect_questrade(token=ikWQKJHLKJdfdjza5a_0EyivzTJk8hfg9b0)\r\n   ```\r\n   **Important:**\r\n   A token will be created at `~/.questrade.json` and used for future API calls\r\n   * If the token is valid future initiations will not require a refresh token\r\n\r\n\r\nIf there is already a valid token, you can simply connect to questrade without declaring a token\r\n   ```\r\n   import CR_Tracker as CR\r\n   CR.connect_questrade()\r\n   ```\r\n\r\n## Calulating your Contribution Room for both Questrade and Wealthsimple Combined\r\n#### [Contribution Room]()\r\nAccepts: ```given_year=None, given_contr_room=None, open_year=2009, birth_year=1990, token=None```\r\n\r\nThe method that contribution_room is calculated is determined by which parameters are inputted by the user\\\r\n**FOR BEST RESULTS: Use the Contribution Room from your [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html) on January 1 of the given year**\r\n\r\n\r\n`given_year` is the year from CRA when you login to [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html)\\\r\n`given_contr_room` is the contribution room from CRA when you login to [CRA My Account](https://www.canada.ca/en/revenue-agency/services/e-services/digital-services-individuals/account-individuals.html)\\\r\n```open_year``` is the year that the Account was opened. Default value is 2009- when the TFSA was first introduced\r\n```birth_year```  is the year that the user was born. Default value is 1990- those born before 1990 were 18 years old in 2009\r\n\r\nBelow is the hierarchy of the contribution room. This function will choose the **first** method above, that is available \r\n\r\n1. If ```given_year``` and ```given_contr_room``` are both provided,\r\nonly account activity in the given_year and onwards will be used  \r\n2. If either ```given_year``` or ```given_contr_room``` are not provided then the search period will be from ```open_year```\r\n3. If ```open_year``` is not provided then the search period will start when the user turned 18 (after 2009) \\\r\nbased on the ```birth_year``` \r\n\r\n\r\n\r\n```\r\nx=CR.contribution_room(given_contr_room=35500,given_year=2022,token=ikWQKJHLKJdfdjza5a_0EyivzTJk8hfg9b0)\r\nx\r\n\r\n=> start_year is 2022\r\nQuestrade time is: {'time': '2024-01-03T17:46:46.904000-05:00'}\r\nSuccessfully Connected to Questrade\r\nTFSA  account list: ['5173xxxx', '5196xxxx', '5205xxxx']\r\nDatetimeIndex(['2022-01-31', '2022-02-28', '2022-03-31', '2022-04-30',\r\n               '2022-05-31', '2022-06-30', '2022-07-31', '2022-08-31',\r\n               '2022-09-30', '2022-10-31', '2022-11-30', '2022-12-31',\r\n               '2023-01-31', '2023-02-28', '2023-03-31', '2023-04-30',\r\n               '2023-05-31', '2023-06-30', '2023-07-31', '2023-08-31',\r\n               '2023-09-30', '2023-10-31', '2023-11-30', '2023-12-31',\r\n               '2024-01-31'],\r\n              dtype='datetime64[ns]', freq='M')\r\ngrabbing activity from 2022-01-31 00:00:00 to 2024-01-31 00:00:00 for TFSA: 5173xxxx. Completed 0 % \r\nProcessing 2022 for account 5173xxxx\r\nProcessing 2023 for account 5173xxxx\r\nProcessing 2024 for account 5173xxxx\r\ngrabbing activity from 2022-01-31 00:00:00 to 2024-01-31 00:00:00 for TFSA: 5196xxxx. Completed 33 % \r\nProcessing 2022 for account 5196xxxx\r\nProcessing 2023 for account 5196xxxx\r\nProcessing 2024 for account 5196xxxx\r\ngrabbing activity from 2022-01-31 00:00:00 to 2024-01-31 00:00:00 for TFSA: 5205xxxx. Completed 66 % \r\nProcessing 2022 for account 5205xxxx\r\nProcessing 2023 for account 5205xxxx\r\nProcessing 2024 for account 5205xxxx\r\nGrabbing Activity Completed-100%\r\nToday's date: 2024-01-03\r\nYour current contribution room is: $ 9xxxxxxx.5xxxxxxx\r\nNext Year's Contribution room on Jan 1 2025 is:  $9xxxxxxxx.5xxxxxxxxx\r\n```\r\n#### contribution_room returns a list of 3 items\r\n\r\n[current contribution room, Next Year's Contribution, panda's dataframe with the summarized results ]\r\n```\r\nx[0]\r\n=> 9xxxxxxx.5xxxxxxx\r\nx[1]\r\n=> 9xxxxxxx.5xxxxxxx\r\nx[2]\r\n=> \r\n| New_Year_Dollar_Limit | Contr_Room_Jan1 | Year | Deposits | Withdrawals | Current_Contr_Room |\r\n```\r\n\r\n\r\n#### [create_df]()\r\nCreates a dataframe containing the activity from questrade \r\n```\r\n create_df(start='2023-09-01', end='2024-01-01', account_type='TFSA',token=None):\r\n```\r\nAccepts: ``` start='2009-01-01', end=str(date.today() + timedelta(days=30)), account_type='TFSA',token=None```\r\n\r\n\r\n`start` is the beginning of the activity search period\\\r\n`end `  is the end of the activity search period\\\r\n```account_type```  can be ['TFSA','RRSP','FHSA']\r\n\r\n#### [max_contr_room_Limit]()\r\n\r\nCalculates the Maximum contribution room based on your birthday in a given year\r\n```\r\nmax_contr_room_Limit(birthyear=2000,end_yr=2024):\r\n```\r\nAccepts: ``` birthyear=1900, end_yr=date.today().year```\r\n\r\n```birth_year```  is the year that the user was born. Default value is 1990- those born before 1990 were 18 years old in 2009\\\r\n`end_yr` is the given year or the year you want to calculate the max contribution room for\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A tool to track your TFSA Contribution Room from Questrade and Wealthsimple",
    "version": "0.20.0",
    "project_urls": {
        "Homepage": "https://github.com/rodnyf/CR-Tracker",
        "Source Code": "https://github.com/rodnyf/CR-Tracker"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4824be723b42b789a471cc49787e27e2b88025cb0b866c29da54988b7358404f",
                "md5": "d1d1a253ba97172f90c32ca15514f268",
                "sha256": "6d8cb809e0919dfa8a44a59cafbd1aceb27dc80636df5fd5eca1044fe3d085ed"
            },
            "downloads": -1,
            "filename": "CR_Tracker-0.20.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d1d1a253ba97172f90c32ca15514f268",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 30762,
            "upload_time": "2024-08-30T19:16:34",
            "upload_time_iso_8601": "2024-08-30T19:16:34.527069Z",
            "url": "https://files.pythonhosted.org/packages/48/24/be723b42b789a471cc49787e27e2b88025cb0b866c29da54988b7358404f/CR_Tracker-0.20.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-30 19:16:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rodnyf",
    "github_project": "CR-Tracker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cr-tracker"
}
        
RF
Elapsed time: 0.61477s