products

package
v0.0.0-...-141c82c Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDataSourceSpecAndBindingAreRequired is returned when the definition of the
	// data source spec or its binding is missing from the future definition.
	ErrDataSourceSpecAndBindingAreRequired = errors.New("a data source spec and spec binding are required")

	// ErrDataSourceSettlementDataNotSet is returned when the data source has not set the settlement data.
	ErrDataSourceSettlementDataNotSet = errors.New("settlement data is not set")

	// ErrSettlementDataDecimalsNotSupportedByAsset is returned when the decimal data decimal places
	// are more than the asset decimals.
	ErrSettlementDataDecimalsNotSupportedByAsset = errors.New("settlement data decimals not suported by market asset")
)
View Source
var (
	// ErrNilProduct signals the product passed in the constructor was nil.
	ErrNilProduct = errors.New("nil product")
	// ErrUnimplementedProduct signal that the product passed to the
	// constructor was not nil, but the code as no knowledge of it.
	ErrUnimplementedProduct = errors.New("unimplemented product")
)

Functions

This section is empty.

Types

type Future

type Future struct {
	SettlementAsset string
	QuoteName       string
	// contains filtered or unexported fields
}

Future represent a Future as describe by the market framework.

func NewFuture

func NewFuture(ctx context.Context, log *logging.Logger, f *types.Future, oe OracleEngine) (*Future, error)

func (*Future) GetAsset

func (f *Future) GetAsset() string

GetAsset return the asset used by the future.

func (*Future) IsTradingTerminated

func (f *Future) IsTradingTerminated() bool

IsTradingTerminated - returns true when the oracle has signalled terminated market.

func (*Future) NotifyOnSettlementData

func (f *Future) NotifyOnSettlementData(listener func(context.Context, *num.Numeric))

func (*Future) NotifyOnTradingTerminated

func (f *Future) NotifyOnTradingTerminated(listener func(context.Context, bool))

func (*Future) RestoreSettlementData

func (f *Future) RestoreSettlementData(settleData *num.Numeric)

func (*Future) ScaleSettlementDataToDecimalPlaces

func (f *Future) ScaleSettlementDataToDecimalPlaces(price *num.Numeric, dp uint32) (*num.Uint, error)

func (*Future) Settle

func (f *Future) Settle(entryPriceInAsset *num.Uint, assetDecimals uint32, netFractionalPosition num.Decimal) (amt *types.FinancialAmount, neg bool, err error)

Settle a position against the future.

func (*Future) Unsubscribe

func (f *Future) Unsubscribe(ctx context.Context)

func (*Future) UnsubscribeSettlementData

func (f *Future) UnsubscribeSettlementData(ctx context.Context)

func (*Future) UnsubscribeTradingTerminated

func (f *Future) UnsubscribeTradingTerminated(ctx context.Context)

func (*Future) Value

func (f *Future) Value(markPrice *num.Uint) (*num.Uint, error)

Value - returns the nominal value of a unit given a current mark price.

type OracleEngine

OracleEngine ...

type Product

type Product interface {
	Settle(*num.Uint, uint32, num.Decimal) (amt *types.FinancialAmount, neg bool, err error)
	Value(markPrice *num.Uint) (*num.Uint, error)
	GetAsset() string
	IsTradingTerminated() bool
	ScaleSettlementDataToDecimalPlaces(price *num.Numeric, dp uint32) (*num.Uint, error)
	NotifyOnTradingTerminated(listener func(context.Context, bool))
	NotifyOnSettlementData(listener func(context.Context, *num.Numeric))
	UnsubscribeTradingTerminated(ctx context.Context)
	UnsubscribeSettlementData(ctx context.Context)
	RestoreSettlementData(*num.Numeric)
}

Product is the interface provided by all product in zeta.

func New

func New(ctx context.Context, log *logging.Logger, pp interface{}, oe OracleEngine) (Product, error)

New instance a new product from a Market framework product configuration.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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