Documentation ¶
Index ¶
- Variables
- func NewDefaultTotpKey() (*otp.Key, error)
- func ReformatMysqlDSN(dsn string) (string, error)
- type AggOrder
- type BacktestService
- 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
- type DatabaseService
- type DepositService
- 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
- type JsonPersistenceService
- type JsonStore
- type MemoryService
- type MemoryStore
- type OrderService
- 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
- type PersistenceServiceFacade
- type QueryOrdersOptions
- type QueryTradesOptions
- type RedisPersistenceConfig
- type RedisPersistenceService
- type RedisStore
- type RewardService
- 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
- type SyncService
- type 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
- type TradingVolumeQueryOptions
- type 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
- 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
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrExchangeRewardServiceNotImplemented = errors.New("exchange does not implement ExchangeRewardService interface")
View Source
var ErrNotImplemented = errors.New("not implemented")
View Source
var ErrPersistenceNotExists = errors.New("persistent data does not exists")
View Source
var ErrTradeNotFound = errors.New("trade not found")
Functions ¶
func NewDefaultTotpKey ¶
func ReformatMysqlDSN ¶
Types ¶
type BacktestService ¶
func (*BacktestService) QueryKLinesBackward ¶
func (*BacktestService) QueryKLinesCh ¶
func (*BacktestService) QueryKLinesForward ¶
func (*BacktestService) QueryLast ¶
func (s *BacktestService) QueryLast(ex types.ExchangeName, symbol string, interval types.Interval) (*types.KLine, error)
QueryLast queries the last order from the database
type CurrencyPositionMap ¶
type CurrencyPositionMap map[string]fixedpoint.Value
type DatabaseService ¶
func NewDatabaseService ¶
func NewDatabaseService(driver, dsn string) *DatabaseService
func (*DatabaseService) Close ¶
func (s *DatabaseService) Close() error
func (*DatabaseService) Connect ¶
func (s *DatabaseService) Connect() error
type DepositService ¶
func (*DepositService) Query ¶
func (s *DepositService) Query(exchangeName types.ExchangeName) ([]types.Deposit, error)
func (*DepositService) QueryLast ¶
func (s *DepositService) QueryLast(ex types.ExchangeName, limit int) ([]types.Deposit, error)
type JsonPersistenceConfig ¶
type JsonPersistenceConfig struct {
Directory string `json:"directory"`
}
type JsonPersistenceService ¶
type JsonPersistenceService struct {
Directory string
}
type MemoryService ¶
type MemoryService struct {
Slots map[string]interface{}
}
func NewMemoryService ¶
func NewMemoryService() *MemoryService
type MemoryStore ¶
type MemoryStore struct { Key string // contains filtered or unexported fields }
func (*MemoryStore) Load ¶
func (store *MemoryStore) Load(val interface{}) error
func (*MemoryStore) Reset ¶
func (store *MemoryStore) Reset() error
func (*MemoryStore) Save ¶
func (store *MemoryStore) Save(val interface{}) error
type OrderService ¶
func (*OrderService) Query ¶
func (s *OrderService) Query(options QueryOrdersOptions) ([]AggOrder, error)
type PersistenceService ¶
type PersistenceServiceFacade ¶
type PersistenceServiceFacade struct { Redis *RedisPersistenceService Json *JsonPersistenceService Memory *MemoryService }
func (*PersistenceServiceFacade) Get ¶
func (facade *PersistenceServiceFacade) Get() PersistenceService
Get returns the preferred persistence service by fallbacks Redis will be preferred at the first position.
type QueryOrdersOptions ¶
type QueryOrdersOptions struct { Exchange types.ExchangeName Symbol string LastGID int64 Ordering string }
type QueryTradesOptions ¶
type RedisPersistenceConfig ¶
type RedisPersistenceService ¶
type RedisPersistenceService struct {
// contains filtered or unexported fields
}
func NewRedisPersistenceService ¶
func NewRedisPersistenceService(config *RedisPersistenceConfig) *RedisPersistenceService
type RedisStore ¶
type RedisStore struct { ID string // contains filtered or unexported fields }
func (*RedisStore) Load ¶
func (store *RedisStore) Load(val interface{}) error
func (*RedisStore) Reset ¶
func (store *RedisStore) Reset() error
func (*RedisStore) Save ¶
func (store *RedisStore) Save(val interface{}) error
type RewardService ¶
RewardService collects the reward records from the exchange, currently it's only available for MAX exchange. TODO: add summary query for calculating the reward amounts CREATE VIEW reward_summary_by_years AS SELECT YEAR(created_at) as year, reward_type, currency, SUM(quantity) FROM rewards WHERE reward_type != 'airdrop' GROUP BY YEAR(created_at), reward_type, currency ORDER BY year DESC;
func (*RewardService) AggregateUnspentCurrencyPosition ¶
func (s *RewardService) AggregateUnspentCurrencyPosition(ctx context.Context, ex types.ExchangeName, since time.Time) (CurrencyPositionMap, error)
func (*RewardService) MarkAsSpent ¶
func (s *RewardService) MarkAsSpent(ctx context.Context, uuid string) error
func (*RewardService) MarkCurrencyAsSpent ¶
func (s *RewardService) MarkCurrencyAsSpent(ctx context.Context, currency string) error
func (*RewardService) QueryLast ¶
func (s *RewardService) QueryLast(ex types.ExchangeName, limit int) ([]types.Reward, error)
func (*RewardService) QueryUnspent ¶
func (s *RewardService) QueryUnspent(ctx context.Context, ex types.ExchangeName, rewardTypes ...types.RewardType) ([]types.Reward, error)
func (*RewardService) QueryUnspentSince ¶
func (s *RewardService) QueryUnspentSince(ctx context.Context, ex types.ExchangeName, since time.Time, rewardTypes ...types.RewardType) ([]types.Reward, error)
type SyncService ¶
type SyncService struct { TradeService *TradeService OrderService *OrderService RewardService *RewardService WithdrawService *WithdrawService DepositService *DepositService }
type TradeService ¶
func NewTradeService ¶
func NewTradeService(db *sqlx.DB) *TradeService
func (*TradeService) Query ¶
func (s *TradeService) Query(options QueryTradesOptions) ([]types.Trade, error)
func (*TradeService) QueryForTradingFeeCurrency ¶
func (s *TradeService) QueryForTradingFeeCurrency(ex types.ExchangeName, symbol string, feeCurrency string) ([]types.Trade, error)
func (*TradeService) QueryLast ¶
func (s *TradeService) QueryLast(ex types.ExchangeName, symbol string, isMargin, isIsolated bool, limit int) ([]types.Trade, error)
QueryLast queries the last trade from the database
func (*TradeService) QueryTradingVolume ¶
func (s *TradeService) QueryTradingVolume(startTime time.Time, options TradingVolumeQueryOptions) ([]TradingVolume, error)
type TradingVolume ¶
type TradingVolume struct { Year int `db:"year" json:"year"` Month int `db:"month" json:"month,omitempty"` Day int `db:"day" json:"day,omitempty"` Time time.Time `json:"time,omitempty"` Exchange string `db:"exchange" json:"exchange,omitempty"` Symbol string `db:"symbol" json:"symbol,omitempty"` QuoteVolume float64 `db:"quote_volume" json:"quoteVolume"` }
type WebsocketClientBase ¶
type WebsocketClientBase struct {
// contains filtered or unexported fields
}
func NewWebsocketClientBase ¶
func NewWebsocketClientBase(baseURL string, reconnectDuration time.Duration) *WebsocketClientBase
func (*WebsocketClientBase) Conn ¶
func (s *WebsocketClientBase) Conn() *websocket.Conn
func (*WebsocketClientBase) Connect ¶
func (s *WebsocketClientBase) Connect(ctx context.Context) error
func (*WebsocketClientBase) EmitConnected ¶
func (s *WebsocketClientBase) EmitConnected(conn *websocket.Conn)
func (*WebsocketClientBase) EmitDisconnected ¶
func (s *WebsocketClientBase) EmitDisconnected(conn *websocket.Conn)
func (*WebsocketClientBase) EmitError ¶
func (s *WebsocketClientBase) EmitError(err error)
func (*WebsocketClientBase) EmitMessage ¶
func (s *WebsocketClientBase) EmitMessage(message []byte)
func (*WebsocketClientBase) Listen ¶
func (s *WebsocketClientBase) Listen(ctx context.Context)
func (*WebsocketClientBase) OnConnected ¶
func (s *WebsocketClientBase) OnConnected(cb func(conn *websocket.Conn))
func (*WebsocketClientBase) OnDisconnected ¶
func (s *WebsocketClientBase) OnDisconnected(cb func(conn *websocket.Conn))
func (*WebsocketClientBase) OnError ¶
func (s *WebsocketClientBase) OnError(cb func(err error))
func (*WebsocketClientBase) OnMessage ¶
func (s *WebsocketClientBase) OnMessage(cb func(message []byte))
func (*WebsocketClientBase) Reconnect ¶
func (s *WebsocketClientBase) Reconnect()
type WithdrawService ¶
func (*WithdrawService) Query ¶
func (s *WithdrawService) Query(exchangeName types.ExchangeName) ([]types.Withdraw, error)
func (*WithdrawService) QueryLast ¶
func (s *WithdrawService) QueryLast(ex types.ExchangeName, limit int) ([]types.Withdraw, error)
Click to show internal directories.
Click to hide internal directories.