ticker

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2018 License: MIT Imports: 20 Imported by: 1

README

TickerProxy

TickerProxy gathers the latest financial data from bitcoinaverage.com. The goal is to provide a caching layer between OpenBazaar nodes and the bitcoinaverage.com infrastructure. It provides exchange rates against BTC for all known fiat symbols and a few crypto symbols.

It can writes responses to a local file and/or AWS S3.

Get your account's API public and private keys from bitcoinaverage.com.

Install

go get github.com/OpenBazaar/tickerproxy

Run

go run "$GOPATH/src/github.com/OpenBazaar/tickerproxy/bin/main.go"

Configuration and defaults

export TICKER_PROXY_SPEED="10"              # Number of seconds to wait between updates
export TICKER_PROXY_PUBKEY=""               # API public key from bitcoinaverage.com
export TICKER_PROXY_PRIVKEY=""              # API private key from bitcoinaverage.com
export TICKER_PROXY_OUTFILE="/path/to/file" # A file to write outputs to
export AWS_REGION="us-east-1"               # An AWS region to write to
export AWS_S3_BUCKET="openbazaar-ticker"    # An AWS bucket to write outputs to
export TICKER_BUGSNAG_APIKEY="secretkey"    # A Bugsnag key for error monitoring

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AltSymbolsToCanonicalSymbols = map[string]string{
	"IOTA": "MIOTA",
}

AltSymbolsToCanonicalSymbols maps symbols that may be used in some sources to represent coins that we use a different symbol for

View Source
var PinnedSymbolsToIDs = map[string]int64{
	"BTC":  1,
	"LTC":  2,
	"NXT":  66,
	"DOGE": 74,
	"DASH": 131,
	"XMR":  328,
	"ETH":  1027,
	"ZEC":  1437,
	"BCH":  1831,

	"BTG":  2083,
	"CMT":  2246,
	"KNC":  1982,
	"BTM":  1866,
	"ICN":  1408,
	"GTC":  2336,
	"BLZ":  2505,
	"HOT":  2682,
	"RCN":  2096,
	"FAIR": 224,
	"EDR":  2835,
	"CPC":  2482,
	"QBT":  2242,
	"KEY":  2398,
	"RED":  2771,
	"HMC":  2484,
	"NET":  1811,
	"LNC":  2677,
	"CAN":  2343,
	"BET":  1771,
	"SPD":  2616,
	"CAT":  2334,
	"GCC":  1531,
	"PUT":  2419,
	"MAG":  2218,
	"CRC":  2664,
	"ACC":  2225,
	"PXC":  35,
	"ETT":  1714,
	"XIN":  2349,
	"HERO": 1805,
	"HNC":  1004,
	"ENT":  1474,
	"LBTC": 1825,
	"CMS":  2262,
}

PinnedSymbolsToIDs maps symbols that may be used by multiple coins to a single coin by its CMC IDs.

View Source
var RequiredSymbols = []string{
	"USD",
	"EUR",
	"GBP",
	"CAD",
	"RUB",
	"BRL",
	"AUD",
	"BGN",
	"NOK",
	"CZK",

	"BTC",
	"BCH",
	"ZEC",
	"ETH",
}

RequiredSymbols are symbols we expect to be present and their absence should be treated as an error.

Functions

func CanonicalizeSymbol added in v0.3.0

func CanonicalizeSymbol(symbol string) string

CanonicalizeSymbol returns the canonical symbol from the given one, which may or may not be a nickname

func Fetch added in v0.3.0

func Fetch(stream *health.Stream, btcAvgPubkey string, btcAvgPrivkey string, writers ...Writer) error

Fetch gets data from all sources, formats it, and sends it to the Writers.

func FetchCMC added in v0.3.0

func FetchCMC() (exchangeRates, error)

func IsCorrectIDForSymbol added in v0.3.0

func IsCorrectIDForSymbol(symbol string, id int64) bool

IsCorrectIDForSymbol checks if the given id is the correct one for the given symbol based on the map `PinnedSymbolsToIDs`

func NewBTCAVGFetcher added in v0.3.0

func NewBTCAVGFetcher(pubkey string, privkey string) fetchFn

func PinnedSymbolsToIDsJSON added in v0.3.0

func PinnedSymbolsToIDsJSON() []byte

PinnedSymbolsToIDsJSON returns the PinnedSymbolsToIDs marshaled to JSON

Types

type Writer added in v0.3.0

type Writer func(job *health.Job, data []byte) error

Writer is a callback for data collected from the backend sources

func NewFileSystemWriter added in v0.3.0

func NewFileSystemWriter(outpath string) Writer

NewFileSystemWriter creates a Writer to writes to a local filesystem

func NewS3Writer added in v0.3.0

func NewS3Writer(region string, bucket string) (Writer, error)

NewS3Writer creates a Writer to writes to AWS S3

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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