Client API Reference¶
StockFeedClient¶
stockfeed.client.StockFeedClient
¶
Synchronous client with automatic provider selection and cache-first access.
By default provider selection is automatic: yfinance is always available as a
free fallback; paid providers (Tiingo, Finnhub, …) are used first when their
API keys are configured. Pass provider="tiingo" to any method to pin a
specific provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
StockFeedSettings | None
|
Configuration (API keys, cache path, …). Reads from env / |
None
|
db_path
|
str | None
|
Override the DuckDB path. Defaults to |
None
|
Source code in src/stockfeed/client.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
__init__(settings=None, db_path=None)
¶
Source code in src/stockfeed/client.py
get_ohlcv(ticker, interval, start, end, provider=None)
¶
Return OHLCV bars for ticker over [start, end).
Checks the cache first (skipped for intraday bars during open market hours).
On a cache miss, tries providers in order until one succeeds, then caches
the result. yfinance is always the final fallback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol. |
required |
interval
|
str | Interval
|
Bar width — |
required |
start
|
str | datetime
|
Inclusive start. Accepts |
required |
end
|
str | datetime
|
Exclusive end. Same format as start. |
required |
provider
|
str | None
|
Pin a specific provider by name (e.g. |
None
|
Source code in src/stockfeed/client.py
get_quote(ticker, provider=None)
¶
Return the latest quote for ticker with automatic provider failover.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol. |
required |
provider
|
str | None
|
Pin a provider by name. |
None
|
Source code in src/stockfeed/client.py
get_ticker_info(ticker, provider=None)
¶
Return company/asset metadata for ticker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol. |
required |
provider
|
str | None
|
Pin a provider by name. |
None
|
Source code in src/stockfeed/client.py
health_check(provider=None)
¶
Probe provider(s) and return health snapshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str | None
|
Check a single provider by name. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, HealthStatus]
|
Keyed by provider name. |
Source code in src/stockfeed/client.py
list_providers()
¶
Return metadata for every registered provider.
Returns:
| Type | Description |
|---|---|
list[ProviderInfo]
|
One entry per registered provider, sorted alphabetically by name. |
Source code in src/stockfeed/client.py
get_option_expirations(ticker, provider=None)
¶
Return available option expiration dates for ticker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol (underlying). |
required |
provider
|
str | None
|
Pin a specific options provider. |
None
|
Source code in src/stockfeed/client.py
get_options_chain(ticker, expiration, provider=None)
¶
Return the full options chain for ticker at expiration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol (underlying). |
required |
expiration
|
date
|
Expiration date. |
required |
provider
|
str | None
|
Pin a specific options provider. |
None
|
Source code in src/stockfeed/client.py
get_option_quote(symbol, provider=None)
¶
Return a live quote for the OCC option symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
OCC option symbol (e.g. |
required |
provider
|
str | None
|
Pin a specific options provider. |
None
|
Source code in src/stockfeed/client.py
AsyncStockFeedClient¶
stockfeed.async_client.AsyncStockFeedClient
¶
Asynchronous client with automatic provider selection and cache-first access.
Mirrors :class:~stockfeed.client.StockFeedClient exactly but exposes
async def methods so callers can await them inside an event loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
StockFeedSettings | None
|
Configuration (API keys, cache path, …). Reads from env / |
None
|
db_path
|
str | None
|
Override the DuckDB path. Defaults to |
None
|
Source code in src/stockfeed/async_client.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
__init__(settings=None, db_path=None, *, dev_mode=False)
¶
Source code in src/stockfeed/async_client.py
get_ohlcv(ticker, interval, start, end, provider=None)
async
¶
Async variant of :meth:~stockfeed.client.StockFeedClient.get_ohlcv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol. |
required |
interval
|
str | Interval
|
Bar width — |
required |
start
|
str | datetime
|
Inclusive start. Accepts |
required |
end
|
str | datetime
|
Exclusive end. Same format as start. |
required |
provider
|
str | None
|
Pin a specific provider by name. |
None
|
Source code in src/stockfeed/async_client.py
get_quote(ticker, provider=None)
async
¶
Async variant of :meth:~stockfeed.client.StockFeedClient.get_quote.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol. |
required |
provider
|
str | None
|
Pin a provider by name. |
None
|
Source code in src/stockfeed/async_client.py
get_ticker_info(ticker, provider=None)
async
¶
Async variant of :meth:~stockfeed.client.StockFeedClient.get_ticker_info.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol. |
required |
provider
|
str | None
|
Pin a provider by name. |
None
|
Source code in src/stockfeed/async_client.py
health_check(provider=None)
async
¶
Async variant of :meth:~stockfeed.client.StockFeedClient.health_check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str | None
|
Check a single provider by name. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, HealthStatus]
|
Keyed by provider name. |
Source code in src/stockfeed/async_client.py
stream_quote(ticker, *, interval=5.0, provider=None, max_errors=5)
async
¶
Stream live quotes by polling ticker every interval seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol. |
required |
interval
|
float
|
Seconds between polls. Defaults to |
5.0
|
provider
|
str | None
|
Pin a specific provider. |
None
|
max_errors
|
int
|
Maximum consecutive transient errors before aborting. |
5
|
Yields:
| Type | Description |
|---|---|
Quote
|
|
Source code in src/stockfeed/async_client.py
simulate(ticker, start, end, interval, *, speed=1.0)
async
¶
Replay historical bars as an async stream (dev/backtest mode).
Requires :attr:~stockfeed.config.StockFeedSettings.dev_mode to be
True (or pass dev_mode=True to the client constructor).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol. |
required |
start
|
str | datetime
|
Inclusive start date. |
required |
end
|
str | datetime
|
Exclusive end date. |
required |
interval
|
str | Interval
|
Bar width — |
required |
speed
|
float
|
Playback multiplier. |
1.0
|
Yields:
| Type | Description |
|---|---|
OHLCVBar
|
|
Source code in src/stockfeed/async_client.py
get_option_expirations(ticker, provider=None)
async
¶
Async variant of :meth:~stockfeed.client.StockFeedClient.get_option_expirations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol (underlying). |
required |
provider
|
str | None
|
Pin a specific options provider. |
None
|
Source code in src/stockfeed/async_client.py
get_options_chain(ticker, expiration, provider=None)
async
¶
Async variant of :meth:~stockfeed.client.StockFeedClient.get_options_chain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
Uppercase ticker symbol (underlying). |
required |
expiration
|
date
|
Expiration date. |
required |
provider
|
str | None
|
Pin a specific options provider. |
None
|
Source code in src/stockfeed/async_client.py
get_option_quote(symbol, provider=None)
async
¶
Async variant of :meth:~stockfeed.client.StockFeedClient.get_option_quote.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
OCC option symbol (e.g. |
required |
provider
|
str | None
|
Pin a specific options provider. |
None
|