Documentation ¶
Index ¶
- Variables
- func Code(e *zerolog.Event, code string)
- func GoInterrupt(ctx context.Context, cancel context.CancelFunc)
- func Interrupt(ctx context.Context) bool
- func Location() string
- func Location2() string
- func Location3() string
- func Msg(e *zerolog.Event)
- func Round2(x float64) float64
- func Round4(x float64) float64
- func Run(keeper *StateKeeper, algo Algo)
- func SetupLogger(c LogConfig) error
- func SmartCopy(dst, src interface{}) error
- func TimeFromMs(x int64) time.Time
- func What(e *zerolog.Event, what string)
- type Algo
- type AlgoContainer
- type AlgoContext
- type Book1
- type CreateOrderResponse
- type Exchange
- type FilterWriter
- type LogConfig
- type Parallel
- type ResourceChecker
- type SingleStack
- type State
- type StateKeeper
- type Ticker
- type Trade
- type VerboseAlgo
Constants ¶
This section is empty.
Variables ¶
View Source
var Checker = ResourceChecker{ // contains filtered or unexported fields }
Checker is a default global instance of ResourceChecker.
View Source
var ErrNotBool = errors.New("not a boolean")
View Source
var ErrUnrecognizedLogLevel = errors.New("unrecognized log level")
View Source
var False = AlgoContext{ Result: false, Bools: nil, Floats: nil, Ints: nil, }
View Source
var True = AlgoContext{ Result: true, Bools: nil, Floats: nil, Ints: nil, }
Functions ¶
func GoInterrupt ¶
func GoInterrupt(ctx context.Context, cancel context.CancelFunc)
func Interrupt ¶
Interrupt returns when either (1) interrupt signal is received by the OS or (2) the given context is done.
func Location2 ¶
func Location2() string
Location2 returns the name of the caller of the caller function.
func Run ¶ added in v0.0.3
func Run(keeper *StateKeeper, algo Algo)
func SetupLogger ¶
func TimeFromMs ¶
Types ¶
type Algo ¶ added in v0.0.3
type Algo interface {
Run(input AlgoContext, ticker Ticker) (output AlgoContext)
}
type AlgoContainer ¶ added in v0.0.3
type AlgoContext ¶ added in v0.0.3
type AlgoContext struct { Result bool Bools map[string]bool Floats map[string]float64 Ints map[string]int }
func NewAlgoContext ¶ added in v1.0.2
func NewAlgoContext() AlgoContext
func (AlgoContext) Copy ¶ added in v1.0.1
func (c AlgoContext) Copy() AlgoContext
type Book1 ¶ added in v0.0.3
type Book1 struct { Time time.Time Symbol string BidPrice float64 BidQuantity float64 AskPrice float64 AskQuantity float64 }
Book1 is the level one order book data.
type CreateOrderResponse ¶ added in v0.0.3
type Exchange ¶ added in v0.0.3
type Exchange interface { // CreateOrder accepts arguments of the following formats: // // - side: buy or sell, // - orderType: market (just that for now). CreateOrder(symbol, side, orderType, quantityStr string, reduceOnly bool) (CreateOrderResponse, error) // ChangeMarginType should be invoked with marginType set to // "crossed" or "isolated". ChangeMarginType(symbol, marginType string) error ChangeLeverage(symbol string, leverage int) error // [2] Streams. Book1(ctx context.Context, symbol string) chan Book1 Trade(ctx context.Context, symbol string) chan Trade }
type FilterWriter ¶
func (*FilterWriter) WriteLevel ¶
type LogConfig ¶ added in v0.0.3
type LogConfig struct { Level string // Enable console logging. ConsoleLoggingEnabled bool // Directory to log to to when filelogging is enabled. Directory string // Filename is the name of the logfile which will be placed inside the directory. Filename string // MaxSize the max size in MB of the logfile before it's rolled. MaxSize int // MaxBackups the max number of rolled files to keep. MaxBackups int // MaxAge the max age in days to keep a logfile. MaxAge int }
https://gist.github.com/panta/2530672ca641d953ae452ecb5ef79d7d
type Parallel ¶ added in v1.0.1
type Parallel struct {
// contains filtered or unexported fields
}
func (*Parallel) Run ¶ added in v1.0.1
func (p *Parallel) Run(input AlgoContext, ticker Ticker) (output AlgoContext)
type ResourceChecker ¶ added in v0.0.3
type ResourceChecker struct {
// contains filtered or unexported fields
}
Checker is a simple tool that check if an object created/initialized is subsequently deleted/deinitialized. Can be used for goroutines, channels, etc.
func (*ResourceChecker) Assert ¶ added in v0.0.3
func (c *ResourceChecker) Assert()
CheckerAssert should be defer-called in main().
func (*ResourceChecker) Pop ¶ added in v0.0.3
func (c *ResourceChecker) Pop(xs ...string)
func (*ResourceChecker) Push ¶ added in v0.0.3
func (c *ResourceChecker) Push(xs ...string)
type SingleStack ¶ added in v0.0.3
type SingleStack struct {
// contains filtered or unexported fields
}
func NewSingleStack ¶ added in v0.0.3
func NewSingleStack() *SingleStack
func (*SingleStack) Insert ¶ added in v0.0.3
func (s *SingleStack) Insert(a Algo)
Insert implements AlgoContainer.
func (*SingleStack) Run ¶ added in v0.0.3
func (s *SingleStack) Run(input AlgoContext, ticker Ticker) (output AlgoContext)
Run implements Algo.
type State ¶ added in v0.0.3
func (*State) ApplyBook1 ¶ added in v0.0.3
func (*State) ApplyTrade ¶ added in v0.0.3
type StateKeeper ¶ added in v0.0.3
type StateKeeper struct { // We yield a new State through this channel after each // update. Channel chan Ticker // contains filtered or unexported fields }
func NewStateKeeper ¶ added in v0.0.3
func NewStateKeeper(numChannels int, symbols ...string) *StateKeeper
func (*StateKeeper) ConsumeBook1 ¶ added in v0.0.3
func (k *StateKeeper) ConsumeBook1(xs chan Book1)
func (*StateKeeper) ConsumeTrade ¶ added in v0.0.3
func (k *StateKeeper) ConsumeTrade(xs chan Trade)
type Ticker ¶ added in v0.0.3
type Ticker struct { Now time.Time Symbol string // Trade data. TradePrice float64 TradeQuantity float64 // Order book level 1 data. BidPrice float64 BidQuantity float64 AskPrice float64 AskQuantity float64 }
Ticker holds all the relevant data for a single trading pair.
func (*Ticker) ApplyBook1 ¶ added in v0.0.3
func (*Ticker) ApplyTrade ¶ added in v0.0.3
type VerboseAlgo ¶ added in v0.0.3
type VerboseAlgo struct{}
func (VerboseAlgo) Run ¶ added in v0.0.3
func (v VerboseAlgo) Run(ctx AlgoContext, ticker Ticker) AlgoContext
Source Files ¶
Click to show internal directories.
Click to hide internal directories.