-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Vignesh edited this page Aug 19, 2020
·
1 revision
Welcome to the stock_hawk wiki!
- Running a script on AWS without a deployment tool like jenkins, requires all the libraries/packages to be locally maintained.
- Refer documentation to begin setup.
- Lambda handler or source file should always be in the root.
- Use the following file structure.
——— src or .zip
——— ——— handler.py
——— some-sub-directory
- create a fresh folder eg: lambda_function and drop your code there (DON'T use sub-folders).
- pip install any package in the format (pip3 install 'package' --target=~/lambda_function/)
- wrap everything together as a .zip file and upload it to AWS.
- root file should be directly accessible within the .zip, so don't include any unnecessary additional sub-folders.
- Name = user; Value = Robinhood login email address
- Name = pass; Value = Robinhood login password
- Name = qr; Value = Robinhood MFA QR code (Check for steps in original README.md)
- Name = ACCESS_KEY; Value = AWS login access key
- Name = SECRET_KEY; Value = AWS secret key
- Name = SENDER; Value = sender email address (verified via AWS SES)
- Name = RECIPIENT; Value = receiver email address (verified via AWS SES)
Optional (If you'd like to setup whats app notifications else skip these, app will still run): - Name = SID; Value = S-ID from twilio
- Name = TOKEN; Value = Token from twilio
- Name = SEND; Value = sender whats app number (fromat - +1xxxxxxxxxx)
- Name = RECEIVE; Value = receiver whats app number (fromat - +1xxxxxxxxxx)
- Create a lambda function with the handler as robinhood.send_whatsapp (this will invoke the send_whats app function inside the robinhood.py file)
- Create an IAM policy with read access to GetParameter and attached to the executing lambda function.
- Once that is done, make sure to check your lambda function's permission to SSM.
- Policy update time: ~5-10 minutes.
- Add trigger to your lambda function (Trigger name: CloudWatch Events/EventBridge)
- Refer aws docs for scheduling format.
- Use files in the repo Historical_Graphs_Included
- This uses the historical data for your stocks and plots the data as a graph.
- Use /tmp/ for it to work on AWS (default writable folder by AWS)
- matplotlib could be a tricky part to implement on lambda so I have added few steps below.
- Go to https://pypi.org/project/matplotlib/#files
- Choose your python version (37 for 3.7 and 38 for 3.8) and download the manylinux1_x86_64.whl file.
- unzip filename.whl && rm filename.whl
- zip all your folders together and upload it to an S3 bucket and run your lambda connecting to S3.