Bandl Data Feed Integration
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Stolgo library utilizes bandl.io as its primary data feed mechanism to facilitate Price Action Trading analysis. By integrating with bandl, Stolgo allows users to fetch financial data from various sources including brokers (like Samco), exchange websites (Nasdaq), or Yahoo Finance through a unified get_data API.
The purpose of this integration is to provide a standardized data structure (Pandas DataFrames) that Stolgo's analytical modules, such as CandleStick, Breakout, and Trend, can consume for backtesting and real-time analysis.
Sources: README.md:27-31, README.md:38-51
Architecture and Data Flow
The integration is built upon a modular architecture where specific provider classes (e.g., Samco, Nasdaq) handle the nuances of different data sources, while a common request layer manages communication.
Data Acquisition Flow
The following diagram illustrates the high-level process of fetching data through the integration:
Request Management
Stolgo implements a robust request layer in lib/stolgo/request.py using requests.Session with custom retry logic and timeout handling. It also provides a Curl class that utilizes subprocess to execute system-level curl commands for environments requiring cloud-mode compatibility.
| Component | Responsibility |
|---|---|
RequestUrl | Manages HTTP sessions with TimeoutHTTPAdapter and Retry logic. |
Curl | Executes shell-based curl commands for data retrieval. |
TimeoutHTTPAdapter | Ensures default timeouts (5s) are applied to all requests. |
Sources: lib/stolgo/request.py:1-105
Supported Data Providers
Samco Integration
The Samco class provides access to Indian market data, including historical index/stock candles, intraday data, and option chains. It requires authentication via user_id, password, and year of birth (yob).
Nasdaq Integration
The Nasdaq class fetches historical stock data from the Nasdaq API. It includes an adjustment mechanism (__get_data_adjusted) that automatically fetches additional data if the returned dataset size is smaller than the requested periods.
Sources: lib/stolgo/nasdaq.py:54-100
Common Data Utilities
The integration relies on lib/stolgo/helper.py to ensure consistency across different feeds:
- Date Formatting:
get_date_rangecalculates start and end dates based on provided parameters or default periods (250 days). - Resampling:
get_data_resampleconverts data into specific timeframes (e.g., 1M, 1D) using standard OHLC (Open, High, Low, Close, Volume) aggregation. - Index Validation:
is_ind_indexchecks if a symbol belongs to the list of supported Indian indices defined inlib/stolgo/common.py.
Sources: lib/stolgo/helper.py:12-25, lib/stolgo/helper.py:93-97, lib/stolgo/common.py:1-12
API Parameters
The primary interface for fetching data across different modules is the get_data method.
| Parameter | Type | Description |
|---|---|---|
symbol | string | The ticker symbol (e.g., "SBIN", "AAPL"). |
start | string | Start date for data retrieval. |
end | string | End date for data retrieval. |
periods | integer | Number of days/candles to retrieve if start/end is missing. |
interval | string | Timeframe (e.g., "1D", "1M"). Defaults to "1D". |
dayfirst | bool | Set to True for European date formats (DD/MM/YYYY). |
Sources: lib/stolgo/samco.py:165-181, lib/stolgo/nasdaq.py:100-112
Summary
The Bandl Data Feed Integration provides Stolgo with a flexible and resilient data acquisition layer. By abstracting the complexities of authentication, URL construction, and date range calculation, it allows developers to focus on technical analysis. The use of Pandas as the core data structure ensures compatibility with Stolgo's internal candlestick and breakout detection modules.
Sources: README.md:12-20, lib/stolgo/samco.py:207-212