service: freq frameworkVersion: ">=1.1.0 <2.0.0" plugins: - serverless-domain-manager - serverless-python-requirements ############################################################################################ # configure out provider and the security guide lines ############################################################################################ provider: name: aws runtime: python3.6 region: us-east-2 #required permissions iamRoleStatements: - Effect: Allow Action: - dynamodb:* Resource: "*" - Effect: Allow Action: - SNS:* Resource: { "Fn::Join" : [":", ["arn:aws:sns:${self:custom.region}", "*:*" ] ] } memorySize: 128 timeout: 90 versionFunctions: false logRetentionInDays: 3 #where to store out data, needs to be manually created! deploymentBucket: name: lambdas-freq # limit the invocations a bit to avoid overloading the server usagePlan: throttle: burstLimit: 100 rateLimit: 50 ############################################################################################ #custom configuration settings ############################################################################################ custom: stage: ${opt:stage, self:provider.stage} region: ${opt:region, self:provider.region} snsTopic: "FreqQueue-${self:custom.stage}" snsTradeTopic: "FreqTradeQueue-${self:custom.stage}" tradeTable: "FreqTradesTable-${self:custom.stage}" strategyTable: "FreqStrategyTable-${self:custom.stage}" ### # custom domain management ### customDomain: basePath: "${self:custom.stage}" domainName: "freq.isaac.international" stage: "${self:custom.stage}" createRoute53Record: true pythonRequirements: slim: true invalidateCaches: true dockerizePip: false fileName: requirements-aws.txt noDeploy: - pytest - moto - plotly - boto3 - pytest-mock - pytest-cov - pymongo package: exclude: - test/** - node_modules/** - doc/** - scripts/** - bin - freqtrade/tests/** ############################################################################################ # this section defines all lambda function and triggers ############################################################################################ functions: #returns all known strategy names from the server #and if they are private or not strategies: memorySize: 128 handler: freqtrade/aws/strategy.names events: - http: path: strategies method: get cors: true environment: strategyTable: ${self:custom.strategyTable} #returns the source code of this given strategy #unless it's private code: memorySize: 128 handler: freqtrade/aws/strategy.code events: - http: path: strategies/{user}/{name}/code method: get cors: true integration: lambda request: parameter: paths: user: true name: true response: headers: Content-Type: "'text/plain'" template: $input.path('$') environment: strategyTable: ${self:custom.strategyTable} # loads the details of the specific strategy get: memorySize: 128 handler: freqtrade/aws/strategy.get events: - http: path: strategies/{user}/{name} method: get cors: true request: parameter: paths: user: true name: true environment: strategyTable: ${self:custom.strategyTable} # loads all trades for a strategy and it's associated pairs trades: memorySize: 128 handler: freqtrade/aws/trade.get_trades events: - http: path: strategies/{user}/{name}/{stake}/{asset} method: get cors: true request: parameter: paths: user: true name: true stake: true asset: true environment: strategyTable: ${self:custom.strategyTable} tradeTable: ${self:custom.tradeTable} #submits a new strategy to the system submit: memorySize: 128 handler: freqtrade/aws/strategy.submit events: - http: path: strategies/submit method: post cors: true environment: topic: ${self:custom.snsTopic} strategyTable: ${self:custom.strategyTable} BASE_URL: ${self:custom.customDomain.domainName}/${self:custom.customDomain.stage} # submits a new trade to the system trade: memorySize: 128 handler: freqtrade/aws/trade.submit events: - http: path: trade method: post cors: true environment: tradeTopic: ${self:custom.snsTradeTopic} # stores the received message in the trade table trade-store: memorySize: 128 handler: freqtrade/aws/trade.store events: - sns: ${self:custom.snsTradeTopic} environment: tradeTable: ${self:custom.tradeTable} # stores the received message in the trade table trade-aggregate: memorySize: 128 handler: freqtrade/aws/trade.get_aggregated_trades events: - http: path: trades/aggregate/{ticker}/{days} method: get cors: true request: parameter: paths: ticker: true days: true environment: tradeTable: ${self:custom.tradeTable} #submits a new strategy to the system submit_github: memorySize: 128 handler: freqtrade/aws/strategy.submit_github events: - http: path: strategies/submit/github method: post cors: true environment: topic: ${self:custom.snsTopic} strategyTable: ${self:custom.strategyTable} #backtests the strategy #should be switched to utilze aws fargate instead #and running a container #so that we can evaluate long running tasks backtest: memorySize: 128 handler: freqtrade/aws/backtesting_lambda.backtest events: - sns: ${self:custom.snsTopic} environment: topic: ${self:custom.snsTopic} tradeTable: ${self:custom.tradeTable} strategyTable: ${self:custom.strategyTable} BASE_URL: https://${self:custom.customDomain.domainName}/${self:custom.customDomain.stage} reservedConcurrency: 1 # schedules all registered strategies on a daily base schedule: memorySize: 128 handler: freqtrade/aws/backtesting_lambda.cron events: - schedule: rate: rate(1440 minutes) enabled: true - schedule: rate: rate(60 minutes) enabled: true environment: topic: ${self:custom.snsTopic} tradeTable: ${self:custom.tradeTable} strategyTable: ${self:custom.strategyTable} reservedConcurrency: 1