nnutils

package
v0.0.0-...-db7d511 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Misc utils. First up is a small wrapper for TicksizeTables, where simple calculations can be made.

Index

Constants

This section is empty.

Variables

View Source
var (
	// This is the most common tick size. Hardcoded here to avoid hitting the db or api for a basic configuration.
	DEFAULT_TICK_TABLE = swagger.TicksizeTable{
		TickSizeId: 14369,
		Ticks: []swagger.TicksizeInterval{
			{Decimals: 3, FromPrice: 0, ToPrice: 0.499, Tick: 0.001},
			{Decimals: 3, FromPrice: 0.5, ToPrice: 0.995, Tick: 0.005},
			{Decimals: 2, FromPrice: 1, ToPrice: 4.99, Tick: 0.01},
			{Decimals: 2, FromPrice: 15, ToPrice: 49.9, Tick: 0.1},
			{Decimals: 2, FromPrice: 150, ToPrice: 499.5, Tick: 0.5},
			{Decimals: 2, FromPrice: 5, ToPrice: 14.95, Tick: 0.05},
			{Decimals: 2, FromPrice: 50, ToPrice: 149.75, Tick: 0.25},
			{Decimals: 0, FromPrice: 500, ToPrice: 4999, Tick: 1},
			{Decimals: 0, FromPrice: 5000, ToPrice: 499995, Tick: 5},
		}}
)

Functions

This section is empty.

Types

type TickTableUtil

type TickTableUtil []swagger.TicksizeInterval

New name, so we dont need to expose swagger package. Assume sorted

func NewDefaultTickTableUtil

func NewDefaultTickTableUtil() (ret TickTableUtil)

func (TickTableUtil) AddTicks

func (ttu TickTableUtil) AddTicks(data float64, ticks int64) float64

func (TickTableUtil) AsTick

func (ttu TickTableUtil) AsTick(data float64) (newVal, tick, from, to float64, decimals int64)

func (TickTableUtil) Len

func (ttu TickTableUtil) Len() int

func (TickTableUtil) Less

func (ttu TickTableUtil) Less(i, j int) bool

func (TickTableUtil) Swap

func (ttu TickTableUtil) Swap(i, j int)

func (TickTableUtil) TicksBetween

func (ttu TickTableUtil) TicksBetween(data1, data2 float64) (ret int64)

func (TickTableUtil) ToString

func (ttu TickTableUtil) ToString(data float64) string

Jump to

Keyboard shortcuts

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