Documentation ¶
Index ¶
- func CancelOrder(id string, attempt ...int) error
- func CreateOrder(order *cb.Order, attempt ...int) (*cb.Order, error)
- func GetActivePositions() (map[string]Position, error)
- func GetAllProductIDs() []string
- func GetFills(productID string) (*[]cb.Fill, error)
- func GetOrder(id string, attempt ...int) (*cb.Order, error)
- func GetOrders(productID string) (*[]cb.Order, error)
- func GetPrice(wsConn *ws.Conn, productID string) (*float64, error)
- func GetTickerPrice(productID string) (*float64, error)
- func GetTradingPositions() (map[string]Position, error)
- func Init(name string, dbProducts *[]Product) (*time.Time, error)
- func Maker() float64
- func Taker() float64
- type Config
- type Pattern
- func (p *Pattern) GoalPrice(price float64) float64
- func (p *Pattern) InitPattern(size, gain, loss, delta float64)
- func (p *Pattern) LossPrice(price float64) float64
- func (p *Pattern) MatchesTweezerBottomPattern(then, that, this Rate) bool
- func (p *Pattern) NewLimitLossOrder(price float64, size string) *cb.Order
- func (p *Pattern) NewLimitSellEntryOrder(price float64, size string) *cb.Order
- func (p *Pattern) NewLimitSellEntryOrderAtGoalPrice(trade *Trade) *cb.Order
- func (p *Pattern) NewMarketBuyOrder() *cb.Order
- func (p *Pattern) NewMarketSellOrder(size string) *cb.Order
- func (p *Pattern) PrecisePrice(f float64) string
- func (p *Pattern) PrecisePriceFromString(s string) string
- func (p *Pattern) PreciseSize(s string) string
- type Position
- type Posture
- type Product
- type Rate
- type Trade
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CancelOrder ¶ added in v1.0.5
CancelOrder is a recursive function that cancels an order equal to the given id.
func CreateOrder ¶ added in v1.0.5
CreateOrder creates an order on Coinbase and returns the order once it is no longer pending and has settled. Given that there are many different types of orders that can be created in many different scenarios, it is the responsibility of the method calling this function to perform logging.
func GetActivePositions ¶ added in v1.0.5
func GetAllProductIDs ¶ added in v1.0.2
func GetAllProductIDs() []string
func GetOrder ¶ added in v1.0.5
GetOrder is a recursive function that returns an order equal to the given id once it is settled and not pending. This function also performs extensive logging given its variable and seriously critical nature.
func GetPrice ¶ added in v1.0.2
GetPrice gets the latest ticker price for the given productID. This method does not perform logging as it is executed thousands of times per second.
func GetTickerPrice ¶ added in v1.0.5
func GetTradingPositions ¶ added in v1.0.6
GetTradingPositions returns a map of trading positions.
Types ¶
type Config ¶ added in v1.0.2
type Config struct { Api struct { Key string `envconfig:"COINBASE_PRO_KEY" yaml:"key"` Passphrase string `envconfig:"COINBASE_PRO_PASSPHRASE" yaml:"pass"` Secret string `envconfig:"COINBASE_PRO_SECRET" yaml:"secret"` Fees struct { Maker float64 `envconfig:"COINBASE_PRO_MAKER_FEE" yaml:"maker"` Taker float64 `envconfig:"COINBASE_PRO_TAKER_FEE" yaml:"taker"` } `yaml:"fees"` } `yaml:"cbp"` }
type Pattern ¶
type Pattern struct { // Id is concatenation of two currencies. eg. BTC-USD ID string `yaml:"id" json:"id"` // Gain is a percentage used to produce the goal sell price from the entry buy price. Gain float64 `yaml:"gain" json:"gain"` // Loss is a percentage used to derive a limit sell price from the entry buy price. Loss float64 `yaml:"loss" json:"loss"` // Size is the amount of the transaction, using the products native quote increment. Size float64 `yaml:"size" json:"size"` // Delta is the size of an acceptable difference between tweezer bottom candlesticks. Delta float64 `yaml:"delta" json:"delta"` }
Pattern defines the criteria for matching rates and placing orders.
func (*Pattern) InitPattern ¶ added in v1.0.1
func (*Pattern) MatchesTweezerBottomPattern ¶
func (*Pattern) NewLimitLossOrder ¶ added in v1.0.5
func (*Pattern) NewLimitSellEntryOrder ¶ added in v1.0.5
func (*Pattern) NewLimitSellEntryOrderAtGoalPrice ¶ added in v1.0.5
func (*Pattern) NewMarketBuyOrder ¶ added in v1.0.5
func (*Pattern) NewMarketSellOrder ¶ added in v1.0.5
func (*Pattern) PrecisePrice ¶ added in v1.0.9
func (*Pattern) PrecisePriceFromString ¶ added in v1.0.9
func (*Pattern) PreciseSize ¶ added in v1.0.9
type Rate ¶
type Rate struct { Unix int64 `json:"unix" gorm:"primaryKey"` ProductId string `json:"product_id" gorm:"primaryKey"` cb.HistoricRate }