param

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LeverageScale is the fixed-point scale used by leverage payloads.
	//
	// Raw leverage is stored as:
	//   raw = multiplier * LeverageScale
	//
	// Examples:
	//   raw 10   -> 1.0x
	//   raw 11   -> 1.1x
	//   raw 1005 -> 100.5x
	LeverageScale native.ParamLeverage = native.ParamLeverageScale

	// LeverageMin is the minimum business leverage multiplier in whole units.
	LeverageMin uint16 = uint16(native.ParamLeverageMin)

	// LeverageMax is the maximum business leverage multiplier in whole units.
	LeverageMax uint16 = uint16(native.ParamLeverageMax)

	// LeverageStep is the fractional increment between adjacent leverage values.
	LeverageStep float32 = float32(native.ParamLeverageStep)
)

Variables

View Source
var (
	ErrNegative        = native.ErrNegative
	ErrDivisionByZero  = native.ErrDivisionByZero
	ErrOverflow        = native.ErrOverflow
	ErrUnderflow       = native.ErrUnderflow
	ErrInvalidFloat    = native.ErrInvalidFloat
	ErrInvalidFormat   = native.ErrInvalidFormat
	ErrInvalidPrice    = native.ErrInvalidPrice
	ErrInvalidLeverage = native.ErrInvalidLeverage
)
View Source
var CashFlowZero = newCashFlowOrPanic(NewCashFlowFromInt(0))
View Source
var ErrAccountIDEmpty = native.ErrAccountIdEmpty
View Source
var ErrAssetEmpty = native.ErrAssetEmpty
View Source
var FeeZero = newFeeOrPanic(NewFeeFromInt(0))
View Source
var LeverageZero = Leverage{}

LeverageZero is the zero-value leverage payload (`not set` state).

View Source
var NotionalZero = newNotionalOrPanic(NewNotionalFromInt(0))
View Source
var PnlZero = newPnlOrPanic(NewPnlFromInt(0))
View Source
var PositionSizeZero = newPositionSizeOrPanic(NewPositionSizeFromInt(0))
View Source
var PriceZero = newPriceOrPanic(NewPriceFromInt(0))
View Source
var QuantityZero = newQuantityOrPanic(NewQuantityFromInt(0))
View Source
var VolumeZero = newVolumeOrPanic(NewVolumeFromInt(0))

Functions

func NewAccountIDOptionFromHandle

func NewAccountIDOptionFromHandle(
	source native.ParamAccountIDOptional,
) optional.Option[AccountID]

func NewAdjustmentAmountFromHandle

func NewAdjustmentAmountFromHandle(
	amount native.ParamAdjustmentAmount,
) optional.Option[AdjustmentAmount]

func NewAssetFromHandle

func NewAssetFromHandle(v native.StringView) optional.Option[Asset]

NewAssetFromHandle builds an Asset from a native StringView returned by the C API. Returns None when the view is not set (nil/empty).

func NewCashFlowOptionFromHandle

func NewCashFlowOptionFromHandle(
	v native.ParamCashFlowOptional,
) optional.Option[CashFlow]

func NewFeeOptionFromHandle

func NewFeeOptionFromHandle(v native.ParamFeeOptional) optional.Option[Fee]

func NewInstrumentFromHandle

func NewInstrumentFromHandle(i native.Instrument) optional.Option[Instrument]

func NewLeverageOptionFromHandle

func NewLeverageOptionFromHandle(v native.ParamLeverage) optional.Option[Leverage]

NewLeverageOptionFromHandle converts native leverage payload into optional Leverage.

`native.ParamLeverageNotSet` maps to empty option; any other value maps to `Some(Leverage)`.

func NewPnlOptionFromHandle

func NewPnlOptionFromHandle(v native.ParamPnlOptional) optional.Option[Pnl]

func NewPriceOptionFromHandle

func NewPriceOptionFromHandle(v native.ParamPriceOptional) optional.Option[Price]

func NewSideFromHandle

func NewSideFromHandle(v native.ParamSide) optional.Option[Side]

func NewTradeAmountFromHandle

func NewTradeAmountFromHandle(amount native.ParamTradeAmount) optional.Option[TradeAmount]

func NewVolumeOptionFromHandle

func NewVolumeOptionFromHandle(v native.ParamVolumeOptional) optional.Option[Volume]

Types

type AccountID

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

AccountID is a type-safe account identifier.

func NewAccountIDFromHandle

func NewAccountIDFromHandle(source native.ParamAccountID) AccountID

func NewAccountIDFromInt

func NewAccountIDFromInt(source uint64) AccountID

NewAccountIDFromInt constructs an account identifier from an integer value.

func NewAccountIDFromString

func NewAccountIDFromString(source string) (AccountID, error)

NewAccountIDFromString constructs an account identifier by hashing input string with FNV-1a 64-bit.

Collision probability (birthday bound approximation):

- 1,000 accounts: < 3 x 10^-14 - 10,000 accounts: < 3 x 10^-12 - 100,000 accounts: < 3 x 10^-10 - 1,000,000 accounts: < 3 x 10^-8

If collision risk is unacceptable, use your own collision-free string-to-integer mapping and construct account identifiers from integers.

func (AccountID) Handle

func (v AccountID) Handle() native.ParamAccountID

Handle exposes the underlying native account identifier.

func (AccountID) String

func (v AccountID) String() string

String formats account identifier as decimal string.

type AdjustmentAmount

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

AdjustmentAmount is a signed balance/position adjustment payload.

func NewAbsoluteAdjustmentAmount

func NewAbsoluteAdjustmentAmount(v PositionSize) AdjustmentAmount

func NewDeltaAdjustmentAmount

func NewDeltaAdjustmentAmount(v PositionSize) AdjustmentAmount

func (AdjustmentAmount) Choose

func (a AdjustmentAmount) Choose(getDelta func(PositionSize), getAbsolute func(PositionSize))

func (AdjustmentAmount) Handle

func (AdjustmentAmount) IsAbsolute

func (a AdjustmentAmount) IsAbsolute() bool

func (AdjustmentAmount) IsDelta

func (a AdjustmentAmount) IsDelta() bool

func (AdjustmentAmount) MustAbsolute

func (a AdjustmentAmount) MustAbsolute() PositionSize

func (AdjustmentAmount) MustDelta

func (a AdjustmentAmount) MustDelta() PositionSize

