mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-08 05:57:43 +00:00
74b49d2bb4
- Introduced TBar struct for efficient OHLCV data representation. - Implemented TBarSeries class for high-performance collection of TBar instances using Structure of Arrays (SoA) layout. - Added TSeries class for time-series data management with zero-copy access. - Created TValue struct for time-value pairs with implicit conversions. - Defined IFeed interface for consistent data feed implementations. - Developed CsvFeed class for loading historical OHLCV data from CSV files. - Implemented GBM class for generating synthetic financial data using Geometric Brownian Motion. - Added Quantower project files for Averages indicator with necessary dependencies and configurations. - Included extensive usage examples and notebooks for TBar, TBarSeries, TSeries, TValue, and feed implementations.
1.7 KiB
1.7 KiB
IFeed Interface
IFeed defines the standard contract for all data feeds in QuanTAlib, ensuring consistent behavior across different data sources (synthetic, file-based, or live API).
Key Concepts
- Bidirectional Control: The
Next(ref bool isNew)method allows the consumer to request a new bar (isNew = true) or an update to the current bar (isNew = false). - Streaming: Designed for bar-by-bar processing, simulating real-time data flow.
- Batching: Supports fetching historical data ranges via
Fetch().
Interface Definition
public interface IFeed
{
/// <summary>
/// Gets the next bar with full control over new/update state.
/// </summary>
TBar Next(ref bool isNew);
/// <summary>
/// Convenience overload for simple next-bar requests.
/// </summary>
TBar Next(bool isNew = true);
/// <summary>
/// Retrieves a batch of historical bars.
/// </summary>
TBarSeries Fetch(int count, long startTime, TimeSpan interval);
}
Implementation Guidelines
When implementing IFeed:
- State Management: Maintain the current position in the data source.
- End of Data: When data is exhausted,
Nextshould return the last valid bar and setisNewtofalse. - Intra-bar Updates: If the source supports it (e.g., live ticks),
Next(isNew: false)should return the updated state of the current bar. If not supported (e.g., CSV), it should return the current bar unchanged. - Thread Safety: Implementations are generally not required to be thread-safe unless specified.
Implementations
GBM: Geometric Brownian Motion generator (Synthetic).CsvFeed: Reads OHLCV data from CSV files (Historical).