Version: v0.2.3 Latest Latest

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

Go to latest
Published: Oct 11, 2017 License: MIT Imports: 1 Imported by: 0




This section is empty.


This section is empty.


func Round

func Round(f float64, decimals int) float64

Round rounds a float to the specified length of dezimals


type PriceParser

type PriceParser struct{}

PriceParser is designed to abstract away the underlying number used as a price. Due to efficiency and floating point precision limitations, this backtester uses an integer to represent all prices. This means that $0.10 is, internally, 100,000,000. Because such large numbers are rather unwieldy for humans, the PriceParser will take a "normal" 2 decimal places numbers as input, and show normal" 2 decimal places numbers as output when requested to `display()` For consistency's sake, PriceParser should be used for ALL prices that enter the backtester system. Numbers should also always be parsed correctly to view.

func (*PriceParser) Display

func (p *PriceParser) Display(i int64) float64

Display an int as float with 2 decimal places

func (*PriceParser) DisplayDecimal

func (p *PriceParser) DisplayDecimal(i int64, decimal int) float64

DisplayDecimal an int as float with custom decimal places

func (*PriceParser) Parse

func (p *PriceParser) Parse(f float64) int64

Parse a float to int

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL