model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SideTypeBuy  SideType = "BUY"
	SideTypeSell SideType = "SELL"

	OrderTypeLimit           OrderType = "LIMIT"
	OrderTypeMarket          OrderType = "MARKET"
	OrderTypeLimitMaker      OrderType = "LIMIT_MAKER"
	OrderTypeStopLoss        OrderType = "STOP_LOSS"
	OrderTypeStopLossLimit   OrderType = "STOP_LOSS_LIMIT"
	OrderTypeTakeProfit      OrderType = "TAKE_PROFIT"
	OrderTypeTakeProfitLimit OrderType = "TAKE_PROFIT_LIMIT"

	OrderStatusTypeNew             OrderStatusType = "NEW"
	OrderStatusTypePartiallyFilled OrderStatusType = "PARTIALLY_FILLED"
	OrderStatusTypeFilled          OrderStatusType = "FILLED"
	OrderStatusTypeCanceled        OrderStatusType = "CANCELED"
	OrderStatusTypePendingCancel   OrderStatusType = "PENDING_CANCEL"
	OrderStatusTypeRejected        OrderStatusType = "REJECTED"
	OrderStatusTypeExpired         OrderStatusType = "EXPIRED"
)

Functions

func NumDecPlaces

func NumDecPlaces(v float64) int64

NumDecPlaces returns the number of decimal places of a float64

Types

type Account

type Account struct {
	Balances []Balance
}

func (Account) Balance

func (a Account) Balance(assetTick, quoteTick string) (Balance, Balance)

func (Account) Equity

func (a Account) Equity() float64

type AssetInfo

type AssetInfo struct {
	BaseAsset  string
	QuoteAsset string

	MinPrice    float64
	MaxPrice    float64
	MinQuantity float64
	MaxQuantity float64
	StepSize    float64
	TickSize    float64

	QuotePrecision     int
	BaseAssetPrecision int
}

type Balance

type Balance struct {
	Asset    string
	Free     float64
	Lock     float64
	Leverage float64
}

type Candle

type Candle struct {
	Pair      string
	Time      time.Time
	UpdatedAt time.Time
	Open      float64
	Close     float64
	Low       float64
	High      float64
	Volume    float64
	Complete  bool

	// Aditional collums from CSV inputs
	Metadata map[string]float64
}

func (Candle) Empty

func (c Candle) Empty() bool

func (Candle) Less

func (c Candle) Less(j Item) bool

func (Candle) ToHeikinAshi

func (c Candle) ToHeikinAshi(ha *HeikinAshi) Candle

func (Candle) ToSlice

func (c Candle) ToSlice(precision int) []string

type Dataframe

type Dataframe struct {
	Pair string

	Close  Series[float64]
	Open   Series[float64]
	High   Series[float64]
	Low    Series[float64]
	Volume Series[float64]

	Time       []time.Time
	LastUpdate time.Time

	// Custom user metadata
	Metadata map[string]Series[float64]
}

func (Dataframe) Sample

func (df Dataframe) Sample(positions int) Dataframe

type HeikinAshi

type HeikinAshi struct {
	PreviousHACandle Candle
}

func NewHeikinAshi

func NewHeikinAshi() *HeikinAshi

func (*HeikinAshi) CalculateHeikinAshi

func (ha *HeikinAshi) CalculateHeikinAshi(c Candle) Candle

type Item

type Item interface {
	Less(Item) bool
}

type Order

type Order struct {
	ID         int64           `db:"id" json:"id" gorm:"primaryKey,autoIncrement"`
	ExchangeID int64           `db:"exchange_id" json:"exchange_id"`
	Pair       string          `db:"pair" json:"pair"`
	Side       SideType        `db:"side" json:"side"`
	Type       OrderType       `db:"type" json:"type"`
	Status     OrderStatusType `db:"status" json:"status"`
	Price      float64         `db:"price" json:"price"`
	Quantity   float64         `db:"quantity" json:"quantity"`

	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`

	// OCO Orders only
	Stop    *float64 `db:"stop" json:"stop"`
	GroupID *int64   `db:"group_id" json:"group_id"`

	// Internal use (Plot)
	RefPrice float64 `json:"ref_price" gorm:"-"`
	Profit   float64 `json:"profit" gorm:"-"`
	Candle   Candle  `json:"-" gorm:"-"`
}

func (Order) String

func (o Order) String() string

type OrderStatusType

type OrderStatusType string

type OrderType

type OrderType string

type PriorityQueue

type PriorityQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewPriorityQueue

func NewPriorityQueue(data []Item) *PriorityQueue

func (*PriorityQueue) Len

func (q *PriorityQueue) Len() int

func (*PriorityQueue) Peek

func (q *PriorityQueue) Peek() Item

func (*PriorityQueue) Pop

func (q *PriorityQueue) Pop() Item

func (*PriorityQueue) PopLock

func (q *PriorityQueue) PopLock() <-chan Item

func (*PriorityQueue) Push

func (q *PriorityQueue) Push(item Item)

type Series

type Series[T constraints.Ordered] []T

Series is a time series of values

func (Series[T]) Cross

func (s Series[T]) Cross(ref Series[T]) bool

Cross returns true if the last value of the series is greater than the last value of the reference series or less than the last value of the reference series

func (Series[T]) Crossover

func (s Series[T]) Crossover(ref Series[T]) bool

Crossover returns true if the last value of the series is greater than the last value of the reference series

func (Series[T]) Crossunder

func (s Series[T]) Crossunder(ref Series[T]) bool

Crossunder returns true if the last value of the series is less than the last value of the reference series

func (Series[T]) Last

func (s Series[T]) Last(position int) T

Last returns the last value of the series given a past index position

func (Series[T]) LastValues

func (s Series[T]) LastValues(size int) []T

LastValues returns the last values of the series given a size

func (Series[T]) Lenght

func (s Series[T]) Lenght() int

Lenght returns the number of values in the series

func (Series[T]) Values

func (s Series[T]) Values() []T

Values returns the values of the series

type Settings

type Settings struct {
	Pairs    []string
	Telegram TelegramSettings
}

type SideType

type SideType string

type TelegramSettings

type TelegramSettings struct {
	Enabled bool
	Token   string
	Users   []int
}

Jump to

Keyboard shortcuts

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