func (AdjustmentAmount) String

func (a AdjustmentAmount) String() string

type Asset

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

Asset is an asset or currency identifier, for example USD, AAPL, or SPX.

Memory model

Asset stores its identifier bytes in a C-heap buffer allocated once at construction time. The buffer is freed automatically by a GC finalizer when the last copy of the Asset (and therefore the last reference to the underlying *native.String) is collected.

This design solves a CGo constraint: every C struct that carries a string field (PitStringView) stores a raw pointer to the string bytes. When such a struct is held in Go memory and passed to C via a Go pointer, the CGo checker enforces "Go memory must not contain Go pointers". By keeping the bytes on the C heap, PitStringView.ptr is always a C pointer — invisible to the checker. See internal/native/asset_buf.go for the allocation details.

Lifetime contract for model structs

Model structs (Order, AccountAdjustment, ExecutionReport, …) write PitStringView pointers into their C structs when an Asset is set. Those pointers remain valid only as long as at least one Asset value referencing the same *native.String stays alive. To guarantee this, every model struct that accepts an Asset keeps a named retain* field that holds the Asset value for its own lifetime. See the model package for details.

Equality and hashing

Asset is NOT comparable with == because pointer identity does not imply string equality (two independently created "USD" assets have different *String pointers). Use Equal for semantic comparison and Hash for use in hash-map implementations.

Finalizer guarantees

runtime.SetFinalizer does NOT guarantee the finalizer runs before program exit — only that it runs before the GC reclaims the object. In a high-frequency trading process the GC runs frequently under memory pressure, so C buffers are reclaimed promptly. A small leak on abnormal exit is acceptable because the OS reclaims the process address space.

func NewAsset

func NewAsset(v string) (Asset, error)

NewAsset validates v and creates an Asset whose bytes live in a C-heap buffer freed automatically by the GC.

func (Asset) Equal

func (a Asset) Equal(b Asset) bool

Equal reports whether a and b identify the same asset by comparing their byte content. Always use Equal instead of == for semantic comparison.

func (Asset) Handle

func (a Asset) Handle() string

Handle returns a Go string backed by the Asset's C buffer, for use by importString in internal/native. Because the backing bytes are C-heap, importString stores a C pointer in PitStringView.ptr — not a Go pointer — so no CGo pointer-check violation occurs.

func (Asset) Hash

func (a Asset) Hash() uint64

Hash returns a content-based FNV-64a hash of the identifier. Assets that are Equal always produce the same Hash value, making it safe to use as a hash-map key.

func (Asset) Safe

func (a Asset) Safe() string

Safe returns a Go-heap copy of the identifier. The returned string is independent of the Asset's C buffer and remains valid after the Asset is collected.

func (Asset) String

func (a Asset) String() string

String implements fmt.Stringer. Returns the same value as Safe().

func (Asset) Unsafe

func (a Asset) Unsafe() string

Unsafe returns a Go string header whose backing bytes are the Asset's C buffer. The string is valid only as long as this Asset (or any copy of it, or any model struct retaining it) is live. Use on hot paths where avoiding a copy matters; prefer Safe() when the string may outlive the Asset.

type CashFlow

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

CashFlow is a cash-flow contribution.

Values are validated and stored in the native value layout. Every arithmetic or conversion call on this type crosses the Go/C boundary via FFI and has a per-operation cost. For ultra-low-latency paths that need many intermediate computations, prefer performing the math on primitive types or a custom representation and cross into CashFlow only once via NewCashFlowFromString / NewCashFlowFromDecimal / NewCashFlowFromHandle.

This cost exists because the SDK guarantees that the same input produces bit-for-bit identical results across all language bindings (Rust, Go, Python). Running arithmetic through the core is the mechanism that enforces that determinism.

func NewCashFlowFromDecimal

func NewCashFlowFromDecimal(v decimal.Decimal) (CashFlow, error)

NewCashFlowFromDecimal converts a shopspring decimal to a CashFlow.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewCashFlowFromDecimalRounded

func NewCashFlowFromDecimalRounded(
	v decimal.Decimal,
	scale uint32,
	strategy RoundingStrategy,
) (CashFlow, error)

NewCashFlowFromDecimalRounded converts a shopspring decimal to a rounded CashFlow.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewCashFlowFromFee

func NewCashFlowFromFee(fee Fee) (CashFlow, error)

func NewCashFlowFromFloat

func NewCashFlowFromFloat(v float64) (CashFlow, error)

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewCashFlowFromString or NewCashFlowFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func NewCashFlowFromFloatRounded

func NewCashFlowFromFloatRounded(
	v float64,
	scale uint32,
	strategy RoundingStrategy,
) (CashFlow, error)

func NewCashFlowFromHandle

func NewCashFlowFromHandle(v native.ParamCashFlow) CashFlow

func NewCashFlowFromInt

func NewCashFlowFromInt(v int64) (CashFlow, error)

func NewCashFlowFromPnl

func NewCashFlowFromPnl(pnl Pnl) (CashFlow, error)

func NewCashFlowFromString

func NewCashFlowFromString(v string) (CashFlow, error)

func NewCashFlowFromStringRounded

func NewCashFlowFromStringRounded(
	v string,
	scale uint32,
	strategy RoundingStrategy,
) (CashFlow, error)

func NewCashFlowFromUint

func NewCashFlowFromUint(v uint64) (CashFlow, error)

func NewCashFlowFromVolumeInflow

func NewCashFlowFromVolumeInflow(volume Volume) (CashFlow, error)

func NewCashFlowFromVolumeOutflow

func NewCashFlowFromVolumeOutflow(volume Volume) (CashFlow, error)

func (CashFlow) CheckedAdd

func (v CashFlow) CheckedAdd(other CashFlow) (CashFlow, error)

func (CashFlow) CheckedDivFloat

func (v CashFlow) CheckedDivFloat(divisor float64) (CashFlow, error)

func (CashFlow) CheckedDivInt

func (v CashFlow) CheckedDivInt(divisor int64) (CashFlow, error)

func (CashFlow) CheckedDivUint

func (v CashFlow) CheckedDivUint(divisor uint64) (CashFlow, error)

func (CashFlow) CheckedMulFloat

func (v CashFlow) CheckedMulFloat(scalar float64) (CashFlow, error)

func (CashFlow) CheckedMulInt

