The service features both a controller file which acts as the entrypoint whenever the Lambda function is invoked as well as a calculator file which receives JSON data from Questrades’ API and calculates balances & creates the summary text to be sent via Slack. The entire pipeline is written in Python (v3.6).
The following is a high level list of chronoical events that occur when the lambda function is invoked:
Refresh token and API url are fetched from DynamoDB
Access token is obtained from Questrade API
Requests sent to Balance/Position endpoints of Questrade API
Percentage Changes are calculated and summary message is constructed
Summary message is sent to Slack