fym

package module
v0.29.6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 12 Imported by: 0

README

hs

hs golang utils lib

Documentation

Index

Constants

View Source
const (
	GateIO  = "gate"
	MXC     = "mxc"
	OKEx    = "okex"
	Huobi   = "huobi"
	Binance = "binance"
)

Variables

This section is empty.

Functions

func ConnectMongo

func ConnectMongo(ctx context.Context, conf MongoConf) (*mongo.Database, error)

func DeleteInt64

func DeleteInt64(ctx context.Context, coll *mongo.Collection, key string) error

func DeleteKey

func DeleteKey(ctx context.Context, coll *mongo.Collection, key string) error

func IsDuplicateError

func IsDuplicateError(err error) bool

func LoadInt64

func LoadInt64(ctx context.Context, coll *mongo.Collection, key string) (int64, error)

func LoadKey

func LoadKey(ctx context.Context, coll *mongo.Collection, key string, value interface{}) error

func MergeTick

func MergeTick(o1, h1, l1, c1, v1, o2, h2, l2, c2, v2 float64) (open, high, low, close, volume float64)

func NewZapLogger

func NewZapLogger(conf LogConf) (*zap.Logger, error)

func ParseJsonConfig

func ParseJsonConfig(filename string, config interface{}) error

func SaveInt64

func SaveInt64(ctx context.Context, coll *mongo.Collection, key string, value int64) error

func SaveKey

func SaveKey(ctx context.Context, coll *mongo.Collection, key string, value interface{}) error

Types

type BroadcastConf

type BroadcastConf = broadcast.Config

type Candle

type Candle struct {
	Capacity  int
	Timestamp []int64 // unix timestamp in seconds
	Open      []float64
	High      []float64
	Low       []float64
	Close     []float64
	Volume    []float64
}

func NewCandle

func NewCandle(capacity int) Candle

func (*Candle) Add

func (c *Candle) Add(other Candle)

func (*Candle) Append

func (c *Candle) Append(ticker Ticker)

func (Candle) Length

func (c Candle) Length() int

func (*Candle) Truncate

func (c *Candle) Truncate()

type ExchangeConf

type ExchangeConf struct {
	Name    string // see const below
	Label   string
	Symbols []string
	Key     string
	Secret  string
	Host    string
}

type FloatTuple

type FloatTuple struct {
	Key   interface{}
	Value float64
}

type GinConf

type GinConf struct {
	Listen string // "host:port"
	Log    string
}

type Grid

type Grid struct {
	Id         int
	Price      decimal.Decimal
	AmountBuy  decimal.Decimal
	AmountSell decimal.Decimal
	TotalBuy   decimal.Decimal
	Order      uint64
}

type GridStrategyConf

type GridStrategyConf struct {
	MaxPrice float64
	MinPrice float64
	Number   int
	Total    float64
}

type HistoryConf

type HistoryConf struct {
	Prefix   string
	Interval string
}

type KVSlice

type KVSlice []FloatTuple

func (KVSlice) Len

func (s KVSlice) Len() int

func (KVSlice) Less

func (s KVSlice) Less(i, j int) bool

func (KVSlice) Swap

func (s KVSlice) Swap(i, j int)

type LogConf

type LogConf struct {
	Level   string
	Outputs []string
	Errors  []string
}

type MongoConf

type MongoConf struct {
	// mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
	URI         string `json:"uri"`
	Database    string `json:"database"`
	MaxPoolSize uint64 `json:"maxPoolSize"`
	MinPoolSize uint64 `json:"minPoolSize"`
	AppName     string `json:"appName"`
}

type MySQLConf

type MySQLConf struct {
	URI string `json:"uri"`
}

type RestGridStrategyConf

type RestGridStrategyConf struct {
	MaxPrice  float64
	MinPrice  float64
	Number    int
	Total     float64
	Rebalance bool
	Interval  string // sleep interval
}

type SQLiteConf

type SQLiteConf struct {
	Location string
}

type Ticker

type Ticker struct {
	Timestamp int64 // unix timestamp in seconds
	Open      float64
	High      float64
	Low       float64
	Close     float64
	Volume    float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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