go-trading212
БесплатноБез исполняемых скриптовНе проверенUnofficial Go client for the Trading 212 Public API, generated with oapi-codegen from the OpenAPI document Trading 212 publishes. Package `trading212`…
от psyb0t619 установок в других каталогахОб этом скилле
go-trading212
Unofficial, typed Go client for the Trading 212 Public API, in package trading212 at the module root.
For install, the full operation list, pagination and response fields, see references/setup.md.
Security & safety
- Trading 212 uses HTTP Basic auth: the API key is the username and the API secret the password. Read both from environment variables (
TRADING212_API_KEY,TRADING212_API_SECRET). Never hardcode, commit or log them, and never print a request with itsAuthorizationheader. - Requests go only to
https://demo.trading212.com(paper trading) orhttps://live.trading212.com(real money). A key works only on the environment it was made for. Default to demo. - Placing or cancelling orders and creating, updating, duplicating or deleting pies act on the account. Call them only when the user asked for that exact action, and use the live host only when the user said so.
When to use
- Go code needs a Trading 212 account summary, positions, open orders or history.
- Go code needs to place or cancel Trading 212 orders or manage pies, at the user's request.
- The project already imports
github.com/psyb0t/go-trading212.
When NOT to use
- The code is not Go. This module ships only a Go package.
- You need a client maintained by Trading 212. This one is unofficial and not affiliated with Trading 212.
- You want to change the generated client itself. See
AGENTS.mdin the repo.
Finding endpoints and types
The examples below cover a few calls. Every operation in the spec has a generated method, and the spec's descriptions are on them as Go doc comments. Look names and fields up instead of guessing. After go get github.com/psyb0t/go-trading212, from inside your module:
go doc github.com/psyb0t/go-trading212 ClientWithResponsesInterface # every endpoint method
go doc github.com/psyb0t/go-trading212 GetPositionsParams # one method, params type or model
go doc -all github.com/psyb0t/go-trading212 # the whole package
The same documentation is at https://pkg.go.dev/github.com/psyb0t/go-trading212.
Method names come from the spec's operation IDs. <OperationId>WithResponse takes the context, then the path parameters in order, then *<OperationId>Params when the operation has query or header parameters, then the request body when it has one. The JSON200 field (or JSON201 and so on, per declared status) holds the decoded body; it is nil for any other status. Some operation IDs are generic or numbered; the note at the end of this file maps them.
Usage
import (
"context"
"fmt"
"net/http"
"os"
"github.com/psyb0t/go-trading212"
)
auth := trading212.WithRequestEditorFn(
func(_ context.Context, req *http.Request) error {
req.SetBasicAuth(
os.Getenv("TRADING212_API_KEY"),
os.Getenv("TRADING212_API_SECRET"),
)
return nil
},
)
client, err := trading212.NewClientWithResponses(
"https://demo.trading212.com",
auth,
)
if err != nil {
return err
}
summary, err := client.GetAccountSummaryWithResponse(ctx)
if err != nil {
return err // transport failure
}
if summary.JSON200 == nil {
return fmt.Errorf("account summary: %s", summary.Status())
}
if total := summary.JSON200.TotalValue; total != nil { // *float64
fmt.Println("account value:", *total)
}
positions, err := client.GetPositionsWithResponse(
ctx,
&trading212.GetPositionsParams{},
)
if err != nil {
return err
}
if positions.JSON200 != nil {
for _, position := range *positions.JSON200 {
fmt.Println(*position.Instrument.Ticker, *position.Quantity)
}
}
Most response fields are pointers; check for nil before dereferencing. The error return covers only transport and decoding failures. An API error (401, 403, 429 and so on) comes back with JSON200 nil: check StatusCode() and Body.
Some method names come straight from the spec's operation IDs and are generic: GetAll, Create, Update, Delete and GetDetailed are the pie endpoints, Orders1 is the order history, PlaceStopOrder1 places a stop order and PlaceStopOrder a stop-limit order.
Установить go-trading212 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл go-trading212?
Unofficial Go client for the Trading 212 Public API, generated with oapi-codegen from the OpenAPI document Trading 212 publishes. Package `trading212` (`github.com/psyb0t/go-trading212`) has a typed `...WithResponse` method for every endpoint: account summary, positions, open orders, limit, market, stop and stop-limit orders, order, dividend and transaction history, CSV report exports, exchange and instrument metadata, and pies. Prices and amounts are `float64`. Use when Go code needs to read a Trading 212 account or place Trading 212 orders, or already imports go-trading212.
Как установить скилл go-trading212?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл go-trading212 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic