Documentation
¶
Index ¶
- Constants
- func GetTokenManager() tokencache.Manager
- func RateLimitGroup(method, path string) string
- type Account
- type BuyingPowerResponse
- type Candle
- type CandlePageResponse
- type Client
- func (c *Client) Authenticate(ctx context.Context, creds broker.Credentials) (*broker.Token, error)
- func (c *Client) CallEndpoint(ctx context.Context, method, path, accountSeq string, ...) (map[string]interface{}, error)
- func (c *Client) CancelOrder(ctx context.Context, accountSeq, orderID string) (OrderOperationResponse, error)
- func (c *Client) CreateOrder(ctx context.Context, accountSeq string, body map[string]interface{}) (OrderResponse, error)
- func (c *Client) GetAccounts(ctx context.Context) ([]Account, error)
- func (c *Client) GetBuyingPower(ctx context.Context, accountSeq, currency string) (BuyingPowerResponse, error)
- func (c *Client) GetCandles(ctx context.Context, symbol, interval string, count int, before string, ...) (CandlePageResponse, error)
- func (c *Client) GetCommissions(ctx context.Context, accountSeq string) ([]Commission, error)
- func (c *Client) GetHoldings(ctx context.Context, accountSeq, symbol string) (HoldingsOverview, error)
- func (c *Client) GetOrder(ctx context.Context, accountSeq, orderID string) (Order, error)
- func (c *Client) GetOrders(ctx context.Context, accountSeq string, query map[string]interface{}) (PaginatedOrderResponse, error)
- func (c *Client) GetPrices(ctx context.Context, symbols ...string) ([]PriceResponse, error)
- func (c *Client) GetSellableQuantity(ctx context.Context, accountSeq, symbol string) (SellableQuantityResponse, error)
- func (c *Client) GetStocks(ctx context.Context, symbols ...string) ([]StockInfo, error)
- func (c *Client) ModifyOrder(ctx context.Context, accountSeq, orderID string, body map[string]interface{}) (OrderOperationResponse, error)
- func (c *Client) Name() string
- func (c *Client) SetBaseURL(baseURL string)
- func (c *Client) SetCredentials(appKey, appSecret string)
- func (c *Client) SetLogger(l *slog.Logger)
- type Commission
- type Cost
- type DailyProfitLoss
- type FileTokenManager
- type HoldingMarketValue
- type HoldingProfitLoss
- type HoldingsItem
- type HoldingsOverview
- type KrMarketDetail
- type MultiCurrencyAmount
- type Order
- type OrderExecution
- type OrderOperationResponse
- type OrderResponse
- type OverviewDailyProfitLoss
- type OverviewMarketValue
- type OverviewProfitLoss
- type PaginatedOrderResponse
- type PriceResponse
- type SellableQuantityResponse
- type StockInfo
- type TokenResponse
Constants ¶
const ( PathOAuthToken = "/oauth2/token" PathAccounts = "/api/v1/accounts" PathPrices = "/api/v1/prices" PathCandles = "/api/v1/candles" PathStocks = "/api/v1/stocks" PathHoldings = "/api/v1/holdings" PathOrders = "/api/v1/orders" PathBuyingPower = "/api/v1/buying-power" PathSellableQuantity = "/api/v1/sellable-quantity" PathCommissions = "/api/v1/commissions" )
const (
// BaseURLReal is the Toss Securities production Open API domain.
BaseURLReal = "https://openapi.tossinvest.com"
)
Variables ¶
This section is empty.
Functions ¶
func GetTokenManager ¶
func GetTokenManager() tokencache.Manager
GetTokenManager returns the package-global token manager.
func RateLimitGroup ¶
RateLimitGroup returns the Toss rate-limit group for a documented operation.
Types ¶
type BuyingPowerResponse ¶
type CandlePageResponse ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Toss Securities Open API REST client.
func NewClientWithTokenManager ¶
func NewClientWithTokenManager(sandbox bool, tm tokencache.Manager) *Client
NewClientWithTokenManager creates a Toss Open API client.
func (*Client) Authenticate ¶
Authenticate issues or reuses a Toss OAuth token.
func (*Client) CallEndpoint ¶
func (c *Client) CallEndpoint(ctx context.Context, method, path, accountSeq string, query map[string]interface{}, body interface{}) (map[string]interface{}, error)
CallEndpoint executes a Toss endpoint and decodes the response as an untyped object.
func (*Client) CancelOrder ¶
func (*Client) CreateOrder ¶
func (*Client) GetBuyingPower ¶
func (*Client) GetCandles ¶
func (*Client) GetCommissions ¶
func (*Client) GetHoldings ¶
func (*Client) GetSellableQuantity ¶
func (*Client) ModifyOrder ¶
func (*Client) SetBaseURL ¶
SetBaseURL overrides the REST base URL. Tests use this for httptest servers.
func (*Client) SetCredentials ¶
SetCredentials stores Toss client credentials for token refresh.
type Commission ¶
type DailyProfitLoss ¶
type FileTokenManager ¶
FileTokenManager stores Toss OAuth tokens in memory and persists them to disk.
func NewFileTokenManager ¶
func NewFileTokenManager() *FileTokenManager
NewFileTokenManager creates the default file-backed token manager.
func NewFileTokenManagerWithDir ¶
func NewFileTokenManagerWithDir(dir string) *FileTokenManager
NewFileTokenManagerWithDir creates a file-backed token manager with an optional fixed directory.
type HoldingMarketValue ¶
type HoldingProfitLoss ¶
type HoldingsItem ¶
type HoldingsItem struct {
Symbol string `json:"symbol"`
Name string `json:"name"`
MarketCountry string `json:"marketCountry"`
Currency string `json:"currency"`
Quantity string `json:"quantity"`
LastPrice string `json:"lastPrice"`
AveragePurchasePrice string `json:"averagePurchasePrice"`
MarketValue HoldingMarketValue `json:"marketValue"`
ProfitLoss HoldingProfitLoss `json:"profitLoss"`
DailyProfitLoss DailyProfitLoss `json:"dailyProfitLoss"`
Cost Cost `json:"cost"`
}
type HoldingsOverview ¶
type HoldingsOverview struct {
TotalPurchaseAmount MultiCurrencyAmount `json:"totalPurchaseAmount"`
MarketValue OverviewMarketValue `json:"marketValue"`
ProfitLoss OverviewProfitLoss `json:"profitLoss"`
DailyProfitLoss OverviewDailyProfitLoss `json:"dailyProfitLoss"`
Items []HoldingsItem `json:"items"`
}
type KrMarketDetail ¶
type MultiCurrencyAmount ¶
type Order ¶
type Order struct {
OrderID string `json:"orderId"`
Symbol string `json:"symbol"`
Side string `json:"side"`
OrderType string `json:"orderType"`
TimeInForce string `json:"timeInForce"`
Status string `json:"status"`
Price *string `json:"price"`
Quantity string `json:"quantity"`
OrderAmount *string `json:"orderAmount"`
Currency string `json:"currency"`
OrderedAt string `json:"orderedAt"`
CanceledAt *string `json:"canceledAt"`
Execution OrderExecution `json:"execution"`
}
type OrderExecution ¶
type OrderExecution struct {
FilledQuantity string `json:"filledQuantity"`
AverageFilledPrice *string `json:"averageFilledPrice"`
FilledAmount *string `json:"filledAmount"`
Commission *string `json:"commission"`
Tax *string `json:"tax"`
FilledAt *string `json:"filledAt"`
SettlementDate *string `json:"settlementDate"`
}
type OrderOperationResponse ¶
type OrderOperationResponse struct {
OrderID string `json:"orderId"`
}
type OrderResponse ¶
type OverviewDailyProfitLoss ¶
type OverviewDailyProfitLoss struct {
Amount MultiCurrencyAmount `json:"amount"`
Rate string `json:"rate"`
}
type OverviewMarketValue ¶
type OverviewMarketValue struct {
Amount MultiCurrencyAmount `json:"amount"`
AmountAfterCost MultiCurrencyAmount `json:"amountAfterCost"`
}
type OverviewProfitLoss ¶
type OverviewProfitLoss struct {
Amount MultiCurrencyAmount `json:"amount"`
AmountAfterCost MultiCurrencyAmount `json:"amountAfterCost"`
Rate string `json:"rate"`
RateAfterCost string `json:"rateAfterCost"`
}
type PaginatedOrderResponse ¶
type PriceResponse ¶
type SellableQuantityResponse ¶
type SellableQuantityResponse struct {
SellableQuantity string `json:"sellableQuantity"`
}
type StockInfo ¶
type StockInfo struct {
Symbol string `json:"symbol"`
Name string `json:"name"`
EnglishName string `json:"englishName"`
ISINCode string `json:"isinCode"`
Market string `json:"market"`
SecurityType string `json:"securityType"`
Status string `json:"status"`
Currency string `json:"currency"`
ListDate *string `json:"listDate"`
DelistDate *string `json:"delistDate"`
LeverageFactor *string `json:"leverageFactor"`
KoreanMarketDetail *KrMarketDetail `json:"koreanMarketDetail"`
}