adapter

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter adapts Toss Securities Open API into broker.Broker.

func NewAdapterWithOptions

func NewAdapterWithOptions(
	sandbox bool,
	accountID string,
	accountSeq string,
	tokenManager tokencache.Manager,
	logger *slog.Logger,
) *Adapter

NewAdapterWithOptions creates a Toss adapter with injectable internals.

func (*Adapter) Authenticate

func (a *Adapter) Authenticate(ctx context.Context, creds broker.Credentials) (*broker.Token, error)

Authenticate authenticates with Toss.

func (*Adapter) CallEndpoint

func (a *Adapter) CallEndpoint(ctx context.Context, method, path string, query map[string]interface{}, body interface{}) (interface{}, error)

CallEndpoint dispatches a raw Toss Open API endpoint using this adapter's account_seq.

func (*Adapter) CancelOrder

func (a *Adapter) CancelOrder(ctx context.Context, orderID string) error

CancelOrder cancels a Toss order.

func (*Adapter) Client

func (a *Adapter) Client() *toss.Client

Client exposes the underlying Toss client for tests and advanced callers.

func (*Adapter) GetBalance

func (a *Adapter) GetBalance(ctx context.Context, accountID string) (*broker.Balance, error)

GetBalance retrieves a Toss account balance summary from holdings and buying-power APIs.

func (*Adapter) GetBuyingPower

func (a *Adapter) GetBuyingPower(ctx context.Context, currency string) (toss.BuyingPowerResponse, error)

func (*Adapter) GetCommissions

func (a *Adapter) GetCommissions(ctx context.Context) ([]toss.Commission, error)

func (*Adapter) GetInstrument

func (a *Adapter) GetInstrument(ctx context.Context, market, symbol string) (*broker.Instrument, error)

GetInstrument returns Toss stock metadata.

func (*Adapter) GetOHLCV

func (a *Adapter) GetOHLCV(ctx context.Context, market, symbol string, opts broker.OHLCVOpts) ([]broker.OHLCV, error)

GetOHLCV retrieves Toss 1d or 1m candles.

func (*Adapter) GetOrder

func (a *Adapter) GetOrder(ctx context.Context, orderID string) (*broker.OrderResult, error)

GetOrder returns a Toss order snapshot.

func (*Adapter) GetOrderFills

func (a *Adapter) GetOrderFills(ctx context.Context, orderID string) ([]broker.OrderFill, error)

GetOrderFills returns a normalized aggregate fill for a Toss order.

func (*Adapter) GetOrders

func (a *Adapter) GetOrders(ctx context.Context, query map[string]interface{}) (toss.PaginatedOrderResponse, error)

func (*Adapter) GetPositions

func (a *Adapter) GetPositions(ctx context.Context, _ string) ([]broker.Position, error)

GetPositions retrieves Toss account positions.

func (*Adapter) GetQuote

func (a *Adapter) GetQuote(ctx context.Context, market, symbol string) (*broker.Quote, error)

GetQuote retrieves a normalized stock quote from Toss prices and the latest daily candle.

func (*Adapter) GetSellableQuantity

func (a *Adapter) GetSellableQuantity(ctx context.Context, symbol string) (toss.SellableQuantityResponse, error)

func (*Adapter) ModifyOrder

func (a *Adapter) ModifyOrder(ctx context.Context, orderID string, req broker.ModifyOrderRequest) (*broker.OrderResult, error)

ModifyOrder modifies a Toss order.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns broker name.

func (*Adapter) PlaceOrder

func (a *Adapter) PlaceOrder(ctx context.Context, req broker.OrderRequest) (*broker.OrderResult, error)

PlaceOrder places a Toss stock order.

Jump to

Keyboard shortcuts

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