A modular Streamlit application for downloading and analyzing OHLCV (Open, High, Low, Close, Volume) data from HistData.com.
- Modular Architecture: Clean separation of concerns using
st.navigationfor main pages and imported functions for tab content - Data Download Manager: Download historical forex data from HistData.com with support for multiple symbols and timeframes
- Efficient Data Storage: Automatic conversion of monthly CSV files to compressed Parquet format
- Data Management: View, update, and manage downloaded datasets with a user-friendly interface
- Comprehensive Testing: 77 unit tests covering structure, functionality, and components
chart_pattern_prototype/
├── Main_App.py # Application entrypoint and router
├── pages/ # Main navigation pages
│ ├── analysis_parent.py # Analysis dashboard with tabs
│ └── data_manager_parent.py # Data management interface
├── components/ # Reusable UI components
│ ├── __init__.py
│ ├── tab_overview.py # Overview tab component
│ ├── tab_metrics.py # Metrics tab component
│ ├── tab_download.py # Data download tab
│ ├── tab_manage_data.py # Data management tab
│ └── histdata_downloader.py # HistData.com downloader utility
├── data/ # Data storage
│ ├── downloads/ # Temporary CSV files
│ └── parquet/ # Compressed Parquet files
├── tests/ # Unit tests
│ ├── test_structure.py # Project structure tests
│ ├── test_histdata_downloader.py # Downloader tests
│ └── test_components.py # Component tests
├── requirements.txt # Python dependencies
└── README.md # This file
-
Clone the repository:
cd chart_pattern_prototype -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
Start the Streamlit application:
streamlit run Main_App.pyThe application will open in your default web browser at http://localhost:8501.
- Navigate to the Data Manager page
- Select the Download Data tab
- Choose:
- Symbol: Forex pair (e.g., EURUSD, GBPUSD)
- Timeframe: Candlestick interval (M1, M5, M15, H1)
- Years to Download: Number of years of historical data
- Click Start Download
Data is automatically downloaded as monthly CSV files and converted to compressed Parquet format for efficient storage and analysis.
- Navigate to the Data Manager page
- Select the Manage Data tab
- View all downloaded datasets with:
- Symbol and timeframe
- Date range
- Number of rows
- File size
- Actions available:
- Update: Download latest data to extend existing datasets
- Delete: Remove datasets
- Preview: View first/last rows and statistics
Run all tests:
pytest tests/ -vRun specific test files:
pytest tests/test_structure.py -v
pytest tests/test_histdata_downloader.py -v
pytest tests/test_components.py -v- EURUSD, GBPUSD, USDJPY, USDCHF, USDCAD
- AUDUSD, NZDUSD, EURGBP, EURJPY, EURCHF
- GBPJPY, AUDJPY, AUDNZD, AUDCAD
- M1 (1 minute)
- M5 (5 minutes)
- M15 (15 minutes)
- H1 (1 hour)
The application uses Streamlit's st.navigation API for main page routing:
- Analysis Dashboard: Example dashboard with overview and metrics tabs
- Data Manager: Download and manage OHLCV data
Each page uses st.tabs() with content rendered by imported functions from the components/ directory:
# pages/data_manager_parent.py
from components.tab_download import render_download_tab
from components.tab_manage_data import render_manage_data_tab
tab1, tab2 = st.tabs(["Download Data", "Manage Data"])
with tab1:
render_download_tab()
with tab2:
render_manage_data_tab()This approach keeps the code modular, testable, and maintainable.
- Download: Monthly CSV files from HistData.com
- Extract: Unzip downloaded archives
- Parse: Convert tick data to OHLCV format if needed
- Combine: Merge monthly data into single DataFrame
- Compress: Save as Parquet with gzip compression
- Cleanup: Remove temporary CSV files
- Read: Load existing Parquet file
- Identify: Determine last available date
- Download: Fetch new monthly data from last date to current
- Merge: Combine new data with existing data
- Save: Overwrite Parquet file with updated data
The downloader provides the framework for automated downloads from HistData.com, but the actual website may:
- Require authentication or API tokens
- Have rate limiting
- Change URL structures
- Require captcha solving
You may need to adjust the download URLs or implement additional authentication based on HistData.com's current requirements.
-
Create a new file in
components/with a render function:# components/my_new_tab.py import streamlit as st def render_my_new_tab(): st.header("My New Tab") # Add your UI code here
-
Import and use in a parent page:
from components.my_new_tab import render_my_new_tab with tab: render_my_new_tab()
-
Create a new file in
pages/:# pages/my_new_page.py import streamlit as st st.title("My New Page")
-
Add to navigation in
Main_App.py:app_pages = [ st.Page("pages/my_new_page.py", title="My Page", icon=":material/star:"), ]
The project includes comprehensive tests:
- 26 structure tests: Verify project organization and imports
- 24 downloader tests: Test data downloading and processing
- 27 component tests: Verify UI component functionality
All tests use mocking to avoid external dependencies and network calls.
This project is provided as-is for educational and development purposes.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request