All Projects → coinrust → Crex

coinrust / Crex

Licence: mit
A Golang cryptocurrency trading API & Library. Support Binance, BitMEX, Deribit, Bybit, Huobi DM, OKEX Futures and more.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Crex

Rqalpha
A extendable, replaceable Python algorithmic backtest && trading framework supporting multiple securities
Stars: ✭ 4,425 (+2565.66%)
Mutual labels:  trading, quant, backtest
Tardis Node
Convenient access to tick-level real-time and historical cryptocurrency market data via Node.js
Stars: ✭ 126 (-24.1%)
Mutual labels:  trading, binance, websocket
Crypto Trading Bot
Cryptocurrency trading bot in javascript for Bitfinex, Bitmex, Binance, FTX, Bybit ... (public edition)
Stars: ✭ 1,089 (+556.02%)
Mutual labels:  trading, binance, websocket
Starquant
a light-weighted, integrated trading/backtesting system/platform(综合量化交易回测系统/平台)
Stars: ✭ 250 (+50.6%)
Mutual labels:  trading, quant, backtest
presso
Event-driven backtest/realtime quantitative trading system.
Stars: ✭ 59 (-64.46%)
Mutual labels:  trading, quant, backtest
binance-downloader
Python tool to download Binance Candlestick (k-line) data from REST API
Stars: ✭ 44 (-73.49%)
Mutual labels:  trading, backtest, binance
Trading Server
A multi-asset, multi-strategy, event-driven trade execution and management platform for running many algorithms/bots at many venues simultaneously with unified risk management and reporting. Uses MongoDB for storage and Telegram for user notifications/trade consent.
Stars: ✭ 191 (+15.06%)
Mutual labels:  trading, binance, backtest
howtrader
Howtrader is a crypto currency quant framework, you can easily develop, backtest and run your own strategy in real market. It also supports tradingview or other 3rd party signals, just simply send a post request and it will help trade automatically. Now it only support binance spot, futures and inverse futures exchange. It will support okex, ftx…
Stars: ✭ 294 (+77.11%)
Mutual labels:  trading, quant, binance
Cryptofeed
Cryptocurrency Exchange Websocket Data Feed Handler
Stars: ✭ 643 (+287.35%)
Mutual labels:  trading, binance, websocket
Marketstore
DataFrame Server for Financial Timeseries Data
Stars: ✭ 1,290 (+677.11%)
Mutual labels:  trading, binance
Python Binance Chain
Binance Chain Exchange API python implementation for automated trading
Stars: ✭ 96 (-42.17%)
Mutual labels:  binance, websocket
Kupi Terminal
Ccxt based, open source, customized, extendable trading platform that supports 130+ crypto exchanges.
Stars: ✭ 104 (-37.35%)
Mutual labels:  trading, binance
Goex
Exchange Rest And WebSocket API For Golang Wrapper support okcoin,okex,huobi,hbdm,bitmex,coinex,poloniex,bitfinex,bitstamp,binance,kraken,bithumb,zb,hitbtc,fcoin, coinbene
Stars: ✭ 1,188 (+615.66%)
Mutual labels:  quant, binance
Tradingview Alert Binance Trader
This trading bot listens to the TradingView alert emails on your inbox and executes trades on Binance based on the parameters set on the TD alerts.
Stars: ✭ 100 (-39.76%)
Mutual labels:  trading, binance
Siis
Trading bot including terminal, for crypto and traditionals markets. Assisted or fully automated strategy.
Stars: ✭ 45 (-72.89%)
Mutual labels:  trading, binance
Abu
阿布量化交易系统(股票,期权,期货,比特币,机器学习) 基于python的开源量化交易,量化投资架构
Stars: ✭ 8,589 (+5074.1%)
Mutual labels:  trading, quant
Strategems.jl
Quantitative systematic trading strategy development and backtesting in Julia
Stars: ✭ 106 (-36.14%)
Mutual labels:  trading, backtest
Vue Crypto Dashboard
Cryptocurrency Dashboard made with Vue
Stars: ✭ 107 (-35.54%)
Mutual labels:  binance, websocket
Cassandre Trading Bot
Cassandre makes it easy to create your Java crypto trading bot. Our Spring boot starter takes care of exchange connections, accounts, orders, trades, and positions.
Stars: ✭ 120 (-27.71%)
Mutual labels:  trading, binance
Exchanges Php
This is a virtual currency SDK that brings together multiple exchanges
Stars: ✭ 134 (-19.28%)
Mutual labels:  binance, websocket

GitHub go.mod Go version license build status

CREX

中文 | English

