model

package
v0.0.193 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EUR = "EUR"
	USD = "USD"
	BTC = "BTC"
	ETH = "ETH"
	LTC = "LTC"
	XRP = "XRP"
)

Variables

View Source
var OrderSideString = map[OrderSide]string{
	ORDER_SIDE_NONE: "",
	BUY:             "buy",
	SELL:            "sell",
}
View Source
var OrderTypeString = map[OrderType]string{
	ORDER_TYPE_NONE: "",
	LIMIT:           "limit",
	MARKET:          "market",
}

Functions

func Call2File

func Call2File(call *Call, name string) error

func Fiat

func Fiat(asset string) bool

func FormatOrderSide

func FormatOrderSide(value OrderSide) string

func GetBaseCurr

func GetBaseCurr(markets []Market, market string) (string, error)

func GetMarket

func GetMarket(exchange Exchange) (string, error)

get the --market=X arg. verifies whether the specific market exists (or not).

func GetQuoteCurr

func GetQuoteCurr(markets []Market, market string) (string, error)

func GetSizeMax

func GetSizeMax(hold, earn bool, def float64, mult multiplier.Mult, prec func() int) float64

GetSizeMax returns the maximum size we can SELL

func GetSizeMin

func GetSizeMin(hold bool, asset string) float64

GetSizeMin returns the minimum size we must BUY, source: https://pro.coinbase.com/markets

func HasMarket

func HasMarket(markets []Market, market string) bool

func IndexByMarket

func IndexByMarket(markets []Market, market string) int

func ParseMarket

func ParseMarket(markets []Market, market string) (base, quote string, err error)

func TweetMarket

func TweetMarket(markets []Market, market string) string

Types

type Assets

type Assets []string

func (Assets) HasAsset

func (assets Assets) HasAsset(asset string) bool

func (Assets) IndexOf

func (assets Assets) IndexOf(asset string) int

func (Assets) IsEmpty

func (assets Assets) IsEmpty() bool

type Book

type Book []Buy

func (Book) Calls

func (b Book) Calls() Calls

func (Book) EntryByPrice

func (b Book) EntryByPrice(price float64) *Buy

func (Book) IndexByPrice

func (b Book) IndexByPrice(price float64) int

type BookSide

type BookSide int
const (
	BOOK_SIDE_BIDS BookSide = iota
	BOOK_SIDE_ASKS
)

type Buy

type Buy struct {
	Market string  `json:"market"`
	Price  float64 `json:"price"`
	Size   float64 `json:"size,omitempty"`
}

type Call

type Call struct {
	*Buy
	Skip   bool   `json:"-"`
	Stop   string `json:"stop,omitempty"`
	Target string `json:"target,omitempty"`
}

func File2Call

func File2Call(name string) (*Call, error)

func (*Call) Corrupt

func (c *Call) Corrupt(orderType OrderType) bool

func (*Call) Deviate

func (c *Call) Deviate(exchange Exchange, client interface{}, kind OrderType, mult float64) (OrderType, float64)

Multiply the buy target. Returns (new order type, deviated buy target). Does not modify the buy signal itself.

func (*Call) HasStop

func (c *Call) HasStop() bool

func (*Call) HasTarget

func (c *Call) HasTarget() bool

func (*Call) ParseStop

func (c *Call) ParseStop() float64

func (*Call) ParseTarget

func (c *Call) ParseTarget() float64

type Calls

type Calls []Call

func (Calls) HasBuy

func (c Calls) HasBuy() bool

func (Calls) IndexByMarket

func (c Calls) IndexByMarket(market string) int

func (Calls) IndexByMarketPrice

func (c Calls) IndexByMarketPrice(market string, price float64) int

func (Calls) IndexByPrice

func (c Calls) IndexByPrice(price float64) int

type Channel

type Channel interface {
	Init() error
	GetName() string
	GetOrderType() OrderType
	GetRateLimit() time.Duration
	GetValidity() (time.Duration, error)
	GetMarkets(exchange Exchange, quote Assets, btcVolumeMin float64, valid time.Duration, sandbox, debug bool, ignore []string) (Markets, error)
	GetCalls(exchange Exchange, market string, sandbox, debug bool) (Calls, error)
}

type Endpoint

type Endpoint struct {
	URI     string `json:"uri,omitempty"`
	Sandbox string `json:"sandbox,omitempty"`
}

type Exchange

