entities

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: GPL-3.0 Imports: 10 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 {
	Parameters        Parameters         `json:"parameters"`
	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"`
}

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 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