modulepackage
0.0.0-20220127032708-9f5570a1c360
Repository: https://github.com/frankrap/goalgo.git
Documentation: pkg.go.dev
# README
goalgo
A real-time quantitative trading platform in Golang.
这是一个基于 Go 的量化系统,此项目不支持回测,新项目请移步: [crex] https://github.com/coinrust/crex (同时支持BitMEX, Deribit, ByBit...)
目前支持基于以下两个库编写策略
GoEx https://github.com/nntaoli-project/GoEx
bitmex-api https://github.com/frankrap/bitmex-api
其中 bitmexwrap 提供了对 BitMEX 交易所的支持,内部集成了 Rest 和 WebSocket 接口
欢迎交流,欲使用此系统,请自行登录以下官网注册账号:
如有问题,请联系加QQ群: 932289088
1.简单的基于 GoEx 策略脚本:
package main
import (
"time"
"github.com/nntaoli-project/GoEx"
"github.com/frankrap/goalgo"
"github.com/frankrap/goalgo/algo"
"github.com/frankrap/goalgo/log"
)
// SimpleGoExStrategy 简单的GoEx策略
type SimpleGoExStrategy struct {
algo.GoExStrategy
}
// Init 策略初始化方法,必须实现
func (s *SimpleGoExStrategy) Init() error {
log.Info("Init")
return nil
}
// Run 策略主逻辑,必须实现
func (s *SimpleGoExStrategy) Run() error {
log.Info("Run")
for s.IsRunning() {
time.Sleep(5 * time.Second)
// 获取交易所 Ticker 数据
ticker, err := s.Exchange.GetTicker(goex.BTC_USDT)
if err != nil {
log.Errorf("%v", err)
continue
}
log.Infof("Ticker %#v", ticker)
}
return nil
}
func main() {
s := &SimpleGoExStrategy{}
goalgo.Serve(s)
}
2.简单的基于 bitmexwrap(BitMEX 期货市场)策略脚本:
package main
import (
"time"
"github.com/frankrap/goalgo"
"github.com/frankrap/goalgo/algo"
"github.com/frankrap/goalgo/log"
)
// BitMEXDemoStrategy 示例策略(BitMEX)
type BitMEXDemoStrategy struct {
algo.BitMEXStrategy
}
// Init 策略初始化方法,必须实现
func (s *BitMEXDemoStrategy) Init() error {
log.Info("Init")
balance, err := s.Exchange.Balance()
if err != nil {
log.Errorf("Balance error: %v", err)
return err
}
log.Infof("balance: %v", balance)
return nil
}
// Run 策略主逻辑,必须实现
func (s *BitMEXDemoStrategy) Run() error {
log.Info("Run")
for s.IsRunning() {
time.Sleep(3 * time.Second)
ticker, err := s.Exchange.Ticker()
if err != nil {
log.Errorf("%v", err)
continue
}
log.Infof("ticker: %v", ticker)
}
return nil
}
func main() {
s := &BitMEXDemoStrategy{}
goalgo.Serve(s)
}
Thanks
This project uses the following external projects or products
- [RabbitMQ] https://www.rabbitmq.com/
- [PostgreSQL] https://www.postgresql.org/
- [ClickHouse] https://clickhouse.yandex/
- [Docker] https://www.docker.com/
- [GoEx] https://github.com/nntaoli-project/GoEx
- [coinex] https://github.com/SuperGod/coinex
- [porthos-go] https://github.com/porthos-rpc/porthos-go
- [go-plugin] https://github.com/hashicorp/go-plugin
- [gin] https://github.com/gin-gonic/gin
- [vuejs] https://vuejs.org/
- ...
捐赠
BTC:17XauetDWtwAZKHRyEw3DpYcRqzhKZzPHq
ETH:0x5e065711852fda9b75c4e490b1e35eea89b9aaa5
XRP:rshdB4kyxXkuPCtCgZw8DrcuSo7jEWfqck
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
GetClient 获得RPC客户端对象.
GetValue 获取一个全局变量.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SetValue 设置一个全局变量.
No description provided by the author
ToBool convert any type to boolean.
ToFloat convert any type to float.
ToFloat32 convert any type to float32.
ToInt convert any type to int.
ToInt64 convert any type to int64.
ToUint64 convert any type to uint64.
# Constants
OptionTag 选项Tag.
No description provided by the author
RobotStatusDisabled 禁用.
RobotStatusError 出错.
RobotStatusRequested RobotStatusStopping 停止中.
RobotStatusRunning 运行中.
RobotStatusStarting 启动中.
RobotStatusStopped 停止.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
ErrNotFound is returned when an item or index is not in the database.
pluginMap is the map of plugins we can dispense.
No description provided by the author
# Structs
BaseStrategy 策略基础类.
Client RPC客户端对象.
Command 表示一个交互命令结构.
ExchangeParams 初始化交易所所需参数.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
OptionInfo 参数信息.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
This is the implementation of plugin.Plugin so we can serve/consume this
This has two methods: Server must return an RPC server for this plugin type.
StrategyRPC Here is an implementation that talks over RPC.
StrategyRPCServer Here is the RPC server that GreeterRPC talks to, conforming to the requirements of net/rpc.
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
AfterOptionsChanged 策略参数改变接口,实现此接口的策略,在动态改变参数后触发此方法.
RobotCtlClient is the client API for RobotCtl service.
RobotCtlServer is the server API for RobotCtl service.
Strategy 策略接口.
StrategyCtl 插件接口.