CREX 是一个用Golang语言开发的量化交易库。支持tick级别数字币期货平台的回测和实盘。实盘与回测无缝切换,无需更改代码。

回测

示例 @backtest

交易结果

开源策略

https://github.com/coinrust/trading-strategies

主要特性

  • 使用简单
  • Tick级别回测
  • 实盘、回测公用策略代码
  • 支持 WebSocket 共有和私有订阅
  • 支持期货、现货回测
  • 支持期货双向合约,正反向合约

支持交易所

CREX库当前支持以下8个加密货币交易市场和交易API

logo id name ver ws doc
binance binancefutures Binance Futures 1 N API
bitmex bitmex BitMEX 1 Y API
deribit deribit Deribit 2 Y API
bybit bybit Bybit 2 Y API
huobi hbdm Huobi DM 1 Y API
huobi hbdmswap Huobi Swap 1 Y API
okex okexfutures OKEX Futures 3 Y API
okex okexswap OKEX Swap 3 Y API

示例

package main

import (
	. "github.com/coinrust/crex"
	"github.com/coinrust/crex/exchanges"
	"log"
	"time"
)

type BasicStrategy struct {
	StrategyBase
}

func (s *BasicStrategy) OnInit() error {
	return nil
}

func (s *BasicStrategy) OnTick() error {
	currency := "BTC"
	symbol := "BTC-PERPETUAL"

	balance, err := s.Exchange.GetBalance(currency)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("balance: %#v", balance)

	s.Exchange.GetOrderBook(symbol, 10)

	s.Exchange.OpenLong(symbol, OrderTypeLimit, 5000, 10)
	s.Exchange.CloseLong(symbol, OrderTypeLimit, 6000, 10)

	s.Exchange.PlaceOrder(symbol,
		Buy, OrderTypeLimit, 1000.0, 10, OrderPostOnlyOption(true))

	s.Exchange.GetOpenOrders(symbol)
	s.Exchange.GetPositions(symbol)
	return nil
}

func (s *BasicStrategy) Run() error {
	// run loop
	for {
		s.OnTick()
		time.Sleep(1 * time.Second)
	}
	return nil
}

func (s *BasicStrategy) OnExit() error {
	return nil
}

func main() {
	exchange := exchanges.NewExchange(exchanges.Deribit,
		ApiProxyURLOption("socks5://127.0.0.1:1080"), // 使用代理
		//ApiAccessKeyOption("[accessKey]"),
		//ApiSecretKeyOption("[secretKey]"),
		ApiTestnetOption(true))

	s := &BasicStrategy{}

	s.Setup(TradeModeLiveTrading, exchange)

	s.OnInit()
	s.Run()
	s.OnExit()
}

WebSocket 示例

package main

import (
	. "github.com/coinrust/crex"
	"github.com/coinrust/crex/exchanges"
	"log"
)

func main() {
	ws := exchanges.NewExchange(exchanges.OkexFutures,
		ApiProxyURLOption("socks5://127.0.0.1:1080"), // 使用代理
		//ApiAccessKeyOption("[accessKey]"),
		//ApiSecretKeyOption("[secretKey]"),
		//ApiPassPhraseOption("[passphrase]"),
		ApiWebSocketOption(true)) // 开启 WebSocket

	market := Market{
		Symbol: "BTC-USD-200626",
	}
	// 订阅订单薄
	ws.SubscribeLevel2Snapshots(market, func(ob *OrderBook) {
		log.Printf("%#v", ob)
	})
	// 订阅成交记录
	ws.SubscribeTrades(market, func(trades []*Trade) {
		log.Printf("%#v", trades)
	})
	// 订阅订单成交信息
	ws.SubscribeOrders(market, func(orders []*Order) {
		log.Printf("%#v", orders)
	})
	// 订阅持仓信息
	ws.SubscribePositions(market, func(positions []*Position) {
		log.Printf("%#v", positions)
	})

	select {}
}

回测数据

1. 标准 CSV 数据格式

  • 列定界符: , (逗号)
  • 换行标记: \n (LF)
  • 日期时间格式: Unix 时间戳 (ms)

时间格式

列名 描述
t Unix 时间戳 (ms)
asks[0-X].price 卖单价(升序)
asks[0-X].amount 卖单量
bids[0-X].price 买单价(降序)
bids[0-X].amount 买单量

样本数据示例

