utils

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(encrypted []byte, key []byte) (decrypted []byte)

*

  • @Description: AES解密
  • @param encrypted
  • @param key
  • @return decrypted

func AESEncrypt

func AESEncrypt(src []byte, key []byte) (encrypted []byte)

*

  • @Description: AES加密
  • @param src
  • @param key
  • @return encrypted

func Abs

func Abs(n int64) int64

*

  • @Description: 取绝对值
  • @param n
  • @return int64

func Accumulate added in v1.1.0

func Accumulate(data []float64) float64

func AppendBool

func AppendBool(a []bool, v bool, limit bool) []bool

*

  • @Description: 向前添加bool类型到数组
  • @param a 原数组
  • @param v 新值
  • @param limit 是否限制数组长度 false:增加长度 true:保持原有长度
  • @return []bool

func AppendFloat

func AppendFloat(a []float64, v float64, limit bool) []float64

*

  • @Description: 向前添加float类型到数组
  • @param a 原数组
  • @param v 新值
  • @param limit 是否限制数组长度 false:增加长度 true:保持原有长度
  • @return []float64

func AppendInt

func AppendInt(a []int64, v int64, limit bool) []int64

*

  • @Description: 向前添加int类型到数组
  • @param a 原数组
  • @param v 新值
  • @param limit 是否限制数组长度 false:增加长度 true:保持原有长度
  • @return []int64

func ArrayDivideFloat added in v1.1.0

func ArrayDivideFloat(data []float64, divisor float64) []float64

func ArrayPositon added in v1.1.0

func ArrayPositon(array []float64, value float64) int

找出value在数组里的索引

func ArrayToString

func ArrayToString(array []string) string

*

  • @Description: 字符串数组转字符串
  • @param array 字符串数组
  • @return string 字符串

func BlueString

func BlueString(s string) string

*

  • @Description: 蓝色字符串
  • @param s
  • @return string

func CrossOver added in v1.1.0

func CrossOver(a []float64, b []float64) bool

func CrossUnder added in v1.1.0

func CrossUnder(a []float64, b []float64) bool

func CyanString

func CyanString(s string) string

*

  • @Description: 蓝绿色字符串
  • @param s
  • @return string

func DecryptString

func DecryptString(encrypted []byte) string

*

  • @Description: 解密字符串
  • @param encrypted
  • @return string

func Diff added in v1.1.0

func Diff(data []float64, leg int) []float64

func EncryptString

func EncryptString(src []byte) string

*

  • @Description: 加密字符串
  • @param src
  • @return string

func Exists

func Exists(path string) bool

Exists

@Description: 判断所给路径文件/文件夹是否存在
@param path
@return bool

func FindPosition added in v1.1.0

func FindPosition(data []float64, condition string, threshold float64) ([]int, int)

func GetBetweenDates

func GetBetweenDates(sdate, edate string) ([]string, error)

*

  • @Description: 根据开始日期和结束日期计算出时间段内所有日期 参数为日期格式,如:2020-01-01
  • @param sdate 开始日期
  • @param edate 结束日期
  • @return []string

func GetDiffDays

func GetDiffDays(startdate string, enddate string) int

*

  • @Description: 获取两个时间相差的天数,0表同一天,正数表t1>t2,负数表t1<t2
  • @param startdate 开始日期
  • @param enddate 结束日期
  • @return int

func GetFileByPath

func GetFileByPath(path string) ([]string, error)

*

  • @Description: 获取目录下所有文件名
  • @param path
  • @return []string
  • @return error

func GetGoogleToken

func GetGoogleToken(secret string) string

获取谷歌验证器code

func GreenString

func GreenString(s string) string

*

  • @Description: 绿色字符串
  • @param s
  • @return string

func IntArrayToFloat added in v1.1.0

func IntArrayToFloat(data []int) []float64

func IsDir

func IsDir(path string) bool

IsDir

@Description: 判断所给路径是否为文件夹
@param path
@return bool

func IsFile

func IsFile(path string) bool

IsFile

@Description: 判断所给路径是否为文件
@param path
@return bool

func IsFileExists

func IsFileExists(filename string) bool

*

  • @Description: 判断文件是否存在
  • @param filename 文件名
  • @return error

func IsInArray

func IsInArray(value string, array []string) bool

*

  • @Description: 判断值是否在数组里
  • @param value 值
  • @param array 数组
  • @return bool 结果

func IsKlineExists

func IsKlineExists(klines []common.Kline, symbol string, timestamp int64) bool

*

  • @Description: 判断Kline原素是否存在
  • @param klines
  • @param symbol
  • @param timestamp
  • @return bool

func MagentaString

func MagentaString(s string) string

*

  • @Description: 洋红色字符串
  • @param s
  • @return string

func MaxArrayFloat added in v1.1.0

func MaxArrayFloat(data []float64) float64

func MaxArrayInt added in v1.1.0

func MaxArrayInt(data []int) int

func MinArrayFloat added in v1.1.0

func MinArrayFloat(data []float64) float64

func MinArrayInt added in v1.1.0

func MinArrayInt(data []int) int

func MovingAverage added in v1.1.0

func MovingAverage(data []float64, length int) []float64

func OnesFloat added in v1.1.0

func OnesFloat(length int) []float64

func OnesInt added in v1.1.0

func OnesInt(length int) []int

func ReadLine

func ReadLine(fileName string) ([]string, error)

读取文件

func RedString

func RedString(s string) string

*

  • @Description: 红色字符串
  • @param s
  • @return string

func SetArrayFloat added in v1.1.0

func SetArrayFloat(data []float64, value float64, start int, end int) []float64

func SetArrayInt added in v1.1.0

func SetArrayInt(data []int, value int, start int, end int) []int

func Sign added in v1.1.0

func Sign(data float64) float64

func Square added in v1.1.0

func Square(data []float64) []float64

func TrueRange added in v1.1.0

func TrueRange(C []float64, H []float64, L []float64) []float64

func ValidLimitPrice

func ValidLimitPrice(price float64, last common.LastPrice) float64

*

  • @Description: 将价格限定在涨跌停版以内
  • @param price
  • @param last
  • @return float64

func YellowString

func YellowString(s string) string

*

  • @Description: 黄色字符串
  • @param s
  • @return string

func ZerosFloat added in v1.1.0

func ZerosFloat(length int) []float64

func ZerosInt added in v1.1.0

func ZerosInt(length int) []int

Types

This section is empty.

Jump to

Keyboard shortcuts

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