title | description | tags | ||
---|---|---|---|---|
Flask |
A popular minimal server framework for Python |
|
- Python
- Flask
- Install Python requirements
pip install -r requirements.txt
- Start the server for development
python3 main.py
These Files are intended to be used during troubleshooting, and to help validate all systems are online and functional #Files Alpaca Api
Setup Script To use this script, add it to your Flask app, and run the create_schema() function when initializing your app. Make sure SQLAlchemy is installed in your environment, and the DATABASE_URL environment variable is set correctly in Railway. This will create the necessary tables in your MySQL database upon deployment. Database Schema
Stocks Table
stock_id (Primary Key)
ticker_symbol (Unique)
company_name
sector
industry
market_cap
IPO_date
other_relevant_fields (like country, exchange, etc.)
Fundamentals Table
fundamental_id (Primary Key)
stock_id (Foreign Key)
fiscal_date_ending
reported_currency
total_revenue
net_income
EPS (Earnings Per Share)
dividend_per_share
PE_ratio (Price-to-Earnings)
ROE (Return on Equity)
debt_to_equity
free_cash_flow
other_financial_metrics
Technical Data Table
data_id (Primary Key)
stock_id (Foreign Key)
timestamp
open_price
high_price
low_price
close_price
volume
adjusted_close (if needed)
granularity (to indicate if it's daily, hourly, minute-wise, etc.)
Analyst Assessments Table
assessment_id (Primary Key)
stock_id (Foreign Key)
analyst_id (if you have multiple users/analysts)
date_of_assessment
resistance_levels
support_levels
predicted_movement
assessment_notes
Backtesting Table
backtest_id (Primary Key)
assessment_id (Foreign Key)
start_date
end_date
performance_metric (like % return, hit/miss on predictions, etc.)
notes
User Table (if you have multiple users)
user_id (Primary Key)
username
email
role
password_hash
other_user_details
Notes:
Normalization: Ensure that the database is normalized to avoid redundancy. For instance, the Stocks Table separates static info about each stock from their dynamic financials.
Indexes: Create indexes on frequently queried columns (like ticker_symbol, timestamp, etc.) for faster retrieval.
Granularity: For the Technical Data Table, consider how granular you want the data. Minute-wise data can grow large, so think about data retention policies.
Security: Secure sensitive data, especially in the User Table.
Flexibility: The schema allows for expansion. You can add new tables or columns as your analysis methods evolve.