-
Notifications
You must be signed in to change notification settings - Fork 332
Closed
Description
Description
When fetching crypto historical data via OpenTypeBB API with yfinance provider, requests fail with HTTP 500 error:
{
"error": "Expected number, received null at path ['close']"
}
Root Cause
In packages/opentypebb/src/standard-models/crypto-historical.ts, line 21:
close: z.number().describe('The close price.')
The close field doesn't allow null values, but yfinance can return null for:
• Current day (market not closed yet)
• Data delays
• Missing data points
All other price fields (open, high, low, volume, vwap) are nullable, but close is not.
Solution
Make close nullable, consistent with other price fields:
// Line 21, change from:
close: z.number().describe('The close price.'),
// To:
close: z.number().nullable().default(null).describe('The close price.'),
Testing
Before Fix
curl "http://localhost:6901/api/v1/crypto/price/historical?symbol=BTC-USD&provider=yfinance&start_date=2026-03-15&end_date=2026-03-16"
# Response: 500 Error
{
"results": null,
"error": "Expected number, received null at path ['close']"
}
After Fix
curl "http://localhost:6901/api/v1/crypto/price/historical?symbol=BTC-USD&provider=yfinance&start_date=2026-03-15&end_date=2026-03-16"
# Response: 200 OK
{
"results": [
{
"date": "2026-03-15",
"open": 71213.68,
"high": 73173.01,
"low": 70882.42,
"close": 72789.91,
"volume": 27991268669,
"vwap": null
},
{
"date": "2026-03-16",
"open": 72820.78,
"close": null,
"volume": 51164610560
}
],
"provider": "yfinance",
"warnings": null
}
Impact
• ✅ Crypto historical price API works with yfinance provider
• ✅ Consistent with other price fields (all nullable)
• ✅ Handles real-world data scenarios
• ✅ No breaking changes (just more permissive validation)
Environment
• OpenAlice: latest
• OpenTypeBB: 0.1.2
• Node.js: 22+
• Provider: yfinanceReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels