Configuration API¶
HTTP Settings¶
set_proxies¶
Set HTTP proxy for all requests.
Parameters:
| Name | Type | Description |
|---|---|---|
proxies |
dict | Proxy configuration |
Example:
set_timeout¶
Set request timeout.
Parameters:
| Name | Type | Description |
|---|---|---|
seconds |
int | Timeout in seconds |
Example:
Caching¶
set_cache¶
Configure caching behavior.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
enabled |
bool | True | Enable/disable caching |
ttl |
int | 300 | Cache TTL in seconds |
Example:
# Enable with 5-minute TTL
fv.set_cache(enabled=True, ttl=300)
# Disable caching
fv.set_cache(enabled=False)
Data Source Management¶
get_source_health¶
Get health status of all data sources.
Returns: Dict with source health information
Example:
health = fv.get_source_health()
print(health)
# {
# "cn_stock_daily": {
# "eastmoney": {"status": "healthy", "failures": 0},
# "sina": {"status": "circuit_open", "failures": 5}
# }
# }
reset_source_circuit¶
Reset circuit breaker for a specific source.
Parameters:
| Name | Type | Description |
|---|---|---|
data_type |
str | Data type (e.g., "cn_stock_daily") |
source_name |
str | Source name (e.g., "eastmoney") |
Example:
set_source_priority¶
Set priority order for data sources.
Parameters:
| Name | Type | Description |
|---|---|---|
data_type |
str | Data type |
sources |
list | Source names in priority order |
Example:
# Make Sina the primary source
fv.set_source_priority("cn_stock_daily", ["sina", "eastmoney", "tencent"])
Failover Configuration¶
Access via fv.config.failover:
# Failures before circuit opens
fv.config.failover.failure_threshold = 5
# Seconds before circuit half-opens
fv.config.failover.circuit_timeout = 60
# Successes needed to close circuit
fv.config.failover.success_threshold = 3
Environment Variables¶
| Variable | Description | Default |
|---|---|---|
FINVISTA_HTTP_PROXY |
HTTP proxy URL | None |
FINVISTA_TIMEOUT |
Request timeout (seconds) | 30 |
FINVISTA_DEBUG |
Enable debug logging | 0 |