-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.diff
More file actions
17 lines (17 loc) · 580 Bytes
/
patch.diff
File metadata and controls
17 lines (17 loc) · 580 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
*** Begin Patch
*** Update File: app/db.py
@@
async def fetch_ohlc_bars(
pool: asyncpg.pool.Pool, symbol: str, timeframe: str, limit: int = 500
) -> list[dict]:
@@
return result
+
+
+async def latest_bar_ts(pool: asyncpg.pool.Pool, symbol: str, timeframe: str):
+ """Return the most recent timestamp we have for a symbol/timeframe, or None."""
+ q = "SELECT ts FROM ohlc_bars WHERE symbol=$1 AND timeframe=$2 ORDER BY ts DESC LIMIT 1"
+ async with pool.acquire() as conn:
+ val = await conn.fetchval(q, symbol, timeframe)
+ return val
*** End Patch