Documentation ¶
Index ¶
- Constants
- Variables
- func Base64Decode(input string) ([]byte, error)
- func Base64Encode(input []byte) string
- func CalculateAmountWithFee(amount, fee float64) float64
- func CalculateFee(amount, fee float64) float64
- func CalculateNetProfit(amount, priceThen, priceNow, costs float64) float64
- func CalculatePercentageDifference(amount, secondAmount float64) float64
- func CalculatePercentageGainOrLoss(priceNow, priceThen float64) float64
- func ChangePerm(directory string) error
- func CreateDir(dir string) error
- func EncodeURLValues(urlPath string, values url.Values) string
- func ExtractHost(address string) string
- func ExtractPort(host string) int
- func FloatFromString(raw interface{}) (float64, error)
- func GetDefaultDataDir(env string) string
- func GetExecutablePath() (string, error)
- func GetHMAC(hashType int, input, key []byte) []byte
- func GetMD5(input []byte) []byte
- func GetOSPathSlash() string
- func GetRandomSalt(input []byte, saltLen int) ([]byte, error)
- func GetSHA256(input []byte) []byte
- func GetSHA512(input []byte) []byte
- func GetURIPath(uri string) string
- func HexEncodeToString(input []byte) string
- func Int64FromString(raw interface{}) (int64, error)
- func IntFromString(raw interface{}) (int, error)
- func IsEnabled(isEnabled bool) string
- func IsValidCryptoAddress(address, crypto string) (bool, error)
- func JSONDecode(data []byte, to interface{}) error
- func JSONEncode(v interface{}) ([]byte, error)
- func JoinStrings(input []string, separator string) string
- func NewHTTPClientWithTimeout(t time.Duration) *http.Client
- func OutputCSV(filePath string, data [][]string) error
- func ReadFile(file string) ([]byte, error)
- func RecvWindow(d time.Duration) int64
- func RemoveFile(file string) error
- func ReplaceString(input, old, newStr string, n int) string
- func RoundFloat(x float64, prec int) float64
- func SendHTTPGetRequest(urlPath string, jsonDecode, isVerbose bool, result interface{}) error
- func SendHTTPRequest(method, urlPath string, headers map[string]string, body io.Reader) (string, error)
- func Sha1ToHex(data string) string
- func SplitStrings(input, separator string) []string
- func StringContains(input, substring string) bool
- func StringDataCompare(haystack []string, needle string) bool
- func StringDataCompareInsensitive(haystack []string, needle string) bool
- func StringDataContains(haystack []string, needle string) bool
- func StringDataContainsInsensitive(haystack []string, needle string) bool
- func StringSliceDifference(slice1, slice2 []string) []string
- func StringToLower(input string) string
- func StringToUpper(input string) string
- func TimeFromUnixTimestampFloat(raw interface{}) (time.Time, error)
- func TrimString(input, cutset string) string
- func UnixMillis(t time.Time) int64
- func UnixTimestampStrToTime(timeStr string) (time.Time, error)
- func UnixTimestampToTime(timeint64 int64) time.Time
- func WriteFile(file string, data []byte) error
- func YesOrNo(input string) bool
Constants ¶
const ( HashSHA1 = iota HashSHA256 HashSHA512 HashSHA512_384 HashMD5 SatoshisPerBTC = 100000000 SatoshisPerLTC = 100000000 WeiPerEther = 1000000000000000000 )
Const declarations for common.go operations
Variables ¶
var ( HTTPClient *http.Client // ErrNotYetImplemented defines a common error across the code base that // alerts of a function that has not been completed or tied into main code ErrNotYetImplemented = errors.New("not yet implemented") // ErrFunctionNotSupported defines a standardised error for an unsupported // wrapper function by an API ErrFunctionNotSupported = errors.New("unsupported wrapper function") )
Vars for common.go operations
Functions ¶
func Base64Decode ¶
Base64Decode takes in a Base64 string and returns a byte array and an error
func Base64Encode ¶
Base64Encode takes in a byte array then returns an encoded base64 string
func CalculateAmountWithFee ¶
CalculateAmountWithFee returns a calculated fee included amount on fee
func CalculateFee ¶
CalculateFee returns a simple fee on amount
func CalculateNetProfit ¶
CalculateNetProfit returns net profit
func CalculatePercentageDifference ¶
CalculatePercentageDifference returns the percentage of difference between multiple time periods
func CalculatePercentageGainOrLoss ¶
CalculatePercentageGainOrLoss returns the percentage rise over a certain period
func ChangePerm ¶
ChangePerm lists all the directories and files in an array
func EncodeURLValues ¶
EncodeURLValues concatenates url values onto a url string and returns a string
func ExtractHost ¶
ExtractHost returns the hostname out of a string
func ExtractPort ¶
ExtractPort returns the port name out of a string
func FloatFromString ¶
FloatFromString format
func GetDefaultDataDir ¶
GetDefaultDataDir returns the default data directory Windows - C:\Users\%USER%\AppData\Roaming\GoCryptoTrader Linux/Unix or OSX - $HOME/.gocryptotrader
func GetExecutablePath ¶
GetExecutablePath returns the executables launch path
func GetOSPathSlash ¶
func GetOSPathSlash() string
GetOSPathSlash returns the slash used by the operating systems file system
func GetRandomSalt ¶
GetRandomSalt returns a random salt
func GetURIPath ¶
GetURIPath returns the path of a URL given a URI
func HexEncodeToString ¶
HexEncodeToString takes in a hexadecimal byte array and returns a string
func IsEnabled ¶
IsEnabled takes in a boolean param and returns a string if it is enabled or disabled
func IsValidCryptoAddress ¶
IsValidCryptoAddress validates your cryptocurrency address string using the regexp package // Validation issues occurring because "3" is contained in litecoin and Bitcoin addresses - non-fatal
func JSONDecode ¶
JSONDecode decodes JSON data into a structure
func JSONEncode ¶
JSONEncode encodes structure data into JSON
func JoinStrings ¶
JoinStrings joins an array together with the required separator and returns it as a string
func NewHTTPClientWithTimeout ¶
NewHTTPClientWithTimeout initialises a new HTTP client with the specified timeout duration
func RecvWindow ¶
RecvWindow converts a supplied time.Duration to milliseconds
func ReplaceString ¶
ReplaceString replaces a string with another
func RoundFloat ¶
RoundFloat rounds your floating point number to the desired decimal place
func SendHTTPGetRequest ¶
SendHTTPGetRequest sends a simple get request using a url string & JSON decodes the response into a struct pointer you have supplied. Returns an error on failure.
func SendHTTPRequest ¶
func SendHTTPRequest(method, urlPath string, headers map[string]string, body io.Reader) (string, error)
SendHTTPRequest sends a request using the http package and returns a response as a string and an error
func SplitStrings ¶
SplitStrings splits blocks of strings from string into a string array using a separator ie "," or "_"
func StringContains ¶
StringContains checks a substring if it contains your input then returns a bool
func StringDataCompare ¶
StringDataCompare data checks the substring array with an input and returns a bool
func StringDataCompareInsensitive ¶
StringDataCompareInsensitive data checks the substring array with an input and returns a bool irrespective of lower or upper case strings
func StringDataContains ¶
StringDataContains checks the substring array with an input and returns a bool
func StringDataContainsInsensitive ¶
StringDataContainsInsensitive checks the substring array with an input and returns a bool irrespective of lower or upper case strings
func StringSliceDifference ¶
StringSliceDifference concatenates slices together based on its index and returns an individual string array
func StringToLower ¶
StringToLower changes strings to lowercase
func StringToUpper ¶
StringToUpper changes strings to uppercase
func TimeFromUnixTimestampFloat ¶
TimeFromUnixTimestampFloat format
func TrimString ¶
TrimString trims unwanted prefixes or postfixes
func UnixMillis ¶
UnixMillis converts a UnixNano timestamp to milliseconds
func UnixTimestampStrToTime ¶
UnixTimestampStrToTime returns a time.time and an error
func UnixTimestampToTime ¶
UnixTimestampToTime returns time.time
Types ¶
This section is empty.