Description
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
About the project...
This is a codebase to initialize the underlying infrastructure and stacks needed for real time quantitative trading as well as the basic application level logic. As a quant, your job is to focus on quantitative logic, the reality is that you have to worry about underlying infrastructure and a lot of different layers when deploying solutions. For example, where to run, how to achieve elasticity, etc. This repository and the event-driven infrastructure provided aim to provide a quick start and entry point into your own quantitative work and to help alleviate these challenges. The solution helps take care of SDLC, market data durability, market data connectivity, DevOps (elasticity), as well as the management of the underlying infrastructure. We use P&L calculations just as an example, but we'll leave the secret sauce up to you.
This real time market portfolio application on AWS is setup through the AWS CDK. The deployed CDK infrastructure comes with an example portfolio of the S&P 500 based on intraday momentum. The intraday momentum pattern says that the first half-hour return on the market since the previous day’s market close will predict the last half-hour return. This predictability will be stronger on more volatile days, on higher volume days, on recession days, and on major macroeconomic news release days.
How to get started. This project is deployed using the AWS CDK.
You will use AWS Cloud9 as the IDE to setup the code and deploy the CDK environment. You can also use a different IDE if you’d prefer.
- Navigate to the AWS Cloud9 console and press Create environment.
- Enter a name - MarketPortfolioEnv.
- Use a t2.micro instance type.
- Leave all other settings as default and choose Create.
- After a few minutes, the environment should be created. Under Cloud9 IDE, press Open.
- In the command line at the bottom, clone the Git repository using the following command:
git clone https://github.com/aws-samples/quant-trading.git
Now that the environment is setup, let’s deploy the application using the CDK. You’ll need to run a few commands to get everything set up for the CDK, this will allow for the entire application to be spun up through the CDK
- In the Cloud9 CLI, type in the following commands to navigate to the CDK portion of the code and install the necessary dependencies
cd AWSQuant/aws-quant-infra/deployment/cdk &&
npm install
- Use this command to bootstrap the environment:
cdk bootstrap
- This command is needed to download a required Lambda layer for AppConfig.
sudo yum install jq -y &&
aws lambda get-layer-version-by-arn —arn arn:aws:lambda:us-east-1:027255383542:layer:AWS-AppConfig-Extension:110 | jq -r '.Content.Location' | xargs curl -o ../../src/lambda/extension.zip
- Now, to deploy the application using the CDK code enter this command:
cdk deploy --all
Note: if you get an error saying the docker build failed and says “no space left on device” run this command:
chmod +x ./../../src/utils/resize_root.sh &&
./../../src/utils/resize_root.sh 50
Note: If you get an error from creating the DynamoDB replica instance in the DB stack, you’ll need to go to the DynamoDB console and delete the replica from the console, then redeploy the CDK stack.
You can have data come in from either IEX or B-PIPE (Bloomberg Market Data Feed). In this section, you’ll enter the API key in Secrets Manager and that will enable the Intraday Momentum application to start working and allow the data to flow in from the market data feed.
- Navigate to the AWS Secrets Manager console.
- You should see two secrets created:
api_token_pk_sandbox
andapi_token_pk
.
- Select
api_token_pk
. - Scroll down to the section that says Secret value and towards the right, select Retrieve secret value.
- Then, choose Edit and paste in your IEX or B-PIPE API key.
- Press Save.
You can view the results of the Intraday Momentum application after the day end by going to the DynamoDB table.
- Navigate to the AWS DynamoDB console.
- On the left, select Tables and then choose the table called
MvpPortfolioMonitoringPortfolioTable
. - Then, press the orange button in the top right that says Explore table items.
- You should then see data populated at the bottom under Items returned.
Note: If you don’t see any data, select the orange Run button to scan the table and retrieve the data.
- If you’d like to analyze this data further, you can download it in CSV format by selecting Actions, then Download results to CSV.
Add additional screenshots, code examples and demos...
For more examples, please refer to the Documentation
- Add Changelog
- Add back to top links
- Add Additional Templates w/ Examples
- Add "components" document to easily copy & paste sections of the readme
- Multi-language Support
- Chinese
- Spanish
See the open issues for a full list of proposed features (and known issues).
This section should list any major frameworks/libraries used to bootstrap your project. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Your Name - @your_twitter - email@example.com
Project Link: https://github.com/your_username/repo_name
Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!