feat(hub): enrich AI coach with fund history, closed trades, and chat uploads

- Add 15-day fund snapshot store and /api/hub/account on all instances

- Summary includes yesterday/today trades, fund columns, and section 5 操作建议

- Chat context distinguishes empty positions from local monitors

- Support image/document attachments in AI chat

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-07 08:54:20 +08:00
parent 51c59b073b
commit 62e48dab92
19 changed files with 947 additions and 106 deletions
+14
View File
@@ -8145,6 +8145,19 @@ def _hub_meta_bundle():
}
def _hub_account_bundle():
funding_capital, trading_capital = get_exchange_capitals(force=True)
funding_usdt = round(funding_capital, FUNDS_DECIMALS) if funding_capital is not None else None
trading_usdt = round(trading_capital, FUNDS_DECIMALS) if trading_capital is not None else None
available = get_available_trading_usdt()
return {
"funding_usdt": funding_usdt,
"trading_usdt": trading_usdt,
"available_trading_usdt": round(available, FUNDS_DECIMALS) if available is not None else None,
"trading_day": get_trading_day(app_now()),
}
def _hub_fetch_ohlcv(symbol, timeframe, since_ms=None, limit=500):
from hub_ohlcv_lib import fetch_ohlcv_for_hub
@@ -8178,6 +8191,7 @@ try:
get_db=get_db,
row_to_dict=row_to_dict,
meta_fn=_hub_meta_bundle,
account_fn=_hub_account_bundle,
views={"add_order": add_order, "add_key": add_key},
ohlcv_fn=_hub_fetch_ohlcv,
)