How jononon/algo-trading-schwab works
Main Components
a) AWS Cloud Environment (us-west-1):
• AWS services used
b) External Components:
• Schwab API (in Phoenix, AZ)
• Market Data Sources (for ETF price data)
Detailed Component Breakdown
a) AWS Components:
• Lambda Function (Central component)
• Main.py as the entry point
• To supporting modules (auth.py, schwab.py, dynamodb.py, ssm.py)
• CloudWatch
• Both logging and alarm flows
• DynamoDB
• Trade information storage
• Systems Manager (SSM)
• Parameter store for Schwab credentials
b) Trading Logic Flow:
• ETF evaluation process
[Recommended Layout]
┌─────────────────────────────── AWS Region (us-west-1) ──────────────────────────────┐
• ┌─────────────┐ ┌─────────────┐ │
• CloudWatch │◄───┤ Lambda │ │
• (Monitoring)│ │ Function │◄──────────────┐ │
• ┘ │ (main.py) │ │ │
• ┬───────┘ │ │
• ┌──────▼───────┐ ┌────────┴───────┐ │
• ┌─────────────┐ │ Trading │ │ SSM │ │
• DynamoDB │◄──┤ Logic │ │ (Credentials) │ │
• (Storage) │ │ (schwab.py) │ └────────────────┘ │
• ┘ └──────────────┘ │
• ┼──────────────────────────────────────────────────────┘
• ┌───────▼──────┐
• Schwab API │
• (Phoenix, AZ)│
• ┘
Key Flows to Highlight
• Trigger Flow: Show the daily market open trigger from CloudWatch Events
• Authentication Flow: Demonstrate the credential retrieval from SSM to Schwab API
• Trading Flow:
• Market data retrieval
• Strategy evaluation
• Trade execution
• Trade recording in DynamoDB
Additional Elements
• Timing indicators for the daily execution
• Error handling paths
• Monitoring and alerting flows
Important Notes
• Serverless nature of the architecture
• Clear separation between AWS and external services
• Security boundary between SSM and the Schwab API
• Latency considerations due to geographic location
Technical Details
• Python runtime version
• Serverless framework deployment flow
• DynamoDB table structure indicators
• CloudWatch alarm thresholds
• API rate limits and constraints