Versions in this module Expand all Collapse all v1 v1.16.3 May 28, 2021 v1.16.2 May 28, 2021 v1.16.1 May 28, 2021 Changes in this version + var ErrExchangeRewardServiceNotImplemented = errors.New("exchange does not implement ExchangeRewardService interface") + var ErrNotImplemented = errors.New("not implemented") + var ErrPersistenceNotExists = errors.New("persistent data does not exists") + var ErrTradeNotFound = errors.New("trade not found") + func NewDefaultTotpKey() (*otp.Key, error) + func ReformatMysqlDSN(dsn string) (string, error) + type AggOrder struct + AveragePrice *float64 + type BacktestService struct + DB *sqlx.DB + func (s *BacktestService) Insert(kline types.KLine) error + func (s *BacktestService) QueryKLinesBackward(exchange types.ExchangeName, symbol string, interval types.Interval, ...) ([]types.KLine, error) + func (s *BacktestService) QueryKLinesCh(since, until time.Time, exchange types.Exchange, symbols []string, ...) (chan types.KLine, chan error) + func (s *BacktestService) QueryKLinesForward(exchange types.ExchangeName, symbol string, interval types.Interval, ...) ([]types.KLine, error) + func (s *BacktestService) QueryLast(ex types.ExchangeName, symbol string, interval types.Interval) (*types.KLine, error) + func (s *BacktestService) Sync(ctx context.Context, exchange types.Exchange, symbol string, ...) error + func (s *BacktestService) SyncKLineByInterval(ctx context.Context, exchange types.Exchange, symbol string, ...) error + type CurrencyPositionMap map[string]fixedpoint.Value + type DatabaseService struct + DB *sqlx.DB + DSN string + Driver string + func NewDatabaseService(driver, dsn string) *DatabaseService + func (s *DatabaseService) Close() error + func (s *DatabaseService) Connect() error + func (s *DatabaseService) Upgrade(ctx context.Context) error + type DepositService struct + DB *sqlx.DB + func (s *DepositService) Insert(deposit types.Deposit) error + func (s *DepositService) Query(exchangeName types.ExchangeName) ([]types.Deposit, error) + func (s *DepositService) QueryLast(ex types.ExchangeName, limit int) ([]types.Deposit, error) + func (s *DepositService) Sync(ctx context.Context, ex types.Exchange) error + type JsonPersistenceConfig struct + Directory string + type JsonPersistenceService struct + Directory string + func (s *JsonPersistenceService) NewStore(id string, subIDs ...string) Store + type JsonStore struct + Directory string + ID string + func (store JsonStore) Load(val interface{}) error + func (store JsonStore) Reset() error + func (store JsonStore) Save(val interface{}) error + type MemoryService struct + Slots map[string]interface{} + func NewMemoryService() *MemoryService + func (s *MemoryService) NewStore(id string, subIDs ...string) Store + type MemoryStore struct + Key string + func (store *MemoryStore) Load(val interface{}) error + func (store *MemoryStore) Reset() error + func (store *MemoryStore) Save(val interface{}) error + type OrderService struct + DB *sqlx.DB + func (s *OrderService) Insert(order types.Order) (err error) + func (s *OrderService) Query(options QueryOrdersOptions) ([]AggOrder, error) + func (s *OrderService) QueryLast(ex types.ExchangeName, symbol string, isMargin, isIsolated bool, limit int) ([]types.Order, error) + func (s *OrderService) Sync(ctx context.Context, exchange types.Exchange, symbol string, ...) error + type PersistenceService interface + NewStore func(id string, subIDs ...string) Store + type PersistenceServiceFacade struct + Json *JsonPersistenceService + Memory *MemoryService + Redis *RedisPersistenceService + func (facade *PersistenceServiceFacade) Get() PersistenceService + type QueryOrdersOptions struct + Exchange types.ExchangeName + LastGID int64 + Ordering string + Symbol string + type QueryTradesOptions struct + Exchange types.ExchangeName + LastGID int64 + Limit int + Ordering string + Symbol string + type RedisPersistenceConfig struct + DB int + Host string + Password string + Port string + type RedisPersistenceService struct + func NewRedisPersistenceService(config *RedisPersistenceConfig) *RedisPersistenceService + func (s *RedisPersistenceService) NewStore(id string, subIDs ...string) Store + type RedisStore struct + ID string + func (store *RedisStore) Load(val interface{}) error + func (store *RedisStore) Reset() error + func (store *RedisStore) Save(val interface{}) error + type RewardService struct + DB *sqlx.DB + func (s *RewardService) AggregateUnspentCurrencyPosition(ctx context.Context, ex types.ExchangeName, since time.Time) (CurrencyPositionMap, error) + func (s *RewardService) Insert(reward types.Reward) error + func (s *RewardService) MarkAsSpent(ctx context.Context, uuid string) error + func (s *RewardService) MarkCurrencyAsSpent(ctx context.Context, currency string) error + func (s *RewardService) QueryLast(ex types.ExchangeName, limit int) ([]types.Reward, error) + func (s *RewardService) QueryUnspent(ctx context.Context, ex types.ExchangeName, rewardTypes ...types.RewardType) ([]types.Reward, error) + func (s *RewardService) QueryUnspentSince(ctx context.Context, ex types.ExchangeName, since time.Time, ...) ([]types.Reward, error) + func (s *RewardService) Sync(ctx context.Context, exchange types.Exchange) error + type Store interface + Load func(val interface{}) error + Reset func() error + Save func(val interface{}) error + type SyncService struct + DepositService *DepositService + OrderService *OrderService + RewardService *RewardService + TradeService *TradeService + WithdrawService *WithdrawService + func (s *SyncService) SyncSessionSymbols(ctx context.Context, exchange types.Exchange, startTime time.Time, ...) error + type TradeService struct + DB *sqlx.DB + func NewTradeService(db *sqlx.DB) *TradeService + func (s *TradeService) Insert(trade types.Trade) error + func (s *TradeService) Load(ctx context.Context, id int64) (*types.Trade, error) + func (s *TradeService) Mark(ctx context.Context, id int64, strategyID string) error + func (s *TradeService) Query(options QueryTradesOptions) ([]types.Trade, error) + func (s *TradeService) QueryForTradingFeeCurrency(ex types.ExchangeName, symbol string, feeCurrency string) ([]types.Trade, error) + func (s *TradeService) QueryLast(ex types.ExchangeName, symbol string, isMargin, isIsolated bool, limit int) ([]types.Trade, error) + func (s *TradeService) QueryTradingVolume(startTime time.Time, options TradingVolumeQueryOptions) ([]TradingVolume, error) + func (s *TradeService) Sync(ctx context.Context, exchange types.Exchange, symbol string) error + func (s *TradeService) UpdatePnL(ctx context.Context, id int64, pnl float64) error + type TradingVolume struct + Day int + Exchange string + Month int + QuoteVolume float64 + Symbol string + Time time.Time + Year int + type TradingVolumeQueryOptions struct + GroupByPeriod string + SegmentBy string + type WebsocketClientBase struct + func NewWebsocketClientBase(baseURL string, reconnectDuration time.Duration) *WebsocketClientBase + func (s *WebsocketClientBase) Conn() *websocket.Conn + func (s *WebsocketClientBase) Connect(ctx context.Context) error + func (s *WebsocketClientBase) EmitConnected(conn *websocket.Conn) + func (s *WebsocketClientBase) EmitDisconnected(conn *websocket.Conn) + func (s *WebsocketClientBase) EmitError(err error) + func (s *WebsocketClientBase) EmitMessage(message []byte) + func (s *WebsocketClientBase) Listen(ctx context.Context) + func (s *WebsocketClientBase) OnConnected(cb func(conn *websocket.Conn)) + func (s *WebsocketClientBase) OnDisconnected(cb func(conn *websocket.Conn)) + func (s *WebsocketClientBase) OnError(cb func(err error)) + func (s *WebsocketClientBase) OnMessage(cb func(message []byte)) + func (s *WebsocketClientBase) Reconnect() + type WithdrawService struct + DB *sqlx.DB + func (s *WithdrawService) Insert(withdrawal types.Withdraw) error + func (s *WithdrawService) Query(exchangeName types.ExchangeName) ([]types.Withdraw, error) + func (s *WithdrawService) QueryLast(ex types.ExchangeName, limit int) ([]types.Withdraw, error) + func (s *WithdrawService) Sync(ctx context.Context, ex types.Exchange) error