type Exchange interface {
	GetInfo() *ExchangeInfo
	GetClient(permission Permission, sandbox bool) (interface{}, error)
	GetMarkets(cached, sandbox bool, ignore []string) ([]Market, error)
	FormatMarket(base, quote string) string
	Sell(stategy Strategy, hold, earn Markets, sandbox, tweet, debug bool, success OnSuccess) error
	Order(client interface{}, side OrderSide, market string, size float64, price float64, kind OrderType, metadata string) (oid []byte, raw []byte, err error)
	StopLoss(client interface{}, market string, size float64, price float64, kind OrderType, metadata string) ([]byte, error)
	OCO(client interface{}, market string, size float64, price, stop float64, metadata string) ([]byte, error)
	GetClosed(client interface{}, market string) (Orders, error)
	GetOpened(client interface{}, market string) (Orders, error)
	GetBook(client interface{}, market string, side BookSide) (interface{}, error)
	Aggregate(client, book interface{}, market string, agg float64) (Book, error)
	GetTicker(client interface{}, market string) (float64, error)
	Get24h(client interface{}, market string) (*Stats, error)
	GetPricePrec(client interface{}, market string) (int, error)
	GetSizePrec(client interface{}, market string) (int, error)
	GetMaxSize(client interface{}, base, quote string, hold, earn bool, def float64, mult multiplier.Mult) float64
	Cancel(client interface{}, market string, side OrderSide) error
	Buy(client interface{}, cancel bool, market string, calls Calls, deviation float64, kind OrderType) error
	IsLeveragedToken(name string) bool
	HasAlgoOrder(client interface{}, market string) (bool, error)
}

type ExchangeInfo

type ExchangeInfo struct {
	Code      string   `json:"code"`
	Name      string   `json:"name"`
	URL       string   `json:"url"`
	REST      Endpoint `json:"rest"`
	WebSocket Endpoint `json:"websocket,omitempty"`
	Country   string   `json:"country,omitempty"`
}

func (*ExchangeInfo) Equals

func (info *ExchangeInfo) Equals(name string) bool

type Frequency

type Frequency int
const (
	ALWAYS Frequency = iota
	ONCE_PER_MINUTE
)

type Market

type Market struct {
	Name  string `json:"name"`
	Base  string `json:"-"`
	Quote string `json:"-"`
}

type Markets

type Markets []string

func (Markets) HasMarket

func (markets Markets) HasMarket(market string) bool

func (Markets) IndexOf

func (markets Markets) IndexOf(market string) int

type Notify

type Notify interface {
	PromptForKeys(interactive, verify bool) (ok bool, err error)
	SendMessage(message interface{}, title string, frequency Frequency) error
}

type OnSuccess

type OnSuccess func(service Notify) error

type Order

type Order struct {
	Side      OrderSide `json:"-"`
	Market    string    `json:"market"`
	Size      float64   `json:"size"`
	Price     float64   `json:"price"`
	CreatedAt time.Time `json:"createdAt"`
}

func (*Order) MarshalJSON

func (order *Order) MarshalJSON() ([]byte, error)

type OrderSide

type OrderSide int
const (
	ORDER_SIDE_NONE OrderSide = iota
	BUY
	SELL
)

func NewOrderSide

func NewOrderSide(data string) OrderSide

func (*OrderSide) String

func (os *OrderSide) String() string

type OrderType

type OrderType int
const (
	ORDER_TYPE_NONE OrderType = iota
	LIMIT
	MARKET
)

func NewOrderType

func NewOrderType(data string) OrderType

func (*OrderType) String

func (ot *OrderType) String() string

type Orders

type Orders []Order

func (Orders) IndexByPrice

func (orders Orders) IndexByPrice(side OrderSide, market string, price float64) int

func (Orders) OrderByPrice

func (orders Orders) OrderByPrice(side OrderSide, market string, price float64) *Order

func (Orders) Youngest

func (orders Orders) Youngest(side OrderSide, def time.Time) time.Time

type Permission

type Permission int
const (
	PRIVATE Permission = iota
	PUBLIC
	BOOK
)

type Stats

type Stats struct {
	Market    string
	High      float64
	Low       float64
	BtcVolume float64
}

func (*Stats) Avg

func (s *Stats) Avg(exchange Exchange, sandbox bool) (float64, error)

type Strategy

type Strategy int
const (
	STRATEGY_STANDARD Strategy = iota
	STRATEGY_STOP_LOSS
)

func GetStrategy

func GetStrategy() (Strategy, error)

Jump to

Keyboard shortcuts

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