Compute option stats from exchange history instead of local DB.
Share history loading between history and stats APIs so average profit/loss matches the option history tab. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,11 +4,13 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from lib.options.options_stats_lib import compute_options_stats
|
||||
from lib.options.options_history_lib import load_options_history
|
||||
from lib.options.options_stats_lib import compute_options_stats_from_history
|
||||
|
||||
|
||||
def _compute_options_stats(get_db) -> dict[str, Any]:
|
||||
return compute_options_stats(get_db)
|
||||
def _compute_options_stats(ex, cfg) -> dict[str, Any]:
|
||||
history = load_options_history(ex, cfg)
|
||||
return compute_options_stats_from_history(history)
|
||||
|
||||
|
||||
def build_options_hub_snapshot(cfg: dict[str, Any]) -> dict[str, Any]:
|
||||
@@ -35,7 +37,7 @@ def build_options_hub_snapshot(cfg: dict[str, Any]) -> dict[str, Any]:
|
||||
has_upl = True
|
||||
upl_total += float(upl)
|
||||
bal = cfg["fetch_options_balances"](ex)
|
||||
stats = _compute_options_stats(cfg["get_db"])
|
||||
stats = _compute_options_stats(ex, cfg)
|
||||
return {
|
||||
"ok": True,
|
||||
"enabled": True,
|
||||
|
||||
Reference in New Issue
Block a user