forked from aws-samples/algorithmic-trading
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Oliver Steffmann
committed
Dec 18, 2020
1 parent
915ecc7
commit 78ea821
Showing
8 changed files
with
149 additions
and
5 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
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,59 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Please run through the strategy notebook first. This will create the container image." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"strategy_image=\"algo_daily_breakout\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"!./deploy.sh $strategy_image" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"!./ecs-cli compose up" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "conda_python3", | ||
"language": "python", | ||
"name": "conda_python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
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,51 @@ | ||
#!/bin/bash | ||
image=$1 | ||
service=$1 | ||
|
||
# Get the account number associated with the current IAM credentials | ||
account=$(aws sts get-caller-identity --query Account --output text) | ||
|
||
if [ $? -ne 0 ] | ||
then | ||
exit 255 | ||
fi | ||
|
||
# Get the region defined in the current configuration | ||
region=$(aws configure get region) | ||
region=${region:-us-east-1} | ||
|
||
echo "create docker-compose.yml" | ||
|
||
cp docker-compose.yml.template docker-compose.yml | ||
sed -i "s/\$ENV/${env}/g" docker-compose.yml | ||
sed -i "s/\$REGION/${region}/g" docker-compose.yml | ||
sed -i "s/\$IMAGE/${account}.dkr.ecr.${region}.amazonaws.com\/${image}/g" docker-compose.yml | ||
sed -i "s/\$SERVICE/${service}/g" docker-compose.yml | ||
|
||
AWS_EXPORTS=`aws cloudformation list-exports` | ||
|
||
VPC=`echo $AWS_EXPORTS | jq -r '.Exports[] | select (.Name=="AlgorithmicTrading-VPC") | .Value'` | ||
SUBNET1=`echo $AWS_EXPORTS | jq -r '.Exports[] | select (.Name=="AlgorithmicTrading-PrivateSubnet1") | .Value'` | ||
SUBNET2=`echo $AWS_EXPORTS | jq -r '.Exports[] | select (.Name=="AlgorithmicTrading-PrivateSubnet2") | .Value'` | ||
SG=`echo $AWS_EXPORTS | jq -r '.Exports[] | select (.Name=="AlgorithmicTrading-ECSHostSecurityGroup") | .Value'` | ||
TASK_ROLE=`echo $AWS_EXPORTS | jq -r '.Exports[] | select (.Name=="AlgorithmicTrading-ECSTaskExecutionRole") | .Value'` | ||
ROLE_ARN=`echo $AWS_EXPORTS | jq -r '.Exports[] | select (.Name=="AlgorithmicTrading-AlgoExecutionRole-ARN") | .Value'` | ||
CLUSTER=`echo $AWS_EXPORTS | jq -r '.Exports[] | select (.Name=="AlgorithmicTrading-ECSCluster") | .Value'` | ||
|
||
echo "create ecs-params.yml" | ||
|
||
cp ecs-params.yml.template ecs-params.yml | ||
sed -i "s/\$VPC/${VPC}/g" ecs-params.yml | ||
sed -i "s/\$SUBNET1/${SUBNET1}/g" ecs-params.yml | ||
sed -i "s/\$SUBNET2/${SUBNET2}/g" ecs-params.yml | ||
sed -i "s/\$SG/${SG}/g" ecs-params.yml | ||
sed -i "s/\$TASK_ROLE/${TASK_ROLE}/g" ecs-params.yml | ||
sed -i "s@\$ROLE_ARN@${ROLE_ARN}@g" ecs-params.yml | ||
|
||
if [ ! -f "ecs-cli" ] ; then | ||
curl -Lo ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest | ||
chmod 777 ecs-cli | ||
echo "ecs-cli installed" | ||
fi | ||
|
||
./ecs-cli configure --region ${region} --cluster ${CLUSTER} --default-launch-type FARGATE |
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,13 @@ | ||
version: "3" | ||
services: | ||
$SERVICE: | ||
image: $IMAGE | ||
environment: | ||
- AWS_DEFAULT_REGION=$REGION | ||
- ALGO_CMD=train | ||
logging: | ||
driver: awslogs | ||
options: | ||
awslogs-group: algo | ||
awslogs-region: $REGION | ||
awslogs-stream-prefix: $SERVICE |
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,21 @@ | ||
version: 1 | ||
task_definition: | ||
task_execution_role: $TASK_ROLE | ||
task_role_arn: $ROLE_ARN | ||
ecs_network_mode: awsvpc | ||
task_size: | ||
mem_limit: 512 | ||
cpu_limit: 256 | ||
run_params: | ||
network_configuration: | ||
awsvpc_configuration: | ||
subnets: | ||
- $SUBNET1 | ||
- $SUBNET2 | ||
security_groups: | ||
- $SG | ||
assign_public_ip: DISABLED | ||
service_discovery: | ||
private_dns_namespace: | ||
vpc: $VPC | ||
name: algo |