Documentation ¶
Index ¶
- Constants
- Variables
- type Base
- func (s *Base) Active() string
- func (s *Base) AddIndicator(onlypush bool, flags []string, columnvalues ...interface{})
- func (s *Base) Buy(symbol string, price float64, volume int64, ptype string, offset string) (int32, string, error)
- func (s *Base) Cancel(requestid int32, ordersn string) int
- func (s *Base) DetectDaemonAlive()
- func (s *Base) GetInstrument(symbol string) (error, string, string, int64, float64)
- func (s *Base) GetInstrumentMultiple(symbolT string) (error, string, int64, float64)
- func (s *Base) GetLastPrice(symbol string) (common.LastPrice, error)
- func (s *Base) GetMainKlineHistory(len int) string
- func (s *Base) GetMainLongOrderPosition() int64
- func (s *Base) GetMainLongRealPosition() int64
- func (s *Base) GetMainShortOrderPosition() int64
- func (s *Base) GetMainShortRealPosition() int64
- func (s *Base) GetMainTickBuffer() string
- func (s *Base) GetMainTickHistory(len int) string
- func (s *Base) GetMainVirtualPosition() int64
- func (s *Base) GetStrategyInfo() string
- func (s *Base) GetSubKlineHistory(len int) string
- func (s *Base) GetSubLongOrderPosition() int64
- func (s *Base) GetSubLongRealPosition() int64
- func (s *Base) GetSubShortOrderPosition() int64
- func (s *Base) GetSubShortRealPosition() int64
- func (s *Base) GetSubTickBuffer() string
- func (s *Base) GetSubTickHistory(len int) string
- func (s *Base) GetSubVirtualPosition() int64
- func (s *Base) Hello() string
- func (s *Base) IsLoading() bool
- func (s *Base) IsReplaying() bool
- func (s *Base) IsRunning() bool
- func (s *Base) MakeReplayReport() string
- func (s *Base) ReadLoadingIndicators() string
- func (s *Base) ReadReplayIndicators(startdate int64, enddate int64, length int) string
- func (s *Base) ReadRunningIndicators() string
- func (s *Base) RegOnInit(on OnInitType)
- func (s *Base) RegOnKline(on OnKlineType)
- func (s *Base) RegOnTick(on OnTickType)
- func (s *Base) Replay(startdate string, enddate string) string
- func (s *Base) Run() string
- func (s *Base) Sell(symbol string, price float64, volume int64, ptype string, offset string) (int32, string, error)
- func (s *Base) SetConfig(daemonhost string, daemonwebhost string, daemonchannel string, ...) string
- func (s *Base) Stop() string
- func (s *Base) StopReplay() string
- func (s *Base) TailOrder(requestid int32, ordersn string, timeout int64, retry int, limit float64) error
- type ColumnValue
- type Contract
- type Indicator
- type K
- type KlineBuffer
- type OnInitType
- type OnKlineType
- type OnTickType
- type Replayer
- type StrategyIf
- type StrategyPlugin
- type StrategyRPCServer
- func (s *StrategyRPCServer) Active(args interface{}, resp *string) error
- func (s *StrategyRPCServer) GetMainKlineHistory(args map[string]interface{}, resp *string) error
- func (s *StrategyRPCServer) GetMainTickBuffer(args interface{}, resp *string) error
- func (s *StrategyRPCServer) GetMainTickHistory(args map[string]interface{}, resp *string) error
- func (s *StrategyRPCServer) GetStrategyInfo(args interface{}, resp *string) error
- func (s *StrategyRPCServer) GetSubKlineHistory(args map[string]interface{}, resp *string) error
- func (s *StrategyRPCServer) GetSubTickBuffer(args interface{}, resp *string) error
- func (s *StrategyRPCServer) GetSubTickHistory(args map[string]interface{}, resp *string) error
- func (s *StrategyRPCServer) Hello(args interface{}, resp *string) error
- func (s *StrategyRPCServer) MakeReplayReport(args interface{}, resp *string) error
- func (s *StrategyRPCServer) ReadLoadingIndicators(args interface{}, resp *string) error
- func (s *StrategyRPCServer) ReadReplayIndicators(args map[string]interface{}, resp *string) error
- func (s *StrategyRPCServer) ReadRunningIndicators(args interface{}, resp *string) error
- func (s *StrategyRPCServer) Replay(args map[string]interface{}, resp *string) error
- func (s *StrategyRPCServer) Run(args interface{}, resp *string) error
- func (s *StrategyRPCServer) SetConfig(args map[string]interface{}, resp *string) error
- func (s *StrategyRPCServer) Stop(args interface{}, resp *string) error
- func (s *StrategyRPCServer) StopReplay(args interface{}, resp *string) error
- type StrategyRPClient
- func (g *StrategyRPClient) Active() string
- func (g *StrategyRPClient) GetMainKlineHistory(len int) string
- func (g *StrategyRPClient) GetMainTickBuffer() string
- func (g *StrategyRPClient) GetMainTickHistory(len int) string
- func (g *StrategyRPClient) GetStrategyInfo() string
- func (g *StrategyRPClient) GetSubKlineHistory(len int) string
- func (g *StrategyRPClient) GetSubTickBuffer() string
- func (g *StrategyRPClient) GetSubTickHistory(len int) string
- func (g *StrategyRPClient) Hello() string
- func (g *StrategyRPClient) MakeReplayReport() string
- func (g *StrategyRPClient) ReadLoadingIndicators() string
- func (g *StrategyRPClient) ReadReplayIndicators(startdate int64, enddate int64, length int) string
- func (g *StrategyRPClient) ReadRunningIndicators() string
- func (g *StrategyRPClient) Replay(startdate string, enddate string) string
- func (g *StrategyRPClient) Run() string
- func (g *StrategyRPClient) SetConfig(daemonhost string, daemonwebhost string, daemonchannel string, ...) string
- func (g *StrategyRPClient) Stop() string
- func (g *StrategyRPClient) StopReplay() string
- type T
Constants ¶
View Source
const ( STOP = 0 LOADING = 1 RUNNING = 2 REPLAY = 3 )
* * @Description: 策略状态 * @return unc
View Source
const ( TICKTYPE = "TICK" KLINETYPE = "KLINE" )
* * @Description: Tick类型 * @return unc
Variables ¶
View Source
var HandshakeConfig = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "BASIC_PLUGIN",
MagicCookieValue: "hello",
}
插件握手协议
View Source
var LastTimeStamp int64
测试用
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct { Contract Contract T T K K Exchange map[string]string Multiplier map[string]int64 MinMove map[string]float64 Extend map[string]interface{} // contains filtered or unexported fields }
func (*Base) AddIndicator ¶
AddIndicator
@Description: 记录回测自定义数据到CSV @receiver s @param onlypush 只推送给前端不记录到csv @param columnvalues 键值对
func (*Base) Buy ¶
func (s *Base) Buy(symbol string, price float64, volume int64, ptype string, offset string) (int32, string, error)
*
- @Description: 买单
- @receiver s 策略指针
- @param symbol 合约代码
- @param price 价格
- @param volume 数量
- @param ptype 订单价格类型 PRICEMARKET:市价/PRICELIMIT:限价
- @param offset 开平仓 TRADEOPEN:开仓/TRADECLOSE:平仓
- @return int32 报单请求id
- @return string 订单号
- @return error 错误信息
func (*Base) Cancel ¶
*
- @Description: 撤单
- @receiver o
- @param requestid 报单请求id
- @param ordersn 订单编号
- @return int 返回错误码
func (*Base) DetectDaemonAlive ¶
func (s *Base) DetectDaemonAlive()
*
- @Description: 检测daemon是否存活
- @receiver s
func (*Base) GetInstrumentMultiple ¶
*
- @Description: 获取合约乘数
- @receiver s
- @param exchangeid
- @param symbol
- @return error
func (*Base) GetLastPrice ¶
*
- @Description: 从本地获取最新价
- @receiver s
- @param symbol 合约代码
- @param period 周期
- @return common.LastPrice
- @return error
func (*Base) GetMainKlineHistory ¶
*
- @Description: 获取主合约历史k线数据
- @receiver s
- @param len
- @return string
func (*Base) GetMainLongOrderPosition ¶ added in v1.2.5
func (*Base) GetMainLongRealPosition ¶ added in v1.2.7
func (*Base) GetMainShortOrderPosition ¶ added in v1.2.5
func (*Base) GetMainShortRealPosition ¶ added in v1.2.7
func (*Base) GetMainTickBuffer ¶ added in v1.2.8
*
- @Description: 从缓存里获取主Tick数据
- @receiver s
- @return string
func (*Base) GetSubLongOrderPosition ¶ added in v1.2.5
func (*Base) GetSubLongRealPosition ¶ added in v1.2.7
func (*Base) GetSubShortOrderPosition ¶ added in v1.2.5
func (*Base) GetSubShortRealPosition ¶ added in v1.2.7
func (*Base) GetSubTickBuffer ¶ added in v1.2.8
*
- @Description: 从缓存获取次Tick数据
- @receiver s
- @param len
- @return string
func (*Base) ReadLoadingIndicators ¶
ReadLoadingIndicators 读取Loading指标数据
@Description: @receiver s @return string
func (*Base) ReadReplayIndicators ¶
ReadReplayIndicators 读取指标数据
@Description: @receiver s @return string
func (*Base) ReadRunningIndicators ¶
ReadRunningIndicators 读取Running指标数据
@Description: @receiver s @return string
func (*Base) RegOnInit ¶
func (s *Base) RegOnInit(on OnInitType)
*
- @Description: 注册初始化回调函数
- @receiver s
- @param on
func (*Base) RegOnKline ¶
func (s *Base) RegOnKline(on OnKlineType)
*
- @Description: 注册kline行情回调函数
- @receiver s
- @param on
func (*Base) RegOnTick ¶
func (s *Base) RegOnTick(on OnTickType)
*
- @Description: 注册tick行情回调函数
- @receiver s
- @param on
func (*Base) Replay ¶
*
- @Description: 回测
- @receiver s
- @param staname
- @param startdate
- @param enddate
- @return error
func (*Base) Sell ¶
func (s *Base) Sell(symbol string, price float64, volume int64, ptype string, offset string) (int32, string, error)
*
- @Description: 卖单
- @receiver s 策略指针
- @param symbol 合约代码
- @param price 价格
- @param volume 数量
- @param ptype 订单价格类型 PRICEMARKET:市价/PRICELIMIT:限价
- @param offset 开平仓 TRADEOPEN:开仓/TRADECLOSE:平仓
- @return int32 报单请求id
- @return string 订单号
- @return error 错误信息
func (*Base) SetConfig ¶
func (s *Base) SetConfig(daemonhost string, daemonwebhost string, daemonchannel string, quoteserverhost string, quotehttphost string, tradeserverhost string, apikey string) string
*
- @Description: 设置配置文件
- @receiver s
* @param daemonhost 策略守护程序地址
- @param string 行情服务器地址
- @param string 交易服务器地址
- @param path 插件所在目录
- @param staname 策略名称
type ColumnValue ¶
* * @Description: 列名值键值对参数结构 * @Name: 列名 * @Value: 值
type Contract ¶
type Contract struct { MainQuote string MainQuoteLen int SubQuote string SubQuoteLen int MainKline common.KlineKey MainKlineLen int SubKline common.KlineKey SubKlineLen int MainTrade string MainTradeExchange string SubTrade string SubTradeExchange string }
* * @Description: 合约相关结构 * @MainQuote: 监控Quote行情主合约 * @SubQuote: 监控Quote行情次合约 * @Mainkline: 监控Kline行情主合约 * @subkline: 监控Kline行情次合约 * @MainTrade: 主交易合约 * @SubTrade: 次交易合约
type Indicator ¶
type Indicator struct { LoadingFile *os.File LoadingFileName string LoadingColumnNames []string LoadingColumnValues map[string]string LoadingCsvWritter *csv.Writer RunningFile *os.File RunningFileName string RunningColumnNames []string RunningColumnValues map[string]string RunningCsvWritter *csv.Writer // contains filtered or unexported fields }
type KlineBuffer ¶
type KlineBuffer struct { Buffer map[common.KlineKey][]common.Kline BufferLen map[common.KlineKey]int }
* * @Description: K线缓存器
type OnKlineType ¶
定义Kline回调函数
type Replayer ¶
type Replayer struct { DataFile *os.File DataFileName string DataColumnNames []string DataColumnValues map[string]string DataCsvWritter *csv.Writer IndicatorFile *os.File IndicatorFileName string IndicatorColumnNames []string IndicatorColumnValues map[string]string IndicatorCsvWritter *csv.Writer }
* * @Description: 回测日志结构
type StrategyIf ¶
type StrategyIf interface { // 检测插件 Hello() string // 运行策略 Run() string // 停止策略 Stop() string // 回测策略 Replay(startdate string, enddate string) string // 生成回测报告 MakeReplayReport() string // 停止回测 StopReplay() string // 激活插件 Active() string // 设置配置参数 SetConfig(daemonhost string, daemonwebhost string, daemonchannel string, quoteserverhost string, quotehttphost string, tradeserverhost string, apikey string) string // 获取策略信息 GetStrategyInfo() string // 获取主Tick行情缓存 GetMainTickBuffer() string // 获取次Tick行情缓存 GetSubTickBuffer() string // 获取主Tick行情历史 GetMainTickHistory(len int) string // 获取次Tick行情历史 GetSubTickHistory(len int) string // 获取主合约行情历史k线 GetMainKlineHistory(len int) string // 获取次合约行情历史k线 GetSubKlineHistory(len int) string // 读取Loading指标数据 ReadLoadingIndicators() string // 读取Running指标数据 ReadRunningIndicators() string // 读取回测指标数据 ReadReplayIndicators(startdate int64, enddate int64, length int) string }
type StrategyPlugin ¶
type StrategyPlugin struct { // Impl Injection Impl StrategyIf }
策略插件
func (StrategyPlugin) Client ¶
func (StrategyPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)
func (*StrategyPlugin) Server ¶
func (p *StrategyPlugin) Server(*plugin.MuxBroker) (interface{}, error)
type StrategyRPCServer ¶
type StrategyRPCServer struct {
Impl StrategyIf
}
* * @Description: 策略插件服务端RPC
func (*StrategyRPCServer) Active ¶
func (s *StrategyRPCServer) Active(args interface{}, resp *string) error
func (*StrategyRPCServer) GetMainKlineHistory ¶
func (s *StrategyRPCServer) GetMainKlineHistory(args map[string]interface{}, resp *string) error
func (*StrategyRPCServer) GetMainTickBuffer ¶ added in v1.2.8
func (s *StrategyRPCServer) GetMainTickBuffer(args interface{}, resp *string) error
func (*StrategyRPCServer) GetMainTickHistory ¶
func (s *StrategyRPCServer) GetMainTickHistory(args map[string]interface{}, resp *string) error
func (*StrategyRPCServer) GetStrategyInfo ¶
func (s *StrategyRPCServer) GetStrategyInfo(args interface{}, resp *string) error
func (*StrategyRPCServer) GetSubKlineHistory ¶
func (s *StrategyRPCServer) GetSubKlineHistory(args map[string]interface{}, resp *string) error
func (*StrategyRPCServer) GetSubTickBuffer ¶ added in v1.2.8
func (s *StrategyRPCServer) GetSubTickBuffer(args interface{}, resp *string) error
func (*StrategyRPCServer) GetSubTickHistory ¶
func (s *StrategyRPCServer) GetSubTickHistory(args map[string]interface{}, resp *string) error
func (*StrategyRPCServer) Hello ¶
func (s *StrategyRPCServer) Hello(args interface{}, resp *string) error
func (*StrategyRPCServer) MakeReplayReport ¶
func (s *StrategyRPCServer) MakeReplayReport(args interface{}, resp *string) error
func (*StrategyRPCServer) ReadLoadingIndicators ¶
func (s *StrategyRPCServer) ReadLoadingIndicators(args interface{}, resp *string) error
func (*StrategyRPCServer) ReadReplayIndicators ¶
func (s *StrategyRPCServer) ReadReplayIndicators(args map[string]interface{}, resp *string) error
func (*StrategyRPCServer) ReadRunningIndicators ¶
func (s *StrategyRPCServer) ReadRunningIndicators(args interface{}, resp *string) error
func (*StrategyRPCServer) Replay ¶
func (s *StrategyRPCServer) Replay(args map[string]interface{}, resp *string) error
func (*StrategyRPCServer) Run ¶
func (s *StrategyRPCServer) Run(args interface{}, resp *string) error
func (*StrategyRPCServer) SetConfig ¶
func (s *StrategyRPCServer) SetConfig(args map[string]interface{}, resp *string) error
func (*StrategyRPCServer) Stop ¶
func (s *StrategyRPCServer) Stop(args interface{}, resp *string) error
func (*StrategyRPCServer) StopReplay ¶
func (s *StrategyRPCServer) StopReplay(args interface{}, resp *string) error
type StrategyRPClient ¶
type StrategyRPClient struct {
// contains filtered or unexported fields
}
*
- @Description: 策略插件客户端RPC
func (*StrategyRPClient) Active ¶
func (g *StrategyRPClient) Active() string
func (*StrategyRPClient) GetMainKlineHistory ¶
func (g *StrategyRPClient) GetMainKlineHistory(len int) string
func (*StrategyRPClient) GetMainTickBuffer ¶ added in v1.2.8
func (g *StrategyRPClient) GetMainTickBuffer() string
func (*StrategyRPClient) GetMainTickHistory ¶
func (g *StrategyRPClient) GetMainTickHistory(len int) string
func (*StrategyRPClient) GetStrategyInfo ¶
func (g *StrategyRPClient) GetStrategyInfo() string
func (*StrategyRPClient) GetSubKlineHistory ¶
func (g *StrategyRPClient) GetSubKlineHistory(len int) string
func (*StrategyRPClient) GetSubTickBuffer ¶ added in v1.2.8
func (g *StrategyRPClient) GetSubTickBuffer() string
func (*StrategyRPClient) GetSubTickHistory ¶
func (g *StrategyRPClient) GetSubTickHistory(len int) string
func (*StrategyRPClient) Hello ¶
func (g *StrategyRPClient) Hello() string
func (*StrategyRPClient) MakeReplayReport ¶
func (g *StrategyRPClient) MakeReplayReport() string
func (*StrategyRPClient) ReadLoadingIndicators ¶
func (g *StrategyRPClient) ReadLoadingIndicators() string
func (*StrategyRPClient) ReadReplayIndicators ¶
func (g *StrategyRPClient) ReadReplayIndicators(startdate int64, enddate int64, length int) string
func (*StrategyRPClient) ReadRunningIndicators ¶
func (g *StrategyRPClient) ReadRunningIndicators() string
func (*StrategyRPClient) Replay ¶
func (g *StrategyRPClient) Replay(startdate string, enddate string) string
func (*StrategyRPClient) Run ¶
func (g *StrategyRPClient) Run() string
func (*StrategyRPClient) Stop ¶
func (g *StrategyRPClient) Stop() string
func (*StrategyRPClient) StopReplay ¶
func (g *StrategyRPClient) StopReplay() string
Click to show internal directories.
Click to hide internal directories.