-
Notifications
You must be signed in to change notification settings - Fork 155
Open
Description
Bug Description
All OHLC values (o, h, l, c) in the Candle model are always None when fetching candles via the SDK, even though the API returns valid data.
Root Cause
In lighter/models/candle.py (lines ~30-37), the fields o, h, l, c are defined twice:
# First definition (lines ~30-33) — no alias
o: Optional[float] = None
h: Optional[float] = None
l: Optional[float] = None
c: Optional[float] = None
# Second definition (lines ~34-37) — with uppercase alias
o: Optional[float] = Field(None, alias="O")
h: Optional[float] = Field(None, alias="H")
l: Optional[float] = Field(None, alias="L")
c: Optional[float] = Field(None, alias="C")
Python overwrites the first definition with the second. Since the second definition uses uppercase aliases ("O", "H", "L", "C"), Pydantic only looks for
uppercase keys. However, the API returns lowercase keys (o, h, l, c), so all values remain None.
How to Reproduce
from lighter import Lighter
lighter = Lighter(...)
candles = await lighter.api.get_candles(market_id=0, resolution=60, ...)
print(candles[0].o) # None
print(candles[0].h) # None
print(candles[0].l) # None
print(candles[0].c) # None
Expected Behavior
OHLC fields should contain the actual price values returned by the API.
Suggested Fix
Remove the duplicate definitions — keep only one set of field definitions without uppercase aliases (since the API returns lowercase keys):
o: Optional[float] = None
h: Optional[float] = None
l: Optional[float] = None
c: Optional[float] = None
Environment
- lighter-sdk version: 1.0.6
- Python: 3.12
- Pydantic: v2
Workaround
Bypass the SDK for candle fetching and use HTTP directly, parsing the JSON response manually.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels