Documentation ¶
Index ¶
- Constants
- Variables
- func CanTransact(side gctorder.Side) bool
- func DataTypeToInt(dataType string) (int64, error)
- func FitStringToLimit(str, spacer string, limit int, upper bool) string
- func GenerateFileName(fileName, extension string) (string, error)
- func Logo() string
- func PurgeColours()
- func RegisterBacktesterSubLoggers() error
- func SetColours(colours *Colours)
- type Colours
- type Directioner
- type Event
Constants ¶
const ( // CandleStr is a config readable data type to tell the backtester to retrieve candle data CandleStr = "candle" // TradeStr is a config readable data type to tell the backtester to retrieve trade data TradeStr = "trade" // DataCandle is an int64 representation of a candle data type DataCandle int64 = iota // DataTrade is an int64 representation of a trade data type DataTrade )
const ASCIILogo = `` /* 743-byte string literal not displayed */
ASCIILogo is a sweet logo that is optionally printed to the command line window
Variables ¶
var ( // ErrNilEvent is a common error for whenever a nil event occurs when it shouldn't have ErrNilEvent = errors.New("nil event received") // ErrInvalidDataType occurs when an invalid data type is defined in the config ErrInvalidDataType = errors.New("invalid datatype received") // ErrFileNotFound returned when the file is not found ErrFileNotFound = errors.New("file not found") )
var ( Backtester *log.SubLogger LiveStrategy *log.SubLogger Setup *log.SubLogger Strategy *log.SubLogger Config *log.SubLogger Portfolio *log.SubLogger Exchange *log.SubLogger Fill *log.SubLogger Report *log.SubLogger Statistics *log.SubLogger CurrencyStatistics *log.SubLogger FundingStatistics *log.SubLogger Holdings *log.SubLogger Data *log.SubLogger FundManager *log.SubLogger )
custom subloggers for backtester use
var CMDColours = Colours{
Default: "\u001b[0m",
Green: "\033[38;5;157m",
White: "\033[38;5;255m",
Grey: "\033[38;5;240m",
DarkGrey: "\033[38;5;243m",
H1: "\033[38;5;33m",
H2: "\033[38;5;39m",
H3: "\033[38;5;45m",
H4: "\033[38;5;51m",
Success: "\033[38;5;40m",
Info: "\u001B[32m",
Debug: "\u001B[34m",
Warn: "\u001B[33m",
Error: "\033[38;5;196m",
}
CMDColours holds colour information for CMD output
Functions ¶
func CanTransact ¶
CanTransact checks whether an order side is valid to the backtester's standards
func DataTypeToInt ¶
DataTypeToInt converts the config string value into an int
func FitStringToLimit ¶
FitStringToLimit ensures a string is of the length of the limit either by truncating the string with ellipses or padding with the spacer
func GenerateFileName ¶
GenerateFileName will convert a proposed filename into something that is more OS friendly
func RegisterBacktesterSubLoggers ¶
func RegisterBacktesterSubLoggers() error
RegisterBacktesterSubLoggers sets up all custom Backtester sub-loggers
func SetColours ¶
func SetColours(colours *Colours)
SetColours sets cmd output colours at startup. Doing it at any other point risks races and this really isn't worth adding a mutex for
Types ¶
type Colours ¶
type Colours struct { Default string Green string White string Grey string DarkGrey string H1 string H2 string H3 string H4 string Success string Info string Debug string Warn string Error string }
Colours defines colour types for CMD output
type Directioner ¶
Directioner dictates the side of an order
type Event ¶
type Event interface { GetBase() *event.Base GetOffset() int64 SetOffset(int64) IsEvent() bool GetTime() time.Time Pair() currency.Pair GetUnderlyingPair() currency.Pair GetExchange() string GetInterval() kline.Interval GetAssetType() asset.Item GetConcatReasons() string GetReasons() []string GetClosePrice() decimal.Decimal AppendReason(string) AppendReasonf(string, ...interface{}) }
Event interface implements required GetTime() & Pair() return