Overview
VibeTrader’s time series system provides a robust foundation for managing temporal financial data. The system handles time-indexed data with support for different timeframes, timezones, and both calendar and occurred modes. Location:src/lib/timeseris/
Core Concepts
Time Representation
All times are represented as milliseconds since epoch (January 1, 1970 00:00 UTC). The system distinguishes between:- Calendar Mode: Regular time intervals (includes gaps like weekends)
- Occurred Mode: Only times when data exists (compact, no gaps)
TSer Interface
The central interface for time series data management. Location:src/lib/timeseris/TSer.ts
DefaultTSer Implementation
The default time series implementation. Location:src/lib/timeseris/DefaultTSer.ts
Capacity Planning
ThevaluesCapacity parameter determines maximum data points:
- 1-minute trading data: 15,000 capacity = ~62.5 days (3 months)
- Daily data: 15,000 capacity = 60 years
- 1-minute calendar: 20,160 capacity = 14 days (2 weeks)
- Daily calendar: 20,160 capacity = 55 years
TFrame (Timeframe)
Represents a time interval combining a unit and multiplier. Location:src/lib/timeseris/TFrame.ts
Predefined Timeframes
Creating Timeframes
Time Calculations
TUnit (Time Unit)
Defines the base time units. Location:src/lib/timeseris/TUnit.ts
TVar (Time Variable)
A horizontal view of time series data - represents a single variable over time. Location:src/lib/timeseris/TVar.ts
TVar Kinds
Data Access
Example: OHLCV Data
TStamps (Timestamps)
Manages the time axis of a time series. Location:src/lib/timeseris/TStamps.ts
TStampsOnOccurred
Compact mode - only stores times when data exists.TStampsOnCalendar
Calendar mode - includes all time intervals (even without data).Time Lookups
Iteration
TVal (Time Value)
Base class for time-indexed values. Location:src/lib/timeseris/TVal.ts
Kline.
Usage Examples
Creating a Time Series
Working with Kline Data
Calendar vs Occurred Mode
Time Series Slicing
Indicator Calculation
Performance Considerations
Binary Search
Timestamp lookups use binary search for O(log n) performance:ValueList Efficiency
ValueList<T> uses typed arrays internally for numeric types, providing:
- Contiguous memory layout
- Cache-friendly access patterns
- Minimal garbage collection overhead
Capacity Management
Choose appropriate capacity to avoid resizing:Best Practices
- Always use TFrame methods for time arithmetic (handles timezone correctly)
- Choose appropriate capacity to avoid resizing
- Use occurred mode for compact storage of sparse data
- Use calendar mode when you need regular intervals
- Binary search methods are fast - use them instead of linear scans
- Create TVars once and reuse - don’t recreate on every access
- Batch data additions using
addAllToVar()when possible
Next Steps
- Learn about Component Hierarchy to see how TSer is used in views
- Review Architecture Overview for the big picture
- Explore the source code in
src/lib/timeseris/