okx

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package okx connects an OKX account through the v5 REST API with a read-only key. OKX is treated as one account: funding, trading and Simple Earn balances are summed, and moves between them are not activities.

History comes from the account ledgers ("bills"), which list every balance change, rather than from order fills, because they reach furthest back:

  • funding account: GET /api/v5/asset/bills-history, since 2021-02-01;
  • trading account: GET /api/v5/account/bills-archive (last 3 months), plus the quarterly archive files since 2021 (POST then GET /api/v5/account/bills-history-archive; a requested file is ready about 2 hours later, so older quarters arrive on a later run);
  • deposits and withdrawals: /api/v5/asset/deposit-history and withdrawal-history (they carry the chain, tx hash and withdrawal fee);
  • Simple Earn interest: /api/v5/finance/savings/lending-history (last month only: older interest stays visible as a reconciliation gap).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg source.Config) (source.Source, error)

New builds the connector from its settings.

Types

type APIError

type APIError struct {
	Code string
	Msg  string
	Path string
}

APIError is an error reported by OKX in the response body.

func (*APIError) Error

func (e *APIError) Error() string

type Source

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

Source is a configured OKX connector.

func (*Source) Activities

func (s *Source) Activities(ctx context.Context, f source.Fetch) error

func (*Source) Balances

func (s *Source) Balances(ctx context.Context) ([]model.Balance, error)

func (*Source) State

func (s *Source) State() []byte

func (*Source) Test

func (s *Source) Test(ctx context.Context) error

Jump to

Keyboard shortcuts

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