test_volatile_exchange

package
v0.4.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 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:    2,
	}
	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 based off of the following function: - PRICE = AVERAGE * (1 + AMPLITUDE * WAVE_VALUE) - WAVE_VALUE = math.Sin(RADIANS) - RADIANS = PERCENTAGE_THROUGH_DAY * FREQUENCY * 2 * math.Pi - PERCENTAGE_THROUGH_DAY = (time.Now().Unix() % SECONDS_IN_A_DAY) / SECONDS_IN_A_DAY 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