Documentation ¶
Index ¶
Constants ¶
const SECONDS_IN_DAY = 24 * 60 * 60
Variables ¶
var ( TestVolatileExchangeParams = VolatileExchangeParams{ AveragePrice: 100, Amplitude: 0.95, Frequency: 1, } TestVolatileExchangeDetails = types.ExchangeQueryDetails{ Exchange: exchange_common.EXCHANGE_ID_TEST_VOLATILE_EXCHANGE, Url: "https://jsonplaceholder.typicode.com/users", 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 VolatileExchangeTicker ¶
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