func (v CashFlow) CheckedMulInt(scalar int64) (CashFlow, error)

func (CashFlow) CheckedMulUint

func (v CashFlow) CheckedMulUint(scalar uint64) (CashFlow, error)

func (CashFlow) CheckedNeg

func (v CashFlow) CheckedNeg() (CashFlow, error)

func (CashFlow) CheckedRemFloat

func (v CashFlow) CheckedRemFloat(divisor float64) (CashFlow, error)

func (CashFlow) CheckedRemInt

func (v CashFlow) CheckedRemInt(divisor int64) (CashFlow, error)

func (CashFlow) CheckedRemUint

func (v CashFlow) CheckedRemUint(divisor uint64) (CashFlow, error)

func (CashFlow) CheckedSub

func (v CashFlow) CheckedSub(other CashFlow) (CashFlow, error)

func (CashFlow) Compare

func (v CashFlow) Compare(other CashFlow) int

func (CashFlow) Decimal

func (v CashFlow) Decimal() decimal.Decimal

func (CashFlow) Equal

func (v CashFlow) Equal(other CashFlow) bool

func (CashFlow) Float

func (v CashFlow) Float() float64

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewCashFlowFromString or NewCashFlowFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func (CashFlow) Handle

func (v CashFlow) Handle() native.ParamCashFlow

func (CashFlow) IsZero

func (v CashFlow) IsZero() bool

func (CashFlow) String

func (v CashFlow) String() string

type Fee

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

Fee is a fee amount.

Values are validated and stored in the native value layout. Every arithmetic or conversion call on this type crosses the Go/C boundary via FFI and has a per-operation cost. For ultra-low-latency paths that need many intermediate computations, prefer performing the math on primitive types or a custom representation and cross into Fee only once via NewFeeFromString / NewFeeFromDecimal / NewFeeFromHandle.

This cost exists because the SDK guarantees that the same input produces bit-for-bit identical results across all language bindings (Rust, Go, Python). Running arithmetic through the core is the mechanism that enforces that determinism.

func NewFeeFromDecimal

func NewFeeFromDecimal(v decimal.Decimal) (Fee, error)

NewFeeFromDecimal converts a shopspring decimal to a Fee.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewFeeFromDecimalRounded

func NewFeeFromDecimalRounded(
	v decimal.Decimal,
	scale uint32,
	strategy RoundingStrategy,
) (Fee, error)

NewFeeFromDecimalRounded converts a shopspring decimal to a rounded Fee.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewFeeFromFloat

func NewFeeFromFloat(v float64) (Fee, error)

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewFeeFromString or NewFeeFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func NewFeeFromFloatRounded

func NewFeeFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Fee, error)

func NewFeeFromHandle

func NewFeeFromHandle(v native.ParamFee) Fee

func NewFeeFromInt

func NewFeeFromInt(v int64) (Fee, error)

func NewFeeFromString

func NewFeeFromString(v string) (Fee, error)

func NewFeeFromStringRounded

func NewFeeFromStringRounded(
	v string,
	scale uint32,
	strategy RoundingStrategy,
) (Fee, error)

func NewFeeFromUint

func NewFeeFromUint(v uint64) (Fee, error)

func (Fee) CashFlow

func (v Fee) CashFlow() (CashFlow, error)

func (Fee) CheckedAdd

func (v Fee) CheckedAdd(other Fee) (Fee, error)

func (Fee) CheckedDivFloat

func (v Fee) CheckedDivFloat(divisor float64) (Fee, error)

func (Fee) CheckedDivInt

func (v Fee) CheckedDivInt(divisor int64) (Fee, error)

func (Fee) CheckedDivUint

func (v Fee) CheckedDivUint(divisor uint64) (Fee, error)

func (Fee) CheckedMulFloat

func (v Fee) CheckedMulFloat(scalar float64) (Fee, error)

func (Fee) CheckedMulInt

func (v Fee) CheckedMulInt(scalar int64) (Fee, error)

func (Fee) CheckedMulUint

func (v Fee) CheckedMulUint(scalar uint64) (Fee, error)

func (Fee) CheckedNeg

func (v Fee) CheckedNeg() (Fee, error)

func (Fee) CheckedRemFloat

func (v Fee) CheckedRemFloat(divisor float64) (Fee, error)

func (Fee) CheckedRemInt

func (v Fee) CheckedRemInt(divisor int64) (Fee, error)

func (Fee) CheckedRemUint

func (v Fee) CheckedRemUint(divisor uint64) (Fee, error)

func (Fee) CheckedSub

func (v Fee) CheckedSub(other Fee) (Fee, error)

func (Fee) Compare

func (v Fee) Compare(other Fee) int

func (Fee) Decimal

func (v Fee) Decimal() decimal.Decimal

func (Fee) Equal

func (v Fee) Equal(other Fee) bool

func (Fee) Float

func (v Fee) Float() float64

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewFeeFromString or NewFeeFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func (Fee) Handle

func (v Fee) Handle() native.ParamFee

func (Fee) IsZero

func (v Fee) IsZero() bool

func (Fee) Pnl

func (v Fee) Pnl() (Pnl, error)

func (Fee) PositionSize

func (v Fee) PositionSize() (PositionSize, error)

func (Fee) String

func (v Fee) String() string

type Instrument

type Instrument struct {
	UnderlyingAsset Asset
	SettlementAsset Asset
}

func NewInstrument

func NewInstrument(underlyingAsset Asset, settlementAsset Asset) Instrument

func (Instrument) Handle

func (i Instrument) Handle() native.Instrument

func (Instrument) String

func (i Instrument) String() string

type Leverage

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

Leverage is a fixed-point leverage multiplier payload.

Storage format:

  • underlying value is uint16 in fixed-point scale 10;
  • one decimal place is encoded in the raw integer.

API behavior:

  • this type does not perform upfront business validation;
  • it is a transport-friendly wrapper around native leverage payload;
  • invalid values are expected to be rejected by operations that consume leverage and return their own errors.

Zero value:

  • zero value is valid as a payload state and represents "not set" (`native.ParamLeverageNotSet`) when interpreted as optional leverage.

func NewLeverageFromFloat32

func NewLeverageFromFloat32(multiplier float32) Leverage

NewLeverageFromFloat32 builds leverage from float32 multiplier.

Conversion uses fixed-point encoding with rounding to nearest tenth:

raw = round(multiplier * LeverageScale)

