-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture & Data Flow
Leonardo Bitto edited this page Jan 3, 2026
·
2 revisions
Petunia follows a Microservice-like architecture, containerized with Docker.
| Service | Container Name | Description |
|---|---|---|
| App | petunia_app |
Python 3.12 environment containing Core Logic, Managers, and Scripts. |
| Database | petunia_db |
PostgreSQL 16 instance storing OHLCV data, Portfolio state, and Trade history. |
| Dashboard | petunia_dashboard |
Streamlit UI for data visualization and system control. |
- Runs
services/daily_run.py. - Updates OHLC data and Portfolio Valuation (Mark-to-Market).
- Shadow Sync: Executes pending orders from Google Sheets if limits are hit.
- Runs
services/weekly_run.py. - Strategy Engine: Selects active strategy via Config (Default: RSI).
- Risk Manager: Calculates Position Size (2% Rule) & Stop Loss.
- Report: Pushes new orders to Google Sheets for review.
-
Source: Yahoo Finance (via
yfinance). -
Trigger:
daily_run.py. -
Process: Fetch OHLCV -> Clean/Normalize -> Upsert to PostgreSQL (
ohlctable).
-
Trigger:
weekly_run.pyorbacktest.py. - Input: Historical Data from DB.
- Process: The active Strategy (EMA or RSI) computes indicators and outputs a DataFrame of Signals (BUY/SELL/HOLD).
- Validation: Signals are validated against a strict Schema Contract.
- Input: Raw Signals + Portfolio State (Cash/Positions).
- Process: The Risk Manager filters signals and calculates Position Size.
-
Output: "Shadow Orders" are sent to the Google Sheet (
Orderstab).
-
Trigger:
daily_run.py. - Process: Checks pending orders in Google Sheet. If current market price hits the Limit Price, the trade is executed in the local DB and cleared from the Cloud.
Petunia Trading System — v1.2.0
Released under MIT License — © 2026 Leonardo Bitto
Disclaimer: This software is for educational purposes only. Do not risk money you cannot afford to lose.
Released under MIT License — © 2026 Leonardo Bitto
Disclaimer: This software is for educational purposes only. Do not risk money you cannot afford to lose.