Skip to main content

SAPI overview

The two packages strategies depend on. Authoritative reference is the doc comments in the source; this page is the index.

pkg/strategy

The Strategy contract.

SymbolPurpose
Strategy (interface)What every strategy must implement. Name() string, Warmup, Decide.
Constructorfunc(cfg map[string]any) (Strategy, error). The factory each strategy registers.
Register(name, ctor)Self-registration in init(). Panics on duplicate name.
Get(name)Registry lookup. Returns the Constructor for name.
List()Sorted list of registered names.
WarmupInputCarries AgentID, Universe, Config, Now, Services.
DecisionInputPer-tick state: Now, Market, PerpPositions, SpotBalances, BasisPositions, Cash, Signals, Limits.
DecisionStrategy output: Orders, Swaps, Cancels, Notes, Confidence.
ServicesFramework deps for the strategy: Logger, Inference, InferenceModel, Registry. Extension point for new framework features.

Source: pkg/strategy/. GoDoc: pkg.go.dev/github.com/teslashibe/permafrost/pkg/strategy.

pkg/types

Trading-domain primitives the SAPI references. Stable public types.

SymbolPurpose
Asset, ChainID, WalletBalance, BalanceMoney + wallets.
OrderIntent, OrderType, Side, TIF, OrderIDPerp orders.
SwapIntentDEX swaps. Pairs with an OrderIntent via BasisKey.
Position, BasisPosition, BasisLeg, BasisStateOpen positions.
MarketSnapshot, SymbolSnap, FundingRatePer-tick market view.
RiskLimitsPer-agent risk bounds.

Source: pkg/types/. GoDoc: pkg.go.dev/github.com/teslashibe/permafrost/pkg/types.

pkg/inference

The OpenAI-compatible LLM contract. Optional for strategies; required only if the strategy uses Services.Inference.

SymbolPurpose
Provider (interface)Name(), Complete(ctx, Request), Embed(ctx, EmbedRequest).
Request, ResponseChat completion.
Message, Role, ToolSpec, ToolCall, SchemaMessages and structured-output config.
EmbedRequest, EmbedResponseEmbeddings.
ErrUnsupportedFeature, ErrRateLimitedSentinel errors strategies should handle.

Source: pkg/inference/. GoDoc: pkg.go.dev/github.com/teslashibe/permafrost/pkg/inference.

What's not in the public SAPI

Strategies in this single-module repo can import internal/* packages directly (Go's internal rule allows it within the same module), but doing so accepts that those internals may change without notice. The packages most commonly reached for:

  • internal/assets -- the curated asset registry plus USDC helpers (assets.LoadEmbedded(), assets.USDCMintFor(chain), assets.USDCAsset(chain)). Reasonable to import; the schema is stable.
  • internal/wallet -- the keystore + signer abstractions. Avoid; strategies should not be touching keys.
  • internal/agent -- the runtime itself. Avoid; you're a guest of this package, not its user.

Stability

pkg/strategy, pkg/types, and pkg/inference are committed public APIs. Breaking changes follow semantic versioning -- major-version bump or nothing. Anything outside pkg/ is fair game to change between releases.

Next steps