pair

package
v0.0.0-...-a2c5123 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 2 Imported by: 0

README

GoCryptoTrader package Pair

Build Status Software License GoDoc Coverage Status Go Report Card

This pair package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Current Features for pair

  • Provides a new data structure for a currency pair

  • Methods to manipulate, create and retrieve different parts of the currency pair

  • Example below:

import "github.com/thrasher-/gocryptotrader/currency/pair"

// Create new pair
newPair := pair.NewCurrencyPair("BTC", "USD")

// Retrieve different parts of the pair
bitcoinString := newPair.GetFirstCurrency
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(pairs []CurrencyPair, p CurrencyPair, exact bool) bool

Contains checks to see if a specified pair exists inside a currency pair array

func ContainsCurrency

func ContainsCurrency(p CurrencyPair, c string) bool

ContainsCurrency checks to see if a pair contains a specific currency

func FindPairDifferences

func FindPairDifferences(oldPairs, newPairs []string) ([]string, []string)

FindPairDifferences returns pairs which are new or have been removed

func PairsToStringArray

func PairsToStringArray(pairs []CurrencyPair) []string

PairsToStringArray returns a list of pairs as a string array

Types

type CurrencyItem

type CurrencyItem string

CurrencyItem is an exported string with methods to manipulate the data instead of using array/slice access modifiers

func (CurrencyItem) Lower

func (c CurrencyItem) Lower() CurrencyItem

Lower converts the CurrencyItem object c to lowercase

func (CurrencyItem) String

func (c CurrencyItem) String() string

String converts the CurrencyItem object c to string

func (CurrencyItem) Upper

func (c CurrencyItem) Upper() CurrencyItem

Upper converts the CurrencyItem object c to uppercase

type CurrencyPair

type CurrencyPair struct {
	Delimiter      string       `json:"delimiter"`
	FirstCurrency  CurrencyItem `json:"first_currency"`
	SecondCurrency CurrencyItem `json:"second_currency"`
}

CurrencyPair holds currency pair information

func CopyPairFormat

func CopyPairFormat(p CurrencyPair, pairs []CurrencyPair, exact bool) CurrencyPair

CopyPairFormat copies the pair format from a list of pairs once matched

func FormatPairs

func FormatPairs(pairs []string, delimiter, index string) []CurrencyPair

FormatPairs formats a string array to a list of currency pairs with the supplied currency pair format

func NewCurrencyPair

func NewCurrencyPair(firstCurrency, secondCurrency string) CurrencyPair

NewCurrencyPair returns a CurrencyPair without a delimiter

func NewCurrencyPairDelimiter

func NewCurrencyPairDelimiter(currency, delimiter string) CurrencyPair

NewCurrencyPairDelimiter splits the desired currency string at delimeter, the returns a CurrencyPair struct

func NewCurrencyPairFromIndex

func NewCurrencyPairFromIndex(currency, index string) CurrencyPair

NewCurrencyPairFromIndex returns a CurrencyPair via a currency string and specific index

func NewCurrencyPairFromString

func NewCurrencyPairFromString(currency string) CurrencyPair

NewCurrencyPairFromString converts currency string into a new CurrencyPair with or without delimeter

func RemovePairsByFilter

func RemovePairsByFilter(p []CurrencyPair, filter string) []CurrencyPair

RemovePairsByFilter checks to see if a pair contains a specific currency and removes it from the list of pairs

func (CurrencyPair) Display

func (c CurrencyPair) Display(delimiter string, uppercase bool) CurrencyItem

Display formats and returns the currency based on user preferences, overriding the default Pair() display

func (CurrencyPair) Equal

func (c CurrencyPair) Equal(p CurrencyPair, exact bool) bool

Equal compares two currency pairs and returns whether or not they are equal

func (CurrencyPair) Pair

func (c CurrencyPair) Pair() CurrencyItem

Pair returns a currency pair string

func (CurrencyPair) Swap

func (c CurrencyPair) Swap() CurrencyPair

Swap swaps the pairs first and second currencies

Jump to

Keyboard shortcuts

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