No business validation is performed.

func NewLeverageFromHandle

func NewLeverageFromHandle(v native.ParamLeverage) Leverage

NewLeverageFromHandle wraps native leverage payload as Leverage.

No business validation is performed.

func NewLeverageFromInt

func NewLeverageFromInt(multiplier uint16) Leverage

NewLeverageFromInt builds leverage from integer multiplier.

Conversion uses fixed-point encoding:

raw = multiplier * LeverageScale

No business validation is performed.

func (Leverage) CalculateMarginRequired

func (v Leverage) CalculateMarginRequired(notional Notional) (Notional, error)

CalculateMarginRequired returns margin for the provided notional.

Formula:

margin = notional / leverage

func (Leverage) Handle

func (v Leverage) Handle() native.ParamLeverage

Handle returns underlying native leverage payload.

func (Leverage) IsSet

func (v Leverage) IsSet() bool

IsSet reports whether leverage payload is explicitly set.

False means payload is equal to `native.ParamLeverageNotSet`.

func (Leverage) Raw

func (v Leverage) Raw() native.ParamLeverage

Raw returns underlying fixed-point leverage payload.

func (Leverage) String

func (v Leverage) String() string

String returns normalized decimal leverage string.

Formatting rules:

  • no trailing ".0" for integer multipliers;
  • one decimal digit for fractional multipliers.

func (Leverage) Value

func (v Leverage) Value() float32

Value returns leverage multiplier as float32.

Example:

raw 1005 -> 100.5

type Notional

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

Notional is the monetary position exposure used for margin and risk calculation.

Notional represents the absolute monetary value of a position in the settlement currency: |price| × quantity. It is always non-negative and captures the full face value at risk regardless of leverage.

Values are validated and stored in the native value layout. Every arithmetic or conversion call on this type crosses the Go/C boundary via FFI and has a per-operation cost. For ultra-low-latency paths that need many intermediate computations, prefer performing the math on primitive types or a custom representation and cross into Notional only once via NewNotionalFromString / NewNotionalFromDecimal / NewNotionalFromHandle.

This cost exists because the SDK guarantees that the same input produces bit-for-bit identical results across all language bindings (Rust, Go, Python). Running arithmetic through the core is the mechanism that enforces that determinism.

func NewNotionalFromDecimal

func NewNotionalFromDecimal(v decimal.Decimal) (Notional, error)

NewNotionalFromDecimal converts a shopspring decimal to a Notional.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewNotionalFromDecimalRounded

func NewNotionalFromDecimalRounded(
	v decimal.Decimal,
	scale uint32,
	strategy RoundingStrategy,
) (Notional, error)

NewNotionalFromDecimalRounded converts a shopspring decimal to a rounded Notional.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewNotionalFromFloat

func NewNotionalFromFloat(v float64) (Notional, error)

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewNotionalFromString or NewNotionalFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func NewNotionalFromFloatRounded

func NewNotionalFromFloatRounded(
	v float64,
	scale uint32,
	strategy RoundingStrategy,
) (Notional, error)

func NewNotionalFromHandle

func NewNotionalFromHandle(v native.ParamNotional) Notional

func NewNotionalFromInt

func NewNotionalFromInt(v int64) (Notional, error)

func NewNotionalFromString

func NewNotionalFromString(v string) (Notional, error)

func NewNotionalFromStringRounded

func NewNotionalFromStringRounded(
	v string,
	scale uint32,
	strategy RoundingStrategy,
) (Notional, error)

func NewNotionalFromUint

func NewNotionalFromUint(v uint64) (Notional, error)

func NewNotionalFromVolume

func NewNotionalFromVolume(v Volume) (Notional, error)

NewNotionalFromVolume converts trade volume into position notional.

Both types represent monetary amounts in the settlement currency; this cast changes the semantic context from "order size" to "position exposure".

func (Notional) CalculateMarginRequired

func (v Notional) CalculateMarginRequired(leverage Leverage) (Notional, error)

CalculateMarginRequired returns the margin needed to hold this position at the given leverage.

Formula: margin = notional / leverage.

func (Notional) CheckedAdd

func (v Notional) CheckedAdd(other Notional) (Notional, error)

func (Notional) CheckedDivFloat

func (v Notional) CheckedDivFloat(divisor float64) (Notional, error)

func (Notional) CheckedDivInt

func (v Notional) CheckedDivInt(divisor int64) (Notional, error)

func (Notional) CheckedDivUint

func (v Notional) CheckedDivUint(divisor uint64) (Notional, error)

func (Notional) CheckedMulFloat

func (v Notional) CheckedMulFloat(scalar float64) (Notional, error)

func (Notional) CheckedMulInt

func (v Notional) CheckedMulInt(scalar int64) (Notional, error)

func (Notional) CheckedMulUint

func (v Notional) CheckedMulUint(scalar uint64) (Notional, error)

func (Notional) CheckedRemFloat

func (v Notional) CheckedRemFloat(divisor float64) (Notional, error)

func (Notional) CheckedRemInt

func (v Notional) CheckedRemInt(divisor int64) (Notional, error)

func (Notional) CheckedRemUint

func (v Notional) CheckedRemUint(divisor uint64) (Notional, error)

func (Notional) CheckedSub

func (v Notional) CheckedSub(other Notional) (Notional, error)

func (Notional) Compare

func (v Notional) Compare(other Notional) int

func (Notional) Decimal

func (v Notional) Decimal() decimal.Decimal

func (Notional) Equal

func (v Notional) Equal(other Notional) bool

func (Notional) Float

func (v Notional) Float() float64

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewNotionalFromString or NewNotionalFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func (Notional) Handle

func (v Notional) Handle() native.ParamNotional

func (Notional) IsZero

func (v Notional) IsZero() bool

func (Notional) String

func (v Notional) String() string

func (Notional) Volume

func (v Notional) Volume() (Volume, error)

ToVolume converts position notional into settlement volume.

The numeric value is preserved; only the semantic context changes from "position exposure" to "order size".

type Pnl

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

Pnl is a profit and loss value.

Values are validated and stored in the native value layout. Every arithmetic or conversion call on this type crosses the Go/C boundary via FFI and has a per-operation cost. For ultra-low-latency paths that need many intermediate computations, prefer performing the math on primitive types or a custom representation and cross into Pnl only once via NewPnlFromString / NewPnlFromDecimal / NewPnlFromHandle.

This cost exists because the SDK guarantees that the same input produces bit-for-bit identical results across all language bindings (Rust, Go, Python). Running arithmetic through the core is the mechanism that enforces that determinism.

func NewPnlFromDecimal

func NewPnlFromDecimal(v decimal.Decimal) (Pnl, error)

NewPnlFromDecimal converts a shopspring decimal to a Pnl.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewPnlFromDecimalRounded

func NewPnlFromDecimalRounded(
	v decimal.Decimal,
	scale uint32,
	strategy RoundingStrategy,
) (Pnl, error)

NewPnlFromDecimalRounded converts a shopspring decimal to a rounded Pnl.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewPnlFromFee

func NewPnlFromFee(fee Fee) (Pnl, error)

func NewPnlFromFloat

func NewPnlFromFloat(v float64) (Pnl, error)

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewPnlFromString or NewPnlFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func NewPnlFromFloatRounded

func NewPnlFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Pnl, error)

func NewPnlFromHandle

func NewPnlFromHandle(v native.ParamPnl) Pnl

func NewPnlFromInt

func NewPnlFromInt(v int64) (Pnl, error)

func NewPnlFromString

func NewPnlFromString(v string) (Pnl, error)

func NewPnlFromStringRounded

func NewPnlFromStringRounded(
	v string,
	scale uint32,
	strategy RoundingStrategy,
) (Pnl, error)

func NewPnlFromUint

func NewPnlFromUint(v uint64) (Pnl, error)

func (Pnl) CashFlow

func (v Pnl) CashFlow() (CashFlow, error)

func (Pnl) CheckedAdd

func (v Pnl) CheckedAdd(other Pnl) (Pnl, error)

func (Pnl) CheckedDivFloat

func (v Pnl) CheckedDivFloat(divisor float64) (Pnl, error)

func (Pnl) CheckedDivInt

func (v Pnl) CheckedDivInt(divisor int64) (Pnl, error)

func (Pnl) CheckedDivUint

func (v Pnl) CheckedDivUint(divisor uint64) (Pnl, error)

func (Pnl) CheckedMulFloat

func (v Pnl) CheckedMulFloat(scalar float64) (Pnl, error)

func (Pnl) CheckedMulInt

func (v Pnl) CheckedMulInt(scalar int64) (Pnl, error)

func (Pnl) CheckedMulUint

func (v Pnl) CheckedMulUint(scalar uint64) (Pnl, error)

func (Pnl) CheckedNeg

func (v Pnl) CheckedNeg() (Pnl, error)

func (Pnl) CheckedRemFloat

func (v Pnl) CheckedRemFloat(divisor float64) (Pnl, error)

func (Pnl) CheckedRemInt

func (v Pnl) CheckedRemInt(divisor int64) (Pnl, error)

func (Pnl) CheckedRemUint

func (v Pnl) CheckedRemUint(divisor uint64) (Pnl, error)

func (Pnl) CheckedSub

func (v Pnl) CheckedSub(other Pnl) (Pnl, error)

func (Pnl) Compare

func (v Pnl) Compare(other Pnl) int

func (Pnl) Decimal

func (v Pnl) Decimal() decimal.Decimal

func (Pnl) Equal

func (v Pnl) Equal(other Pnl) bool

func (Pnl) Float

func (v Pnl) Float() float64

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewPnlFromString or NewPnlFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func (Pnl) Handle

func (v Pnl) Handle() native.ParamPnl

func (Pnl) IsZero

func (v Pnl) IsZero() bool

func (Pnl) PositionSize

func (v Pnl) PositionSize() (PositionSize, error)

func (Pnl) String

func (v Pnl) String() string

type PositionEffect

type PositionEffect native.ParamPositionEffect

PositionEffect is fill effect on position.

const (
	// PositionEffectOpen opens or increases a position.
	PositionEffectOpen PositionEffect = native.ParamPositionEffectOpen
	// PositionEffectClose reduces or closes a position.
	PositionEffectClose PositionEffect = native.ParamPositionEffectClose
)

func (PositionEffect) String

func (v PositionEffect) String() string

type PositionMode

type PositionMode native.ParamPositionMode

PositionMode is position accounting mode.

const (
	// PositionModeNetting tracks one net position per instrument.
	PositionModeNetting PositionMode = native.ParamPositionModeNetting
	// PositionModeHedged tracks independent long and short legs.
	PositionModeHedged PositionMode = native.ParamPositionModeHedged
)

func (PositionMode) Handle

func (PositionMode) String

func (v PositionMode) String() string

type PositionSide

type PositionSide native.ParamPositionSide

PositionSide is open position direction.

const (
	// PositionSideLong is long direction.
	PositionSideLong PositionSide = native.ParamPositionSideLong
	// PositionSideShort is short direction.
	PositionSideShort PositionSide = native.ParamPositionSideShort
)

func (PositionSide) IsLong

func (v PositionSide) IsLong() bool

IsLong returns true when side is long.

func (PositionSide) IsShort

func (v PositionSide) IsShort() bool

IsShort returns true when side is short.

func (PositionSide) Opposite

func (v PositionSide) Opposite() PositionSide

Opposite returns the opposite position side.

func (PositionSide) String

func (v PositionSide) String() string

type PositionSize

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

PositionSize is a position size value.

Values are validated and stored in the native value layout. Every arithmetic or conversion call on this type crosses the Go/C boundary via FFI and has a per-operation cost. For ultra-low-latency paths that need many intermediate computations, prefer performing the math on primitive types or a custom representation and cross into PositionSize only once via NewPositionSizeFromString / NewPositionSizeFromDecimal / NewPositionSizeFromHandle.

This cost exists because the SDK guarantees that the same input produces bit-for-bit identical results across all language bindings (Rust, Go, Python). Running arithmetic through the core is the mechanism that enforces that determinism.

func NewPositionSizeFromDecimal

func NewPositionSizeFromDecimal(v decimal.Decimal) (PositionSize, error)

NewPositionSizeFromDecimal converts a shopspring decimal to a PositionSize.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewPositionSizeFromDecimalRounded

func NewPositionSizeFromDecimalRounded(
	v decimal.Decimal,
	scale uint32,
	strategy RoundingStrategy,
) (PositionSize, error)

