Documentation
¶
Index ¶
Constants ¶
View Source
const ( EventCandleParam = "candle_param" EventCandle = "candle" EventOrder = "order" EventOrderCancelAll = "order_cancel_all" // own trades EventTrade = "trade" EventPosition = "position" EventCurPosition = "cur_position" // position of current script EventRiskLimit = "risk_limit" EventDepth = "depth" // all trades in the markets EventTradeHistory = "trade_history" EventBalance = "balance" EventBalanceInit = "balance_init" EventWatch = "watch" EventNotify = "notify" )
Events
View Source
const ( Long = 1 Short = 2 )
Variables ¶
View Source
var ( EventTypes = map[string]reflect.Type{ EventCandleParam: reflect.TypeOf(CandleParam{}), EventCandle: reflect.TypeOf(Candle{}), EventOrder: reflect.TypeOf(TradeAction{}), EventTrade: reflect.TypeOf(Trade{}), EventPosition: reflect.TypeOf(Position{}), EventDepth: reflect.TypeOf(Depth{}), EventTradeHistory: reflect.TypeOf(Trade{}), EventBalance: reflect.TypeOf(Balance{}), EventBalanceInit: reflect.TypeOf(BalanceInfo{}), EventWatch: reflect.TypeOf(WatchParam{}), EventNotify: reflect.TypeOf(NotifyEvent{}), } )
Functions ¶
func Map2Candle ¶
func Map2Candle(data interface{}) (candle *Candle)
Map2Candle convert candle to map
Types ¶
type CandleInfo ¶
CandleInfo candle data with symbol info
type CandleName ¶
CandleName candle info
func NewCandleName ¶
func NewCandleName(name, binSize string) *CandleName
NewCandleName create CandleName with name and binSize
func ParseCandleName ¶
func ParseCandleName(name string) *CandleName
ParseCandleName parse string to CandleName
type CandleParam ¶
type CandleParam struct {
Start time.Time
End time.Time
Exchange string
BinSize string
Symbol string
}
CandleParam get candle param
type KlineMaker ¶
type KlineMaker interface {
GetName() string
KlineChan(start, end time.Time, symbol, bSize string) (klines chan []interface{}, err chan error)
WatchKline(symbols []SymbolInfo, datas chan *CandleInfo) error
}
KlineMaker kline maker
type NotifyEvent ¶
NotifyEvent event to send notify
type RiskLimit ¶
type RiskLimit struct {
Code string // symbol info, empty = global
Lever float64 // lever
MaxLostRatio float64 // max lose ratio
}
RiskLimit risk limit
type RiskLimits ¶
RiskLimits risk limits
func NewRiskLimits ¶
func NewRiskLimits() (rl RiskLimits)
func (RiskLimits) GetLimitRatio ¶
func (rl RiskLimits) GetLimitRatio(limit RiskLimit) (ret float64)
func (RiskLimits) Update ¶
func (rl RiskLimits) Update(limit RiskLimit)
type SymbolInfo ¶
type SymbolInfo struct {
ID int64 `xorm:"pk autoincr null 'id'"`
Exchange string `xorm:"notnull unique(esr) 'exchange'"`
Symbol string `xorm:"notnull unique(esr) 'symbol'"`
Resolutions string `xorm:"notnull unique(esr) 'resolutions'"`
Pricescale int `xorm:"notnull 'pricescale'"`
}
SymbolInfo symbol infos
func (*SymbolInfo) GetResolutions ¶
func (si *SymbolInfo) GetResolutions() []string
type WatchParam ¶
WatchParam add watch event param
Click to show internal directories.
Click to hide internal directories.