A Python application for fetching historical cryptocurrency data from Delta Exchange India API with configurable timeframes.
- Configurable Timeframes: Fetch data with multiple resolutions (1m, 5m, 1h, 1d, etc.)
- Multiple Symbols: Support for Bitcoin, Ethereum, Solana, and other perpetual futures
- Smart Rate Limiting: Handles API rate limits and pagination automatically
- Data Export: Saves data to CSV files with proper formatting
- Technical Indicators: Calculate RSI, SMA-50, EMA Crossover, ATR, MACD, and more
- Comprehensive Logging: Detailed logs for monitoring and debugging
- Error Handling: Robust error handling and retry mechanisms
| Resolution | Description |
|---|---|
| 1m | 1 minute candles |
| 3m | 3 minute candles |
| 5m | 5 minute candles |
| 15m | 15 minute candles |
| 30m | 30 minute candles |
| 1h | 1 hour candles |
| 2h | 2 hour candles |
| 4h | 4 hour candles |
| 6h | 6 hour candles |
| 1d | Daily candles |
| 1w | Weekly candles |
- Python 3.8 or higher
- Internet connection for API access
-
Clone the repository:
git clone https://github.com/yourusername/Deltain-trader.git cd Deltain-trader -
Create and activate virtual environment:
# Create virtual environment python -m venv venv # Activate (Windows) venv\Scripts\activate # Activate (Linux/Mac) source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
The project uses a central configuration file (config.py) with the following settings:
- Base URL:
https://api.india.delta.exchange - API Version: v2
- Rate Limiting: 5 requests per second
- Default Symbols: BTCUSD, ETHUSD, SOLUSD
- Time Zone: Asia/Kolkata (IST)
- Default Lookback: 10 days
- Default Resolution: 1 minute candles
- Data Directory:
data/ - Log Directory:
logs/ - CSV Format:
{symbol}_{resolution}_{start_date}_{end_date}.csv
Run the main script for interactive resolution selection:
python main.pyThe script will:
- Display available timeframe options
- Prompt you to select a resolution
- Fetch data for all configured symbols
- Save results to CSV files
from data_fetcher import DeltaExchangeDataFetcher
# Fetch 1-minute data
minute_fetcher = DeltaExchangeDataFetcher(resolution="1m")
minute_data = minute_fetcher.fetch_symbol_data("BTCUSD")
# Fetch hourly data
hourly_fetcher = DeltaExchangeDataFetcher(resolution="1h")
hourly_data = hourly_fetcher.fetch_symbol_data("BTCUSD")
# Fetch multiple symbols
symbols = ["BTCUSD", "ETHUSD", "SOLUSD"]
results = hourly_fetcher.fetch_multiple_symbols(symbols)Run the example script to see different usage patterns:
python examples/timeframe_examples.pyDeltain-trader/
βββ config.py # Configuration settings
βββ data_fetcher.py # Core data fetching functionality
βββ technical_indicators.py # Technical analysis indicators calculator
βββ main.py # Interactive script entry point
βββ requirements.txt # Python dependencies
βββ README.md # This documentation
βββ data/ # Directory for saved CSV files
β βββ RSI/ # RSI indicator data
β βββ SMA50/ # SMA-50 indicator data
β βββ EMA_CROSSOVER/ # EMA 9-21 crossover data
β βββ ATR/ # Average True Range data
β βββ MACD/ # MACD indicator data
β βββ BBANDS/ # Bollinger Bands data
β βββ VWAP/ # Volume Weighted Average Price data
β βββ OBV/ # On-Balance Volume data
β βββ ADX/ # Average Directional Index data
β βββ consolidated/ # Combined indicators data
βββ logs/ # Directory for log files
βββ examples/ # Example scripts
βββ timeframe_examples.py
The technical_indicators.py module is a comprehensive technical analysis engine that calculates and organizes multiple technical indicators for cryptocurrency market analysis.
| Indicator | Description | Parameters |
|---|---|---|
| RSI-14 | Relative Strength Index | Period: 14, Overbought: 60, Oversold: 40 |
| SMA-50 | Simple Moving Average | Period: 50 days |
| EMA 9-21 Crossover | Exponential Moving Average Crossover | Fast: 9 periods, Slow: 21 periods |
| ATR-14 | Average True Range | Period: 14 |
| MACD | Moving Average Convergence Divergence | Fast: 12, Slow: 26, Signal: 9 |
| Bollinger Bands | Volatility Bands | Period: 20, Deviations: 2 |
| VWAP | Volume Weighted Average Price | Calculated per session |
| OBV | On-Balance Volume | Uses price and volume relationship |
| ADX | Average Directional Index | Period: 14, Threshold: 25 |
- Organized Data Storage: Each indicator is saved in its dedicated directory
- Consolidated Dataset: Creates a combined file with all indicators
- CSV Output: All data is exported to CSV format for easy integration
- Custom Signals: Generates trading signals based on indicator values
- Statistical Analysis: Provides current market condition insights
- Batch Processing: Process multiple symbols and timeframes at once
Process all data files in the data directory:
python technical_indicators.pyfrom technical_indicators import process_all_csv_files, process_csv_file, create_output_directories
# Process all CSV files in the data directory
results = process_all_csv_files()
# Process a specific file
from pathlib import Path
file_path = Path("data/BTCUSD_1h_20230101_20230131.csv")
dirs = create_output_directories()
stats = process_csv_file(file_path, dirs)The technical indicators module organizes data in the following structure:
- Individual Indicator Files: Each indicator is saved in its dedicated subfolder
- Naming Convention:
{symbol}_{timeframe}_{start_date}_{end_date}_{indicator}.csv - Consolidated File: All indicators combined in one file at
data/consolidated/{symbol}_{timeframe}_{start_date}_{end_date}_ALL_INDICATORS.csv
The module provides trading signals based on each indicator:
- RSI Signals: Overbought (β₯60), Oversold (β€40), Neutral (40-60)
- SMA Signals: Price Above/Below SMA, Rising/Falling Trend
- EMA Crossover: Bullish Cross (9 crosses above 21), Bearish Cross (9 crosses below 21)
- MACD Signals: Bullish (MACD > Signal), Bearish (MACD < Signal)
- Bollinger Bands: Above Bands, Below Bands, Inside Bands
- ADX Signals: Strong Trend (>25), Weak Trend (β€25)
Each CSV file contains the following columns:
symbol: Trading pair symbol (e.g., BTCUSD)datetime_ist: Timestamp in IST timezonedatetime: UTC timestamptime: Unix timestampopen: Opening pricehigh: Highest pricelow: Lowest priceclose: Closing pricevolume: Trading volumeprice_change: Price change (close - open)price_change_pct: Percentage price change
Files are saved with the following format:
BTCUSD_1m_20250710_20250720.csv(1-minute data)ETHUSD_1h_20250710_20250720.csv(1-hour data)SOLUSD_1d_20250710_20250720.csv(daily data)
Edit config.py to add or remove trading pairs:
SYMBOLS = [
"BTCUSD", # Bitcoin perpetual
"ETHUSD", # Ethereum perpetual
"SOLUSD", # Solana perpetual
"ADAUSD", # Add Cardano
"DOTUSD", # Add Polkadot
]Change the data collection period:
DAYS_TO_FETCH = 30 # Fetch last 30 days instead of 10Adjust API request frequency:
MAX_REQUESTS_PER_SECOND = 3 # Slower rate limitingfrom data_fetcher import DeltaExchangeDataFetcher
# Initialize with custom resolution
fetcher = DeltaExchangeDataFetcher(resolution="5m")
# Fetch data for specific symbol
df = fetcher.fetch_symbol_data("BTCUSD")
# Save with custom parameters
from datetime import datetime
fetcher.save_to_csv(df, "BTCUSD", datetime.now(), datetime.now())# Process different timeframes for analysis
resolutions = ["1m", "5m", "1h", "1d"]
symbol = "BTCUSD"
for resolution in resolutions:
fetcher = DeltaExchangeDataFetcher(resolution=resolution)
data = fetcher.fetch_symbol_data(symbol)
print(f"{resolution}: {len(data)} records")- requests: HTTP library for API communication
- pandas: Data manipulation and CSV export
- python-dateutil: Date handling utilities
- pytz: Timezone support
- python-dotenv: Environment variable management
-
No data retrieved:
- Check internet connection
- Verify symbol names are correct
- Check Delta Exchange API status
-
Rate limiting errors:
- Increase
REQUEST_DELAYin config.py - Reduce
MAX_REQUESTS_PER_SECOND
- Increase
-
File permission errors:
- Ensure write permissions for
data/andlogs/directories - Run script with appropriate permissions
- Ensure write permissions for
For detailed troubleshooting, modify the logging level:
import logging
logging.basicConfig(level=logging.DEBUG)This project uses the Delta Exchange India API. For complete API documentation, visit: https://docs.delta.exchange/#introduction
This software is for educational and research purposes only. Trading cryptocurrencies involves significant risk. Always conduct your own research and consider your risk tolerance before making any trading decisions.
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
If you encounter any issues or have questions:
- Check the troubleshooting section
- Review the logs in
logs/data_fetcher.log - Open an issue on GitHub with detailed error information
- Real-time data streaming via WebSocket
- Technical indicators calculation
- Data visualization dashboard
- Database storage support
- Multiple exchange support
- Automated trading strategies
Happy Trading! π