NewPositionSizeFromDecimalRounded converts a shopspring decimal to a rounded PositionSize.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewPositionSizeFromFee

func NewPositionSizeFromFee(fee Fee) (PositionSize, error)

func NewPositionSizeFromFloat

func NewPositionSizeFromFloat(v float64) (PositionSize, error)

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewPositionSizeFromString or NewPositionSizeFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func NewPositionSizeFromFloatRounded

func NewPositionSizeFromFloatRounded(
	v float64,
	scale uint32,
	strategy RoundingStrategy,
) (PositionSize, error)

func NewPositionSizeFromHandle

func NewPositionSizeFromHandle(v native.ParamPositionSize) PositionSize

func NewPositionSizeFromInt

func NewPositionSizeFromInt(v int64) (PositionSize, error)

func NewPositionSizeFromPnl

func NewPositionSizeFromPnl(pnl Pnl) (PositionSize, error)

func NewPositionSizeFromQuantityAndSide

func NewPositionSizeFromQuantityAndSide(q Quantity, side Side) (PositionSize, error)

func NewPositionSizeFromString

func NewPositionSizeFromString(v string) (PositionSize, error)

func NewPositionSizeFromStringRounded

func NewPositionSizeFromStringRounded(
	v string,
	scale uint32,
	strategy RoundingStrategy,
) (PositionSize, error)

func NewPositionSizeFromUint

func NewPositionSizeFromUint(v uint64) (PositionSize, error)

func (PositionSize) CheckedAdd

func (v PositionSize) CheckedAdd(other PositionSize) (PositionSize, error)

func (PositionSize) CheckedAddQuantity

func (v PositionSize) CheckedAddQuantity(q Quantity, side Side) (PositionSize, error)

func (PositionSize) CheckedDivFloat

func (v PositionSize) CheckedDivFloat(divisor float64) (PositionSize, error)

func (PositionSize) CheckedDivInt

func (v PositionSize) CheckedDivInt(divisor int64) (PositionSize, error)

func (PositionSize) CheckedDivUint

func (v PositionSize) CheckedDivUint(divisor uint64) (PositionSize, error)

func (PositionSize) CheckedMulFloat

func (v PositionSize) CheckedMulFloat(scalar float64) (PositionSize, error)

func (PositionSize) CheckedMulInt

func (v PositionSize) CheckedMulInt(scalar int64) (PositionSize, error)

func (PositionSize) CheckedMulUint

func (v PositionSize) CheckedMulUint(scalar uint64) (PositionSize, error)

func (PositionSize) CheckedNeg

func (v PositionSize) CheckedNeg() (PositionSize, error)

func (PositionSize) CheckedRemFloat

func (v PositionSize) CheckedRemFloat(divisor float64) (PositionSize, error)

func (PositionSize) CheckedRemInt

func (v PositionSize) CheckedRemInt(divisor int64) (PositionSize, error)

func (PositionSize) CheckedRemUint

func (v PositionSize) CheckedRemUint(divisor uint64) (PositionSize, error)

func (PositionSize) CheckedSub

func (v PositionSize) CheckedSub(other PositionSize) (PositionSize, error)

func (PositionSize) CloseQuantity

func (v PositionSize) CloseQuantity() (Quantity, optional.Option[Side])

func (PositionSize) Compare

func (v PositionSize) Compare(other PositionSize) int

func (PositionSize) Decimal

func (v PositionSize) Decimal() decimal.Decimal

func (PositionSize) Equal

func (v PositionSize) Equal(other PositionSize) bool

func (PositionSize) Float

func (v PositionSize) Float() float64

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewPositionSizeFromString or NewPositionSizeFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func (PositionSize) Handle

func (PositionSize) IsZero

func (v PositionSize) IsZero() bool

func (PositionSize) OpenQuantity

func (v PositionSize) OpenQuantity() (Quantity, Side)

func (PositionSize) String

func (v PositionSize) String() string

type Price

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

Price is a per-unit instrument price.

Values are validated and stored in the native value layout. Every arithmetic or conversion call on this type crosses the Go/C boundary via FFI and has a per-operation cost. For ultra-low-latency paths that need many intermediate computations, prefer performing the math on primitive types or a custom representation and cross into Price only once via NewPriceFromString / NewPriceFromDecimal / NewPriceFromHandle.

This cost exists because the SDK guarantees that the same input produces bit-for-bit identical results across all language bindings (Rust, Go, Python). Running arithmetic through the core is the mechanism that enforces that determinism.

func NewPriceFromDecimal

func NewPriceFromDecimal(v decimal.Decimal) (Price, error)

NewPriceFromDecimal converts a shopspring decimal to a Price.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewPriceFromDecimalRounded

func NewPriceFromDecimalRounded(
	v decimal.Decimal,
	scale uint32,
	strategy RoundingStrategy,
) (Price, error)

NewPriceFromDecimalRounded converts a shopspring decimal to a rounded Price.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewPriceFromFloat

func NewPriceFromFloat(v float64) (Price, error)

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewPriceFromString or NewPriceFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func NewPriceFromFloatRounded

func NewPriceFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Price, error)

func NewPriceFromHandle

func NewPriceFromHandle(v native.ParamPrice) Price

func NewPriceFromInt

func NewPriceFromInt(v int64) (Price, error)

func NewPriceFromString

func NewPriceFromString(v string) (Price, error)

func NewPriceFromStringRounded

func NewPriceFromStringRounded(
	v string,
	scale uint32,
	strategy RoundingStrategy,
) (Price, error)

func NewPriceFromUint

func NewPriceFromUint(v uint64) (Price, error)

func (Price) CalculateVolume

func (v Price) CalculateVolume(quantity Quantity) (Volume, error)

func (Price) CheckedAdd

func (v Price) CheckedAdd(other Price) (Price, error)

func (Price) CheckedDivFloat

func (v Price) CheckedDivFloat(divisor float64) (Price, error)

func (Price) CheckedDivInt

func (v Price) CheckedDivInt(divisor int64) (Price, error)

func (Price) CheckedDivUint

func (v Price) CheckedDivUint(divisor uint64) (Price, error)

func (Price) CheckedMulFloat

func (v Price) CheckedMulFloat(scalar float64) (Price, error)

func (Price) CheckedMulInt

func (v Price) CheckedMulInt(scalar int64) (Price, error)

func (Price) CheckedMulUint

func (v Price) CheckedMulUint(scalar uint64) (Price, error)

