service

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 15 Imported by: 3 modules, 16 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultTotpKey added in v1.4.0

func NewDefaultTotpKey() (*otp.Key, error)

func ReformatMysqlDSN added in v1.11.0

func ReformatMysqlDSN(dsn string) (string, error)

Types

type AggOrder added in v1.11.0

type AggOrder struct {
	types.Order
	AveragePrice *float64 `json:"averagePrice" db:"average_price"`
}

type BacktestService

type BacktestService struct {
	DB *sqlx.DB
}

func (*BacktestService) Insert

func (s *BacktestService) Insert(kline types.KLine) error

func (*BacktestService) QueryKLinesBackward

func (s *BacktestService) QueryKLinesBackward(exchange types.ExchangeName, symbol string, interval types.Interval, endTime time.Time) ([]types.KLine, error)

func (*BacktestService) QueryKLinesCh

func (s *BacktestService) QueryKLinesCh(since, until time.Time, exchange types.Exchange, symbols []string, intervals []types.Interval) (chan types.KLine, chan error)

func (*BacktestService) QueryKLinesForward

func (s *BacktestService) QueryKLinesForward(exchange types.ExchangeName, symbol string, interval types.Interval, startTime time.Time) ([]types.KLine, error)

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

func (*BacktestService) Sync

func (s *BacktestService) Sync(ctx context.Context, exchange types.Exchange, symbol string, startTime time.Time) error

type DatabaseService added in v1.11.0

type DatabaseService struct {
	Driver string
	DSN    string
	DB     *sqlx.DB
}

func NewDatabaseService added in v1.11.0

func NewDatabaseService(driver, dsn string) *DatabaseService

func (*DatabaseService) Close added in v1.11.0

func (s *DatabaseService) Close() error

func (*DatabaseService) Connect added in v1.11.0

func (s *DatabaseService) Connect() error

func (*DatabaseService) Upgrade added in v1.11.0

func (s *DatabaseService) Upgrade(ctx context.Context) error

type OrderService

type OrderService struct {
	DB *sqlx.DB
}

func (*OrderService) Insert

func (s *OrderService) Insert(order types.Order) (err error)

func (*OrderService) Query

func (s *OrderService) Query(options QueryOrdersOptions) ([]AggOrder, error)

func (*OrderService) QueryLast

func (s *OrderService) QueryLast(ex types.ExchangeName, symbol string, isMargin bool, isIsolated bool) (*types.Order, error)

QueryLast queries the last order from the database

type QueryOrdersOptions added in v1.11.0

type QueryOrdersOptions struct {
	Exchange types.ExchangeName
	Symbol   string
	LastGID  int64
	Ordering string
}

type QueryTradesOptions added in v1.11.0

type QueryTradesOptions struct {
	Exchange types.ExchangeName
	Symbol   string
	LastGID  int64
	// ASC or DESC
	Ordering string
	Limit    int
}

type SyncService

type SyncService struct {
	TradeService *TradeService
	OrderService *OrderService
}

func (*SyncService) SyncOrders

func (s *SyncService) SyncOrders(ctx context.Context, exchange types.Exchange, symbol string, startTime time.Time) error

func (*SyncService) SyncTrades

func (s *SyncService) SyncTrades(ctx context.Context, exchange types.Exchange, symbol string, startTime time.Time) error

type TradeService

type TradeService struct {
	DB *sqlx.DB
}

func NewTradeService

func NewTradeService(db *sqlx.DB) *TradeService

func (*TradeService) Insert

func (s *TradeService) Insert(trade types.Trade) error

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 bool, isIsolated bool) (*types.Trade, error)

QueryLast queries the last trade from the database

func (*TradeService) QueryTradingVolume added in v1.11.0

func (s *TradeService) QueryTradingVolume(startTime time.Time, options TradingVolumeQueryOptions) ([]TradingVolume, error)

type TradingVolume added in v1.11.0

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 TradingVolumeQueryOptions added in v1.11.0

type TradingVolumeQueryOptions struct {
	GroupByPeriod string
	SegmentBy     string
}

Jump to

Keyboard shortcuts

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