mock

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCandleStickServiceLimit = 1000

DefaultCandleStickServiceLimit is the limit for CandleStick service if none is specified

View Source
var TestCandleSticks = []CandleSticks{
	{
		Symbol: "BTC-USDC", Period: models.M1, CandleSticks: []models.CandleStick{
			{Time: time.Time{}, Open: 10, High: 10, Low: 10, Close: 10},
			{Time: time.Time{}, Open: 15, High: 15, Low: 15, Close: 15}},
	},
	{
		Symbol: "ETH-USDC", Period: models.M5, CandleSticks: []models.CandleStick{
			{Time: time.Time{}, Open: 20, High: 20, Low: 20, Close: 20},
			{Time: time.Time{}, Open: 25, High: 25, Low: 25, Close: 25}},
	},
	{
		Symbol: "IOTA-USDC", Period: models.M15, CandleSticks: []models.CandleStick{
			{Time: time.Unix(1257894000, 0), Open: 30, High: 30, Low: 30, Close: 30},
			{Time: time.Unix(1257894900, 0), Open: 35, High: 35, Low: 35, Close: 35}},
	},
	{
		Symbol: "BTC-USDC", Period: models.M5, CandleSticks: []models.CandleStick{
			{Time: time.Unix(1257894000, 0), Open: 30, High: 30, Low: 30, Close: 30},
			{Time: time.Unix(1257894300, 0), Open: 35, High: 35, Low: 35, Close: 35}},
	},
}

TestCandleSticks are candle sticks that can be used for test

Functions

func TestCandleSticksCount

func TestCandleSticksCount() (count int)

TestCandleSticksCount will return the count of candles for TestCandleSticks

Types

type CandleStickService

type CandleStickService struct {
	// contains filtered or unexported fields
}

CandleStickService is the mocked service for candlesticks

func (*CandleStickService) Do

func (m *CandleStickService) Do(ctx context.Context) ([]models.CandleStick, error)

Do will execute a request for candlesticks

func (*CandleStickService) EndTime

EndTime will specify the time where the list ends (earliest time) for next candlesticks request

func (*CandleStickService) Limit

Limit will specify the number of candlesticks the list should have at its maximum If the limit is higher than the default limit, it will be limited to this one

func (*CandleStickService) Period

Period will specify a period for next candlesticks request

func (*CandleStickService) SetError

func (m *CandleStickService) SetError(err error)

SetError will set an error that will be raised each time a Do() is executed You can set it at nil if you want to deactivate it

func (*CandleStickService) Symbol

Symbol will specify a symbol for next candlesticks request

type CandleSticks

type CandleSticks struct {
	Symbol       string
	Period       int64
	CandleSticks []models.CandleStick
}

CandleSticks are candlesticks that can be used in MockCandleStickService

type MockedService

type MockedService struct {
	// contains filtered or unexported fields
}

MockedService represents the Binance service mocked

func New

func New() *MockedService

New will create a mocked service

func (*MockedService) AddCandleSticks

func (m *MockedService) AddCandleSticks(cs []CandleSticks)

AddCandleSticks will add fake candlesticks to service that can be used in candlestick services

func (*MockedService) NewCandleStickService

func (m *MockedService) NewCandleStickService() interfaces.CandleStickServiceInterface

NewCandleStickService will create a new candlestick service

func (*MockedService) NextError

func (m *MockedService) NextError(err error)

NextError will set an error for the next Do() on any child service

Jump to

Keyboard shortcuts

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