func (Price) CheckedNeg

func (v Price) CheckedNeg() (Price, error)

func (Price) CheckedRemFloat

func (v Price) CheckedRemFloat(divisor float64) (Price, error)

func (Price) CheckedRemInt

func (v Price) CheckedRemInt(divisor int64) (Price, error)

func (Price) CheckedRemUint

func (v Price) CheckedRemUint(divisor uint64) (Price, error)

func (Price) CheckedSub

func (v Price) CheckedSub(other Price) (Price, error)

func (Price) Compare

func (v Price) Compare(other Price) int

func (Price) Decimal

func (v Price) Decimal() decimal.Decimal

func (Price) Equal

func (v Price) Equal(other Price) bool

func (Price) Float

func (v Price) Float() float64

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewPriceFromString or NewPriceFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func (Price) Handle

func (v Price) Handle() native.ParamPrice

func (Price) IsZero

func (v Price) IsZero() bool

func (Price) String

func (v Price) String() string

type Quantity

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

Quantity is an instrument quantity.

Values are validated and stored in the native value layout. Every arithmetic or conversion call on this type crosses the Go/C boundary via FFI and has a per-operation cost. For ultra-low-latency paths that need many intermediate computations, prefer performing the math on primitive types or a custom representation and cross into Quantity only once via NewQuantityFromString / NewQuantityFromDecimal / NewQuantityFromHandle.

This cost exists because the SDK guarantees that the same input produces bit-for-bit identical results across all language bindings (Rust, Go, Python). Running arithmetic through the core is the mechanism that enforces that determinism.

func NewQuantityFromDecimal

func NewQuantityFromDecimal(v decimal.Decimal) (Quantity, error)

NewQuantityFromDecimal converts a shopspring decimal to a Quantity.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewQuantityFromDecimalRounded

func NewQuantityFromDecimalRounded(
	v decimal.Decimal,
	scale uint32,
	strategy RoundingStrategy,
) (Quantity, error)

NewQuantityFromDecimalRounded converts a shopspring decimal to a rounded Quantity.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewQuantityFromFloat

func NewQuantityFromFloat(v float64) (Quantity, error)

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewQuantityFromString or NewQuantityFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func NewQuantityFromFloatRounded

func NewQuantityFromFloatRounded(
	v float64,
	scale uint32,
	strategy RoundingStrategy,
) (Quantity, error)

func NewQuantityFromHandle

func NewQuantityFromHandle(v native.ParamQuantity) Quantity

func NewQuantityFromInt

func NewQuantityFromInt(v int64) (Quantity, error)

func NewQuantityFromString

func NewQuantityFromString(v string) (Quantity, error)

func NewQuantityFromStringRounded

func NewQuantityFromStringRounded(
	v string,
	scale uint32,
	strategy RoundingStrategy,
) (Quantity, error)

func NewQuantityFromUint

func NewQuantityFromUint(v uint64) (Quantity, error)

func (Quantity) CalculateVolume

func (v Quantity) CalculateVolume(price Price) (Volume, error)

func (Quantity) CheckedAdd

func (v Quantity) CheckedAdd(other Quantity) (Quantity, error)

func (Quantity) CheckedDivFloat

func (v Quantity) CheckedDivFloat(divisor float64) (Quantity, error)

func (Quantity) CheckedDivInt

func (v Quantity) CheckedDivInt(divisor int64) (Quantity, error)

func (Quantity) CheckedDivUint

func (v Quantity) CheckedDivUint(divisor uint64) (Quantity, error)

func (Quantity) CheckedMulFloat

func (v Quantity) CheckedMulFloat(scalar float64) (Quantity, error)

func (Quantity) CheckedMulInt

func (v Quantity) CheckedMulInt(scalar int64) (Quantity, error)

func (Quantity) CheckedMulUint

func (v Quantity) CheckedMulUint(scalar uint64) (Quantity, error)

func (Quantity) CheckedRemFloat

func (v Quantity) CheckedRemFloat(divisor float64) (Quantity, error)

func (Quantity) CheckedRemInt

func (v Quantity) CheckedRemInt(divisor int64) (Quantity, error)

func (Quantity) CheckedRemUint

func (v Quantity) CheckedRemUint(divisor uint64) (Quantity, error)

func (Quantity) CheckedSub

func (v Quantity) CheckedSub(other Quantity) (Quantity, error)

func (Quantity) Compare

func (v Quantity) Compare(other Quantity) int

func (Quantity) Decimal

func (v Quantity) Decimal() decimal.Decimal

func (Quantity) Equal

func (v Quantity) Equal(other Quantity) bool

func (Quantity) Float

func (v Quantity) Float() float64

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewQuantityFromString or NewQuantityFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func (Quantity) Handle

func (v Quantity) Handle() native.ParamQuantity

func (Quantity) IsZero

func (v Quantity) IsZero() bool

func (Quantity) String

func (v Quantity) String() string

type RoundingStrategy

type RoundingStrategy native.ParamRoundingStrategy

RoundingStrategy configures decimal rounding behavior.

const (
	// RoundingStrategyMidpointNearestEven rounds midpoint to nearest even.
	RoundingStrategyMidpointNearestEven RoundingStrategy = native.ParamRoundingStrategyMidpointNearestEven
	// RoundingStrategyMidpointAwayFromZero rounds midpoint away from zero.
	RoundingStrategyMidpointAwayFromZero RoundingStrategy = native.ParamRoundingStrategyMidpointAwayFromZero
	// RoundingStrategyUp always rounds toward positive infinity.
	RoundingStrategyUp RoundingStrategy = native.ParamRoundingStrategyUp
	// RoundingStrategyDown always rounds toward negative infinity.
	RoundingStrategyDown RoundingStrategy = native.ParamRoundingStrategyDown
)
const (
	// RoundingStrategyDefault is the recommended default strategy.
	RoundingStrategyDefault RoundingStrategy = native.ParamRoundingStrategyDefault
	// RoundingStrategyBanker is banker's rounding alias.
	RoundingStrategyBanker RoundingStrategy = native.ParamRoundingStrategyBanker
	// RoundingStrategyConservativeProfit rounds down for conservative profit estimates.
	RoundingStrategyConservativeProfit RoundingStrategy = native.ParamRoundingStrategyConservativeProfit
	// RoundingStrategyConservativeLoss rounds down for conservative loss estimates.
	RoundingStrategyConservativeLoss RoundingStrategy = native.ParamRoundingStrategyConservativeLoss
)

