Documentation
¶
Overview ¶
Package types defines shared Webull domain types that are safe for external use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InstrumentType ¶
type InstrumentType string
InstrumentType identifies the kind of instrument.
const ( // InstrumentStock is a common stock. InstrumentStock InstrumentType = "STOCK" // InstrumentETF is an exchange-traded fund. InstrumentETF InstrumentType = "ETF" // InstrumentOption is a listed option contract. InstrumentOption InstrumentType = "OPTION" // InstrumentFuture is a futures contract. InstrumentFuture InstrumentType = "FUTURE" // InstrumentIndex is an index. InstrumentIndex InstrumentType = "INDEX" // InstrumentCrypto is a cryptocurrency pair. InstrumentCrypto InstrumentType = "CRYPTO" )
func (InstrumentType) String ¶
func (t InstrumentType) String() string
String returns the instrument type code.
type Market ¶
type Market string
Market identifies a tradable market.
const ( // MarketHK is the Hong Kong market. MarketHK Market = "HK" // MarketUS is the United States market. MarketUS Market = "US" // MarketJP is the Japan market. MarketJP Market = "JP" // MarketSG is the Singapore market. MarketSG Market = "SG" // MarketCN is the mainland China market. MarketCN Market = "CN" )
type Page ¶
type Page[T any] struct { // Data is the page of results, empty when the page is past the end. // // A server that returns a present but empty data array decodes to an empty // non-nil slice; a server that omits the key entirely decodes to nil. Both are // len-zero, so test with len rather than against nil. Data []T `json:"data"` // PaginationKey is the cursor for the next page, empty when this is the last page. // // The value is opaque and server-issued: it is a base64 cursor, not an offset, so // it cannot be constructed, ordered, or compared by a caller. Pass it back // unmodified. PaginationKey string `json:"pagination_key"` }
Page is one page of a cursor-paginated list response.
Fourteen list endpoints across the data and brokerfd packages document their 200 response as this shape rather than as a bare array:
{"data": [ ... ], "pagination_key": "eyJ2IjoxLCJsYXN0SWQiOi..."}
Those methods used to decode straight into a slice, which cannot read this body at all: `encoding/json` reports `cannot unmarshal object into Go value of type []T` and the call fails. That is a loud failure rather than a silent zero, so it is not the class of defect the response-contract gate was built to catch silently, but it means the methods could not succeed against a conforming server. They return a Page now.
A Page is one response, not the whole collection. Pagination is cursor-based: send Page.PaginationKey back on the next request to get the following page, and stop when the returned key is empty. There is no total count and no page number on the wire, so there is no way to know the count in advance other than by paging to the end.
The generic parameter is the element type, so a caller reads out.Data for the rows and out.PaginationKey for the cursor:
page, err := c.ListFDAccounts(ctx, "")
for page.PaginationKey != "" {
// ... consume page.Data ...
page, err = c.ListFDAccounts(ctx, page.PaginationKey)
}