Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pa_agent/data/akshare_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,20 @@ def _call_with_retries(
assert last_exc is not None
raise last_exc

@staticmethod
def _baostock_primary_enabled() -> bool:
"""PA_AGENT_BAOSTOCK_PRIMARY=1 时优先走 baostock,不再每轮先撞东财风控。"""
flag = os.environ.get("PA_AGENT_BAOSTOCK_PRIMARY", "").strip().lower()
return flag in {"1", "true", "yes"}

def _fetch_history(self, symbol: str, timeframe: str, n: int) -> list[dict[str, Any]]:
if self._baostock_ok and self._baostock_primary_enabled():
try:
return self._fetch_history_baostock(symbol, timeframe, n)
except Exception as exc:
logger.warning(
"Baostock 首选源失败 (%s): %s,回退 AkShare 主源", symbol, exc
)
try:
if timeframe == "1d":
return self._fetch_daily_ak(symbol, n)
Expand Down