Simulated
_RTYPE_MAP = {models.BarPeriod.SECOND: 32, models.BarPeriod.MINUTE: 33, models.BarPeriod.HOUR: 34, models.BarPeriod.DAY: 35}
module-attribute
_RTYPE_TO_BAR_PERIOD = {v: kfor (k, v) in (_RTYPE_MAP.items())}
module-attribute
SimulatedDatafeed
Bases: DatafeedBase
Simulated market data feed backed by a secmaster SQLite database.
This datafeed replays historical OHLCV bars from a secmaster database, resolving symbols
via time-bounded symbology mappings. Bars are delivered in timestamp order, with all bars
sharing the same timestamp published before calling wait_until_system_idle.
Subclasses must set publisher_name, dataset, and symbol_type as class attributes to
scope the feed to a specific data source. The database must contain publishers with numeric
source_instrument_id values; symbol-only publishers (e.g., yfinance) are not supported.
__init__(event_bus)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_bus
|
EventBus
|
Event bus used to publish bar events and synchronize with subscribers. |
required |
Source code in src/onesecondtrader/datafeeds/simulated.py
connect()
Open a connection to the secmaster database and resolve the publisher.
If already connected, this method returns immediately.
Source code in src/onesecondtrader/datafeeds/simulated.py
disconnect()
Close the database connection and stop any active streaming.
If not connected, this method returns immediately.
Source code in src/onesecondtrader/datafeeds/simulated.py
subscribe(symbols, bar_period)
Register symbols for bar delivery at the specified period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbols
|
list[str]
|
List of ticker symbols to subscribe. |
required |
bar_period
|
BarPeriod
|
Bar aggregation period for the subscription. |
required |
Source code in src/onesecondtrader/datafeeds/simulated.py
unsubscribe(symbols, bar_period)
Remove symbols from bar delivery at the specified period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbols
|
list[str]
|
List of ticker symbols to unsubscribe. |
required |
bar_period
|
BarPeriod
|
Bar aggregation period for the subscription. |
required |
Source code in src/onesecondtrader/datafeeds/simulated.py
wait_until_complete()
Stream all subscribed bars and block until delivery is complete.
Bars are published in timestamp order. After each timestamp batch, the method waits for all event bus subscribers to become idle before proceeding.