t,asks[0].price,asks[0].amount,asks[1].price,asks[1].amount,asks[2].price,asks[2].amount,asks[3].price,asks[3].amount,asks[4].price,asks[4].amount,asks[5].price,asks[5].amount,asks[6].price,asks[6].amount,asks[7].price,asks[7].amount,asks[8].price,asks[8].amount,asks[9].price,asks[9].amount,bids[0].price,bids[0].amount,bids[1].price,bids[1].amount,bids[2].price,bids[2].amount,bids[3].price,bids[3].amount,bids[4].price,bids[4].amount,bids[5].price,bids[5].amount,bids[6].price,bids[6].amount,bids[7].price,bids[7].amount,bids[8].price,bids[8].amount,bids[9].price,bids[9].amount
1569888000143,8304.5,7010,8305,60,8305.5,1220,8306,80,8307,200,8307.5,1650,8308,68260,8308.5,120000,8309,38400,8309.5,8400,8304,185750,8303.5,52200,8303,20600,8302.5,4500,8302,2000,8301.5,18200,8301,18000,8300.5,90,8300,71320,8299.5,310
1569888000285,8304.5,7010,8305,60,8305.5,1220,8306,80,8307,200,8307.5,1650,8308,68260,8308.5,120000,8309,38400,8309.5,8400,8304,185750,8303.5,52200,8303,20600,8302.5,4500,8302,2000,8301.5,18200,8301,18000,8300.5,5090,8300,71320,8299.5,310
1569888000307,8304.5,7010,8305,60,8305.5,1220,8306,80,8307,200,8307.5,11010,8308,68260,8308.5,120000,8309,38400,8309.5,8400,8304,185750,8303.5,52200,8303,20600,8302.5,4500,8302,2000,8301.5,18200,8301,18000,8300.5,5090,8300,71320,8299.5,310
1569888000309,8304.5,7010,8305,60,8305.5,1220,8306,80,8307,200,8307.5,20370,8308,68260,8308.5,120000,8309,38400,8309.5,8400,8304,185750,8303.5,52200,8303,20600,8302.5,4500,8302,2000,8301.5,18200,8301,18000,8300.5,5090,8300,71320,8299.5,310
1569888000406,8304.5,7010,8305,60,8305.5,1220,8306,80,8307,8960,8307.5,11010,8308,68260,8308.5,120000,8309,38400,8309.5,8400,8304,185750,8303.5,52200,8303,20600,8302.5,4500,8302,2000,8301.5,18200,8301,18000,8300.5,5090,8300,71320,8299.5,310
1569888000500,8304.5,7010,8305,60,8305.5,1220,8306,80,8307,200,8307.5,20370,8308,68260,8308.5,120000,8309,38400,8309.5,8400,8304,185750,8303.5,52200,8303,20600,8302.5,4500,8302,2000,8301.5,18200,8301,18000,8300.5,5090,8300,71320,8299.5,310
1569888000522,8304.5,10270,8305,60,8305.5,1220,8306,80,8307,200,8307.5,20370,8308,68260,8308.5,120000,8309,38400,8309.5,8400,8304,185750,8303.5,52200,8303,20600,8302.5,4500,8302,2000,8301.5,18200,8301,18000,8300.5,5090,8300,71320,8299.5,310
1569888000527,8304.5,10270,8305,60,8305.5,1220,8306,80,8307,200,8307.5,20370,8308,68260,8308.5,120000,8309,38400,8309.5,8400,8304,185010,8303.5,52200,8303,20600,8302.5,4500,8302,2000,8301.5,18200,8301,18000,8300.5,5090,8300,71320,8299.5,310

2. MongoDB (推荐)

  • Database. for example: tick_db
  • Collection. for example: deribit:BTC-PERPETUAL
  • Document: t: timestamp (ms) a: asks Array [[ask_price_0,ask_amount_0],[ask_price_1,ask_amount_1],...] b: bids Array [[bid_price_0,ask_amount_0],[bid_price_1,bid_amount_1],...]
{"_id":{"$oid":"5eb946d88316c7a9c541705c"},"t":{"$numberLong":"1569888000143"},"a":[[8304.5,7010],[8305,60],[8305.5,1220],[8306,80],[8307,200],[8307.5,1650],[8308,68260],[8308.5,120000],[8309,38400],[8309.5,8400]],"b":[[8304,185750],[8303.5,52200],[8303,20600],[8302.5,4500],[8302,2000],[8301.5,18200],[8301,18000],[8300.5,90],[8300,71320],[8299.5,310]]}

数据处理示例

Example of importing data into a database:

cd ./cmd/deribit-data-to-db
go build
./deribit-data-to-db

TODO

  • Paper trading.

QQ群

QQ群: 932289088

捐赠

METHOD ADDRESS
BTC 1Nk4AsGj5HEJ5csRenTUPab1sjUySCZ3Pq
ETH 0xa74eade7ea08a8c48d7de4d582fac145afc86e3d

LICENSE

MIT ©coinrust

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].