Documentation
¶
Index ¶
- Constants
- Variables
- func NewAccountIDOptionFromHandle(source native.ParamAccountIDOptional) optional.Option[AccountID]
- func NewAdjustmentAmountFromHandle(amount native.ParamAdjustmentAmount) optional.Option[AdjustmentAmount]
- func NewAssetFromHandle(v native.StringView) optional.Option[Asset]
- func NewCashFlowOptionFromHandle(v native.ParamCashFlowOptional) optional.Option[CashFlow]
- func NewFeeOptionFromHandle(v native.ParamFeeOptional) optional.Option[Fee]
- func NewInstrumentFromHandle(i native.Instrument) optional.Option[Instrument]
- func NewLeverageOptionFromHandle(v native.ParamLeverage) optional.Option[Leverage]
- func NewNotionalOptionFromHandle(v native.ParamNotionalOptional) optional.Option[Notional]
- func NewPnlOptionFromHandle(v native.ParamPnlOptional) optional.Option[Pnl]
- func NewPositionModeFromHandle(v native.ParamPositionMode) optional.Option[PositionMode]
- func NewPositionSideFromHandle(v native.ParamPositionSide) optional.Option[PositionSide]
- func NewPositionSizeOptionFromHandle(v native.ParamPositionSizeOptional) optional.Option[PositionSize]
- func NewPriceOptionFromHandle(v native.ParamPriceOptional) optional.Option[Price]
- func NewQuantityOptionFromHandle(v native.ParamQuantityOptional) optional.Option[Quantity]
- func NewSideFromHandle(v native.ParamSide) optional.Option[Side]
- func NewTradeAmountFromHandle(amount native.ParamTradeAmount) optional.Option[TradeAmount]
- func NewVolumeOptionFromHandle(v native.ParamVolumeOptional) optional.Option[Volume]
- type AccountID
- type AdjustmentAmount
- func (a AdjustmentAmount) Choose(getDelta func(PositionSize), getAbsolute func(PositionSize))
- func (a AdjustmentAmount) Handle() native.ParamAdjustmentAmount
- func (a AdjustmentAmount) IsAbsolute() bool
- func (a AdjustmentAmount) IsDelta() bool
- func (a AdjustmentAmount) MustAbsolute() PositionSize
- func (a AdjustmentAmount) MustDelta() PositionSize
- func (a AdjustmentAmount) String() string
- type Asset
- type CashFlow
- func NewCashFlowFromDecimal(v decimal.Decimal) (CashFlow, error)
- func NewCashFlowFromDecimalRounded(v decimal.Decimal, scale uint32, strategy RoundingStrategy) (CashFlow, error)
- func NewCashFlowFromFee(fee Fee) (CashFlow, error)
- func NewCashFlowFromFloat(v float64) (CashFlow, error)
- func NewCashFlowFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (CashFlow, error)
- func NewCashFlowFromHandle(v native.ParamCashFlow) CashFlow
- func NewCashFlowFromInt(v int64) (CashFlow, error)
- func NewCashFlowFromPnl(pnl Pnl) (CashFlow, error)
- func NewCashFlowFromString(v string) (CashFlow, error)
- func NewCashFlowFromStringRounded(v string, scale uint32, strategy RoundingStrategy) (CashFlow, error)
- func NewCashFlowFromUint(v uint64) (CashFlow, error)
- func NewCashFlowFromVolumeInflow(volume Volume) (CashFlow, error)
- func NewCashFlowFromVolumeOutflow(volume Volume) (CashFlow, error)
- func (v CashFlow) CheckedAdd(other CashFlow) (CashFlow, error)
- func (v CashFlow) CheckedDivFloat(divisor float64) (CashFlow, error)
- func (v CashFlow) CheckedDivInt(divisor int64) (CashFlow, error)
- func (v CashFlow) CheckedDivUint(divisor uint64) (CashFlow, error)
- func (v CashFlow) CheckedMulFloat(scalar float64) (CashFlow, error)
- func (v CashFlow) CheckedMulInt(scalar int64) (CashFlow, error)
- func (v CashFlow) CheckedMulUint(scalar uint64) (CashFlow, error)
- func (v CashFlow) CheckedNeg() (CashFlow, error)
- func (v CashFlow) CheckedRemFloat(divisor float64) (CashFlow, error)
- func (v CashFlow) CheckedRemInt(divisor int64) (CashFlow, error)
- func (v CashFlow) CheckedRemUint(divisor uint64) (CashFlow, error)
- func (v CashFlow) CheckedSub(other CashFlow) (CashFlow, error)
- func (v CashFlow) Compare(other CashFlow) int
- func (v CashFlow) Decimal() decimal.Decimal
- func (v CashFlow) Equal(other CashFlow) bool
- func (v CashFlow) Float() float64
- func (v CashFlow) Handle() native.ParamCashFlow
- func (v CashFlow) IsZero() bool
- func (v CashFlow) String() string
- type Fee
- func NewFeeFromDecimal(v decimal.Decimal) (Fee, error)
- func NewFeeFromDecimalRounded(v decimal.Decimal, scale uint32, strategy RoundingStrategy) (Fee, error)
- func NewFeeFromFloat(v float64) (Fee, error)
- func NewFeeFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Fee, error)
- func NewFeeFromHandle(v native.ParamFee) Fee
- func NewFeeFromInt(v int64) (Fee, error)
- func NewFeeFromString(v string) (Fee, error)
- func NewFeeFromStringRounded(v string, scale uint32, strategy RoundingStrategy) (Fee, error)
- func NewFeeFromUint(v uint64) (Fee, error)
- func (v Fee) CashFlow() (CashFlow, error)
- func (v Fee) CheckedAdd(other Fee) (Fee, error)
- func (v Fee) CheckedDivFloat(divisor float64) (Fee, error)
- func (v Fee) CheckedDivInt(divisor int64) (Fee, error)
- func (v Fee) CheckedDivUint(divisor uint64) (Fee, error)
- func (v Fee) CheckedMulFloat(scalar float64) (Fee, error)
- func (v Fee) CheckedMulInt(scalar int64) (Fee, error)
- func (v Fee) CheckedMulUint(scalar uint64) (Fee, error)
- func (v Fee) CheckedNeg() (Fee, error)
- func (v Fee) CheckedRemFloat(divisor float64) (Fee, error)
- func (v Fee) CheckedRemInt(divisor int64) (Fee, error)
- func (v Fee) CheckedRemUint(divisor uint64) (Fee, error)
- func (v Fee) CheckedSub(other Fee) (Fee, error)
- func (v Fee) Compare(other Fee) int
- func (v Fee) Decimal() decimal.Decimal
- func (v Fee) Equal(other Fee) bool
- func (v Fee) Float() float64
- func (v Fee) Handle() native.ParamFee
- func (v Fee) IsZero() bool
- func (v Fee) Pnl() (Pnl, error)
- func (v Fee) PositionSize() (PositionSize, error)
- func (v Fee) String() string
- type Instrument
- type Leverage
- type Notional
- func NewNotionalFromDecimal(v decimal.Decimal) (Notional, error)
- func NewNotionalFromDecimalRounded(v decimal.Decimal, scale uint32, strategy RoundingStrategy) (Notional, error)
- func NewNotionalFromFloat(v float64) (Notional, error)
- func NewNotionalFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Notional, error)
- func NewNotionalFromHandle(v native.ParamNotional) Notional
- func NewNotionalFromInt(v int64) (Notional, error)
- func NewNotionalFromString(v string) (Notional, error)
- func NewNotionalFromStringRounded(v string, scale uint32, strategy RoundingStrategy) (Notional, error)
- func NewNotionalFromUint(v uint64) (Notional, error)
- func NewNotionalFromVolume(v Volume) (Notional, error)
- func (v Notional) CalculateMarginRequired(leverage Leverage) (Notional, error)
- func (v Notional) CheckedAdd(other Notional) (Notional, error)
- func (v Notional) CheckedDivFloat(divisor float64) (Notional, error)
- func (v Notional) CheckedDivInt(divisor int64) (Notional, error)
- func (v Notional) CheckedDivUint(divisor uint64) (Notional, error)
- func (v Notional) CheckedMulFloat(scalar float64) (Notional, error)
- func (v Notional) CheckedMulInt(scalar int64) (Notional, error)
- func (v Notional) CheckedMulUint(scalar uint64) (Notional, error)
- func (v Notional) CheckedRemFloat(divisor float64) (Notional, error)
- func (v Notional) CheckedRemInt(divisor int64) (Notional, error)
- func (v Notional) CheckedRemUint(divisor uint64) (Notional, error)
- func (v Notional) CheckedSub(other Notional) (Notional, error)
- func (v Notional) Compare(other Notional) int
- func (v Notional) Decimal() decimal.Decimal
- func (v Notional) Equal(other Notional) bool
- func (v Notional) Float() float64
- func (v Notional) Handle() native.ParamNotional
- func (v Notional) IsZero() bool
- func (v Notional) String() string
- func (v Notional) Volume() (Volume, error)
- type Pnl
- func NewPnlFromDecimal(v decimal.Decimal) (Pnl, error)
- func NewPnlFromDecimalRounded(v decimal.Decimal, scale uint32, strategy RoundingStrategy) (Pnl, error)
- func NewPnlFromFee(fee Fee) (Pnl, error)
- func NewPnlFromFloat(v float64) (Pnl, error)
- func NewPnlFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Pnl, error)
- func NewPnlFromHandle(v native.ParamPnl) Pnl
- func NewPnlFromInt(v int64) (Pnl, error)
- func NewPnlFromString(v string) (Pnl, error)
- func NewPnlFromStringRounded(v string, scale uint32, strategy RoundingStrategy) (Pnl, error)
- func NewPnlFromUint(v uint64) (Pnl, error)
- func (v Pnl) CashFlow() (CashFlow, error)
- func (v Pnl) CheckedAdd(other Pnl) (Pnl, error)
- func (v Pnl) CheckedDivFloat(divisor float64) (Pnl, error)
- func (v Pnl) CheckedDivInt(divisor int64) (Pnl, error)
- func (v Pnl) CheckedDivUint(divisor uint64) (Pnl, error)
- func (v Pnl) CheckedMulFloat(scalar float64) (Pnl, error)
- func (v Pnl) CheckedMulInt(scalar int64) (Pnl, error)
- func (v Pnl) CheckedMulUint(scalar uint64) (Pnl, error)
- func (v Pnl) CheckedNeg() (Pnl, error)
- func (v Pnl) CheckedRemFloat(divisor float64) (Pnl, error)
- func (v Pnl) CheckedRemInt(divisor int64) (Pnl, error)
- func (v Pnl) CheckedRemUint(divisor uint64) (Pnl, error)
- func (v Pnl) CheckedSub(other Pnl) (Pnl, error)
- func (v Pnl) Compare(other Pnl) int
- func (v Pnl) Decimal() decimal.Decimal
- func (v Pnl) Equal(other Pnl) bool
- func (v Pnl) Float() float64
- func (v Pnl) Handle() native.ParamPnl
- func (v Pnl) IsZero() bool
- func (v Pnl) PositionSize() (PositionSize, error)
- func (v Pnl) String() string
- type PositionEffect
- type PositionMode
- type PositionSide
- type PositionSize
- func NewPositionSizeFromDecimal(v decimal.Decimal) (PositionSize, error)
- func NewPositionSizeFromDecimalRounded(v decimal.Decimal, scale uint32, strategy RoundingStrategy) (PositionSize, error)
- func NewPositionSizeFromFee(fee Fee) (PositionSize, error)
- func NewPositionSizeFromFloat(v float64) (PositionSize, error)
- func NewPositionSizeFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (PositionSize, error)
- func NewPositionSizeFromHandle(v native.ParamPositionSize) PositionSize
- func NewPositionSizeFromInt(v int64) (PositionSize, error)
- func NewPositionSizeFromPnl(pnl Pnl) (PositionSize, error)
- func NewPositionSizeFromQuantityAndSide(q Quantity, side Side) (PositionSize, error)
- func NewPositionSizeFromString(v string) (PositionSize, error)
- func NewPositionSizeFromStringRounded(v string, scale uint32, strategy RoundingStrategy) (PositionSize, error)
- func NewPositionSizeFromUint(v uint64) (PositionSize, error)
- func (v PositionSize) CheckedAdd(other PositionSize) (PositionSize, error)
- func (v PositionSize) CheckedAddQuantity(q Quantity, side Side) (PositionSize, error)
- func (v PositionSize) CheckedDivFloat(divisor float64) (PositionSize, error)
- func (v PositionSize) CheckedDivInt(divisor int64) (PositionSize, error)
- func (v PositionSize) CheckedDivUint(divisor uint64) (PositionSize, error)
- func (v PositionSize) CheckedMulFloat(scalar float64) (PositionSize, error)
- func (v PositionSize) CheckedMulInt(scalar int64) (PositionSize, error)
- func (v PositionSize) CheckedMulUint(scalar uint64) (PositionSize, error)
- func (v PositionSize) CheckedNeg() (PositionSize, error)
- func (v PositionSize) CheckedRemFloat(divisor float64) (PositionSize, error)
- func (v PositionSize) CheckedRemInt(divisor int64) (PositionSize, error)
- func (v PositionSize) CheckedRemUint(divisor uint64) (PositionSize, error)
- func (v PositionSize) CheckedSub(other PositionSize) (PositionSize, error)
- func (v PositionSize) CloseQuantity() (Quantity, optional.Option[Side])
- func (v PositionSize) Compare(other PositionSize) int
- func (v PositionSize) Decimal() decimal.Decimal
- func (v PositionSize) Equal(other PositionSize) bool
- func (v PositionSize) Float() float64
- func (v PositionSize) Handle() native.ParamPositionSize
- func (v PositionSize) IsZero() bool
- func (v PositionSize) OpenQuantity() (Quantity, Side)
- func (v PositionSize) String() string
- type Price
- func NewPriceFromDecimal(v decimal.Decimal) (Price, error)
- func NewPriceFromDecimalRounded(v decimal.Decimal, scale uint32, strategy RoundingStrategy) (Price, error)
- func NewPriceFromFloat(v float64) (Price, error)
- func NewPriceFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Price, error)
- func NewPriceFromHandle(v native.ParamPrice) Price
- func NewPriceFromInt(v int64) (Price, error)
- func NewPriceFromString(v string) (Price, error)
- func NewPriceFromStringRounded(v string, scale uint32, strategy RoundingStrategy) (Price, error)
- func NewPriceFromUint(v uint64) (Price, error)
- func (v Price) CalculateVolume(quantity Quantity) (Volume, error)
- func (v Price) CheckedAdd(other Price) (Price, error)
- func (v Price) CheckedDivFloat(divisor float64) (Price, error)
- func (v Price) CheckedDivInt(divisor int64) (Price, error)
- func (v Price) CheckedDivUint(divisor uint64) (Price, error)
- func (v Price) CheckedMulFloat(scalar float64) (Price, error)
- func (v Price) CheckedMulInt(scalar int64) (Price, error)
- func (v Price) CheckedMulUint(scalar uint64) (Price, error)
- func (v Price) CheckedNeg() (Price, error)
- func (v Price) CheckedRemFloat(divisor float64) (Price, error)
- func (v Price) CheckedRemInt(divisor int64) (Price, error)
- func (v Price) CheckedRemUint(divisor uint64) (Price, error)
- func (v Price) CheckedSub(other Price) (Price, error)
- func (v Price) Compare(other Price) int
- func (v Price) Decimal() decimal.Decimal
- func (v Price) Equal(other Price) bool
- func (v Price) Float() float64
- func (v Price) Handle() native.ParamPrice
- func (v Price) IsZero() bool
- func (v Price) String() string
- type Quantity
- func NewQuantityFromDecimal(v decimal.Decimal) (Quantity, error)
- func NewQuantityFromDecimalRounded(v decimal.Decimal, scale uint32, strategy RoundingStrategy) (Quantity, error)
- func NewQuantityFromFloat(v float64) (Quantity, error)
- func NewQuantityFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Quantity, error)
- func NewQuantityFromHandle(v native.ParamQuantity) Quantity
- func NewQuantityFromInt(v int64) (Quantity, error)
- func NewQuantityFromString(v string) (Quantity, error)
- func NewQuantityFromStringRounded(v string, scale uint32, strategy RoundingStrategy) (Quantity, error)
- func NewQuantityFromUint(v uint64) (Quantity, error)
- func (v Quantity) CalculateVolume(price Price) (Volume, error)
- func (v Quantity) CheckedAdd(other Quantity) (Quantity, error)
- func (v Quantity) CheckedDivFloat(divisor float64) (Quantity, error)
- func (v Quantity) CheckedDivInt(divisor int64) (Quantity, error)
- func (v Quantity) CheckedDivUint(divisor uint64) (Quantity, error)
- func (v Quantity) CheckedMulFloat(scalar float64) (Quantity, error)
- func (v Quantity) CheckedMulInt(scalar int64) (Quantity, error)
- func (v Quantity) CheckedMulUint(scalar uint64) (Quantity, error)
- func (v Quantity) CheckedRemFloat(divisor float64) (Quantity, error)
- func (v Quantity) CheckedRemInt(divisor int64) (Quantity, error)
- func (v Quantity) CheckedRemUint(divisor uint64) (Quantity, error)
- func (v Quantity) CheckedSub(other Quantity) (Quantity, error)
- func (v Quantity) Compare(other Quantity) int
- func (v Quantity) Decimal() decimal.Decimal
- func (v Quantity) Equal(other Quantity) bool
- func (v Quantity) Float() float64
- func (v Quantity) Handle() native.ParamQuantity
- func (v Quantity) IsZero() bool
- func (v Quantity) String() string
- type RoundingStrategy
- type Side
- type Trade
- type TradeAmount
- type Volume
- func NewVolumeFromDecimal(v decimal.Decimal) (Volume, error)
- func NewVolumeFromDecimalRounded(v decimal.Decimal, scale uint32, strategy RoundingStrategy) (Volume, error)
- func NewVolumeFromFloat(v float64) (Volume, error)
- func NewVolumeFromFloatRounded(v float64, scale uint32, strategy RoundingStrategy) (Volume, error)
- func NewVolumeFromHandle(v native.ParamVolume) Volume
- func NewVolumeFromInt(v int64) (Volume, error)
- func NewVolumeFromString(v string) (Volume, error)
- func NewVolumeFromStringRounded(v string, scale uint32, strategy RoundingStrategy) (Volume, error)
- func NewVolumeFromUint(v uint64) (Volume, error)
- func (v Volume) CalculateQuantity(price Price) (Quantity, error)
- func (v Volume) CashFlowInflow() CashFlow
- func (v Volume) CashFlowOutflow() CashFlow
- func (v Volume) CheckedAdd(other Volume) (Volume, error)
- func (v Volume) CheckedDivFloat(divisor float64) (Volume, error)
- func (v Volume) CheckedDivInt(divisor int64) (Volume, error)
- func (v Volume) CheckedDivUint(divisor uint64) (Volume, error)
- func (v Volume) CheckedMulFloat(scalar float64) (Volume, error)
- func (v Volume) CheckedMulInt(scalar int64) (Volume, error)
- func (v Volume) CheckedMulUint(scalar uint64) (Volume, error)
- func (v Volume) CheckedRemFloat(divisor float64) (Volume, error)
- func (v Volume) CheckedRemInt(divisor int64) (Volume, error)
- func (v Volume) CheckedRemUint(divisor uint64) (Volume, error)
- func (v Volume) CheckedSub(other Volume) (Volume, error)
- func (v Volume) Compare(other Volume) int
- func (v Volume) Decimal() decimal.Decimal
- func (v Volume) Equal(other Volume) bool
- func (v Volume) Float() float64
- func (v Volume) Handle() native.ParamVolume
- func (v Volume) IsZero() bool
- func (v Volume) String() string
Constants ¶
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 ¶
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 )
var CashFlowZero = newCashFlowOrPanic(NewCashFlowFromInt(0))
var ErrAccountIDEmpty = native.ErrAccountIdEmpty
var ErrAssetEmpty = native.ErrAssetEmpty
var FeeZero = newFeeOrPanic(NewFeeFromInt(0))
var LeverageZero = Leverage{}
LeverageZero is the zero-value leverage payload (`not set` state).
var NotionalZero = newNotionalOrPanic(NewNotionalFromInt(0))
var PnlZero = newPnlOrPanic(NewPnlFromInt(0))
var PositionSizeZero = newPositionSizeOrPanic(NewPositionSizeFromInt(0))
var PriceZero = newPriceOrPanic(NewPriceFromInt(0))
var QuantityZero = newQuantityOrPanic(NewQuantityFromInt(0))
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 NewNotionalOptionFromHandle ¶
func NewNotionalOptionFromHandle(v native.ParamNotionalOptional) optional.Option[Notional]
func NewPnlOptionFromHandle ¶
func NewPnlOptionFromHandle(v native.ParamPnlOptional) optional.Option[Pnl]
func NewPositionModeFromHandle ¶
func NewPositionModeFromHandle(v native.ParamPositionMode) optional.Option[PositionMode]
func NewPositionSideFromHandle ¶
func NewPositionSideFromHandle(v native.ParamPositionSide) optional.Option[PositionSide]
func NewPositionSizeOptionFromHandle ¶
func NewPositionSizeOptionFromHandle( v native.ParamPositionSizeOptional, ) optional.Option[PositionSize]
func NewPriceOptionFromHandle ¶
func NewPriceOptionFromHandle(v native.ParamPriceOptional) optional.Option[Price]
func NewQuantityOptionFromHandle ¶
func NewQuantityOptionFromHandle(v native.ParamQuantityOptional) optional.Option[Quantity]
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 ¶
NewAccountIDFromInt constructs an account identifier from an integer value.
func NewAccountIDFromString ¶
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.
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 (a AdjustmentAmount) Handle() native.ParamAdjustmentAmount
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 ¶
NewAsset validates v and creates an Asset whose bytes live in a C-heap buffer freed automatically by the GC.
func (Asset) Equal ¶
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 ¶
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 ¶
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 ¶
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) Unsafe ¶
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 ¶
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 NewCashFlowFromFloat ¶
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 NewCashFlowFromPnl ¶
func NewCashFlowFromString ¶
func NewCashFlowFromStringRounded ¶
func NewCashFlowFromStringRounded( v string, scale uint32, strategy RoundingStrategy, ) (CashFlow, error)
func NewCashFlowFromUint ¶
func (CashFlow) CheckedDivFloat ¶
func (CashFlow) CheckedMulFloat ¶
func (CashFlow) CheckedNeg ¶
func (CashFlow) CheckedRemFloat ¶
func (CashFlow) Float ¶
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
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 ¶
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 ¶
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 NewFeeFromInt ¶
func NewFeeFromString ¶
func NewFeeFromStringRounded ¶
func NewFeeFromStringRounded( v string, scale uint32, strategy RoundingStrategy, ) (Fee, error)
func NewFeeFromUint ¶
func (Fee) CheckedNeg ¶
func (Fee) Float ¶
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) PositionSize ¶
func (v Fee) PositionSize() (PositionSize, error)
type Instrument ¶
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 ¶
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 ¶
NewLeverageFromInt builds leverage from integer multiplier.
Conversion uses fixed-point encoding:
raw = multiplier * LeverageScale
No business validation is performed.
func (Leverage) CalculateMarginRequired ¶
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 ¶
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.
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 ¶
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 ¶
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 NewNotionalFromString ¶
func NewNotionalFromStringRounded ¶
func NewNotionalFromStringRounded( v string, scale uint32, strategy RoundingStrategy, ) (Notional, error)
func NewNotionalFromUint ¶
func NewNotionalFromVolume ¶
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 ¶
CalculateMarginRequired returns the margin needed to hold this position at the given leverage.
Formula: margin = notional / leverage.
func (Notional) CheckedDivFloat ¶
func (Notional) CheckedMulFloat ¶
func (Notional) CheckedRemFloat ¶
func (Notional) Float ¶
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
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 ¶
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 NewPnlFromFloat ¶
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 NewPnlFromInt ¶
func NewPnlFromString ¶
func NewPnlFromStringRounded ¶
func NewPnlFromStringRounded( v string, scale uint32, strategy RoundingStrategy, ) (Pnl, error)
func NewPnlFromUint ¶
func (Pnl) CheckedNeg ¶
func (Pnl) Float ¶
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) PositionSize ¶
func (v Pnl) PositionSize() (PositionSize, error)
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 (v PositionMode) Handle() native.ParamPositionMode
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 (v PositionSize) Handle() native.ParamPositionSize
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 ¶
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 ¶
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 NewPriceFromString ¶
func NewPriceFromStringRounded ¶
func NewPriceFromStringRounded( v string, scale uint32, strategy RoundingStrategy, ) (Price, error)
func NewPriceFromUint ¶
func (Price) CheckedNeg ¶
func (Price) Float ¶
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
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 ¶
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 ¶
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 NewQuantityFromString ¶
func NewQuantityFromStringRounded ¶
func NewQuantityFromStringRounded( v string, scale uint32, strategy RoundingStrategy, ) (Quantity, error)
func NewQuantityFromUint ¶
func (Quantity) CheckedDivFloat ¶
func (Quantity) CheckedMulFloat ¶
func (Quantity) CheckedRemFloat ¶
func (Quantity) Float ¶
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
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 ¶
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 )
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 ¶
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 ¶
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 NewVolumeFromString ¶
func NewVolumeFromStringRounded ¶
func NewVolumeFromStringRounded( v string, scale uint32, strategy RoundingStrategy, ) (Volume, error)
func NewVolumeFromUint ¶
func (Volume) CashFlowInflow ¶
func (Volume) CashFlowOutflow ¶
func (Volume) Float ¶
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