utils

package
v0.0.0-...-6daa909 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcSpread

func CalcSpread(bidMax float64, askMin float64) (spread float64, midPoint float64)

CalcSpread calculates the spread stats for the given bidMax and askMin orderbook values

func GetAssetString

func GetAssetString(assetType string, code string, issuer string) string

GetAssetString returns a string representation of an asset

func PanicIfError

func PanicIfError(e error)

PanicIfError is an utility function that panics if err != nil

func Retry

func Retry(numRetries int, delay time.Duration, logger *hlog.Entry, f func() error) error

Retry retries running a function that returns an error numRetries times, multiplying the sleep time by a factor of 2 each time it retries.

func SliceDiff

func SliceDiff(a, b []string) (diff []string)

SliceDiff returns the elements in `a` that aren't in `b`.

func TimeToRFC3339

func TimeToRFC3339(t time.Time) string

TimeToRFC3339 converts a time.Time to a string in RFC3339 format

func TimeToUnixEpoch

func TimeToUnixEpoch(t time.Time) int64

TimeToTimestamp converts a time.Time into a Unix epoch

func WriteJSONToFile

func WriteJSONToFile(jsonBytes []byte, filename string) (numBytes int, err error)

WriteJSONToFile atomically writes a json []byte dump to <filename> It ensures atomicity by first creating a tmp file (filename.tmp), writing the contents to it, then renaming it to the originally specified filename.

Types

This section is empty.

Jump to

Keyboard shortcuts

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