Data sources¶
The process-wide data source, used when nothing more specific was given.
sources ¶
The process-level data source: what answers when nothing was bound.
import beacon
beacon.use(fetcher) # point the process somewhere, once
p.asset("AAA").prices(...) # every unbound portfolio reads it
A source bound to the object wins: a backtest result's views always read the data its run used. This module is the fallback for objects that have none, resolved in this order:
- a source set explicitly with :func:
use; - otherwise the default store on disk (the one
python -m beacon.syntheticwrites and the server auto-loads), loaded lazily on first need and cached; - if neither exists, a :class:
DataSourceErrorthat names both fixes.
The source is process-global, so results that read it depend on process state. Objects that must be reproducible, such as backtest results, carry their own binding, which always wins.
use ¶
Set the process's data source, or clear it with None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fetcher
|
DataFetcher | None
|
What unbound reads should resolve against, or None to fall back to the default store again. |
required |
resolve ¶
The data source an unbound read should use.
Returns:
| Name | Type | Description |
|---|---|---|
DataFetcher |
DataFetcher
|
The explicit source when one was set, else the default |
DataFetcher
|
store, loaded lazily on first call and cached for the process. |
Raises:
| Type | Description |
|---|---|
DataSourceError
|
When neither exists. The message names both fixes. |