mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
fix(intraday): mark a chart from before the latest session
stocks intraday never set quote.behind_session, so on a holiday or when Stockbit lags, a past session's chart read as current. Mark it as quotes do and print the same note under the header. Claude-Session: https://claude.ai/code/session_01RqPPVeVDrnLoP7NUZmLRxY
This commit is contained in:
parent
570439369e
commit
6f8d3c071a
10 changed files with 20 additions and 9 deletions
|
|
@ -223,6 +223,9 @@ pub fn print_intraday(day: &Intraday, no_color: bool) -> Result<(), IdxError> {
|
|||
if let Some(note) = &q.session_note {
|
||||
println!("Note: {}", terminal_safe(note));
|
||||
}
|
||||
for note in stale_quote_notes(std::slice::from_ref(q), chrono::Utc::now()) {
|
||||
println!("{}", terminal_safe(¬e));
|
||||
}
|
||||
|
||||
let prices: Vec<f64> = day.points.iter().map(|p| p.price).collect();
|
||||
if let (Some(first), Some(last)) = (day.points.first(), day.points.last()) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ exit: 0
|
|||
--- stdout
|
||||
^JKSE.JK 5,388 +60 (+1.12%)
|
||||
prev close 5,328 · volume 36,446,806,700 · market close · last trade 2026-10-22 16:14 WIB
|
||||
Note: ^JKSE.JK last traded on 2026-10-22; this price is not current.
|
||||
|
||||
▃▄▄▆▆▆▆▆▆▇▇▇▇▇████▇▇▇▇███▇▇▇▇███▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
|
||||
08:58 to 16:14 WIB · low 5,192.41 · high 5,419.34 · 335 minutes
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -2,6 +2,7 @@ exit: 0
|
|||
--- stdout
|
||||
BBCA.JK 5,175 -100 (-1.90%)
|
||||
prev close 5,275 · volume 286,928,500 · market close · last trade 2026-10-22 16:14 WIB
|
||||
Note: BBCA.JK last traded on 2026-10-22; this price is not current.
|
||||
|
||||
▄▅▇█▅▇▇▇▅▇▇▇▇▇▇██▇▅▇▅▅███▇▅▇▅▇▇▇▅▇▅▅▄▅▄▅▄▄▅▅▅▅▅▇▅▄▄▄▄▄▄▂▄▄▄▄
|
||||
08:58 to 16:14 WIB · low 5,125 · high 5,250 · 335 minutes
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ impl Market<'_> {
|
|||
let idx = self.idx;
|
||||
let resolved = idx.resolve(symbol)?;
|
||||
let provider = intraday_provider();
|
||||
cached_fetch(
|
||||
let mut day = cached_fetch(
|
||||
&idx.cache,
|
||||
CacheSpec {
|
||||
bucket: "stockbit-intraday",
|
||||
|
|
@ -87,7 +87,11 @@ impl Market<'_> {
|
|||
policy,
|
||||
|| provider.intraday(&resolved),
|
||||
Ok,
|
||||
)
|
||||
)?;
|
||||
// Stockbit's page keeps the last session's chart up after the close,
|
||||
// so a cached or lagging day reads as current unless it is marked.
|
||||
mark_behind_session(&mut day.data.quote, latest_session(Utc::now()));
|
||||
Ok(day)
|
||||
}
|
||||
|
||||
/// Resolves the history source for an optional `--history-provider`
|
||||
|
|
|
|||
|
|
@ -143,8 +143,9 @@ minutes."
|
|||
`market_status`, `bid`/`offer` only while the market is open, `session_note`) and \
|
||||
`points`, the price per minute in WIB, oldest first. Delayed at least 10 minutes; no \
|
||||
per-minute volume. Empty `points` means the stock did not trade this session (see \
|
||||
`session_note`), not an error. UPSTREAMBLOCKED means stockbit.com refused this machine \
|
||||
(HTTP 403): do not retry at once."
|
||||
`session_note`), not an error. `quote.behind_session` is true when the chart is from \
|
||||
before the latest IDX session (a holiday, or Stockbit lagging), as in get_quotes. \
|
||||
UPSTREAMBLOCKED means stockbit.com refused this machine (HTTP 403): do not retry at once."
|
||||
)]
|
||||
async fn get_intraday(&self, params: Parameters<IntradayParams>) -> ToolResult {
|
||||
let IntradayParams { symbol, tail } = params.0;
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@
|
|||
"name": "get_foreign_flow"
|
||||
},
|
||||
{
|
||||
"description": "Today's session of one IDX stock or index from Stockbit's public page (no login), whichever provider the server uses: `quote` (price, change, volume, `market_status`, `bid`/`offer` only while the market is open, `session_note`) and `points`, the price per minute in WIB, oldest first. Delayed at least 10 minutes; no per-minute volume. Empty `points` means the stock did not trade this session (see `session_note`), not an error. UPSTREAMBLOCKED means stockbit.com refused this machine (HTTP 403): do not retry at once.",
|
||||
"description": "Today's session of one IDX stock or index from Stockbit's public page (no login), whichever provider the server uses: `quote` (price, change, volume, `market_status`, `bid`/`offer` only while the market is open, `session_note`) and `points`, the price per minute in WIB, oldest first. Delayed at least 10 minutes; no per-minute volume. Empty `points` means the stock did not trade this session (see `session_note`), not an error. `quote.behind_session` is true when the chart is from before the latest IDX session (a holiday, or Stockbit lagging), as in get_quotes. UPSTREAMBLOCKED means stockbit.com refused this machine (HTTP 403): do not retry at once.",
|
||||
"inputSchema": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"properties": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue