-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Price Alpha Update: Working step function
- Granular lambda functions with prices alpha daily and prices alpha monthly separated - Separation in batches with sublists designed to run in one hour slots to avoid API limit errors - Processing of monthly returns of WRDS and Alpha into one table at the end of statemachine
- Loading branch information
1 parent
0d50471
commit ce52231
Showing
5 changed files
with
224 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
import json | ||
import boto3 | ||
from botocore.exceptions import ClientError | ||
from ast import literal_eval | ||
|
||
from utils import sql_manager, aws, utils | ||
from alpha import api, table | ||
|
||
|
||
def lambda_handler(event, context): | ||
print("event", event) | ||
|
||
# Example | ||
# http://127.0.0.1:3000/update-prices?size=compact&symbols=AMZN,AAPL,MSFT | ||
# 'queryStringParameters': {'parallel': '1', 'size': 'compact', 'symbols': 'AMZN,AAPL,MSFT'} | ||
|
||
# Inputs | ||
if 'queryStringParameters' in event: | ||
inputs = event["queryStringParameters"] | ||
else: | ||
inputs = event | ||
|
||
# Gather parameters | ||
symbols = inputs["symbols"].split(",") if "symbols" in inputs else [] | ||
parallel = utils.str2bool(inputs["parallel"]) if "parallel" in inputs else False | ||
print(f"symbols = {symbols}") | ||
print(f"parallel = {parallel}") | ||
|
||
# Decrypts secret using the associated KMS key. | ||
db_credentials = literal_eval(aws.get_secret("prod/awsportfolio/key")) | ||
|
||
alpha_prices_monthly = table.AlphaTablePricesMonthly( | ||
"prices_alpha_monthly", | ||
sql_params=db_credentials | ||
) | ||
|
||
if symbols: | ||
alpha_prices_monthly.update_list(symbols, parallel=parallel) | ||
|
||
return { | ||
"statusCode": 200, | ||
"body": json.dumps({ | ||
"message": "Monthly prices updated for symbols provided", | ||
}), | ||
} |
Oops, something went wrong.