Documentation
¶
Overview ¶
Package params holds canonical, internal representations of Market Data API request parameters that are shared across resource packages. Its central type, Window, models the API's mutually-exclusive date-selection parameters (date / from / to / countback). Public resource packages wrap Window in their own sealed union types so that a caller can only ever express one valid date mode, making illegal combinations impossible to write. Window's fields are unexported and it can only be built through the constructors here, so the exclusivity rules cannot be bypassed.
Index ¶
- type Window
- func (w Window) AnchorCountback(to time.Time) Window
- func (w Window) Apply(v url.Values)
- func (w Window) Chunk(from, to time.Time) Window
- func (w Window) Countback() int
- func (w Window) Date() time.Time
- func (w Window) From() time.Time
- func (w Window) IsRange() bool
- func (w Window) IsZero() bool
- func (w Window) Kind() WindowKind
- func (w Window) To() time.Time
- func (w Window) Validate() error
- type WindowKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is the canonical, validated representation of the API's date-window parameters. Construct it only with the mode constructors (OnDate, Between, Since, Until, LastN, LastNUntil); the zero value is a valid "no date parameters" window.
func LastNUntil ¶
LastNUntil selects the n periods ending at to (countback= & to=).
func Since ¶
Since selects an open-ended range starting at from (from=), letting the API default the end to the most recent period.
func (Window) AnchorCountback ¶
AnchorCountback returns the window unchanged unless it is a bare countback (KindCountback), in which case it returns the equivalent countback-ending-at-to window. It lets an endpoint pin the "n most recent periods" semantics with an explicit to= anchor on endpoints where the API silently ignores a countback that arrives without one.
func (Window) Apply ¶
Apply writes the window's parameters into v using the API's calendar-date format. It assumes the window has already passed Window.Validate.
func (Window) Chunk ¶
Chunk derives a from/to sub-window bounded by the given dates. It lets a caller split a large range into smaller concurrent requests without needing to name this package.
func (Window) From ¶
From, To, Date, and Countback expose the underlying values for callers that need them (for example, the candle range-splitting logic in stocks).
func (Window) IsRange ¶
IsRange reports whether the window is an explicit closed from/to range, the only mode eligible for the stocks candle range-splitting optimization.
func (Window) Kind ¶
func (w Window) Kind() WindowKind
Kind reports which date mode the window carries.
func (Window) Validate ¶
Validate checks the window's values before any request is built. It enforces the value-range rules that cannot be encoded in the type system: countback must be positive, dates present for their mode must be non-zero, and an explicit from must not be after to. It returns a sdkerrors.ValidationError on failure so callers can reject the request pre-network.
type WindowKind ¶
type WindowKind uint8
WindowKind identifies which mutually-exclusive date mode a Window carries.
const ( // KindNone is the zero Window: no date parameters are sent. KindNone WindowKind = iota // KindDate is a single calendar date (date=). KindDate // KindFromTo is an explicit closed range (from= & to=). KindFromTo // KindFrom is an open-ended range starting at from (from=). KindFrom // KindTo is a range ending at to (to=). KindTo // KindCountback is a fixed number of the most recent periods (countback=). KindCountback // KindCountbackTo is a fixed number of periods ending at to (countback= & to=). KindCountbackTo )