You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/Data/external-data.md
+43-1Lines changed: 43 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ The framework provides two ways to load external data:
13
13
1.**Data Sources** — Declare `DataSource.from_csv()`, `DataSource.from_json()`, or `DataSource.from_parquet()` in your strategy's `data_sources` list. Data is fetched automatically and available in your `data` dict.
14
14
2.**Context methods** — Call `context.fetch_csv()`, `context.fetch_json()`, or `context.fetch_parquet()` on demand inside your strategy's `run_strategy` method.
15
15
16
-
Both approaches support caching, refresh intervals, date parsing, and pre/post-processing callbacks.
16
+
Both approaches support caching, refresh intervals, date parsing, request headers, and pre/post-processing callbacks.
17
17
18
18
## Supported Formats
19
19
@@ -112,6 +112,7 @@ class MyStrategy(TradingStrategy):
112
112
earnings = context.fetch_json(
113
113
url="https://api.example.com/earnings",
114
114
date_column="report_date",
115
+
headers={"Authorization": "Bearer <token>"},
115
116
)
116
117
117
118
# Fetch Parquet on demand
@@ -132,9 +133,50 @@ All three factory methods and context methods accept the same core parameters:
132
133
|`date_format`|`str`|`None`| strftime format for parsing dates (e.g., `"%Y-%m-%d"`). Auto-detected if omitted. |
133
134
|`cache`|`bool`|`True`| Cache fetched data locally to avoid repeated downloads. |
134
135
|`refresh_interval`|`str`|`None`| How often to re-fetch: `"1m"`, `"5m"`, `"15m"`, `"30m"`, `"1h"`, `"4h"`, `"1d"`, `"1W"`. |
136
+
|`headers`|`dict`|`None`| Optional HTTP headers to send with the request, such as API keys or bearer tokens. |
135
137
|`pre_process`|`callable`|`None`| Transform raw text before parsing. Receives `str`, returns `str`. Not available for Parquet. |
136
138
|`post_process`|`callable`|`None`| Transform the parsed DataFrame. Receives `DataFrame`, returns `DataFrame`. |
137
139
140
+
## Authenticated APIs
141
+
142
+
Use `headers` when an external data API requires authentication. For example, Adanos Market Sentiment can be loaded as an optional alternative-data signal without writing a custom provider:
143
+
144
+
```python
145
+
import json
146
+
import os
147
+
148
+
import polars as pl
149
+
150
+
from investing_algorithm_framework import TimeUnit, TradingStrategy
0 commit comments