Documentation
¶
Index ¶
- Constants
- Variables
- func BeginningOfTheDay(t time.Time) time.Time
- func FNV32(s string) uint32
- func FilterSimpleArgs(args []interface{}) (simpleArgs []interface{})
- func FormatFloat(val float64, prec int) string
- func FormatValue(val fixedpoint.Value, prec int) string
- func GetEnvVarBool(n string) (bool, bool)
- func GetEnvVarDuration(n string) (time.Duration, bool)
- func GetEnvVarInt(n string) (int, bool)
- func IsPaperTrade() bool
- func MaskKey(key string) string
- func MillisecondsJitter(d time.Duration, jitterInMilliseconds int) time.Duration
- func MustParseFloat(s string) float64
- func NewValidLimiter(r rate.Limit, b int) (*rate.Limiter, error)
- func NotZero(v float64) bool
- func Over24Hours(since time.Time) bool
- func ParseFloat(s string) (float64, error)
- func ParseTimeWithFormats(strTime string, formats []string) (time.Time, error)
- func PnLColor(pnl fixedpoint.Value) string
- func PnLEmojiMargin(pnl, margin, resolution fixedpoint.Value) (out string)
- func PnLEmojiSimple(pnl fixedpoint.Value) string
- func PnLSignString(pnl fixedpoint.Value) string
- func Pow10(n int64) int64
- func Render(tpl string, args interface{}) string
- func Retry(ctx context.Context, attempts int, duration time.Duration, ...) (err error)
- func SafeMkdirAll(p string) error
- func SetEnvVarBool(n string, v *bool) bool
- func ShouldDelay(l *rate.Limiter, minInterval time.Duration) time.Duration
- func StringSliceContains(slice []string, needle string) bool
- func TryLock(lock *sync.RWMutex) bool
- func TryRLock(lock *sync.RWMutex) bool
- func UnixMilli() int64
- func WriteJsonFile(p string, obj interface{}) error
- func Zero(v float64) bool
- type Reonce
- type Response
- type RetryPredicator
- type TimeProfile
- type VolatileMemory
Constants ¶
const GrayColor = "#f0f0f0"
const GreenColor = "#228B22"
const (
InfiniteRetry = 0
)
const MaxDigits = 18 // MAX_INT64 ~ 9 * 10^18
const Pointer = reflect.Pointer
const RedColor = "#800000"
Variables ¶
var DefaultPnLLevelResolution = fixedpoint.NewFromFloat(0.001)
var LossEmoji = "🔥"
var Pow10Table = [MaxDigits + 1]int64{
1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18,
}
var ProfitEmoji = "💰"
Functions ¶
func FilterSimpleArgs ¶ added in v1.33.4
func FilterSimpleArgs(args []interface{}) (simpleArgs []interface{})
FilterSimpleArgs filters out the simple type arguments int, string, bool, and []byte
func FormatFloat ¶
func FormatValue ¶ added in v1.28.0
func FormatValue(val fixedpoint.Value, prec int) string
func GetEnvVarBool ¶ added in v1.17.0
func GetEnvVarInt ¶ added in v1.17.0
func IsPaperTrade ¶ added in v1.33.0
func IsPaperTrade() bool
func MillisecondsJitter ¶ added in v1.17.0
func MustParseFloat ¶
func Over24Hours ¶ added in v1.18.0
func ParseFloat ¶
func ParseTimeWithFormats ¶ added in v1.27.0
func PnLColor ¶ added in v1.39.0
func PnLColor(pnl fixedpoint.Value) string
func PnLEmojiMargin ¶ added in v1.39.0
func PnLEmojiMargin(pnl, margin, resolution fixedpoint.Value) (out string)
func PnLEmojiSimple ¶ added in v1.39.0
func PnLEmojiSimple(pnl fixedpoint.Value) string
func PnLSignString ¶ added in v1.39.0
func PnLSignString(pnl fixedpoint.Value) string
func Retry ¶
func Retry(ctx context.Context, attempts int, duration time.Duration, fnToRetry func() error, errHandler func(error), predicators ...RetryPredicator) (err error)
Retry retrys the passed function for "attempts" times, if passed function return error. Setting attempts to zero means keep retrying.
func SafeMkdirAll ¶ added in v1.33.0
func SetEnvVarBool ¶ added in v1.18.0
func StringSliceContains ¶ added in v1.11.1
func WriteJsonFile ¶ added in v1.33.0
Types ¶
type Response ¶ added in v1.11.0
Response is wrapper for standard http.Response and provides more methods.
func NewResponse ¶ added in v1.11.0
NewResponse is a wrapper of the http.Response instance, it reads the response body and close the file.
func (*Response) DecodeJSON ¶ added in v1.11.0
type RetryPredicator ¶
type TimeProfile ¶ added in v1.17.0
func StartTimeProfile ¶ added in v1.17.0
func StartTimeProfile(args ...string) TimeProfile
func (*TimeProfile) Stop ¶ added in v1.17.0
func (p *TimeProfile) Stop() time.Duration
func (*TimeProfile) StopAndLog ¶ added in v1.33.0
func (p *TimeProfile) StopAndLog(f logFunction)
func (*TimeProfile) TilNow ¶ added in v1.17.0
func (p *TimeProfile) TilNow() time.Duration
type VolatileMemory ¶
type VolatileMemory struct {
// contains filtered or unexported fields
}
func NewDetectorCache ¶
func NewDetectorCache() *VolatileMemory
func (*VolatileMemory) IsObjectFresh ¶
func (i *VolatileMemory) IsObjectFresh(obj interface{}, ttl time.Duration) bool
func (*VolatileMemory) IsTextFresh ¶
func (i *VolatileMemory) IsTextFresh(text string, ttl time.Duration) bool