model

package
v0.0.0-...-e5e8b79 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Asset        float64
	AssetHold    float64
	Currency     float64
	CurrencyHold float64
}

Balance holds the account info related to an exchange account. This includes asset and base currency amounts and holds.

type BoolOption

type BoolOption struct {
	Name         string
	Description  string
	DefaultValue bool
	Value        bool
}

BoolOption provides a strategy option that holds a boolean value for the strategy to use

func (*BoolOption) String

func (option *BoolOption) String() string

String provides a string representaion of the stragety option in the format: --option-name=<value> Simple Description (default: true)

type DurationOption

type DurationOption struct {
	Name         string
	Description  string
	DefaultValue time.Duration
	Value        time.Duration
}

DurationOption provides a strategy option that holds a time.Duration value for the strategy to use

func (*DurationOption) String

func (option *DurationOption) String() string

String provides a string representaion of the stragety option in the format: --option-name=<value> Simple Description (default: 1s)

type Exchange

type Exchange interface {
	GetTrades(productID string) ([]*Trade, error)
	GetBalance(currency string, asset string) (*Balance, error)
	GetQuote(productID string) (*Quote, error)
}

Exchange provides methods to get trades, balances, and product id quotes from a supported crypto-currency exchange

type IntOption

type IntOption struct {
	Name         string
	Description  string
	DefaultValue int
	Value        int
}

IntOption provides a strategy option that holds a int value for the strategy to use

func (*IntOption) String

func (option *IntOption) String() string

String provides a string representaion of the stragety option in the format: --option-name=<value> Simple Description (default: 1)

type Option

type Option interface {
	fmt.Stringer
}

Option is a wrapper around the fmt.Stringer interface to enforce that all strategy options have a Stringer method

type Period

type Period struct {
	High     float64
	Low      float64
	Close    float64
	Selector string
}

Period holds high level information about exchange trades with a certain time "period". Periods will be used to feed into strategies to determine market signals

type Product

type Product struct {
	Asset          string `json:"asset"`
	Currency       string `json:"currency"`
	MinSize        string `json:"min_size"`
	MaxSize        string `json:"max_size"`
	Increment      string `json:"increment"`
	AssetIncrement string `json:"asset_increment"`
	Label          string `json:"label"`
}

Product holds "product" info from an exchange

type Quote

type Quote struct {
	Bid float64
	Ask float64
}

Quote holds the Bid and Ask info that represents a asset/currency pair from a crypto-currency exchange

type Selector

type Selector struct {
	ExchangeID string
	ProductID  string
	Asset      string
	Currency   string
}

Selector holds info related to the exchange, and asset/currency pair tatanka should pull trade info, balance info for

func NewSelectorFromString

func NewSelectorFromString(selectorStr string) (*Selector, error)

func (*Selector) String

func (selector *Selector) String() string

String provides a string representaion of a Selector and will return in the format "{exchange_slug}.{product_id}" (e.g. gdax.BTC-USD)

type Signal

type Signal int

Signal represents a market signal that indicates whether a market is currently bullish (going up) or bearish (going down)

const (
	BuySignal Signal = iota
	SellSignal
)

type Strategy

type Strategy interface {
	Name() string
	Description() string
	Options() []Option
	Calculate(periods []*Period) (float64, error)
	Signal(float64) Signal
}

Strategy represents a market strategy to determine a signal in the market.

type Trade

type Trade struct {
	TradeID string
	Price   float64
	Size    float64
	Time    time.Time
	Side    string
}

Trade represents a trade that has occurred on a crypto-currency exchange

func (*Trade) ID

func (t *Trade) ID() string

type Trades

type Trades []*Trade

func (Trades) Len

func (t Trades) Len() int

func (Trades) Less

func (t Trades) Less(i, j int) bool

func (Trades) Swap

func (t Trades) Swap(i, j int)

Jump to

Keyboard shortcuts

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