Creates one deterministic, offline input unit containing a declared session calendar, matching OHLCV observations, instrument metadata, and raw input frames for ledgr's five point-in-time fact constructors. The calendar is created before the observations: sessions are never inferred from bars.
Usage
ledgr_sim_pit_inputs(
instrument_ids,
from,
to,
seed = 1L,
venue_id = "DEMO_VENUE",
universe_id = "DEMO_UNIVERSE",
timezone = "UTC",
session_open = "09:30:00",
session_close = "16:00:00",
cases = c("venue_closure", "missing_observation", "delisting", "halt", "cash_dividend"),
knowledge = c(sessions = "evidenced", membership = "evidenced", lifetime = "evidenced",
trading_status = "evidenced"),
include_instruments = TRUE
)Arguments
- instrument_ids
Unique, non-empty synthetic instrument identifiers.
- from, to
Inclusive civil-date bounds.
- seed
Integer seed controlling only generated numeric bar content.
- venue_id, universe_id
Stable identifiers for the synthetic venue and membership universe.
- timezone
IANA timezone used for the synthetic venue calendar.
- session_open, session_close
Local
HH:MM:SSsession times.- cases
Character vector selecting from
"venue_closure","missing_observation","delisting","halt", and"cash_dividend".- knowledge
Named character vector selecting
"evidenced"or"assume_effective"separately for sessions, membership, lifetime, and trading status. Corporate-action rows always carry explicit evidence clocks.- include_instruments
Whether to include the optional instrument master.
Value
An ordinary named list. bars, instruments, sessions,
membership, lifetime, trading_status, and corporate_actions are
plain data frames; recipe records constructor arguments and scope IDs;
and cases locates each applied teaching case. When cash_dividend is
disabled, corporate_actions is an empty data frame and its recipe entry
is marked disabled.
Details
The default cases require at least four instruments and ten weekdays in the
requested window. They add one weekday venue closure, one missing observation
on a declared open session, one delisting, one halt whose knowledge arrives
after its effective time, and one validated gross cash dividend. Effective
intervals are half-open. Under "evidenced" every row carries a knowledge
time; "assume_effective", recorded in the recipe, leaves it missing and
the fact constructor uses the effective time (see ledgr_facts()).
The delisting retains its boundary observation and emits no later bars. The
halt retains its effective-boundary bar, omits observations strictly inside
the halted interval, and resumes at the excluded interval end.
A changed seed changes prices and volumes, not calendar, facts, case placement, columns, or scope. The returned facts and bars belong together; they are not a fact overlay for an unrelated observation panel.
Examples
inputs <- ledgr_sim_pit_inputs(
instrument_ids = paste0("EX", 1:4),
from = "2020-01-01",
to = "2020-01-31",
seed = 7
)
names(inputs)
#> [1] "bars" "instruments" "sessions"
#> [4] "membership" "lifetime" "trading_status"
#> [7] "corporate_actions" "recipe" "cases"
inputs$cases
#> type instrument_id date
#> 1 venue_closure <NA> 2020-01-06
#> 2 missing_observation EX4 2020-01-09
#> 3 delisting EX1 2020-01-14
#> 4 halt EX2 2020-01-03
#> 5 cash_dividend EX3 2020-01-10