func (RoundingStrategy) String

func (r RoundingStrategy) String() string

type Side

type Side native.ParamSide

Side represents the side of a trade or order.

const (
	// SideBuy means buy side.
	SideBuy Side = native.ParamSideBuy
	// SideSell means sell side.
	SideSell Side = native.ParamSideSell
)

func (Side) Handle

func (v Side) Handle() native.ParamSide

func (Side) IsBuy

func (v Side) IsBuy() bool

IsBuy returns true when side is buy.

func (Side) IsSell

func (v Side) IsSell() bool

IsSell returns true when side is sell.

func (Side) Opposite

func (v Side) Opposite() Side

Opposite returns the opposite side.

func (Side) Sign

func (v Side) Sign() int8

Sign returns +1 for buy and -1 for sell.

func (Side) String

func (v Side) String() string

type Trade

type Trade struct {
	Price    Price
	Quantity Quantity
}

Trade represents execution price and quantity.

func (Trade) String

func (v Trade) String() string

type TradeAmount

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

func NewQuantityTradeAmount

func NewQuantityTradeAmount(v Quantity) TradeAmount

func NewVolumeTradeAmount

func NewVolumeTradeAmount(v Volume) TradeAmount

func (TradeAmount) Choose

func (a TradeAmount) Choose(getQuantity func(Quantity), getVolume func(Volume))

func (TradeAmount) Handle

func (a TradeAmount) Handle() native.ParamTradeAmount

func (TradeAmount) IsQuantity

func (a TradeAmount) IsQuantity() bool

func (TradeAmount) IsVolume

func (a TradeAmount) IsVolume() bool

func (TradeAmount) MustQuantity

func (a TradeAmount) MustQuantity() Quantity

func (TradeAmount) MustVolume

func (a TradeAmount) MustVolume() Volume

type Volume

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

Volume is a settlement notional volume.

Values are validated and stored in the native value layout. Every arithmetic or conversion call on this type crosses the Go/C boundary via FFI and has a per-operation cost. For ultra-low-latency paths that need many intermediate computations, prefer performing the math on primitive types or a custom representation and cross into Volume only once via NewVolumeFromString / NewVolumeFromDecimal / NewVolumeFromHandle.

This cost exists because the SDK guarantees that the same input produces bit-for-bit identical results across all language bindings (Rust, Go, Python). Running arithmetic through the core is the mechanism that enforces that determinism.

func NewVolumeFromDecimal

func NewVolumeFromDecimal(v decimal.Decimal) (Volume, error)

NewVolumeFromDecimal converts a shopspring decimal to a Volume.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewVolumeFromDecimalRounded

func NewVolumeFromDecimalRounded(
	v decimal.Decimal,
	scale uint32,
	strategy RoundingStrategy,
) (Volume, error)

NewVolumeFromDecimalRounded converts a shopspring decimal to a rounded Volume.

WARNING: This constructor delegates to native decimal conversion that truncates the coefficient to 64 bits. If the decimal mantissa exceeds int64 range, higher bits are silently discarded without any error or panic.

func NewVolumeFromFloat

func NewVolumeFromFloat(v float64) (Volume, error)

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewVolumeFromString or NewVolumeFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func NewVolumeFromFloatRounded

func NewVolumeFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Volume, error)

func NewVolumeFromHandle

func NewVolumeFromHandle(v native.ParamVolume) Volume

func NewVolumeFromInt

func NewVolumeFromInt(v int64) (Volume, error)

func NewVolumeFromString

func NewVolumeFromString(v string) (Volume, error)

func NewVolumeFromStringRounded

func NewVolumeFromStringRounded(
	v string,
	scale uint32,
	strategy RoundingStrategy,
) (Volume, error)

func NewVolumeFromUint

func NewVolumeFromUint(v uint64) (Volume, error)

func (Volume) CalculateQuantity

func (v Volume) CalculateQuantity(price Price) (Quantity, error)

func (Volume) CashFlowInflow

func (v Volume) CashFlowInflow() CashFlow

func (Volume) CashFlowOutflow

func (v Volume) CashFlowOutflow() CashFlow

func (Volume) CheckedAdd

func (v Volume) CheckedAdd(other Volume) (Volume, error)

func (Volume) CheckedDivFloat

func (v Volume) CheckedDivFloat(divisor float64) (Volume, error)

func (Volume) CheckedDivInt

func (v Volume) CheckedDivInt(divisor int64) (Volume, error)

func (Volume) CheckedDivUint

func (v Volume) CheckedDivUint(divisor uint64) (Volume, error)

func (Volume) CheckedMulFloat

func (v Volume) CheckedMulFloat(scalar float64) (Volume, error)

func (Volume) CheckedMulInt

func (v Volume) CheckedMulInt(scalar int64) (Volume, error)

func (Volume) CheckedMulUint

func (v Volume) CheckedMulUint(scalar uint64) (Volume, error)

func (Volume) CheckedRemFloat

func (v Volume) CheckedRemFloat(divisor float64) (Volume, error)

func (Volume) CheckedRemInt

func (v Volume) CheckedRemInt(divisor int64) (Volume, error)

func (Volume) CheckedRemUint

func (v Volume) CheckedRemUint(divisor uint64) (Volume, error)

func (Volume) CheckedSub

func (v Volume) CheckedSub(other Volume) (Volume, error)

func (Volume) Compare

func (v Volume) Compare(other Volume) int

func (Volume) Decimal

func (v Volume) Decimal() decimal.Decimal

func (Volume) Equal

func (v Volume) Equal(other Volume) bool

func (Volume) Float

func (v Volume) Float() float64

WARNING: float64 values are inherently imprecise. The same numeric literal interpreted as float64 can differ by one ULP from its string representation and may produce different values on different platforms or compilers. DO NOT use for monetary data received from external systems — prefer NewVolumeFromString or NewVolumeFromDecimal. This constructor is provided for parity and test convenience only; cross-platform determinism is NOT guaranteed when construction goes through float64.

func (Volume) Handle

func (v Volume) Handle() native.ParamVolume

func (Volume) IsZero

func (v Volume) IsZero() bool

func (Volume) String

func (v Volume) String() string

Jump to

Keyboard shortcuts

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