test_volatile_exchange

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const SECONDS_IN_DAY = 24 * 60 * 60

Variables

View Source
var (
	TestVolatileExchangeParams = VolatileExchangeParams{
		AveragePrice: 100,
		Amplitude:    0.5,
		Frequency:    1,
	}
	TestVolatileExchangeDetails = types.ExchangeQueryDetails{
		Exchange:      exchange_common.EXCHANGE_ID_TEST_VOLATILE_EXCHANGE,
		Url:           "https://www.google.com/",
		PriceFunction: VolatileExchangePriceFunction,
		IsMultiMarket: false,
	}
)

Test Exchange used for testing purposes.

Functions

func VolatileExchangePriceFunction

func VolatileExchangePriceFunction(
	response *http.Response,
	tickerToExponent map[string]int32,
	resolver types.Resolver,
) (tickerToPrice map[string]uint64, unavailableTickers map[string]error, err error)

VolatileExchangePriceFunction generates a time-based price value. The value follows a cosine wave function, but that includes jumps from the lowest value to the highest value (and vice versa) once per period. The general formula is written below. - PRICE = AVERAGE * (1 + AMPLITUDE * WAVE_VALUE) - WAVE_VALUE = math.Cos(RADIANS) - RADIANS = (PHASE <= 0.5 ? PHASE * 4 : PHASE * 4 - 1) * math.Pi - PHASE = (FREQUENCY * UNIX_SECONDS / SECONDS_IN_DAY) % 1 The following values are parametrized in `VolatileExchangeParams`: - AVERAGE, AMPLITUDE, FREQUENCY

Types

type VolatileExchangeParams

type VolatileExchangeParams struct {
	AveragePrice float64
	Amplitude    float64
	Frequency    float64
}

type VolatileExchangeTicker

type VolatileExchangeTicker struct {
	Pair  string
	Price string
}

VolatileExchangeTicker is our representation of ticker information for a test market. It implements interface `Ticker` in util.go.

func (VolatileExchangeTicker) GetAskPrice

func (t VolatileExchangeTicker) GetAskPrice() string

func (VolatileExchangeTicker) GetBidPrice

func (t VolatileExchangeTicker) GetBidPrice() string

func (VolatileExchangeTicker) GetLastPrice

func (t VolatileExchangeTicker) GetLastPrice() string

func (VolatileExchangeTicker) GetPair

func (t VolatileExchangeTicker) GetPair() string

Jump to

Keyboard shortcuts

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