Documentation ¶
Index ¶
- Constants
- func BackupCache()
- func GetMyOrdersCache() *cache.Cache
- func InitLSSD() error
- func IsLSSDConnProblem(err error) bool
- func PeriodicOrderListener(bot *Bot, tradingPair string, withOwnOrders bool, interval time.Duration, ...)
- func PeriodicPing(interval time.Duration, entry *logrus.Entry)
- func ReadFile(path string) ([]byte, error)
- func SetLogger(logLvl string)
- func SetupCache(tradingBot *Bot)
- func ValidateCurrency(currency string) bool
- type Bot
- func (t *Bot) AddCurrencies() error
- func (t *Bot) CancelOrder(tradingPair string, orderID string) (*lssdrpc.CancelOrderResponse, error)
- func (t *Bot) EnableTradingPair(pair string) error
- func (t *Bot) Init() error
- func (t *Bot) ListOrders(tradingPair string, myOrders bool, printCLI bool) ([]lssdrpc.Order, error)
- func (t *Bot) PlaceOrder(tradingPair string, price int64, funds int64, side lssdrpc.OrderSide, ...) (*lssdrpc.PlaceOrderResponse, error)
- func (t *Bot) SubscribeOrders() error
- func (t *Bot) SubscribeSwaps() error
- type Connection
- type LNDConfig
- type Order
- type OrderCollection
- func (o *OrderCollection) Add(order Order) *OrderCollection
- func (o *OrderCollection) GetByOrderID(orderId string) *Order
- func (o *OrderCollection) GetPriceTopOrdersSorted(side string, limit int, excludingMyOrders bool) *OrderCollection
- func (o *OrderCollection) SumFunds(status string) (sum int64)
- func (o *OrderCollection) Unique() *OrderCollection
Constants ¶
const ( OrderSideSell = "sell" OrderSideBuy = "buy" OrderStatusPlaced = "placed" OrderStatusCanceled = "canceled" OrderStatusCompleted = "completed" )
const (
LSSDConnectionProblem = "connect: connection refused"
)
Variables ¶
This section is empty.
Functions ¶
func BackupCache ¶
func BackupCache()
func GetMyOrdersCache ¶
func GetMyOrdersCache() *cache.Cache
func IsLSSDConnProblem ¶
func PeriodicOrderListener ¶
func PeriodicPing ¶
Periodically perform request to check if LSSD is running Its using "enableTradingPair" instead of an actual ping endpoint but its just for the concept
func SetupCache ¶
func SetupCache(tradingBot *Bot)
SetupCache func will read previously used cache files to get back to the order state it was before shutting down
func ValidateCurrency ¶
ValidateCurrency checks if the given currency is allowed or not
Types ¶
type Bot ¶
type Bot struct { OrderClient lssdrpc.OrdersClient SwapClient lssdrpc.SwapsClient CurrencyClient lssdrpc.CurrenciesClient TradingPairClient lssdrpc.TradingPairsClient LNDConfig LNDConfig Log *logrus.Entry LogLevel string OrderLimit int Timeout time.Duration SentryDSN string }
Bot struct holds all the gRPC client connections, the resolved config and the logger
func NewBot ¶
func NewBot(o lssdrpc.OrdersClient, s lssdrpc.SwapsClient, c lssdrpc.CurrenciesClient, t lssdrpc.TradingPairsClient, lndConfig LNDConfig, timeout time.Duration, orderLimit int) (*Bot, error)
NewBot func will create a new Bot object based on all the lssd client connections and the resolved config
func (*Bot) AddCurrencies ¶
AddCurrencies func will register all the currencies by performing a lssd grpc request for all certificates are specified in the config
func (*Bot) CancelOrder ¶
CancelOrder func will perform a lssd gRPC request to the PlaceOrder endpoint of the Orders service for a specified trading pair and order settings
func (*Bot) EnableTradingPair ¶
EnableTradingPair func will enable the given tradingPair
func (*Bot) ListOrders ¶
ListOrders func will perform a lssd gRPC request to the ListOrders endpoint of the Orders service for a specified trading pair
func (*Bot) PlaceOrder ¶
func (t *Bot) PlaceOrder(tradingPair string, price int64, funds int64, side lssdrpc.OrderSide, orderType string, label string) (*lssdrpc.PlaceOrderResponse, error)
PlaceOrder func will perform a lssd gRPC request to the PlaceOrder endpoint of the Orders service for a specified trading pair and order settings
func (*Bot) SubscribeOrders ¶
SubscribeOrders func will subscribe to orders
func (*Bot) SubscribeSwaps ¶
SubscribeSwaps func will subscribe to swaps
type Connection ¶
Connection struct holds connection data
func (*Connection) Format ¶
func (c *Connection) Format() string
Format func will format in a common host:port scheme
type LNDConfig ¶
type LNDConfig struct { TLSPaths map[string]string // map[LTC]-> /path/to/lnd_ltc.tls.cert Certs map[string]string // map[LTC]-> -----BEGIN CERTIFICATE-----... Connections map[string]Connection // map[LTC]{Host: localhost, Port: 10001} }
LNDConfig holds mandatory information how to connection / authenticate with a LND
func NewConfig ¶
func NewConfig() LNDConfig
NewConfig func will create a config with initialized maps
type Order ¶
type Order struct { PairId string `json:"pairId"` OrderId string `json:"orderId"` Price int64 `json:"price"` //satoshis Funds int64 `json:"funds"` //satoshis CreatedAt uint64 `json:"createdAt"` Side string `json:"side"` Status string `json:"status"` OrderType string `json:"type"` Label string `json:"label,omitempty"` IsOwn bool `json:"isOwn"` }
func GetFromCacheByOrderId ¶
func GetMyOrderByID ¶
type OrderCollection ¶
type OrderCollection []Order
func GetMemoryEnrichedMyOrders ¶
func GetMemoryEnrichedMyOrders(tp string) OrderCollection
func (*OrderCollection) Add ¶
func (o *OrderCollection) Add(order Order) *OrderCollection
func (*OrderCollection) GetByOrderID ¶
func (o *OrderCollection) GetByOrderID(orderId string) *Order
func (*OrderCollection) GetPriceTopOrdersSorted ¶
func (o *OrderCollection) GetPriceTopOrdersSorted(side string, limit int, excludingMyOrders bool) *OrderCollection
func (*OrderCollection) SumFunds ¶
func (o *OrderCollection) SumFunds(status string) (sum int64)
func (*OrderCollection) Unique ¶
func (o *OrderCollection) Unique() *OrderCollection