entities

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToAccountModels

func ToAccountModels(balances []Balance) map[string]account.Account

ToAccountModels transforms account entities to account models.

func ToOrderModels

func ToOrderModels(orders []Order) ([]order.Order, error)

ToOrderModels converts a slice of entities to a slice of models.

func ToTickSubscriptionModels

func ToTickSubscriptionModels(entities []TickSubscription) []tick.Subscription

ToTickSubscriptionModels converts a slice of entities to a slice of models.

Types

type Backtest

type Backtest struct {
	ID   string `db:"id"`
	Data []byte `db:"data"`
}

Backtest is the entity for a backtest.

func FromBacktestModel

func FromBacktestModel(bt backtest.Backtest) (Backtest, error)

FromBacktestModel converts a model into an entity.

func (Backtest) ToModel

func (bt Backtest) ToModel() (backtest.Backtest, error)

ToModel converts the entity to a model.

type BacktestData

type BacktestData struct {
	StartTime         time.Time          `json:"start_time"`
	EndTime           time.Time          `json:"end_time"`
	Mode              string             `json:"mode"`
	PricePeriod       string             `json:"price_period"`
	CurrentTime       time.Time          `json:"current_time"`
	CurrentPriceType  string             `json:"current_price_type"`
	Balances          []Balance          `json:"balances"`
	Orders            []Order            `json:"orders"`
	TickSubscriptions []TickSubscription `json:"tick_subscriptions"`
	Callbacks         Callbacks          `json:"callbacks"`
}

BacktestData is the entity for the backtest data.

type Balance

type Balance struct {
	AssetName string  `json:"asset_name"`
	Exchange  string  `json:"exchange"`
	Balance   float64 `json:"balance"`
}

Balance is the entity for a balance.

func FromAccountModels

func FromAccountModels(accounts map[string]account.Account) []Balance

FromAccountModels transforms account models to account entities.

type CallbackWorkflow added in v1.1.1

type CallbackWorkflow struct {
	Name             string        `json:"name"`
	TaskQueueName    string        `json:"task_queue_name"`
	ExecutionTimeout time.Duration `json:"execution_timeout"`
}

CallbackWorkflow is the entity for a callback workflow.

func FromCallbackWorkflowModel added in v1.1.1

func FromCallbackWorkflowModel(cw runtime.CallbackWorkflow) CallbackWorkflow

FromCallbackWorkflowModel converts a runtime.CallbackWorkflow model to a CallbackWorkflow entity.

func (CallbackWorkflow) ToCallbackWorkflowModel added in v1.1.1

func (cw CallbackWorkflow) ToCallbackWorkflowModel() runtime.CallbackWorkflow

ToCallbackWorkflowModel converts a CallbackWorkflow entity to a runtime.CallbackWorkflow model.

type Callbacks added in v1.1.1

type Callbacks struct {
	OnInitCallback      CallbackWorkflow `json:"on_init_callback"`
	OnNewPricesCallback CallbackWorkflow `json:"on_new_prices_callback"`
	OnExitCallback      CallbackWorkflow `json:"on_exit_callback"`
}

Callbacks is the entity for callbacks.

func FromCallbacksModel added in v1.1.1

func FromCallbacksModel(c runtime.Callbacks) Callbacks

FromCallbacksModel converts a runtime.Callbacks model to a Callbacks entity.

func (Callbacks) ToCallbacksModel added in v1.1.1

func (c Callbacks) ToCallbacksModel() runtime.Callbacks

ToCallbacksModel converts a Callbacks entity to a runtime.Callbacks model.

type Order

type Order struct {
	ID            string     `json:"id"`
	ExecutionTime *time.Time `json:"execution_time"`
	Type          string     `json:"type"`
	Exchange      string     `json:"exchange"`
	Pair          string     `json:"pair"`
	Side          string     `json:"side"`
	Quantity      float64    `json:"quantity"`
	Price         float64    `json:"price"`
}

Order is the entity for an order.

func FromOrderModel

func FromOrderModel(m order.Order) Order

FromOrderModel converts a model into an entity.

func FromOrderModels

func FromOrderModels(models []order.Order) []Order

FromOrderModels converts a slice of models into a slice of entities.

func (Order) ToModel

func (o Order) ToModel() (order.Order, error)

ToModel converts the entity to a model.

type Parameters

type Parameters struct {
	StartTime   time.Time `json:"start_time"`
	EndTime     time.Time `json:"end_time"`
	Mode        string    `json:"mode"`
	PricePeriod string    `json:"price_period"`
}

Parameters is the entity for the parameters of a backtest.

type TickSubscription

type TickSubscription struct {
	Exchange string `json:"exchange"`
	Pair     string `json:"pair"`
}

TickSubscription is the entity for a tick subscription.

func FromTickSubscriptionModel

func FromTickSubscriptionModel(m tick.Subscription) TickSubscription

FromTickSubscriptionModel converts a model to an entity.

func FromTickSubscriptionModels

func FromTickSubscriptionModels(models []tick.Subscription) []TickSubscription

FromTickSubscriptionModels converts a slice of models to a slice of entities.

func (TickSubscription) ToModel

func (ts TickSubscription) ToModel() tick.Subscription

ToModel converts the entity to a model.

Jump to

Keyboard shortcuts

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