adapter

package
v0.17.4 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: Apache-2.0 Imports: 13 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 LS Securities OpenAPI into broker.Broker.

func NewAdapterWithOptions

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

NewAdapterWithOptions creates an LS adapter with injectable internals.

func (*Adapter) Authenticate

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

Authenticate authenticates with LS.

func (*Adapter) BuildOverseasTradeSubscriptions

func (a *Adapter) BuildOverseasTradeSubscriptions(ctx context.Context, market string, maxRows int) ([]ls.RealtimeSubscription, error)

BuildOverseasTradeSubscriptions returns overseas trade subscriptions from LS overseas stock master.

func (*Adapter) BuildTradeSubscriptions

func (a *Adapter) BuildTradeSubscriptions(ctx context.Context) ([]ls.RealtimeSubscription, error)

BuildTradeSubscriptions returns KOSPI/KOSDAQ trade subscriptions from LS stock master.

func (*Adapter) CallEndpoint

func (a *Adapter) CallEndpoint(ctx context.Context, method, path, trCD string, request interface{}) (interface{}, error)

CallEndpoint executes a documented LS REST endpoint by path and tr_cd.

func (*Adapter) CancelOrder

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

CancelOrder requires original symbol and quantity, which the common API does not carry yet for LS order cancellation.

func (*Adapter) Client

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

Client exposes the underlying LS client for advanced users and tests.

func (*Adapter) ConnectRealtime

func (a *Adapter) ConnectRealtime(ctx context.Context) (*ls.RealtimeConn, error)

ConnectRealtime opens an LS realtime WebSocket connection.

func (*Adapter) GetBalance

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

GetBalance retrieves LS stock account balance summary.

func (*Adapter) GetInstrument

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

GetInstrument returns stock master metadata.

func (*Adapter) GetOHLCV

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

GetOHLCV retrieves daily/weekly/monthly candles.

func (*Adapter) GetOrder

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

GetOrder is not implemented until LS order history is mapped into the common contract.

func (*Adapter) GetOrderFills

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

GetOrderFills is not implemented until LS fill history is mapped into the common contract.

func (*Adapter) GetPositions

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

GetPositions retrieves LS account positions.

func (*Adapter) GetQuote

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

GetQuote retrieves a domestic or supported overseas stock quote.

func (*Adapter) ModifyOrder

ModifyOrder requires original symbol and order type context, which the common API does not carry yet.

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 regular cash stock order.

Jump to

Keyboard shortcuts

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