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
|
|
@ -92,6 +92,22 @@ mod tests {
|
|||
assert_eq!(history[0].close, 9875);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn history_dates_use_exchange_offset_not_utc() {
|
||||
// Weekly bars are stamped at Monday 00:00 WIB, i.e. Sunday 17:00Z.
|
||||
let raw = r#"{"chart":{"error":null,"result":[{
|
||||
"meta":{"gmtoffset":25200},
|
||||
"timestamp":[1790528400],
|
||||
"indicators":{"quote":[{"open":[6000],"high":[6150],"low":[5975],"close":[6100],"volume":[1000]}]}
|
||||
}]}}"#;
|
||||
let history = parse_history_from_str("BBCA.JK", raw).expect("history parsed");
|
||||
assert_eq!(history[0].date.to_string(), "2026-09-28");
|
||||
|
||||
let without_offset = raw.replace(r#""gmtoffset":25200"#, r#""symbol":"BBCA.JK""#);
|
||||
let history = parse_history_from_str("BBCA.JK", &without_offset).expect("history parsed");
|
||||
assert_eq!(history[0].date.to_string(), "2026-09-28");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_realistic_fixture_json() {
|
||||
let quote_raw =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue