ptb

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

PTB SDK for Go

SDK resmi PTB Public API: data & analitik saham Bursa Efek Indonesia (REST + WebSocket). Official Go SDK for the PTB Public API: Indonesia Stock Exchange data & analytics (REST + WebSocket).

Bahasa Indonesia · English · Docs: https://developers.papertobillion.com

Status: v0.1.0, belum ada tag rilis. / No release tag yet.


Bahasa Indonesia

Instalasi
go get github.com/ealfarozi/ptb-sdk-go

Membutuhkan Go 1.23+ (iterator range-over-func). Satu-satunya dependensi adalah github.com/coder/websocket.

Mulai cepat
export PTB_API_KEY=ptbk_live_...
import ptb "github.com/ealfarozi/ptb-sdk-go"

c, err := ptb.New() // membaca PTB_API_KEY; atau ptb.New(ptb.WithAPIKey(k))
q, err := c.Stocks.Quote(ctx, "BBCA", nil)
fmt.Println(q.Data.Last)
fmt.Println(*q.Billing.CreditsCharged, *q.Billing.BalanceAfter) // blok billing
fmt.Println(*q.Billing.HeaderCharged, *q.Billing.HeaderRemaining) // header X-PTB-Credits-*
Semua endpoint
Path Method
GET /stocks/{symbol}/trades c.Stocks.Trades(ctx, "BBCA", &ptb.StocksSymbolTradesParams{Date: "2026-11-26"})
GET /stocks/{symbol}/brokers/summary c.Stocks.BrokersSummary(ctx, "BBCA", nil)
GET /market/net-flow c.Market.NetFlow(ctx, nil)
GET /indices/{code} c.Indices.Get(ctx, "IHSG", &ptb.IndicesCodeParams{Interval: "1d"})
GET /compare c.Compare(ctx, &ptb.CompareParams{Symbols: "BBCA,BBRI"})
POST /batch c.Batch(ctx, body, nil)

Peta 71 operasi ada di ptb.Operations. Parameter angka opsional memakai pointer, misalnya Limit: ptb.Int(500). Endpoint yang belum ada di SDK bisa dipanggil dengan ptb.Do[T](c, ctx, "GET", "/path", url.Values{}, nil).

Paging
for t, err := range c.Stocks.TradesIter(ctx, "BBCA", &ptb.StocksSymbolTradesParams{Date: "2026-11-26"}) {
    if err != nil { return err }
    _ = t.Lots // mengikuti meta.next_cursor, 1.000 baris (1 Kredit) per halaman
}
Kredit, ETag, dan 304
a, _ := c.Market.NetFlow(ctx, nil)
b, _ := c.Market.NetFlow(ctx, nil, ptb.IfNoneMatch(a.ETag))
if b.NotModified { /* 304, 0 Kredit */ }

r.RateLimit berisi Limit, Remaining, dan Reset.

Retry dan idempotency

Status 429, 5xx, 202 (data_preparing), dan error jaringan diulang otomatis (WithMaxRetries(3)) dengan backoff eksponensial + jitter. Retry-After diikuti persis. Setiap POST membawa Idempotency-Key otomatis yang sama di setiap retry. Kunci sendiri bisa diberikan lewat ptb.IdempotencyKey("...").

Error
_, err := c.Stocks.Quote(ctx, "XXXX", nil)
if errors.Is(err, ptb.ErrSymbolNotFound) { ... }
var ae *ptb.APIError
if errors.As(err, &ae) { fmt.Println(ae.Status, ae.Code, ae.RequestID, ae.DocsURL, ae.RetryAfter) }

Sentinel yang tersedia: ErrInvalidParams, ErrRangeTooLarge, ErrUnauthorized, ErrInsufficientCredits, ErrNotFound, ErrSymbolNotFound, ErrRateLimited, ErrDataPreparing, dan ErrServer. Error jaringan berbentuk *ptb.ConnectionError.

WebSocket
s, _ := ptb.NewStream()
defer s.Close()
s.Subscribe(ctx, "trades", []string{"BBCA", "BBRI"}, nil)
s.Subscribe(ctx, "orderflow", []string{"BBCA"}, &ptb.SubscribeOptions{TF: "1m"})
for m, err := range s.Messages(ctx) {
    if err != nil { log.Fatal(err) }
    if m.Type == "event" { fmt.Println(m.Symbol, *m.Seq, string(m.Data)) }
}

Kalau koneksi putus, SDK menyambung ulang dengan backoff, mengirim resume dari seq terakhir, lalu subscribe lagi. ping dikirim saat koneksi diam.

Contoh lengkap ada di examples/.


English

go get github.com/ealfarozi/ptb-sdk-go
c, err := ptb.New() // reads PTB_API_KEY
q, err := c.Stocks.Quote(ctx, "BBCA", nil)
  • Every /v1 endpoint as a typed method on a service (c.Stocks, c.Market, c.Indices, ...), with generated ...Params and response structs. ptb.Operations maps all 71 operations.
  • Paging: ...Iter methods return iter.Seq2[T, error] that follow meta.next_cursor (1,000 rows and 1 Kredit per page).
  • Credits: Response.Billing exposes the billing block and the X-PTB-Credits-* headers. Response.RateLimit is also available.
  • ETag: ptb.IfNoneMatch(etag). A 304 sets NotModified and costs 0 Kredit.
  • Retries: 429, 5xx, 202, and network errors use exponential backoff with jitter. Retry-After is honoured.
  • Idempotency: automatic Idempotency-Key on every POST, stable across retries.
  • Typed errors: *APIError plus sentinels for every catalog code, matched with errors.Is.
  • WebSocket: Stream supports subscribe/unsubscribe/resume, auto-reconnect, resume from the last seq, and idle ping.

See examples/.


Development

npx @stoplight/prism-cli@5.14.2 mock -p 4010 spec/openapi.json &   # mock server from the contract
PTB_MOCK_URL=http://127.0.0.1:4010 go test -race ./...
go vet ./...
python3 scripts/generate.py --lang go --out endpoints_gen.go && gofmt -w endpoints_gen.go   # after spec/ changes

endpoints_gen.go is generated from spec/openapi.json. CI fails if it is out of date.

This SDK is a thin client only. It contains no PTB analytics logic. Market data is information, not investment advice.

License

MIT

Documentation

Overview

Package ptb is the official Go SDK for the PTB Public API: Indonesia Stock Exchange (IDX/BEI) data and analytics over REST and WebSocket.

c, err := ptb.New() // reads PTB_API_KEY
q, err := c.Stocks.Quote(ctx, "BBCA", nil)
fmt.Println(q.Data.Last, q.Billing.CreditsCharged)

Index

Constants

View Source
const (
	CodeInvalidParams       = "invalid_params"
	CodeRangeTooLarge       = "range_too_large"
	CodeUnauthorized        = "unauthorized"
	CodeInsufficientCredits = "insufficient_credits"
	CodeSymbolNotFound      = "symbol_not_found"
	CodeRateLimited         = "rate_limited"
	CodeDataPreparing       = "data_preparing"
)

Error codes from the PTB Public API error catalog.

View Source
const DefaultBaseURL = "https://api.papertobillion.com/v1"

DefaultBaseURL is the production REST base URL.

View Source
const DefaultStreamURL = "wss://api.papertobillion.com/v1/stream"

DefaultStreamURL is the production WebSocket URL.

View Source
const Version = "0.1.0"

Version of this SDK.

Variables

View Source
var (
	ErrInvalidParams       = errors.New("ptb: invalid_params")
	ErrRangeTooLarge       = errors.New("ptb: range_too_large")
	ErrUnauthorized        = errors.New("ptb: unauthorized")
	ErrInsufficientCredits = errors.New("ptb: insufficient_credits")
	ErrNotFound            = errors.New("ptb: not_found")
	ErrSymbolNotFound      = errors.New("ptb: symbol_not_found")
	ErrRateLimited         = errors.New("ptb: rate_limited")
	ErrDataPreparing       = errors.New("ptb: data_preparing")
	ErrServer              = errors.New("ptb: server_error")
	ErrMissingAPIKey       = errors.New("ptb: API key missing: use WithAPIKey or set PTB_API_KEY")
)

Sentinel errors; match with errors.Is(err, ptb.ErrInsufficientCredits).

View Source
var Channels = []string{"trades", "orderflow", "orderbook", "heatmap", "bigtrades", "bookevents", "quote", "index", "market", "picks"}

Channels defined in spec/asyncapi.json.

View Source
var Operations = map[string]string{
	"GET /account":                              "Account.Get",
	"GET /account/balance":                      "Account.Balance",
	"GET /account/usage":                        "Account.Usage",
	"POST /quota/estimate":                      "Quota.Estimate",
	"GET /me/watchlist":                         "Me.Watchlist",
	"GET /reference/stocks":                     "Reference.Stocks",
	"GET /reference/brokers":                    "Reference.Brokers",
	"GET /reference/indices":                    "Reference.Indices",
	"GET /reference/sectors":                    "Reference.Sectors",
	"GET /reference/calendar":                   "Reference.Calendar",
	"GET /market/eod":                           "Market.EOD",
	"GET /market/most-active":                   "Market.MostActive",
	"GET /market/movers":                        "Market.Movers",
	"GET /market/bubbles":                       "Market.Bubbles",
	"GET /market/net-flow":                      "Market.NetFlow",
	"GET /market/foreign-flow":                  "Market.ForeignFlow",
	"GET /market/foreign-flow/stocks":           "Market.ForeignFlowStocks",
	"GET /market/flow":                          "Market.Flow",
	"GET /market/action":                        "Market.Action",
	"GET /market/extreme-results":               "Market.ExtremeResults",
	"GET /market/premarket-auction":             "Market.PremarketAuction",
	"GET /market/scripless":                     "Market.Scripless",
	"GET /market/scripless/top":                 "Market.ScriplessTop",
	"GET /indices":                              "Indices.List",
	"GET /indices/{code}":                       "Indices.Get",
	"GET /indices/activity":                     "Indices.Activity",
	"GET /indices/ihsg/flow":                    "Indices.IHSGFlow",
	"GET /indices/ihsg/contributors":            "Indices.IHSGContributors",
	"GET /indices/ihsg/sectors":                 "Indices.IHSGSectors",
	"GET /indices/ihsg/sectors/rotation":        "Indices.IHSGSectorsRotation",
	"GET /indices/ihsg/clusters":                "Indices.IHSGClusters",
	"GET /indices/ptb":                          "Indices.PTB",
	"GET /indices/ptb/history":                  "Indices.PTBHistory",
	"GET /stocks/{symbol}/profile":              "Stocks.Profile",
	"GET /stocks/{symbol}/quote":                "Stocks.Quote",
	"GET /stocks/{symbol}/ohlcv":                "Stocks.Ohlcv",
	"GET /stocks/{symbol}/corporate-actions":    "Stocks.CorporateActions",
	"GET /stocks/{symbol}/foreign-flow":         "Stocks.ForeignFlow",
	"GET /stocks/{symbol}/scripless":            "Stocks.Scripless",
	"GET /stocks/{symbol}/technical":            "Stocks.Technical",
	"GET /stocks/{symbol}/performance":          "Stocks.Performance",
	"GET /compare":                              "Compare",
	"GET /stocks/{symbol}/orderbook":            "Stocks.Orderbook",
	"GET /stocks/{symbol}/orderflow":            "Stocks.Orderflow",
	"GET /stocks/{symbol}/trades":               "Stocks.Trades",
	"GET /stocks/{symbol}/trades/summary":       "Stocks.TradesSummary",
	"GET /stocks/{symbol}/flow-summary":         "Stocks.FlowSummary",
	"GET /stocks/{symbol}/pressure":             "Stocks.Pressure",
	"GET /stocks/{symbol}/big-trades":           "Stocks.BigTrades",
	"GET /stocks/{symbol}/book-events":          "Stocks.BookEvents",
	"GET /stocks/{symbol}/volume-profile":       "Stocks.VolumeProfile",
	"GET /stocks/{symbol}/auction":              "Stocks.Auction",
	"GET /stocks/{symbol}/heatmap":              "Stocks.Heatmap",
	"GET /stocks/{symbol}/brokers/summary":      "Stocks.BrokersSummary",
	"GET /stocks/{symbol}/brokers/net-position": "Stocks.BrokersNetPosition",
	"GET /stocks/{symbol}/brokers/flow":         "Stocks.BrokersFlow",
	"GET /stocks/{symbol}/brokers/inventory":    "Stocks.BrokersInventory",
	"GET /stocks/{symbol}/brokers/quadrant":     "Stocks.BrokersQuadrant",
	"GET /brokers/inventory":                    "Brokers.Inventory",
	"GET /brokers/{code}/activity":              "Brokers.Activity",
	"GET /brokers/{code}/stalker":               "Brokers.Stalker",
	"GET /brokers/{code}/quadrant":              "Brokers.Quadrant",
	"GET /screeners/broker":                     "Screeners.Broker",
	"GET /radar/market":                         "Radar.Market",
	"GET /radar/anomaly":                        "Radar.Anomaly",
	"GET /rankings/trade-flow":                  "Rankings.TradeFlow",
	"GET /radar/technical":                      "Radar.Technical",
	"GET /picks/today":                          "Picks.Today",
	"GET /picks/history":                        "Picks.History",
	"GET /picks/stats":                          "Picks.Stats",
	"POST /batch":                               "Batch",
}

Operations maps every REST operation to its SDK method (Service.Method).

Functions

func Bool

func Bool(b bool) *bool

Bool returns a pointer to b (for optional boolean params).

func Float

func Float(f float64) *float64

Float returns a pointer to f (for optional number params).

func Int

func Int(n int64) *int64

Int returns a pointer to n (for optional integer params).

Types

type APIError

type APIError struct {
	Status     int
	Code       string
	Message    string
	DocsURL    string
	RequestID  string
	RetryAfter time.Duration
	Body       []byte
}

APIError is returned when the API answers with {"error": {...}, "request_id": ...}. Use errors.As to read it, or errors.Is with the sentinel errors above.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Is

func (e *APIError) Is(target error) bool

Is lets errors.Is match the sentinel for the error code (and its parent class).

type AccountBalanceData

type AccountBalanceData struct {
	Total    int64            `json:"total,omitempty"`    // Kredit yang bisa dipakai sekarang
	Monthly  map[string]any   `json:"monthly,omitempty"`  // Kuota bulanan: granted, used, resets_at
	Prepaid  []map[string]any `json:"prepaid,omitempty"`  // Lot prepaid: credits, remaining, purchased_at, expires_at (FIFO)
	Reserved int64            `json:"reserved,omitempty"` // Kredit yang sedang ditahan request berjalan
}

AccountBalanceData is generated from the OpenAPI schema.

type AccountBalanceParams

type AccountBalanceParams struct {
}

AccountBalanceParams are the query parameters of GET /account/balance.

type AccountData

type AccountData struct {
	UserID       string         `json:"user_id,omitempty"`        // ID akun
	Plan         string         `json:"plan,omitempty"`           // prepaid|dev|pro|business
	PlanRenewsAt string         `json:"plan_renews_at,omitempty"` // Tanggal reset kuota bulanan berikutnya (paket tahunan)
	RateLimit    map[string]any `json:"rate_limit,omitempty"`     // Batas per menit, request berat, koneksi WS, saham live bersamaan, item batch
	Free         bool           `json:"free,omitempty"`           // Akun gratis (superadmin/free): tidak dipotong kredit
}

AccountData is generated from the OpenAPI schema.

type AccountParams

type AccountParams struct {
}

AccountParams are the query parameters of GET /account.

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

AccountService groups the endpoints under /account.

func (*AccountService) Balance

Balance calls GET /account/balance — Saldo Kredit

**Kredit:** 0 kredit (tetap kena rate limit)

func (*AccountService) Get

Get calls GET /account — Profil akun dan paket

**Kredit:** 0 kredit (tetap kena rate limit)

func (*AccountService) Usage

Usage calls GET /account/usage — Riwayat pemakaian per request

**Kredit:** 0 kredit (tetap kena rate limit)

func (*AccountService) UsageIter

UsageIter iterates every row of Usage across all pages (1 Kredit per page).

type AccountUsageDataItem

type AccountUsageDataItem struct {
	RequestID string `json:"request_id,omitempty"` // ID request
	At        string `json:"at,omitempty"`         // Waktu
	KeyID     string `json:"key_id,omitempty"`     // Key yang dipakai
	Path      string `json:"path,omitempty"`       // Endpoint/channel
	Status    int64  `json:"status,omitempty"`     // Kode HTTP
	Credits   int64  `json:"credits,omitempty"`    // Kredit dipotong
	Rule      string `json:"rule,omitempty"`       // Aturan tagihan
}

AccountUsageDataItem is generated from the OpenAPI schema.

type AccountUsageParams

type AccountUsageParams struct {
	From    string `query:"from"`    // Awal rentang (YYYY-MM-DD, inklusif)
	To      string `query:"to"`      // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	KeyID   string `query:"key_id"`  // Filter satu API key
	Path    string `query:"path"`    // Filter endpoint, mis. /stocks/{symbol}/trades
	Channel string `query:"channel"` // rest atau ws (rest|ws|all)
	Limit   *int64 `query:"limit"`   // Baris per halaman
	Cursor  string `query:"cursor"`  // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields  string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

AccountUsageParams are the query parameters of GET /account/usage.

type BatchData

type BatchData struct {
	Status  string           `json:"status,omitempty"`  // COMPLETE|PARTIAL|FAILED
	Results []map[string]any `json:"results,omitempty"` // {id, status, data|error, credits_charged}
	Billing map[string]any   `json:"billing,omitempty"` // {credits_charged, balance_after}
}

BatchData is generated from the OpenAPI schema.

type BatchParams

type BatchParams struct {
}

BatchParams are the query parameters of POST /batch.

type Billing

type Billing struct {
	CreditsCharged  *int64 `json:"credits_charged,omitempty"`
	BalanceAfter    *int64 `json:"balance_after,omitempty"`
	Free            *bool  `json:"free,omitempty"`
	Rule            string `json:"rule,omitempty"`
	HeaderCharged   *int64 `json:"-"` // X-PTB-Credits-Charged
	HeaderRemaining *int64 `json:"-"` // X-PTB-Credits-Remaining
}

Billing is the response "billing" block plus the credit headers.

type BrokersCodeActivityDataItem

type BrokersCodeActivityDataItem struct {
	Symbol    string  `json:"symbol,omitempty"`
	BuyValue  float64 `json:"buy_value,omitempty"`
	SellValue float64 `json:"sell_value,omitempty"`
	NetValue  float64 `json:"net_value,omitempty"`
	NetLots   int64   `json:"net_lots,omitempty"`
	Days      int64   `json:"days,omitempty"`
	BuyAvg    float64 `json:"buy_avg,omitempty"`
	SellAvg   float64 `json:"sell_avg,omitempty"`
}

BrokersCodeActivityDataItem is generated from the OpenAPI schema.

type BrokersCodeActivityParams

type BrokersCodeActivityParams struct {
	From   string `query:"from"`   // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`     // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Side   string `query:"side"`   // (both|buy|sell)
	Sort   string `query:"sort"`   // (net|buy|sell|value)
	Order  string `query:"order"`  // Arah urutan (asc|desc)
	Limit  *int64 `query:"limit"`  // Baris per halaman
	Cursor string `query:"cursor"` // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

BrokersCodeActivityParams are the query parameters of GET /brokers/{code}/activity.

type BrokersCodeQuadrantData

type BrokersCodeQuadrantData struct {
	Symbols []map[string]any `json:"symbols,omitempty"` // {symbol, net_value, avg_price, price, distance_pct}
}

BrokersCodeQuadrantData is generated from the OpenAPI schema.

type BrokersCodeQuadrantParams

type BrokersCodeQuadrantParams struct {
	Period string `query:"period"` // (1d|5d|1m|3m|6m)
	Top    *int64 `query:"top"`
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

BrokersCodeQuadrantParams are the query parameters of GET /brokers/{code}/quadrant.

type BrokersCodeStalkerDataItem

type BrokersCodeStalkerDataItem struct {
	Symbols []map[string]any `json:"symbols,omitempty"` // {symbol, buy_value, sell_value, buy_freq, sell_freq, net_value, buy_avg, sell_avg}
	Daily   []map[string]any `json:"daily,omitempty"`   // {date, net_value, buy_value, sell_value, cumulative_net}
}

BrokersCodeStalkerDataItem is generated from the OpenAPI schema.

type BrokersCodeStalkerParams

type BrokersCodeStalkerParams struct {
	From   string `query:"from"`    // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`      // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Period string `query:"period"`  // Periode relatif; diabaikan bila from/to diisi (1d|5d|1m|3m|6m|ytd|1y)
	Symbol string `query:"symbol"`  // Filter satu saham
	UseNet *bool  `query:"use_net"` // Net (true) atau total beli+jual
	Limit  *int64 `query:"limit"`   // Baris per halaman
	Cursor string `query:"cursor"`  // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

BrokersCodeStalkerParams are the query parameters of GET /brokers/{code}/stalker.

type BrokersInventoryDataItem

type BrokersInventoryDataItem struct {
	Symbol string           `json:"symbol,omitempty"`
	Broker string           `json:"broker,omitempty"`
	Points []map[string]any `json:"points,omitempty"` // {date, value}
}

BrokersInventoryDataItem is generated from the OpenAPI schema.

type BrokersInventoryParams

type BrokersInventoryParams struct {
	From    string `query:"from"`    // Awal rentang (YYYY-MM-DD, inklusif)
	To      string `query:"to"`      // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Symbols string `query:"symbols"` // Daftar kode saham dipisah koma
	Brokers string `query:"brokers"` // Dipisah koma
	Limit   *int64 `query:"limit"`   // Baris per halaman
	Cursor  string `query:"cursor"`  // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields  string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

BrokersInventoryParams are the query parameters of GET /brokers/inventory.

type BrokersService

type BrokersService struct {
	// contains filtered or unexported fields
}

BrokersService groups the endpoints under /brokers.

func (*BrokersService) Activity

Activity calls GET /brokers/{code}/activity — Saham yang dibeli/dijual satu broker

Rentang maks 100 hari.

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*BrokersService) ActivityIter

ActivityIter iterates every row of Activity across all pages (1 Kredit per page).

func (*BrokersService) Inventory

Inventory calls GET /brokers/inventory — Inventori broker × saham (chart)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*BrokersService) InventoryIter

InventoryIter iterates every row of Inventory across all pages (1 Kredit per page).

func (*BrokersService) Quadrant

Quadrant calls GET /brokers/{code}/quadrant — Broker Quadrant: posisi satu broker di banyak saham

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*BrokersService) Stalker

Stalker calls GET /brokers/{code}/stalker — Broker Stalker: jejak satu broker

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*BrokersService) StalkerIter

StalkerIter iterates every row of Stalker across all pages (1 Kredit per page).

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls the PTB Public API. It is safe for concurrent use.

func New

func New(opts ...Option) (*Client, error)

New creates a client.

func (*Client) Batch

func (c *Client) Batch(ctx context.Context, body any, params *BatchParams, opts ...RequestOption) (*Response[BatchData], error)

Batch calls POST /batch — Banyak request dalam satu panggilan

Biaya = jumlah biaya tiap item; batch sendiri gratis. Item hari ini untuk data Order Flow memakai aturan 5 kredit per 1.000 trade. Kredit ditahan sebesar perkiraan maksimal, item gagal 0 kredit, sisa dikembalikan. Batas item: prepaid 10, Dev 25, Pro 50, Business 100.

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*Client) Compare

func (c *Client) Compare(ctx context.Context, params *CompareParams, opts ...RequestOption) (*Response[CompareData], error)

Compare calls GET /compare — Bandingkan beberapa saham

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*Client) Raw

func (c *Client) Raw(ctx context.Context, method, path string, query url.Values) (*http.Response, error)

Raw performs an authenticated request and returns the unparsed response (e.g. format=csv). No retries.

type CompareData

type CompareData struct {
	Symbols []map[string]any `json:"symbols,omitempty"` // {code, sector, last, change_pct, value, trend, return_22d, return_66d, rsi, net_flow, foreign_phase, broker_phase}
	Series  []map[string]any `json:"series,omitempty"`  // {date, values{code: return%}}
}

CompareData is generated from the OpenAPI schema.

type CompareParams

type CompareParams struct {
	Symbols string `query:"symbols"` // Required. 2–5 kode dipisah koma
	Days    *int64 `query:"days"`    // Jendela return rebased (22|66|132|250)
	From    string `query:"from"`    // Awal rentang (YYYY-MM-DD, inklusif)
	To      string `query:"to"`      // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Metrics string `query:"metrics"` // Dipisah koma
	Fields  string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

CompareParams are the query parameters of GET /compare.

type ConnectionError

type ConnectionError struct{ Err error }

ConnectionError wraps network failures after retries are exhausted.

func (*ConnectionError) Error

func (e *ConnectionError) Error() string

func (*ConnectionError) Unwrap

func (e *ConnectionError) Unwrap() error

type IndicesActivityData

type IndicesActivityData struct {
	Code      string           `json:"code,omitempty"`
	Last      float64          `json:"last,omitempty"`
	ChangePct float64          `json:"change_pct,omitempty"`
	Intraday  []map[string]any `json:"intraday,omitempty"` // {time, close}
}

IndicesActivityData is generated from the OpenAPI schema.

type IndicesActivityParams

type IndicesActivityParams struct {
	Codes  string `query:"codes"`  // Kode indeks dipisah koma
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesActivityParams are the query parameters of GET /indices/activity.

type IndicesCodeDataItem

type IndicesCodeDataItem struct {
	Time       string  `json:"time,omitempty"`
	Open       float64 `json:"open,omitempty"`
	High       float64 `json:"high,omitempty"`
	Low        float64 `json:"low,omitempty"`
	Close      float64 `json:"close,omitempty"`
	VolumeLots int64   `json:"volume_lots,omitempty"`
	Value      float64 `json:"value,omitempty"`
	Up         int64   `json:"up,omitempty"`
	Down       int64   `json:"down,omitempty"`
}

IndicesCodeDataItem is generated from the OpenAPI schema.

type IndicesCodeParams

type IndicesCodeParams struct {
	Interval string `query:"interval"` // (1m|5m|15m|1h|1d)
	From     string `query:"from"`     // Awal rentang (YYYY-MM-DD, inklusif)
	To       string `query:"to"`       // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Date     string `query:"date"`     // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Limit    *int64 `query:"limit"`    // Baris per halaman
	Cursor   string `query:"cursor"`   // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields   string `query:"fields"`   // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesCodeParams are the query parameters of GET /indices/{code}.

type IndicesData

type IndicesData struct {
	Code      string  `json:"code,omitempty"`
	Open      float64 `json:"open,omitempty"`
	High      float64 `json:"high,omitempty"`
	Low       float64 `json:"low,omitempty"`
	Close     float64 `json:"close,omitempty"`
	Prev      float64 `json:"prev,omitempty"`
	ChangePct float64 `json:"change_pct,omitempty"`
	Value     float64 `json:"value,omitempty"`
	Up        int64   `json:"up,omitempty"`   // Naik
	Down      int64   `json:"down,omitempty"` // Turun
	Unchanged int64   `json:"unchanged,omitempty"`
}

IndicesData is generated from the OpenAPI schema.

type IndicesIHSGClustersData

type IndicesIHSGClustersData struct {
	Sector   string           `json:"sector,omitempty"`
	Turnover float64          `json:"turnover,omitempty"` // Σ turnover
	Stocks   []map[string]any `json:"stocks,omitempty"`   // {code, turnover, change_pct, delta_value}
}

IndicesIHSGClustersData is generated from the OpenAPI schema.

type IndicesIHSGClustersParams

type IndicesIHSGClustersParams struct {
	Date      string `query:"date"`       // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	PerSector *int64 `query:"per_sector"` // Saham per sektor
	Fields    string `query:"fields"`     // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesIHSGClustersParams are the query parameters of GET /indices/ihsg/clusters.

type IndicesIHSGContributorsData

type IndicesIHSGContributorsData struct {
	Code       string  `json:"code,omitempty"`
	Points     float64 `json:"points,omitempty"` // Sumbangan poin IHSG
	Weight     float64 `json:"weight,omitempty"` // Bobot %
	Last       float64 `json:"last,omitempty"`
	Prev       float64 `json:"prev,omitempty"`
	ChangePct  float64 `json:"change_pct,omitempty"`
	DeltaValue float64 `json:"delta_value,omitempty"` // Agresi bersih (Rp)
	Turnover   float64 `json:"turnover,omitempty"`
	Sector     string  `json:"sector,omitempty"`
}

IndicesIHSGContributorsData is generated from the OpenAPI schema.

type IndicesIHSGContributorsParams

type IndicesIHSGContributorsParams struct {
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Sector string `query:"sector"` // Filter sektor (lihat /reference/sectors)
	Sort   string `query:"sort"`   // (points|weight|change_pct|turnover)
	Order  string `query:"order"`  // Arah urutan (asc|desc)
	Limit  *int64 `query:"limit"`
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesIHSGContributorsParams are the query parameters of GET /indices/ihsg/contributors.

type IndicesIHSGFlowDataItem

type IndicesIHSGFlowDataItem struct {
	Time          string           `json:"time,omitempty"`
	HakaValue     float64          `json:"haka_value,omitempty"`
	HakiValue     float64          `json:"haki_value,omitempty"`
	UnknownValue  float64          `json:"unknown_value,omitempty"`
	AuctionValue  float64          `json:"auction_value,omitempty"`
	NetValue      float64          `json:"net_value,omitempty"`
	CumulativeNet float64          `json:"cumulative_net,omitempty"` // Σ net berjalan
	Advancers     int64            `json:"advancers,omitempty"`
	Decliners     int64            `json:"decliners,omitempty"`
	Pressure      float64          `json:"pressure,omitempty"`
	Big           []map[string]any `json:"big,omitempty"` // Big Trade anggota IHSG: {code,time,price,value,side}
}

IndicesIHSGFlowDataItem is generated from the OpenAPI schema.

type IndicesIHSGFlowParams

type IndicesIHSGFlowParams struct {
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Step   *int64 `query:"step"`   // Lebar bar (detik) (1|5|10|30|60|180|300|900|1800|3600)
	Since  *int64 `query:"since"`  // Hanya bar setelah detik ini (polling hari ini)
	Limit  *int64 `query:"limit"`  // Baris per halaman
	Cursor string `query:"cursor"` // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesIHSGFlowParams are the query parameters of GET /indices/ihsg/flow.

type IndicesIHSGSectorsData

type IndicesIHSGSectorsData struct {
	Sector      string  `json:"sector,omitempty"`
	Points      float64 `json:"points,omitempty"`
	Weight      float64 `json:"weight,omitempty"`
	ChangePct   float64 `json:"change_pct,omitempty"`
	DeltaValue  float64 `json:"delta_value,omitempty"`
	Turnover    float64 `json:"turnover,omitempty"`
	Pressure    float64 `json:"pressure,omitempty"`
	Up          int64   `json:"up,omitempty"`
	Down        int64   `json:"down,omitempty"`
	TotalPoints float64 `json:"total_points,omitempty"` // Σ poin semua sektor (di meta)
}

IndicesIHSGSectorsData is generated from the OpenAPI schema.

type IndicesIHSGSectorsParams

type IndicesIHSGSectorsParams struct {
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Sort   string `query:"sort"`   // (points|change_pct|weight|turnover|pressure)
	Order  string `query:"order"`  // Arah urutan (asc|desc)
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesIHSGSectorsParams are the query parameters of GET /indices/ihsg/sectors.

type IndicesIHSGSectorsRotationData

type IndicesIHSGSectorsRotationData struct {
	Sector          string  `json:"sector,omitempty"`
	ChangePct       float64 `json:"change_pct,omitempty"`       // Sumbu x
	AggressionRatio float64 `json:"aggression_ratio,omitempty"` // delta/turnover, sumbu y
	Weight          float64 `json:"weight,omitempty"`           // Ukuran gelembung
}

IndicesIHSGSectorsRotationData is generated from the OpenAPI schema.

type IndicesIHSGSectorsRotationParams

type IndicesIHSGSectorsRotationParams struct {
	Date        string   `query:"date"`         // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	MinTurnover *float64 `query:"min_turnover"` // Turnover minimal (Rp)
	Fields      string   `query:"fields"`       // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesIHSGSectorsRotationParams are the query parameters of GET /indices/ihsg/sectors/rotation.

type IndicesPTBData

type IndicesPTBData struct {
	Code     string `json:"code,omitempty"`
	LastDate string `json:"last_date,omitempty"`
	Active   bool   `json:"active,omitempty"`
}

IndicesPTBData is generated from the OpenAPI schema.

type IndicesPTBHistoryDataItem

type IndicesPTBHistoryDataItem struct {
	Period  string           `json:"period,omitempty"`
	Members []map[string]any `json:"members,omitempty"` // {code, week_open, close, float_pct, rank, entry_price, status, result_pct}
}

IndicesPTBHistoryDataItem is generated from the OpenAPI schema.

type IndicesPTBHistoryParams

type IndicesPTBHistoryParams struct {
	Period string `query:"period"` // Senin awal periode (YYYY-MM-DD); kosong = daftar periode
	From   string `query:"from"`   // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`     // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Limit  *int64 `query:"limit"`  // Baris per halaman
	Cursor string `query:"cursor"` // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesPTBHistoryParams are the query parameters of GET /indices/ptb/history.

type IndicesPTBParams

type IndicesPTBParams struct {
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesPTBParams are the query parameters of GET /indices/ptb.

type IndicesParams

type IndicesParams struct {
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

IndicesParams are the query parameters of GET /indices.

type IndicesService

type IndicesService struct {
	// contains filtered or unexported fields
}

IndicesService groups the endpoints under /indices.

func (*IndicesService) Activity

Activity calls GET /indices/activity — Beberapa indeks sekaligus

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) Get

Get calls GET /indices/{code} — Candle indeks harian/intraday

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) GetIter

GetIter iterates every row of Get across all pages (1 Kredit per page).

func (*IndicesService) IHSGClusters

IHSGClusters calls GET /indices/ihsg/clusters — Mover Clusters per sektor

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) IHSGContributors

IHSGContributors calls GET /indices/ihsg/contributors — IHSG Leaders & Laggards (poin per saham)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) IHSGFlow

IHSGFlow calls GET /indices/ihsg/flow — HAKA/HAKI anggota IHSG per bar (IHSG Flow Trend)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) IHSGFlowIter

IHSGFlowIter iterates every row of IHSGFlow across all pages (1 Kredit per page).

func (*IndicesService) IHSGSectors

IHSGSectors calls GET /indices/ihsg/sectors — Sektor: poin IHSG, %, bobot, tekanan (Movement/List/Heatmap)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) IHSGSectorsRotation

IHSGSectorsRotation calls GET /indices/ihsg/sectors/rotation — Sector Rotation (harga vs agresi)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) List

func (s *IndicesService) List(ctx context.Context, params *IndicesParams, opts ...RequestOption) (*Response[IndicesData], error)

List calls GET /indices — Ringkasan semua indeks

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) PTB

PTB calls GET /indices/ptb — Index PTB: konstituen aktif

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) PTBHistory

PTBHistory calls GET /indices/ptb/history — Riwayat periode Index PTB

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*IndicesService) PTBHistoryIter

PTBHistoryIter iterates every row of PTBHistory across all pages (1 Kredit per page).

type MarketActionData

type MarketActionData struct {
	Bars []map[string]any `json:"bars,omitempty"` // {time, ihsg, up, down, unchanged, breadth, aggression_pct}
}

MarketActionData is generated from the OpenAPI schema.

type MarketActionParams

type MarketActionParams struct {
	Date     string `query:"date"`     // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Interval string `query:"interval"` // (1m|5m|15m)
	Fields   string `query:"fields"`   // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketActionParams are the query parameters of GET /market/action.

type MarketBubblesData

type MarketBubblesData struct {
	Code            string  `json:"code,omitempty"`
	Last            float64 `json:"last,omitempty"`
	Ref             float64 `json:"ref,omitempty"` // Harga acuan jendela
	ChangePct       float64 `json:"change_pct,omitempty"`
	Value           float64 `json:"value,omitempty"`
	VolumeLots      int64   `json:"volume_lots,omitempty"`
	Freq            int64   `json:"freq,omitempty"` // Hanya 1D
	VWAP            float64 `json:"vwap,omitempty"`
	DeltaValue      float64 `json:"delta_value,omitempty"` // Agresi bersih (Rp)
	AggressiveValue float64 `json:"aggressive_value,omitempty"`
	Rvol            float64 `json:"rvol,omitempty"` // Volume relatif
	AsOf            string  `json:"as_of,omitempty"`
	Phase           string  `json:"phase,omitempty"` // PRE_OPEN|OPEN|BREAK|CLOSED
}

MarketBubblesData is generated from the OpenAPI schema.

type MarketBubblesParams

type MarketBubblesParams struct {
	Window   string   `query:"window"`    // (1s|5s|10s|30s|1m|3m|5m|15m|30m|1H|1D|5D|20D)
	Sector   string   `query:"sector"`    // Filter sektor (lihat /reference/sectors)
	MinValue *float64 `query:"min_value"` // Nilai minimal (Rp)
	Limit    *int64   `query:"limit"`     // Baris per halaman
	Fields   string   `query:"fields"`    // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketBubblesParams are the query parameters of GET /market/bubbles.

type MarketEODDataItem

type MarketEODDataItem struct {
	Code        string  `json:"code,omitempty"`         // Kode
	Open        float64 `json:"open,omitempty"`         // Open
	High        float64 `json:"high,omitempty"`         // High
	Low         float64 `json:"low,omitempty"`          // Low
	Close       float64 `json:"close,omitempty"`        // Close
	Prev        float64 `json:"prev,omitempty"`         // Close sebelumnya
	Change      float64 `json:"change,omitempty"`       // Perubahan
	ChangePct   float64 `json:"change_pct,omitempty"`   // Perubahan %
	VolumeLots  int64   `json:"volume_lots,omitempty"`  // Volume (lot)
	Value       float64 `json:"value,omitempty"`        // Nilai (Rp)
	Freq        int64   `json:"freq,omitempty"`         // Frekuensi
	ForeignBuy  float64 `json:"foreign_buy,omitempty"`  // Beli asing (Rp)
	ForeignSell float64 `json:"foreign_sell,omitempty"` // Jual asing (Rp)
}

MarketEODDataItem is generated from the OpenAPI schema.

type MarketEODParams

type MarketEODParams struct {
	Date    string `query:"date"`    // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Board   string `query:"board"`   // Papan perdagangan (RG|NG|TN|ALL)
	Symbols string `query:"symbols"` // Daftar kode saham dipisah koma
	Sector  string `query:"sector"`  // Filter sektor (lihat /reference/sectors)
	Sort    string `query:"sort"`    // (code|value|volume|freq|change_pct)
	Order   string `query:"order"`   // Arah urutan (asc|desc)
	Limit   *int64 `query:"limit"`   // Baris per halaman
	Cursor  string `query:"cursor"`  // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields  string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketEODParams are the query parameters of GET /market/eod.

type MarketExtremeResultsData

type MarketExtremeResultsData struct {
	Days []map[string]any `json:"days,omitempty"` // {date, weekday, trading, symbols[]}
}

MarketExtremeResultsData is generated from the OpenAPI schema.

type MarketExtremeResultsParams

type MarketExtremeResultsParams struct {
	Month  string `query:"month"`  // YYYY-MM, default bulan ini
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketExtremeResultsParams are the query parameters of GET /market/extreme-results.

type MarketFlowData

type MarketFlowData struct {
	AggressionNet   float64          `json:"aggression_net,omitempty"` // Σ HAKA − Σ HAKI anggota IHSG (Rp)
	ForeignToday    float64          `json:"foreign_today,omitempty"`
	ForeignWeek     float64          `json:"foreign_week,omitempty"`
	ForeignMonth    float64          `json:"foreign_month,omitempty"`
	ForeignHistory  []map[string]any `json:"foreign_history,omitempty"` // 20 hari
	TopAccumulation []map[string]any `json:"top_accumulation,omitempty"`
	TopDistribution []map[string]any `json:"top_distribution,omitempty"`
}

MarketFlowData is generated from the OpenAPI schema.

type MarketFlowParams

type MarketFlowParams struct {
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketFlowParams are the query parameters of GET /market/flow.

type MarketForeignFlowData

type MarketForeignFlowData struct {
	Today           map[string]any   `json:"today,omitempty"` // Net asing hari ini (Rp)
	Weekly          map[string]any   `json:"weekly,omitempty"`
	Monthly         map[string]any   `json:"monthly,omitempty"`
	History         []map[string]any `json:"history,omitempty"`          // {date, net_value} terbaru dulu
	TopAccumulation []map[string]any `json:"top_accumulation,omitempty"` // {code,name,price,change,value}
	TopDistribution []map[string]any `json:"top_distribution,omitempty"`
}

MarketForeignFlowData is generated from the OpenAPI schema.

type MarketForeignFlowParams

type MarketForeignFlowParams struct {
	From   string `query:"from"`   // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`     // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketForeignFlowParams are the query parameters of GET /market/foreign-flow.

type MarketForeignFlowStocksDataItem

type MarketForeignFlowStocksDataItem struct {
	Code        string  `json:"code,omitempty"`
	ForeignBuy  float64 `json:"foreign_buy,omitempty"`  // Rp
	ForeignSell float64 `json:"foreign_sell,omitempty"` // Rp
	ForeignNet  float64 `json:"foreign_net,omitempty"`  // Rp
	Close       float64 `json:"close,omitempty"`
	ChangePct   float64 `json:"change_pct,omitempty"`
}

MarketForeignFlowStocksDataItem is generated from the OpenAPI schema.

type MarketForeignFlowStocksParams

type MarketForeignFlowStocksParams struct {
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	From   string `query:"from"`   // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`     // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Side   string `query:"side"`   // (all|accumulation|distribution)
	Sort   string `query:"sort"`   // (net|buy|sell)
	Order  string `query:"order"`  // Arah urutan (asc|desc)
	Limit  *int64 `query:"limit"`  // Baris per halaman
	Cursor string `query:"cursor"` // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketForeignFlowStocksParams are the query parameters of GET /market/foreign-flow/stocks.

type MarketMostActiveData

type MarketMostActiveData struct {
	Code       string  `json:"code,omitempty"` // Kode
	Last       float64 `json:"last,omitempty"` // Harga terakhir
	Prev       float64 `json:"prev,omitempty"` // Prev
	Change     float64 `json:"change,omitempty"`
	ChangePct  float64 `json:"change_pct,omitempty"`
	Open       float64 `json:"open,omitempty"`
	High       float64 `json:"high,omitempty"`
	Low        float64 `json:"low,omitempty"`
	VolumeLots int64   `json:"volume_lots,omitempty"`
	Value      float64 `json:"value,omitempty"`
	Freq       int64   `json:"freq,omitempty"`
}

MarketMostActiveData is generated from the OpenAPI schema.

type MarketMostActiveParams

type MarketMostActiveParams struct {
	By     string `query:"by"`     // (value|volume|freq|gainer|loser)
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Board  string `query:"board"`  // Papan perdagangan (RG|NG|TN|ALL)
	Limit  *int64 `query:"limit"`  // Jumlah baris
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketMostActiveParams are the query parameters of GET /market/most-active.

type MarketMoversData

type MarketMoversData struct {
	Gainers []map[string]any `json:"gainers,omitempty"` // Baris seperti most-active
	Losers  []map[string]any `json:"losers,omitempty"`
}

MarketMoversData is generated from the OpenAPI schema.

type MarketMoversParams

type MarketMoversParams struct {
	Date     string   `query:"date"`      // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Type     string   `query:"type"`      // (gainer|loser|both)
	MinValue *float64 `query:"min_value"` // Nilai transaksi minimal (Rp)
	Limit    *int64   `query:"limit"`     // Baris per sisi
	Fields   string   `query:"fields"`    // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketMoversParams are the query parameters of GET /market/movers.

type MarketNetFlowDataItem

type MarketNetFlowDataItem struct {
	Code         string  `json:"code,omitempty"`
	HakaValue    float64 `json:"haka_value,omitempty"`     // Nilai beli agresif (Rp)
	HakiValue    float64 `json:"haki_value,omitempty"`     // Nilai jual agresif (Rp)
	NetValue     float64 `json:"net_value,omitempty"`      // HAKA − HAKI
	AuctionValue float64 `json:"auction_value,omitempty"`  // Nilai lelang
	BigBuyCount  int64   `json:"big_buy_count,omitempty"`  // Jumlah Big Trade beli ≥ p99
	BigSellCount int64   `json:"big_sell_count,omitempty"` // Jumlah Big Trade jual ≥ p99
	P99Value     float64 `json:"p99_value,omitempty"`      // Ambang Big Trade p99 (Rp)
	Last         float64 `json:"last,omitempty"`
	ChangePct    float64 `json:"change_pct,omitempty"`
	LastTradeAt  string  `json:"last_trade_at,omitempty"`
}

MarketNetFlowDataItem is generated from the OpenAPI schema.

type MarketNetFlowParams

type MarketNetFlowParams struct {
	Date    string `query:"date"`    // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Symbols string `query:"symbols"` // Daftar kode saham dipisah koma
	Sort    string `query:"sort"`    // (net|haka|haki|big_net|value|change_pct)
	Order   string `query:"order"`   // Arah urutan (asc|desc)
	Limit   *int64 `query:"limit"`   // Baris per halaman
	Cursor  string `query:"cursor"`  // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields  string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketNetFlowParams are the query parameters of GET /market/net-flow.

type MarketPremarketAuctionData

type MarketPremarketAuctionData struct {
	Code      string  `json:"code,omitempty"`
	Iep       float64 `json:"iep,omitempty"`        // Harga indikatif
	IevLots   int64   `json:"iev_lots,omitempty"`   // Volume indikatif
	ChangePct float64 `json:"change_pct,omitempty"` // vs prev
	Value     float64 `json:"value,omitempty"`
}

MarketPremarketAuctionData is generated from the OpenAPI schema.

type MarketPremarketAuctionParams

type MarketPremarketAuctionParams struct {
	Date   string `query:"date"` // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Slot   string `query:"slot"` // Slot waktu pre-opening, mis. 08:59
	Limit  *int64 `query:"limit"`
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketPremarketAuctionParams are the query parameters of GET /market/premarket-auction.

type MarketScriplessDataItem

type MarketScriplessDataItem struct {
	ID               string  `json:"id,omitempty"`
	Code             string  `json:"code,omitempty"`
	EventDate        string  `json:"event_date,omitempty"`
	EventType        string  `json:"event_type,omitempty"`
	HolderType       string  `json:"holder_type,omitempty"` // Jenis pemegang (nama individu tidak dibuka)
	NewScriplessLots int64   `json:"new_scripless_lots,omitempty"`
	PctOutstanding   float64 `json:"pct_outstanding,omitempty"`
	EstimatedValue   float64 `json:"estimated_value,omitempty"` // Rp
	Magnitude        string  `json:"magnitude,omitempty"`
}

MarketScriplessDataItem is generated from the OpenAPI schema.

type MarketScriplessParams

type MarketScriplessParams struct {
	Date              string   `query:"date"`                // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	From              string   `query:"from"`                // Awal rentang (YYYY-MM-DD, inklusif)
	To                string   `query:"to"`                  // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Symbol            string   `query:"symbol"`              // Filter saham
	EventType         string   `query:"event_type"`          // Jenis event
	MinLots           *int64   `query:"min_lots"`            // Lot minimal
	MinPctOutstanding *float64 `query:"min_pct_outstanding"` // % saham beredar minimal
	OnlyConversions   *bool    `query:"only_conversions"`    // Hanya konversi
	Sort              string   `query:"sort"`                // (lot|pct_outstanding|value|date)
	Order             string   `query:"order"`               // Arah urutan (asc|desc)
	Limit             *int64   `query:"limit"`               // Baris per halaman
	Cursor            string   `query:"cursor"`              // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields            string   `query:"fields"`              // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketScriplessParams are the query parameters of GET /market/scripless.

type MarketScriplessTopData

type MarketScriplessTopData struct {
	Code  string  `json:"code,omitempty"`
	Value float64 `json:"value,omitempty"` // Nilai metrik
}

MarketScriplessTopData is generated from the OpenAPI schema.

type MarketScriplessTopParams

type MarketScriplessTopParams struct {
	Metric string `query:"metric"` // (lot|frequency|pct_outstanding|value)
	Period string `query:"period"` // (1D|7D|30D|3M|6M|YTD)
	Limit  *int64 `query:"limit"`
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

MarketScriplessTopParams are the query parameters of GET /market/scripless/top.

type MarketService

type MarketService struct {
	// contains filtered or unexported fields
}

MarketService groups the endpoints under /market.

func (*MarketService) Action

Action calls GET /market/action — Market Action: IHSG, breadth, tekanan

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) Bubbles

Bubbles calls GET /market/bubbles — Peta aliran dana (bubbles)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) EOD

EOD calls GET /market/eod — OHLCV seluruh saham satu tanggal

Satu halaman memuat ±1.000 saham, jadi seluruh pasar = 1 kredit.

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) EODIter

EODIter iterates every row of EOD across all pages (1 Kredit per page).

func (*MarketService) ExtremeResults

ExtremeResults calls GET /market/extreme-results — Kalender extreme results

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) Flow

Flow calls GET /market/flow — Market Flow: net agresi & net asing hari ini

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) ForeignFlow

ForeignFlow calls GET /market/foreign-flow — Aliran asing seluruh pasar

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) ForeignFlowStocks

ForeignFlowStocks calls GET /market/foreign-flow/stocks — Net asing per saham (semua saham)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) ForeignFlowStocksIter

ForeignFlowStocksIter iterates every row of ForeignFlowStocks across all pages (1 Kredit per page).

func (*MarketService) MostActive

MostActive calls GET /market/most-active — Saham teraktif

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) Movers

Movers calls GET /market/movers — Top gainers & losers

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) NetFlow

NetFlow calls GET /market/net-flow — HAKA/HAKI & Big Trade p99 seluruh saham

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) NetFlowIter

NetFlowIter iterates every row of NetFlow across all pages (1 Kredit per page).

func (*MarketService) PremarketAuction

PremarketAuction calls GET /market/premarket-auction — Pre-opening (IEP/IEV)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) Scripless

Scripless calls GET /market/scripless — Event konversi scripless

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*MarketService) ScriplessIter

ScriplessIter iterates every row of Scripless across all pages (1 Kredit per page).

func (*MarketService) ScriplessTop

ScriplessTop calls GET /market/scripless/top — Peringkat scripless

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

type MeService

type MeService struct {
	// contains filtered or unexported fields
}

MeService groups the endpoints under /me.

func (*MeService) Watchlist

func (s *MeService) Watchlist(ctx context.Context, params *MeWatchlistParams, opts ...RequestOption) (*Response[MeWatchlistData], error)

Watchlist calls GET /me/watchlist — Watchlist pribadi pemilik key

Hanya watchlist milik pemilik key. Tidak ada cara membaca watchlist akun lain.

**Kredit:** 0 kredit (tetap kena rate limit)

type MeWatchlistData

type MeWatchlistData struct {
	Symbols   []map[string]any `json:"symbols,omitempty"`    // Kode saham bertanda bintang
	UpdatedAt string           `json:"updated_at,omitempty"` // Terakhir diubah
}

MeWatchlistData is generated from the OpenAPI schema.

type MeWatchlistParams

type MeWatchlistParams struct {
}

MeWatchlistParams are the query parameters of GET /me/watchlist.

type Meta

type Meta struct {
	Symbol        string  `json:"symbol,omitempty"`
	Date          string  `json:"date,omitempty"`
	SessionStatus string  `json:"session_status,omitempty"`
	Limit         int64   `json:"limit,omitempty"`
	Returned      int64   `json:"returned,omitempty"`
	NextCursor    *string `json:"next_cursor,omitempty"`
	HasMore       *bool   `json:"has_more,omitempty"`
	SchemaVersion string  `json:"schema_version,omitempty"`
}

Meta is the response "meta" block.

func (Meta) Next

func (m Meta) Next() string

Next returns the cursor for the next page, or "" when there is none.

type Option

type Option func(*Client)

Option configures a Client.

func WithAPIKey

func WithAPIKey(k string) Option

WithAPIKey sets the API key (default: $PTB_API_KEY).

func WithBackoff

func WithBackoff(base, max time.Duration) Option

WithBackoff sets base and max backoff (default 500ms, 30s). Retry-After always wins.

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL overrides the base URL (default: $PTB_BASE_URL or DefaultBaseURL).

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient sets the underlying *http.Client (timeouts, proxies, transports).

func WithHeader

func WithHeader(k, v string) Option

WithHeader adds a header to every request.

func WithMaxRetries

func WithMaxRetries(n int) Option

WithMaxRetries sets retries for 202/429/5xx/network errors (default 3).

func WithUserAgent

func WithUserAgent(ua string) Option

WithUserAgent overrides the User-Agent.

type PicksHistoryDataItem

type PicksHistoryDataItem struct {
	ID         string  `json:"id,omitempty"`
	Code       string  `json:"code,omitempty"`
	Date       string  `json:"date,omitempty"`
	EntryPrice float64 `json:"entry_price,omitempty"`
	Result     string  `json:"result,omitempty"`
	ResultPct  float64 `json:"result_pct,omitempty"`
}

PicksHistoryDataItem is generated from the OpenAPI schema.

type PicksHistoryParams

type PicksHistoryParams struct {
	From   string `query:"from"`   // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`     // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Result string `query:"result"` // (all|win|loss|draw|open)
	Limit  *int64 `query:"limit"`  // Baris per halaman
	Cursor string `query:"cursor"` // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

PicksHistoryParams are the query parameters of GET /picks/history.

type PicksService

type PicksService struct {
	// contains filtered or unexported fields
}

PicksService groups the endpoints under /picks.

func (*PicksService) History

History calls GET /picks/history — Riwayat picks

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*PicksService) HistoryIter

HistoryIter iterates every row of History across all pages (1 Kredit per page).

func (*PicksService) Stats

Stats calls GET /picks/stats — Statistik picks

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*PicksService) Today

Today calls GET /picks/today — Picks hari ini

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

type PicksStatsData

type PicksStatsData struct {
	Total   int64   `json:"total,omitempty"`
	Win     int64   `json:"win,omitempty"`
	Loss    int64   `json:"loss,omitempty"`
	Draw    int64   `json:"draw,omitempty"`
	WinRate float64 `json:"win_rate,omitempty"`
}

PicksStatsData is generated from the OpenAPI schema.

type PicksStatsParams

type PicksStatsParams struct {
	Days   *int64 `query:"days"`
	Month  string `query:"month"`  // YYYY-MM
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

PicksStatsParams are the query parameters of GET /picks/stats.

type PicksTodayData

type PicksTodayData struct {
	ID           string         `json:"id,omitempty"`
	Code         string         `json:"code,omitempty"`
	Date         string         `json:"date,omitempty"`
	Description  string         `json:"description,omitempty"`
	Result       string         `json:"result,omitempty"`
	EntryPrice   float64        `json:"entry_price,omitempty"`
	Intraday     map[string]any `json:"intraday,omitempty"`      // {open, high, low, close, up_pct}
	MarketClosed bool           `json:"market_closed,omitempty"` // di meta
	Holiday      string         `json:"holiday,omitempty"`       // di meta
}

PicksTodayData is generated from the OpenAPI schema.

type PicksTodayParams

type PicksTodayParams struct {
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

PicksTodayParams are the query parameters of GET /picks/today.

type QuotaEstimateData

type QuotaEstimateData struct {
	TotalMax       int64  `json:"total_max,omitempty"`       // Jumlah biaya maksimal
	PricingVersion string `json:"pricing_version,omitempty"` // Versi tarif
}

QuotaEstimateData is generated from the OpenAPI schema.

type QuotaEstimateParams

type QuotaEstimateParams struct {
}

QuotaEstimateParams are the query parameters of POST /quota/estimate.

type QuotaService

type QuotaService struct {
	// contains filtered or unexported fields
}

QuotaService groups the endpoints under /quota.

func (*QuotaService) Estimate

func (s *QuotaService) Estimate(ctx context.Context, body any, params *QuotaEstimateParams, opts ...RequestOption) (*Response[QuotaEstimateData], error)

Estimate calls POST /quota/estimate — Perkiraan biaya sebelum menarik data

**Kredit:** 0 kredit (tetap kena rate limit)

type RadarAnomalyData

type RadarAnomalyData struct {
	Code            string  `json:"code,omitempty"`
	ChangePct       float64 `json:"change_pct,omitempty"`
	AggressionRatio float64 `json:"aggression_ratio,omitempty"`
	Turnover        float64 `json:"turnover,omitempty"`
	BigNetCount     int64   `json:"big_net_count,omitempty"`
}

RadarAnomalyData is generated from the OpenAPI schema.

type RadarAnomalyParams

type RadarAnomalyParams struct {
	Date         string   `query:"date"` // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Tab          string   `query:"tab"`  // (updist|downacc|bigsell|flat)
	MinChangePct *float64 `query:"min_change_pct"`
	MinRatio     *float64 `query:"min_ratio"`
	MinTurnover  *float64 `query:"min_turnover"`
	Limit        *int64   `query:"limit"`
	Fields       string   `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

RadarAnomalyParams are the query parameters of GET /radar/anomaly.

type RadarMarketData

type RadarMarketData struct {
	Code            string  `json:"code,omitempty"`
	ChangePct       float64 `json:"change_pct,omitempty"`
	AggressionRatio float64 `json:"aggression_ratio,omitempty"`
	DeltaValue      float64 `json:"delta_value,omitempty"`
	Turnover        float64 `json:"turnover,omitempty"`
	BigNetCount     int64   `json:"big_net_count,omitempty"`
}

RadarMarketData is generated from the OpenAPI schema.

type RadarMarketParams

type RadarMarketParams struct {
	Date         string   `query:"date"`           // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Tab          string   `query:"tab"`            // (acc|dist|mom|big)
	MinRatio     *float64 `query:"min_ratio"`      // Rasio agresi minimal (|delta/turnover|)
	MinTurnover  *float64 `query:"min_turnover"`   // Turnover minimal (Rp)
	MinChangePct *float64 `query:"min_change_pct"` // Untuk tab mom
	Limit        *int64   `query:"limit"`
	Fields       string   `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

RadarMarketParams are the query parameters of GET /radar/market.

type RadarService

type RadarService struct {
	// contains filtered or unexported fields
}

RadarService groups the endpoints under /radar.

func (*RadarService) Anomaly

Anomaly calls GET /radar/anomaly — Anomaly Radar: divergensi harga vs agresi

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*RadarService) Market

Market calls GET /radar/market — Market Radar: akumulasi/distribusi agresif

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*RadarService) Technical

Technical calls GET /radar/technical — Technical Radar untuk daftar saham

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

type RadarTechnicalData

type RadarTechnicalData struct {
	Code      string           `json:"code,omitempty"`
	ChangePct float64          `json:"change_pct,omitempty"`
	Trend     string           `json:"trend,omitempty"`
	RSI       float64          `json:"rsi,omitempty"`
	Signals   []map[string]any `json:"signals,omitempty"`
}

RadarTechnicalData is generated from the OpenAPI schema.

type RadarTechnicalParams

type RadarTechnicalParams struct {
	Symbols   string `query:"symbols"` // Required. Maks 50, dipisah koma
	Date      string `query:"date"`    // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	RSIPeriod *int64 `query:"rsi_period"`
	Fields    string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

RadarTechnicalParams are the query parameters of GET /radar/technical.

type RankingsService

type RankingsService struct {
	// contains filtered or unexported fields
}

RankingsService groups the endpoints under /rankings.

func (*RankingsService) TradeFlow

TradeFlow calls GET /rankings/trade-flow — Trade Flow Rankings

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

type RankingsTradeFlowData

type RankingsTradeFlowData struct {
	Rank            int64   `json:"rank,omitempty"`
	Code            string  `json:"code,omitempty"`
	AggressionRatio float64 `json:"aggression_ratio,omitempty"`
	DeltaValue      float64 `json:"delta_value,omitempty"`
	Turnover        float64 `json:"turnover,omitempty"`
	BigNetCount     int64   `json:"big_net_count,omitempty"`
}

RankingsTradeFlowData is generated from the OpenAPI schema.

type RankingsTradeFlowParams

type RankingsTradeFlowParams struct {
	Date        string   `query:"date"`         // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	By          string   `query:"by"`           // (ratio|net|turnover|big_net)
	Order       string   `query:"order"`        // Arah urutan (asc|desc)
	MinTurnover *float64 `query:"min_turnover"` // Untuk by=ratio
	Limit       *int64   `query:"limit"`
	Fields      string   `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

RankingsTradeFlowParams are the query parameters of GET /rankings/trade-flow.

type RateLimit

type RateLimit struct {
	Limit, Remaining, Reset *int64
}

RateLimit holds the RateLimit-* headers.

type ReferenceBrokersData

type ReferenceBrokersData struct {
	Code string `json:"code,omitempty"` // Kode broker
	Name string `json:"name,omitempty"` // Nama
	Type string `json:"type,omitempty"` // foreign|local
}

ReferenceBrokersData is generated from the OpenAPI schema.

type ReferenceBrokersParams

type ReferenceBrokersParams struct {
	Type string `query:"type"` // (all|foreign|local)
}

ReferenceBrokersParams are the query parameters of GET /reference/brokers.

type ReferenceCalendarData

type ReferenceCalendarData struct {
	Date    string `json:"date,omitempty"`    // Tanggal
	Trading bool   `json:"trading,omitempty"` // Hari bursa
	Holiday string `json:"holiday,omitempty"` // Nama libur bila ada
}

ReferenceCalendarData is generated from the OpenAPI schema.

type ReferenceCalendarParams

type ReferenceCalendarParams struct {
	From string `query:"from"` // Awal rentang (YYYY-MM-DD, inklusif)
	To   string `query:"to"`   // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
}

ReferenceCalendarParams are the query parameters of GET /reference/calendar.

type ReferenceIndicesData

type ReferenceIndicesData struct {
	Code string `json:"code,omitempty"` // Kode indeks
	Name string `json:"name,omitempty"` // Nama
}

ReferenceIndicesData is generated from the OpenAPI schema.

type ReferenceIndicesParams

type ReferenceIndicesParams struct {
}

ReferenceIndicesParams are the query parameters of GET /reference/indices.

type ReferenceSectorsData

type ReferenceSectorsData struct {
	Sector     string           `json:"sector,omitempty"`      // Sektor
	SubSectors []map[string]any `json:"sub_sectors,omitempty"` // Sub-sektor
}

ReferenceSectorsData is generated from the OpenAPI schema.

type ReferenceSectorsParams

type ReferenceSectorsParams struct {
}

ReferenceSectorsParams are the query parameters of GET /reference/sectors.

type ReferenceService

type ReferenceService struct {
	// contains filtered or unexported fields
}

ReferenceService groups the endpoints under /reference.

func (*ReferenceService) Brokers

Brokers calls GET /reference/brokers — Daftar broker

**Kredit:** 0 kredit (tetap kena rate limit)

func (*ReferenceService) Calendar

Calendar calls GET /reference/calendar — Kalender hari bursa

**Kredit:** 0 kredit (tetap kena rate limit)

func (*ReferenceService) Indices

Indices calls GET /reference/indices — Daftar indeks

**Kredit:** 0 kredit (tetap kena rate limit)

func (*ReferenceService) Sectors

Sectors calls GET /reference/sectors — Daftar sektor & sub-sektor

**Kredit:** 0 kredit (tetap kena rate limit)

func (*ReferenceService) Stocks

Stocks calls GET /reference/stocks — Daftar saham

**Kredit:** 0 kredit (tetap kena rate limit)

type ReferenceStocksData

type ReferenceStocksData struct {
	Code      string           `json:"code,omitempty"`       // Kode
	Name      string           `json:"name,omitempty"`       // Nama emiten
	Sector    string           `json:"sector,omitempty"`     // Sektor
	SubSector string           `json:"sub_sector,omitempty"` // Sub-sektor
	MarketCap float64          `json:"market_cap,omitempty"` // Kapitalisasi (Rp)
	LogoURL   string           `json:"logo_url,omitempty"`   // Logo
	Notations []map[string]any `json:"notations,omitempty"`  // Notasi khusus BEI
}

ReferenceStocksData is generated from the OpenAPI schema.

type ReferenceStocksParams

type ReferenceStocksParams struct {
	Search    string `query:"search"`     // Cari kode/nama
	Sector    string `query:"sector"`     // Filter sektor (lihat /reference/sectors)
	SubSector string `query:"sub_sector"` // Filter sub-sektor
	Sort      string `query:"sort"`       // (code_asc|change_pct_desc|change_pct_asc|value_desc|volume_desc)
	Limit     *int64 `query:"limit"`      // Baris per halaman
	Cursor    string `query:"cursor"`     // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
}

ReferenceStocksParams are the query parameters of GET /reference/stocks.

type RequestOption

type RequestOption func(*reqOpts)

RequestOption tunes a single call.

func IdempotencyKey

func IdempotencyKey(k string) RequestOption

IdempotencyKey sets the POST Idempotency-Key (generated automatically when omitted).

func IfNoneMatch

func IfNoneMatch(etag string) RequestOption

IfNoneMatch sends If-None-Match; a 304 costs 0 Kredit and sets Response.NotModified.

type Response

type Response[T any] struct {
	Data        T           `json:"data"`
	Meta        Meta        `json:"meta"`
	Billing     Billing     `json:"billing"`
	RequestID   string      `json:"request_id"`
	RateLimit   RateLimit   `json:"-"`
	ETag        string      `json:"-"`
	Status      int         `json:"-"`
	NotModified bool        `json:"-"`
	Header      http.Header `json:"-"`
}

Response is a decoded API response. Data is the zero value when NotModified (HTTP 304, 0 Kredit).

func Do

func Do[T any](c *Client, ctx context.Context, method, path string, query url.Values, body any, opts ...RequestOption) (*Response[T], error)

Do calls any /v1 path and decodes "data" into T (useful for endpoints newer than this SDK).

type ScreenersBrokerDataItem

type ScreenersBrokerDataItem struct {
	Symbol                  string           `json:"symbol,omitempty"`
	Days                    int64            `json:"days,omitempty"`
	Status                  string           `json:"status,omitempty"`
	BestBroker              string           `json:"best_broker,omitempty"`
	BestBrokerForeign       bool             `json:"best_broker_foreign,omitempty"`
	BestBrokerRelativeValue float64          `json:"best_broker_relative_value,omitempty"`
	TotalBuy                float64          `json:"total_buy,omitempty"`
	TotalSell               float64          `json:"total_sell,omitempty"`
	TotalDiff               float64          `json:"total_diff,omitempty"`
	Brokers                 []map[string]any `json:"brokers,omitempty"`
}

ScreenersBrokerDataItem is generated from the OpenAPI schema.

type ScreenersBrokerParams

type ScreenersBrokerParams struct {
	From        string `query:"from"`         // Awal rentang (YYYY-MM-DD, inklusif)
	To          string `query:"to"`           // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Range       string `query:"range"`        // Menimpa from/to (1M|3M|6M|YTD)
	ExtremeOnly *bool  `query:"extreme_only"` // Hanya daftar extreme
	Broker      string `query:"broker"`       // Filter broker terbaik
	Q           string `query:"q"`            // Cari kode saham/broker
	Sort        string `query:"sort"`         // (diff_value|relative_value|symbol)
	Order       string `query:"order"`        // Arah urutan (asc|desc)
	Limit       *int64 `query:"limit"`        // Baris per halaman
	Cursor      string `query:"cursor"`       // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields      string `query:"fields"`       // Kolom yang dikembalikan, dipisah koma. Default: semua
}

ScreenersBrokerParams are the query parameters of GET /screeners/broker.

type ScreenersService

type ScreenersService struct {
	// contains filtered or unexported fields
}

ScreenersService groups the endpoints under /screeners.

func (*ScreenersService) Broker

Broker calls GET /screeners/broker — Broker Screener (shark)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*ScreenersService) BrokerIter

BrokerIter iterates every row of Broker across all pages (1 Kredit per page).

type StocksService

type StocksService struct {
	// contains filtered or unexported fields
}

StocksService groups the endpoints under /stocks.

func (*StocksService) Auction

Auction calls GET /stocks/{symbol}/auction — Auction Hub: match pre-opening, pre-closing

**Kredit:** Sesi hari ini: 5 kredit per 1.000 trade yang belum dibayar (min 5). Sesi selesai: 1 kredit per halaman

func (*StocksService) BigTrades

BigTrades calls GET /stocks/{symbol}/big-trades — Big Trade

**Kredit:** Sesi hari ini: 5 kredit per 1.000 trade yang belum dibayar (min 5). Sesi selesai: 1 kredit per halaman

func (*StocksService) BigTradesIter

BigTradesIter iterates every row of BigTrades across all pages (1 Kredit per page).

func (*StocksService) BookEvents

BookEvents calls GET /stocks/{symbol}/book-events — Book events (wall ditarik, absorption)

**Kredit:** Sesi hari ini: 5 kredit per 1.000 trade yang belum dibayar (min 5). Sesi selesai: 1 kredit per halaman

func (*StocksService) BookEventsIter

BookEventsIter iterates every row of BookEvents across all pages (1 Kredit per page).

func (*StocksService) BrokersFlow

BrokersFlow calls GET /stocks/{symbol}/brokers/flow — Broker Flow: net per broker, fase, asing vs lokal

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) BrokersInventory

BrokersInventory calls GET /stocks/{symbol}/brokers/inventory — Inventori kumulatif broker (Stalker Inventori)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) BrokersInventoryIter

BrokersInventoryIter iterates every row of BrokersInventory across all pages (1 Kredit per page).

func (*StocksService) BrokersNetPosition

BrokersNetPosition calls GET /stocks/{symbol}/brokers/net-position — Posisi bersih broker per hari

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) BrokersNetPositionIter

BrokersNetPositionIter iterates every row of BrokersNetPosition across all pages (1 Kredit per page).

func (*StocksService) BrokersQuadrant

BrokersQuadrant calls GET /stocks/{symbol}/brokers/quadrant — Stock Quadrant: posisi tiap broker vs harga

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) BrokersSummary

BrokersSummary calls GET /stocks/{symbol}/brokers/summary — Broker summary

Hanya sesi yang sudah selesai (kode broker tidak dibuka saat sesi berjalan). Rentang maks 366 hari.

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) CorporateActions

CorporateActions calls GET /stocks/{symbol}/corporate-actions — Aksi korporasi

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) CorporateActionsIter

CorporateActionsIter iterates every row of CorporateActions across all pages (1 Kredit per page).

func (*StocksService) FlowSummary

FlowSummary calls GET /stocks/{symbol}/flow-summary — Ringkasan flow: HAKA, HAKI, net, Big Trade

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) ForeignFlow

ForeignFlow calls GET /stocks/{symbol}/foreign-flow — Aliran asing satu saham

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) ForeignFlowIter

ForeignFlowIter iterates every row of ForeignFlow across all pages (1 Kredit per page).

func (*StocksService) Heatmap

Heatmap calls GET /stocks/{symbol}/heatmap — Heatmap order book per kolom waktu

**Kredit:** Sesi hari ini: 5 kredit per menit yang belum dibayar per saham. Sesi selesai: 1 kredit per halaman

func (*StocksService) HeatmapIter

HeatmapIter iterates every row of Heatmap across all pages (1 Kredit per page).

func (*StocksService) Ohlcv

Ohlcv calls GET /stocks/{symbol}/ohlcv — Candle harian / intraday

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) OhlcvIter

OhlcvIter iterates every row of Ohlcv across all pages (1 Kredit per page).

func (*StocksService) Orderbook

Orderbook calls GET /stocks/{symbol}/orderbook — Order book terkini (snapshot)

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) Orderflow

Orderflow calls GET /stocks/{symbol}/orderflow — Bar order flow: delta, CVD, VWAP, POC, footprint

**Kredit:** Sesi hari ini: 5 kredit per 1.000 trade yang belum dibayar (min 5). Sesi selesai: 1 kredit per halaman

func (*StocksService) OrderflowIter

OrderflowIter iterates every row of Orderflow across all pages (1 Kredit per page).

func (*StocksService) Performance

Performance calls GET /stocks/{symbol}/performance — Return beberapa periode

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) Pressure

Pressure calls GET /stocks/{symbol}/pressure — Buy/Sell Pressure per menit

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) PressureIter

PressureIter iterates every row of Pressure across all pages (1 Kredit per page).

func (*StocksService) Profile

Profile calls GET /stocks/{symbol}/profile — Profil emiten

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) Quote

Quote calls GET /stocks/{symbol}/quote — Harga & statistik terkini

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) Scripless

Scripless calls GET /stocks/{symbol}/scripless — Riwayat scripless satu saham

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) ScriplessIter

ScriplessIter iterates every row of Scripless across all pages (1 Kredit per page).

func (*StocksService) Technical

Technical calls GET /stocks/{symbol}/technical — Technical Reading: tren, indikator, S/R, sinyal

**Kredit:** 1 kredit per hit; untuk daftar: 1 kredit per halaman (maks 1.000 baris)

func (*StocksService) Trades

Trades calls GET /stocks/{symbol}/trades — Done trade

Selama sesi berjalan, kode broker disembunyikan.

**Kredit:** Sesi hari ini: 5 kredit per 1.000 trade yang belum dibayar (min 5). Sesi selesai: 1 kredit per halaman

func (*StocksService) TradesIter

TradesIter iterates every row of Trades across all pages (1 Kredit per page).

func (*StocksService) TradesSummary

TradesSummary calls GET /stocks/{symbol}/trades/summary — Done Summary: lot HAKA/HAKI per harga

**Kredit:** Sesi hari ini: 5 kredit per 1.000 trade yang belum dibayar (min 5). Sesi selesai: 1 kredit per halaman

func (*StocksService) VolumeProfile

VolumeProfile calls GET /stocks/{symbol}/volume-profile — Volume profile: POC, VAH, VAL, HVN, LVN

**Kredit:** Sesi hari ini: 5 kredit per 1.000 trade yang belum dibayar (min 5). Sesi selesai: 1 kredit per halaman

func (*StocksService) VolumeProfileIter

VolumeProfileIter iterates every row of VolumeProfile across all pages (1 Kredit per page).

type StocksSymbolAuctionData

type StocksSymbolAuctionData struct {
	Matches []map[string]any `json:"matches,omitempty"` // {phase, time, price, lots, value, trades}
}

StocksSymbolAuctionData is generated from the OpenAPI schema.

type StocksSymbolAuctionParams

type StocksSymbolAuctionParams struct {
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolAuctionParams are the query parameters of GET /stocks/{symbol}/auction.

type StocksSymbolBigTradesDataItem

type StocksSymbolBigTradesDataItem struct {
	Time        string         `json:"time,omitempty"`
	Side        string         `json:"side,omitempty"`
	Price       float64        `json:"price,omitempty"` // VWAP order
	PriceMin    float64        `json:"price_min,omitempty"`
	PriceMax    float64        `json:"price_max,omitempty"`
	Lots        int64          `json:"lots,omitempty"`
	Value       float64        `json:"value,omitempty"`
	Fills       int64          `json:"fills,omitempty"`       // Jumlah trade penyusun
	Broker      string         `json:"broker,omitempty"`      // Hanya sesi selesai
	Percentiles map[string]any `json:"percentiles,omitempty"` // p80..p99 (di meta)
}

StocksSymbolBigTradesDataItem is generated from the OpenAPI schema.

type StocksSymbolBigTradesParams

type StocksSymbolBigTradesParams struct {
	Date       string   `query:"date"`       // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Percentile string   `query:"percentile"` // (p80|p90|p95|p99)
	MinValue   *float64 `query:"min_value"`  // Menimpa percentile bila diisi (Rp)
	Side       string   `query:"side"`       // (all|buy|sell)
	FromTime   string   `query:"from_time"`  // Jam mulai dalam sesi, WIB (HH:MM[:SS])
	ToTime     string   `query:"to_time"`    // Jam akhir dalam sesi, WIB (HH:MM[:SS])
	Limit      *int64   `query:"limit"`      // Baris per halaman
	Cursor     string   `query:"cursor"`     // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields     string   `query:"fields"`     // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolBigTradesParams are the query parameters of GET /stocks/{symbol}/big-trades.

type StocksSymbolBookEventsDataItem

type StocksSymbolBookEventsDataItem struct {
	Time     string  `json:"time,omitempty"`
	Kind     string  `json:"kind,omitempty"`
	Side     string  `json:"side,omitempty"`
	Price    float64 `json:"price,omitempty"`
	LotsFrom int64   `json:"lots_from,omitempty"`
	LotsTo   int64   `json:"lots_to,omitempty"`
	Wall     bool    `json:"wall,omitempty"`
}

StocksSymbolBookEventsDataItem is generated from the OpenAPI schema.

type StocksSymbolBookEventsParams

type StocksSymbolBookEventsParams struct {
	Date       string `query:"date"`       // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Percentile *int64 `query:"percentile"` // (80|90|95|99)
	MinDrop    *int64 `query:"min_drop"`   // % penurunan minimal (30|50|70)
	Side       string `query:"side"`       // (all|bid|ask)
	FromTime   string `query:"from_time"`  // Jam mulai dalam sesi, WIB (HH:MM[:SS])
	ToTime     string `query:"to_time"`    // Jam akhir dalam sesi, WIB (HH:MM[:SS])
	Limit      *int64 `query:"limit"`      // Baris per halaman
	Cursor     string `query:"cursor"`     // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields     string `query:"fields"`     // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolBookEventsParams are the query parameters of GET /stocks/{symbol}/book-events.

type StocksSymbolBrokersFlowData

type StocksSymbolBrokersFlowData struct {
	Phase      string           `json:"phase,omitempty"`
	ForeignNet float64          `json:"foreign_net,omitempty"`
	LocalNet   float64          `json:"local_net,omitempty"`
	TopBuy     []map[string]any `json:"top_buy,omitempty"`
	TopSell    []map[string]any `json:"top_sell,omitempty"`
}

StocksSymbolBrokersFlowData is generated from the OpenAPI schema.

type StocksSymbolBrokersFlowParams

type StocksSymbolBrokersFlowParams struct {
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Period string `query:"period"` // Periode relatif; diabaikan bila from/to diisi (1d|5d|1m|3m|6m|ytd|1y)
	From   string `query:"from"`   // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`     // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Top    *int64 `query:"top"`
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolBrokersFlowParams are the query parameters of GET /stocks/{symbol}/brokers/flow.

type StocksSymbolBrokersInventoryDataItem

type StocksSymbolBrokersInventoryDataItem struct {
	Date   string         `json:"date,omitempty"`
	Series map[string]any `json:"series,omitempty"` // {broker_or_group: cumulative_net}
}

StocksSymbolBrokersInventoryDataItem is generated from the OpenAPI schema.

type StocksSymbolBrokersInventoryParams

type StocksSymbolBrokersInventoryParams struct {
	Period  string `query:"period"`  // Periode relatif; diabaikan bila from/to diisi (1d|5d|1m|3m|6m|ytd|1y)
	From    string `query:"from"`    // Awal rentang (YYYY-MM-DD, inklusif)
	To      string `query:"to"`      // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Mode    string `query:"mode"`    // (broker|group)
	Top     *int64 `query:"top"`     // Net buyer & seller teratas
	Brokers string `query:"brokers"` // Paksa broker tertentu, dipisah koma
	Limit   *int64 `query:"limit"`   // Baris per halaman
	Cursor  string `query:"cursor"`  // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields  string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolBrokersInventoryParams are the query parameters of GET /stocks/{symbol}/brokers/inventory.

type StocksSymbolBrokersNetPositionDataItem

type StocksSymbolBrokersNetPositionDataItem struct {
	Date      string  `json:"date,omitempty"`
	Broker    string  `json:"broker,omitempty"`
	BuyValue  float64 `json:"buy_value,omitempty"`
	SellValue float64 `json:"sell_value,omitempty"`
	NetValue  float64 `json:"net_value,omitempty"`
	BuyAvg    float64 `json:"buy_avg,omitempty"`
	SellAvg   float64 `json:"sell_avg,omitempty"`
	Group     string  `json:"group,omitempty"` // shark|retail
}

StocksSymbolBrokersNetPositionDataItem is generated from the OpenAPI schema.

type StocksSymbolBrokersNetPositionParams

type StocksSymbolBrokersNetPositionParams struct {
	From    string `query:"from"`    // Awal rentang (YYYY-MM-DD, inklusif)
	To      string `query:"to"`      // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Period  string `query:"period"`  // Periode relatif; diabaikan bila from/to diisi (1d|5d|1m|3m|6m|ytd|1y)
	Brokers string `query:"brokers"` // Dipisah koma
	Group   string `query:"group"`   // (all|shark|retail)
	Limit   *int64 `query:"limit"`   // Baris per halaman
	Cursor  string `query:"cursor"`  // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields  string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolBrokersNetPositionParams are the query parameters of GET /stocks/{symbol}/brokers/net-position.

type StocksSymbolBrokersQuadrantData

type StocksSymbolBrokersQuadrantData struct {
	Price   float64          `json:"price,omitempty"`   // Harga acuan
	Brokers []map[string]any `json:"brokers,omitempty"` // {broker, net_value, avg_price, distance_pct, group}
}

StocksSymbolBrokersQuadrantData is generated from the OpenAPI schema.

type StocksSymbolBrokersQuadrantParams

type StocksSymbolBrokersQuadrantParams struct {
	Period string `query:"period"` // (1d|5d|1m|3m|6m)
	Who    string `query:"who"`    // (all|shark|retail)
	Top    *int64 `query:"top"`
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolBrokersQuadrantParams are the query parameters of GET /stocks/{symbol}/brokers/quadrant.

type StocksSymbolBrokersSummaryData

type StocksSymbolBrokersSummaryData struct {
	Phase      string           `json:"phase,omitempty"` // AKUMULASI|DISTRIBUSI|NETRAL
	TotalValue float64          `json:"total_value,omitempty"`
	Buyers     int64            `json:"buyers,omitempty"`
	Sellers    int64            `json:"sellers,omitempty"`
	TopBuy     []map[string]any `json:"top_buy,omitempty"` // {broker, name, net_value, lots, avg_price, is_foreign, buy_value, sell_value}
	TopSell    []map[string]any `json:"top_sell,omitempty"`
}

StocksSymbolBrokersSummaryData is generated from the OpenAPI schema.

type StocksSymbolBrokersSummaryParams

type StocksSymbolBrokersSummaryParams struct {
	Period   string `query:"period"`   // Periode relatif; diabaikan bila from/to diisi (1d|5d|1m|3m|6m|ytd|1y)
	From     string `query:"from"`     // Awal rentang (YYYY-MM-DD, inklusif)
	To       string `query:"to"`       // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Investor string `query:"investor"` // (all|foreign|domestic)
	Brokers  string `query:"brokers"`  // Filter kode broker dipisah koma
	Side     string `query:"side"`     // (both|buy|sell)
	Top      *int64 `query:"top"`      // Jumlah broker per sisi (0 = semua)
	GroupBy  string `query:"group_by"` // (broker|date)
	Fields   string `query:"fields"`   // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolBrokersSummaryParams are the query parameters of GET /stocks/{symbol}/brokers/summary.

type StocksSymbolCorporateActionsDataItem

type StocksSymbolCorporateActionsDataItem struct {
	ID          string         `json:"id,omitempty"`
	Type        string         `json:"type,omitempty"`
	Stage       string         `json:"stage,omitempty"`
	Title       string         `json:"title,omitempty"`
	AnnouncedAt string         `json:"announced_at,omitempty"`
	EffectiveAt string         `json:"effective_at,omitempty"`
	Details     map[string]any `json:"details,omitempty"`
}

StocksSymbolCorporateActionsDataItem is generated from the OpenAPI schema.

type StocksSymbolCorporateActionsParams

type StocksSymbolCorporateActionsParams struct {
	Type   string `query:"type"`   // Jenis (dividen, rights, split, RUPS, ...)
	Stage  string `query:"stage"`  // Tahap
	From   string `query:"from"`   // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`     // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Sort   string `query:"sort"`   // (announced|effective|type)
	Order  string `query:"order"`  // Arah urutan (asc|desc)
	Limit  *int64 `query:"limit"`  // Baris per halaman
	Cursor string `query:"cursor"` // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolCorporateActionsParams are the query parameters of GET /stocks/{symbol}/corporate-actions.

type StocksSymbolFlowSummaryData

type StocksSymbolFlowSummaryData struct {
	HakaValue    float64 `json:"haka_value,omitempty"`
	HakiValue    float64 `json:"haki_value,omitempty"`
	NetValue     float64 `json:"net_value,omitempty"`
	BuyPct       float64 `json:"buy_pct,omitempty"` // HAKA/(HAKA+HAKI)
	BigBuyCount  int64   `json:"big_buy_count,omitempty"`
	BigSellCount int64   `json:"big_sell_count,omitempty"`
	BigNetCount  int64   `json:"big_net_count,omitempty"`
	P99Value     float64 `json:"p99_value,omitempty"`
}

StocksSymbolFlowSummaryData is generated from the OpenAPI schema.

type StocksSymbolFlowSummaryParams

type StocksSymbolFlowSummaryParams struct {
	Date   string `query:"date"`   // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolFlowSummaryParams are the query parameters of GET /stocks/{symbol}/flow-summary.

type StocksSymbolForeignFlowDataItem

type StocksSymbolForeignFlowDataItem struct {
	Date          string  `json:"date,omitempty"`
	ForeignBuy    float64 `json:"foreign_buy,omitempty"`
	ForeignSell   float64 `json:"foreign_sell,omitempty"`
	ForeignNet    float64 `json:"foreign_net,omitempty"`
	CumulativeNet float64 `json:"cumulative_net,omitempty"`
	Phase         string  `json:"phase,omitempty"` // AKUMULASI|DISTRIBUSI|NETRAL (di meta)
}

StocksSymbolForeignFlowDataItem is generated from the OpenAPI schema.

type StocksSymbolForeignFlowParams

type StocksSymbolForeignFlowParams struct {
	From   string `query:"from"`   // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`     // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Period string `query:"period"` // Periode relatif; diabaikan bila from/to diisi (1d|5d|1m|3m|6m|ytd|1y)
	Limit  *int64 `query:"limit"`  // Baris per halaman
	Cursor string `query:"cursor"` // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolForeignFlowParams are the query parameters of GET /stocks/{symbol}/foreign-flow.

type StocksSymbolHeatmapDataItem

type StocksSymbolHeatmapDataItem struct {
	Time string           `json:"time,omitempty"` // Kolom
	Bids []map[string]any `json:"bids,omitempty"` // {price, lots}
	Asks []map[string]any `json:"asks,omitempty"`
}

StocksSymbolHeatmapDataItem is generated from the OpenAPI schema.

type StocksSymbolHeatmapParams

type StocksSymbolHeatmapParams struct {
	Date     string `query:"date"`      // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Step     *int64 `query:"step"`      // Lebar kolom (detik)
	FromTime string `query:"from_time"` // Jam mulai dalam sesi, WIB (HH:MM[:SS])
	ToTime   string `query:"to_time"`   // Jam akhir dalam sesi, WIB (HH:MM[:SS])
	Depth    *int64 `query:"depth"`     // Level per sisi
	Limit    *int64 `query:"limit"`     // Baris per halaman
	Cursor   string `query:"cursor"`    // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields   string `query:"fields"`    // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolHeatmapParams are the query parameters of GET /stocks/{symbol}/heatmap.

type StocksSymbolOhlcvDataItem

type StocksSymbolOhlcvDataItem struct {
	Time        string  `json:"time,omitempty"`
	Open        float64 `json:"open,omitempty"`
	High        float64 `json:"high,omitempty"`
	Low         float64 `json:"low,omitempty"`
	Close       float64 `json:"close,omitempty"`
	VolumeLots  int64   `json:"volume_lots,omitempty"`
	Value       float64 `json:"value,omitempty"`
	Freq        int64   `json:"freq,omitempty"`
	ForeignBuy  float64 `json:"foreign_buy,omitempty"`  // Hanya 1d
	ForeignSell float64 `json:"foreign_sell,omitempty"` // Hanya 1d
}

StocksSymbolOhlcvDataItem is generated from the OpenAPI schema.

type StocksSymbolOhlcvParams

type StocksSymbolOhlcvParams struct {
	Interval string `query:"interval"` // (1m|5m|15m|30m|1h|1d|1w|1mo)
	From     string `query:"from"`     // Awal rentang (YYYY-MM-DD, inklusif)
	To       string `query:"to"`       // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Board    string `query:"board"`    // Papan perdagangan (RG|NG|TN|ALL)
	Limit    *int64 `query:"limit"`    // Baris per halaman
	Cursor   string `query:"cursor"`   // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields   string `query:"fields"`   // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolOhlcvParams are the query parameters of GET /stocks/{symbol}/ohlcv.

type StocksSymbolOrderbookData

type StocksSymbolOrderbookData struct {
	Bids []map[string]any `json:"bids,omitempty"` // {price, lots, orders}
	Asks []map[string]any `json:"asks,omitempty"`
	AsOf string           `json:"as_of,omitempty"`
	Ohlc map[string]any   `json:"ohlc,omitempty"`
}

StocksSymbolOrderbookData is generated from the OpenAPI schema.

type StocksSymbolOrderbookParams

type StocksSymbolOrderbookParams struct {
	Depth  *int64 `query:"depth"`  // Level per sisi
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolOrderbookParams are the query parameters of GET /stocks/{symbol}/orderbook.

type StocksSymbolOrderflowDataItem

type StocksSymbolOrderflowDataItem struct {
	Time        string           `json:"time,omitempty"` // Awal bar
	Open        float64          `json:"open,omitempty"`
	High        float64          `json:"high,omitempty"`
	Low         float64          `json:"low,omitempty"`
	Close       float64          `json:"close,omitempty"`
	Lots        int64            `json:"lots,omitempty"`
	Value       float64          `json:"value,omitempty"`
	Trades      int64            `json:"trades,omitempty"`
	BuyLots     int64            `json:"buy_lots,omitempty"`
	SellLots    int64            `json:"sell_lots,omitempty"`
	UnknownLots int64            `json:"unknown_lots,omitempty"`
	Delta       int64            `json:"delta,omitempty"`
	DeltaPct    float64          `json:"delta_pct,omitempty"`
	CVD         int64            `json:"cvd,omitempty"`
	VWAP        float64          `json:"vwap,omitempty"`
	POC         float64          `json:"poc,omitempty"`
	Rvol        float64          `json:"rvol,omitempty"`
	Footprint   []map[string]any `json:"footprint,omitempty"` // {price, buy_lots, sell_lots, delta, trades, imbalance, stacked}
	Big         []map[string]any `json:"big,omitempty"`       // {time, price, lots, value, side}
	Signals     []map[string]any `json:"signals,omitempty"`
}

StocksSymbolOrderflowDataItem is generated from the OpenAPI schema.

type StocksSymbolOrderflowParams

type StocksSymbolOrderflowParams struct {
	Date     string `query:"date"`      // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Tf       string `query:"tf"`        // (1s|5s|10s|30s|1m|3m|5m|15m|30m|1H|1D)
	Days     *int64 `query:"days"`      // Jumlah sesi ke belakang (dibatasi per tf)
	FromTime string `query:"from_time"` // Jam mulai dalam sesi, WIB (HH:MM[:SS])
	ToTime   string `query:"to_time"`   // Jam akhir dalam sesi, WIB (HH:MM[:SS])
	Include  string `query:"include"`   // ohlc, delta, cvd, vwap, poc, rvol, band, footprint, big, signals, clusters
	Big      string `query:"big"`       // Ambang Big Trade: auto, p99, p95, p90, p80, atau nilai Rp minimal
	Limit    *int64 `query:"limit"`     // Baris per halaman
	Cursor   string `query:"cursor"`    // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields   string `query:"fields"`    // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolOrderflowParams are the query parameters of GET /stocks/{symbol}/orderflow.

type StocksSymbolPerformanceData

type StocksSymbolPerformanceData struct {
	Returns map[string]any `json:"returns,omitempty"` // {1d: %, 1w: %, ...}
	Close   float64        `json:"close,omitempty"`
	AsOf    string         `json:"as_of,omitempty"`
}

StocksSymbolPerformanceData is generated from the OpenAPI schema.

type StocksSymbolPerformanceParams

type StocksSymbolPerformanceParams struct {
	Date    string `query:"date"`    // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Periods string `query:"periods"` // Dipisah koma
	Fields  string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolPerformanceParams are the query parameters of GET /stocks/{symbol}/performance.

type StocksSymbolPressureDataItem

type StocksSymbolPressureDataItem struct {
	Time      string  `json:"time,omitempty"`
	BuyValue  float64 `json:"buy_value,omitempty"`
	SellValue float64 `json:"sell_value,omitempty"`
	BuyPct    float64 `json:"buy_pct,omitempty"`
}

StocksSymbolPressureDataItem is generated from the OpenAPI schema.

type StocksSymbolPressureParams

type StocksSymbolPressureParams struct {
	Date     string `query:"date"`     // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Interval string `query:"interval"` // (1m|5m|15m)
	Limit    *int64 `query:"limit"`    // Baris per halaman
	Cursor   string `query:"cursor"`   // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields   string `query:"fields"`   // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolPressureParams are the query parameters of GET /stocks/{symbol}/pressure.

type StocksSymbolProfileData

type StocksSymbolProfileData struct {
	Code          string           `json:"code,omitempty"`
	Name          string           `json:"name,omitempty"`
	Sector        string           `json:"sector,omitempty"`
	Board         string           `json:"board,omitempty"`
	ListingDate   string           `json:"listing_date,omitempty"`
	Address       string           `json:"address,omitempty"`
	Website       string           `json:"website,omitempty"`
	Commissioners []map[string]any `json:"commissioners,omitempty"`
	Directors     []map[string]any `json:"directors,omitempty"`
	Shareholders  []map[string]any `json:"shareholders,omitempty"`
	Subsidiaries  []map[string]any `json:"subsidiaries,omitempty"`
	Notations     []map[string]any `json:"notations,omitempty"` // Notasi khusus BEI
}

StocksSymbolProfileData is generated from the OpenAPI schema.

type StocksSymbolProfileParams

type StocksSymbolProfileParams struct {
	Include string `query:"include"` // Bagian yang disertakan, dipisah koma
	Fields  string `query:"fields"`  // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolProfileParams are the query parameters of GET /stocks/{symbol}/profile.

type StocksSymbolQuoteData

type StocksSymbolQuoteData struct {
	Last       float64 `json:"last,omitempty"`
	Prev       float64 `json:"prev,omitempty"`
	Open       float64 `json:"open,omitempty"`
	High       float64 `json:"high,omitempty"`
	Low        float64 `json:"low,omitempty"`
	ChangePct  float64 `json:"change_pct,omitempty"`
	VolumeLots int64   `json:"volume_lots,omitempty"`
	Value      float64 `json:"value,omitempty"`
	Freq       int64   `json:"freq,omitempty"`
	VWAP       float64 `json:"vwap,omitempty"`
	Phase      string  `json:"phase,omitempty"`
	AsOf       string  `json:"as_of,omitempty"`
}

StocksSymbolQuoteData is generated from the OpenAPI schema.

type StocksSymbolQuoteParams

type StocksSymbolQuoteParams struct {
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolQuoteParams are the query parameters of GET /stocks/{symbol}/quote.

type StocksSymbolScriplessDataItem

type StocksSymbolScriplessDataItem struct {
	Date                string  `json:"date,omitempty"`
	EventCount          int64   `json:"event_count,omitempty"`
	NewScriplessLots    int64   `json:"new_scripless_lots,omitempty"`
	PctOutstandingTotal float64 `json:"pct_outstanding_total,omitempty"`
}

StocksSymbolScriplessDataItem is generated from the OpenAPI schema.

type StocksSymbolScriplessParams

type StocksSymbolScriplessParams struct {
	View   string `query:"view"`   // (daily|monthly|events)
	From   string `query:"from"`   // Awal rentang (YYYY-MM-DD, inklusif)
	To     string `query:"to"`     // Akhir rentang (YYYY-MM-DD, inklusif). Default: sesi terakhir
	Limit  *int64 `query:"limit"`  // Baris per halaman
	Cursor string `query:"cursor"` // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields string `query:"fields"` // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolScriplessParams are the query parameters of GET /stocks/{symbol}/scripless.

type StocksSymbolTechnicalData

type StocksSymbolTechnicalData struct {
	Trend             string           `json:"trend,omitempty"` // uptrend|downtrend|sideways
	RSI               float64          `json:"rsi,omitempty"`
	MACD              map[string]any   `json:"macd,omitempty"`               // {macd, signal, hist}
	SMA               map[string]any   `json:"sma,omitempty"`                // {20: .., 50: ..}
	SupportResistance map[string]any   `json:"support_resistance,omitempty"` // {pivot, s1, s2, s3, r1, r2, r3}
	Signals           []map[string]any `json:"signals,omitempty"`            // golden_cross, death_cross, rsi_overbought, rsi_oversold, macd_cross_up, macd_cross_down
	Series            []map[string]any `json:"series,omitempty"`             // Bila series=true
}

StocksSymbolTechnicalData is generated from the OpenAPI schema.

type StocksSymbolTechnicalParams

type StocksSymbolTechnicalParams struct {
	Date       string `query:"date"`       // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Indicators string `query:"indicators"` // rsi, macd, sma, ema, bb (dipisah koma)
	RSIPeriod  *int64 `query:"rsi_period"`
	MACD       string `query:"macd"`     // fast,slow,signal
	SMA        string `query:"sma"`      // Periode SMA dipisah koma
	EMA        string `query:"ema"`      // Periode EMA dipisah koma
	Series     *bool  `query:"series"`   // Sertakan deret indikator per hari
	Lookback   *int64 `query:"lookback"` // Hari untuk deret
	Fields     string `query:"fields"`   // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolTechnicalParams are the query parameters of GET /stocks/{symbol}/technical.

type StocksSymbolTradesDataItem

type StocksSymbolTradesDataItem struct {
	Seq        int64   `json:"seq,omitempty"` // Nomor urut trade dalam sesi
	Time       string  `json:"time,omitempty"`
	Price      float64 `json:"price,omitempty"`
	Lots       int64   `json:"lots,omitempty"`
	Value      float64 `json:"value,omitempty"`
	Side       string  `json:"side,omitempty"`       // buy|sell|auction|unknown
	Buyer      string  `json:"buyer,omitempty"`      // Hanya sesi selesai
	Seller     string  `json:"seller,omitempty"`     // Hanya sesi selesai
	BuyerType  string  `json:"buyer_type,omitempty"` // foreign|domestic
	SellerType string  `json:"seller_type,omitempty"`
}

StocksSymbolTradesDataItem is generated from the OpenAPI schema.

type StocksSymbolTradesParams

type StocksSymbolTradesParams struct {
	Date      string   `query:"date"`      // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Side      string   `query:"side"`      // (all|buy|sell|auction)
	FromTime  string   `query:"from_time"` // Jam mulai dalam sesi, WIB (HH:MM[:SS])
	ToTime    string   `query:"to_time"`   // Jam akhir dalam sesi, WIB (HH:MM[:SS])
	MinValue  *float64 `query:"min_value"` // Nilai minimal (Rp)
	MinLots   *int64   `query:"min_lots"`  // Lot minimal
	PriceFrom *float64 `query:"price_from"`
	PriceTo   *float64 `query:"price_to"`
	Broker    string   `query:"broker"`   // Kode broker (hanya sesi selesai)
	Investor  string   `query:"investor"` // Hanya sesi selesai (all|foreign|domestic)
	Board     string   `query:"board"`    // Papan perdagangan (RG|NG|TN|ALL)
	Sort      string   `query:"sort"`     // (time_asc|time_desc)
	Limit     *int64   `query:"limit"`    // Baris per halaman
	Cursor    string   `query:"cursor"`   // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields    string   `query:"fields"`   // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolTradesParams are the query parameters of GET /stocks/{symbol}/trades.

type StocksSymbolTradesSummaryData

type StocksSymbolTradesSummaryData struct {
	Price     float64        `json:"price,omitempty"`
	BuyLots   int64          `json:"buy_lots,omitempty"`
	SellLots  int64          `json:"sell_lots,omitempty"`
	NetLots   int64          `json:"net_lots,omitempty"`
	Trades    int64          `json:"trades,omitempty"`
	Investors map[string]any `json:"investors,omitempty"` // Sesi selesai: {foreign_buy, foreign_sell, domestic_buy, domestic_sell}
}

StocksSymbolTradesSummaryData is generated from the OpenAPI schema.

type StocksSymbolTradesSummaryParams

type StocksSymbolTradesSummaryParams struct {
	Date     string `query:"date"`      // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	FromTime string `query:"from_time"` // Jam mulai dalam sesi, WIB (HH:MM[:SS])
	ToTime   string `query:"to_time"`   // Jam akhir dalam sesi, WIB (HH:MM[:SS])
	Fields   string `query:"fields"`    // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolTradesSummaryParams are the query parameters of GET /stocks/{symbol}/trades/summary.

type StocksSymbolVolumeProfileDataItem

type StocksSymbolVolumeProfileDataItem struct {
	POC    float64          `json:"poc,omitempty"`
	Vah    float64          `json:"vah,omitempty"`
	Val    float64          `json:"val,omitempty"`
	Hvn    []map[string]any `json:"hvn,omitempty"`
	Lvn    []map[string]any `json:"lvn,omitempty"`
	Levels []map[string]any `json:"levels,omitempty"` // {price, lots, buy_lots, sell_lots, delta, pct, tag}
}

StocksSymbolVolumeProfileDataItem is generated from the OpenAPI schema.

type StocksSymbolVolumeProfileParams

type StocksSymbolVolumeProfileParams struct {
	Date      string   `query:"date"`       // Tanggal sesi WIB (YYYY-MM-DD). Default: sesi terakhir/hari ini
	Mode      string   `query:"mode"`       // (session|previous|composite)
	Days      *int64   `query:"days"`       // Sesi untuk composite (5|20|60|90)
	ValueArea *float64 `query:"value_area"` // Porsi value area
	FromTime  string   `query:"from_time"`  // Jam mulai dalam sesi, WIB (HH:MM[:SS])
	ToTime    string   `query:"to_time"`    // Jam akhir dalam sesi, WIB (HH:MM[:SS])
	Tick      *float64 `query:"tick"`       // Lebar level harga (kelipatan fraksi); default fraksi BEI
	Limit     *int64   `query:"limit"`      // Baris per halaman
	Cursor    string   `query:"cursor"`     // Cursor dari `meta.next_cursor` halaman sebelumnya. Filter lain wajib sama dengan request pertama
	Fields    string   `query:"fields"`     // Kolom yang dikembalikan, dipisah koma. Default: semua
}

StocksSymbolVolumeProfileParams are the query parameters of GET /stocks/{symbol}/volume-profile.

type Stream

type Stream struct {

	// Connects counts successful connections.
	Connects int
	// contains filtered or unexported fields
}

Stream is a WebSocket client with automatic reconnect and resume from the last seq.

s, _ := ptb.NewStream()
s.Subscribe(ctx, "trades", []string{"BBCA"}, nil)
for msg, err := range s.Messages(ctx) { ... }

func NewStream

func NewStream(opts ...StreamOption) (*Stream, error)

NewStream creates a stream client. It connects lazily on Messages.

func (*Stream) Close

func (s *Stream) Close() error

Close closes the connection; Messages ends.

func (*Stream) LastSeq

func (s *Stream) LastSeq(channel, symbol string) (int64, bool)

LastSeq returns the last seq seen for channel/symbol.

func (*Stream) Messages

func (s *Stream) Messages(ctx context.Context) func(yield func(StreamMessage, error) bool)

Messages connects (and reconnects) and yields every message until ctx is done or Close is called. Pong messages are swallowed. A non-retryable failure is yielded as an error, then the sequence ends.

func (*Stream) Resume

func (s *Stream) Resume(ctx context.Context, channel, symbol string, fromSeq int64) error

Resume explicitly resumes one symbol from fromSeq (normally automatic after reconnect).

func (*Stream) Subscribe

func (s *Stream) Subscribe(ctx context.Context, channel string, symbols []string, o *SubscribeOptions) error

Subscribe adds symbols on a channel (nil symbols for market-wide channels).

func (*Stream) Unsubscribe

func (s *Stream) Unsubscribe(ctx context.Context, channel string, symbols []string, tf string) error

Unsubscribe removes symbols (nil = all) from a channel.

type StreamMessage

type StreamMessage struct {
	Type          string          `json:"type"`
	Channel       string          `json:"channel,omitempty"`
	Symbol        string          `json:"symbol,omitempty"`
	Seq           *int64          `json:"seq,omitempty"`
	Time          string          `json:"time,omitempty"`
	SchemaVersion string          `json:"schema_version,omitempty"`
	Data          json.RawMessage `json:"data,omitempty"`
	Error         *struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"error,omitempty"`
	Raw json.RawMessage `json:"-"`
}

StreamMessage is one message from /v1/stream. Type is "event", "error", ...

type StreamOption

type StreamOption func(*Stream)

StreamOption configures a Stream.

func StreamAPIKey

func StreamAPIKey(k string) StreamOption

StreamAPIKey sets the key (default $PTB_API_KEY).

func StreamBackoff

func StreamBackoff(base, max time.Duration) StreamOption

StreamBackoff sets reconnect backoff (default 500ms, 30s).

func StreamMaxReconnects

func StreamMaxReconnects(n int) StreamOption

StreamMaxReconnects stops after n consecutive failed reconnects (default: never).

func StreamPingInterval

func StreamPingInterval(d time.Duration) StreamOption

StreamPingInterval sets the idle ping interval (default 20s).

func StreamURL

func StreamURL(u string) StreamOption

StreamURL overrides the stream URL (default $PTB_STREAM_URL or DefaultStreamURL).

type SubscribeOptions

type SubscribeOptions struct {
	TF    string
	Extra map[string]any
}

SubscribeOptions are optional subscribe fields (tf for orderflow, extra keys like interval/kind for market).

Directories

Path Synopsis
examples
paging command
Iterate every done trade of a finished session (1 Kredit per 1,000-row page).
Iterate every done trade of a finished session (1 Kredit per 1,000-row page).
quickstart command
Quickstart: PTB_API_KEY=...
Quickstart: PTB_API_KEY=...
stream command
Live trades; reconnects and resumes from the last seq automatically.
Live trades; reconnects and resumes from the last seq automatically.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL