mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
fix(history): date candles in Jakarta time, not UTC
MSN stamps each IDX trading day at local midnight (17:00Z the previous day), so every MSN candle was labelled one day early. Yahoo weekly and monthly bars have the same stamp and were labelled Sunday / last day of the previous month. Take the date in the exchange offset instead: Yahoo's meta.gmtoffset when present, else WIB (UTC+7). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ld3fDSDiBzAaQvgZJX5NKM
This commit is contained in:
parent
793d765e5a
commit
0ba3d805a7
6 changed files with 43 additions and 4 deletions
|
|
@ -648,7 +648,10 @@ pub(super) fn parse_history(
|
|||
let volume = series_volume_at(series, idx);
|
||||
|
||||
out.push(Ohlc {
|
||||
date: timestamp.date_naive(),
|
||||
// MSN stamps each IDX day at local midnight (17:00Z the day before).
|
||||
date: timestamp
|
||||
.with_timezone(&crate::api::idx_offset())
|
||||
.date_naive(),
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
|
|
@ -935,7 +938,8 @@ mod tests {
|
|||
let history = parse_history("BBCA.JK", &raw).expect("chart history should parse");
|
||||
|
||||
assert_eq!(history.len(), 3);
|
||||
assert_eq!(history[0].date.to_string(), "2026-01-13");
|
||||
// `2026-01-13T17:00:00Z` is midnight WIB on the 14th, the trading day it belongs to.
|
||||
assert_eq!(history[0].date.to_string(), "2026-01-14");
|
||||
assert_eq!(history[0].open, 8000);
|
||||
assert_eq!(history[0].high, 8000);
|
||||
assert_eq!(history[0].low, 8000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue