Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
f0cii committed Mar 25, 2020
1 parent b1db701 commit 33f4c4e
Show file tree
Hide file tree
Showing 38 changed files with 76 additions and 76 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# GoTrader
# CREX

[README](README.md) | [English README](README_en.md)

### GoTrader
GoTrader 是一个用Golang语言开发的量化交易库。支持tick级别数字币期货平台的回测和实盘。
### CREX
CREX 是一个用Golang语言开发的量化交易库。支持tick级别数字币期货平台的回测和实盘。

### 标准 CSV 数据格式
* 列定界符: , (逗号)
Expand Down Expand Up @@ -33,10 +33,10 @@ t,asks[0].price,asks[0].amount,asks[1].price,asks[1].amount,asks[2].price,asks[2
```

### 回测
示例 [@backtest](https://github.com/coinrust/gotrader/blob/master/examples/backtest/main.go)
示例 [@backtest](https://github.com/coinrust/crex/blob/master/examples/backtest/main.go)

### 实盘
示例 [@live trading](https://github.com/coinrust/gotrader/blob/master/examples/live/main.go)
示例 [@live trading](https://github.com/coinrust/crex/blob/master/examples/live/main.go)

### 主要特性
* 使用简单
Expand All @@ -46,19 +46,19 @@ t,asks[0].price,asks[0].amount,asks[1].price,asks[1].amount,asks[2].price,asks[2
### 支持交易所
| 交易所 | 回测 | 实盘 | Broker |
| ----------------------------------------------------- |------------------ | ----------------- | ----------------- |
| [BitMEX](https://www.bitmex.com/register/o0Duru) | Yes | Yes | [Sim](https://github.com/coinrust/gotrader/tree/master/brokers/bitmex-sim-broker) / [Live](https://github.com/coinrust/gotrader/tree/master/brokers/bitmex-broker) |
| [Deribit](https://www.deribit.com/reg-7357.93) | Yes | Yes | [Sim](https://github.com/coinrust/gotrader/tree/master/brokers/deribit-sim-broker) / [Live](https://github.com/coinrust/gotrader/tree/master/brokers/deribit-broker) |
| [Bybit](https://www.bybit.com/app/register?ref=qQggy) | No | Yes | [Live](https://github.com/coinrust/gotrader/tree/master/brokers/bybit-broker) |
| [Huobi DM](https://www.huobi.vc/zh-cn/topic/invited/?invite_code=7hzc5) | No | Yes | [Live](https://github.com/coinrust/gotrader/tree/master/brokers/huobi-broker) |
| [OKEXFutures](https://www.okex.me/join/1890951) | No | Yes | [Live](https://github.com/coinrust/gotrader/tree/master/brokers/okex-broker) |
| [BitMEX](https://www.bitmex.com/register/o0Duru) | Yes | Yes | [Sim](https://github.com/coinrust/crex/tree/master/brokers/bitmex-sim-broker) / [Live](https://github.com/coinrust/crex/tree/master/brokers/bitmex-broker) |
| [Deribit](https://www.deribit.com/reg-7357.93) | Yes | Yes | [Sim](https://github.com/coinrust/crex/tree/master/brokers/deribit-sim-broker) / [Live](https://github.com/coinrust/crex/tree/master/brokers/deribit-broker) |
| [Bybit](https://www.bybit.com/app/register?ref=qQggy) | No | Yes | [Live](https://github.com/coinrust/crex/tree/master/brokers/bybit-broker) |
| [Huobi DM](https://www.huobi.vc/zh-cn/topic/invited/?invite_code=7hzc5) | No | Yes | [Live](https://github.com/coinrust/crex/tree/master/brokers/huobi-broker) |
| [OKEXFutures](https://www.okex.me/join/1890951) | No | Yes | [Live](https://github.com/coinrust/crex/tree/master/brokers/okex-broker) |

### 示例
```golang
package main

import (
. "github.com/coinrust/gotrader"
"github.com/coinrust/gotrader/brokers"
. "github.com/coinrust/crex"
"github.com/coinrust/crex/brokers"
"log"
"time"
)
Expand Down
22 changes: 11 additions & 11 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# GoTrader
# CREX

[README](README.md) | [English README](README_en.md)

### GoTrader
### CREX
A real-time quantitative trading/backtesting library in Golang.

### Standard CSV data types formats
Expand Down Expand Up @@ -33,10 +33,10 @@ t,asks[0].price,asks[0].amount,asks[1].price,asks[1].amount,asks[2].price,asks[2
```

### Backtesting
See [@backtest](https://github.com/coinrust/gotrader/blob/master/examples/backtest/main.go)
See [@backtest](https://github.com/coinrust/crex/blob/master/examples/backtest/main.go)

### Live trading
See [@live trading](https://github.com/coinrust/gotrader/blob/master/examples/live/main.go)
See [@live trading](https://github.com/coinrust/crex/blob/master/examples/live/main.go)

### Main Features
* Ease of use.
Expand All @@ -47,19 +47,19 @@ See [@live trading](https://github.com/coinrust/gotrader/blob/master/examples/li
| Exchange Name | Backtesting | Live trading | Broker |
| ----------------------------------------------------- |------------------ | ----------------- | ----------------- |
| ----------------------------------------------------- |------------------ | ----------------- | ----------------- |
| [BitMEX](https://www.bitmex.com/register/o0Duru) | Yes | Yes | [Sim](https://github.com/coinrust/gotrader/tree/master/brokers/bitmex-sim-broker) / [Live](https://github.com/coinrust/gotrader/tree/master/brokers/bitmex-broker) |
| [Deribit](https://www.deribit.com/reg-7357.93) | Yes | Yes | [Sim](https://github.com/coinrust/gotrader/tree/master/brokers/deribit-sim-broker) / [Live](https://github.com/coinrust/gotrader/tree/master/brokers/deribit-broker) |
| [Bybit](https://www.bybit.com/app/register?ref=qQggy) | No | Yes | [Live](https://github.com/coinrust/gotrader/tree/master/brokers/bybit-broker) |
| [Huobi DM](https://www.huobi.vc/zh-cn/topic/invited/?invite_code=7hzc5) | No | Yes | [Live](https://github.com/coinrust/gotrader/tree/master/brokers/huobi-broker) |
| [OKEXFutures](https://www.okex.me/join/1890951) | No | Yes | [Live](https://github.com/coinrust/gotrader/tree/master/brokers/okex-broker) |
| [BitMEX](https://www.bitmex.com/register/o0Duru) | Yes | Yes | [Sim](https://github.com/coinrust/crex/tree/master/brokers/bitmex-sim-broker) / [Live](https://github.com/coinrust/crex/tree/master/brokers/bitmex-broker) |
| [Deribit](https://www.deribit.com/reg-7357.93) | Yes | Yes | [Sim](https://github.com/coinrust/crex/tree/master/brokers/deribit-sim-broker) / [Live](https://github.com/coinrust/crex/tree/master/brokers/deribit-broker) |
| [Bybit](https://www.bybit.com/app/register?ref=qQggy) | No | Yes | [Live](https://github.com/coinrust/crex/tree/master/brokers/bybit-broker) |
| [Huobi DM](https://www.huobi.vc/zh-cn/topic/invited/?invite_code=7hzc5) | No | Yes | [Live](https://github.com/coinrust/crex/tree/master/brokers/huobi-broker) |
| [OKEXFutures](https://www.okex.me/join/1890951) | No | Yes | [Live](https://github.com/coinrust/crex/tree/master/brokers/okex-broker) |

### Example
```golang
package main

import (
. "github.com/coinrust/gotrader"
"github.com/coinrust/gotrader/brokers"
. "github.com/coinrust/crex"
"github.com/coinrust/crex/brokers"
"log"
"time"
)
Expand Down
2 changes: 1 addition & 1 deletion accountsummary.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gotrader
package crex

type AccountSummary struct {
Balance float64
Expand Down
4 changes: 2 additions & 2 deletions backtest/backtest.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package backtest

import (
. "github.com/coinrust/gotrader"
data "github.com/coinrust/gotrader/data"
. "github.com/coinrust/crex"
data "github.com/coinrust/crex/data"
"log"
"time"
)
Expand Down
2 changes: 1 addition & 1 deletion bar.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gotrader
package crex

type Bar struct {
Event
Expand Down
2 changes: 1 addition & 1 deletion broker.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gotrader
package crex

type Broker interface {
// 订阅事件
Expand Down
2 changes: 1 addition & 1 deletion brokers/bitmex-broker/broker.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package bitmex_broker

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/frankrap/bitmex-api"
"github.com/frankrap/bitmex-api/swagger"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion brokers/bitmex-broker/broker_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package bitmex_broker

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/frankrap/bitmex-api"
"testing"
)
Expand Down
8 changes: 4 additions & 4 deletions brokers/bitmex-sim-broker/helper.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package bitmex_sim_broker

import (
"github.com/coinrust/gotrader"
"github.com/coinrust/crex"
)

// 计算收益
// pnl: 收益(BTC/ETH)
// pnlUsd: 收益(USD)
func CalcPnl(side gotrader.Direction, positionSize float64, entryPrice float64, exitPrice float64) (pnl float64, pnlUsd float64) {
func CalcPnl(side crex.Direction, positionSize float64, entryPrice float64, exitPrice float64) (pnl float64, pnlUsd float64) {
//side := "Short" // "Short"
//positionSize := 3850.0
//entryPrice := 3850.0
Expand All @@ -17,10 +17,10 @@ func CalcPnl(side gotrader.Direction, positionSize float64, entryPrice float64,
if positionSize == 0 {
return
}
if side == gotrader.Buy {
if side == crex.Buy {
pnl = (((entryPrice - exitPrice) / exitPrice) * (positionSize / entryPrice)) * -1
pnlUsd = ((entryPrice - exitPrice) * (positionSize / entryPrice)) * -1
} else if side == gotrader.Sell {
} else if side == crex.Sell {
pnl = ((entryPrice - exitPrice) / exitPrice) * (positionSize / entryPrice)
pnlUsd = (entryPrice - exitPrice) * (positionSize / entryPrice)
}
Expand Down
6 changes: 3 additions & 3 deletions brokers/bitmex-sim-broker/simbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package bitmex_sim_broker
import (
"errors"
"fmt"
. "github.com/coinrust/gotrader"
"github.com/coinrust/gotrader/data"
"github.com/coinrust/gotrader/util2"
. "github.com/coinrust/crex"
"github.com/coinrust/crex/data"
"github.com/coinrust/crex/util2"
"log"
"math"
"time"
Expand Down
12 changes: 6 additions & 6 deletions brokers/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package brokers

import (
"fmt"
. "github.com/coinrust/gotrader"
bitmex_broker "github.com/coinrust/gotrader/brokers/bitmex-broker"
bybit_broker "github.com/coinrust/gotrader/brokers/bybit-broker"
deribit_broker "github.com/coinrust/gotrader/brokers/deribit-broker"
hbdm_broker "github.com/coinrust/gotrader/brokers/hbdm-broker"
okex_broker "github.com/coinrust/gotrader/brokers/okex-broker"
. "github.com/coinrust/crex"
bitmex_broker "github.com/coinrust/crex/brokers/bitmex-broker"
bybit_broker "github.com/coinrust/crex/brokers/bybit-broker"
deribit_broker "github.com/coinrust/crex/brokers/deribit-broker"
hbdm_broker "github.com/coinrust/crex/brokers/hbdm-broker"
okex_broker "github.com/coinrust/crex/brokers/okex-broker"
"github.com/frankrap/bitmex-api"
"github.com/frankrap/deribit-api"
"log"
Expand Down
2 changes: 1 addition & 1 deletion brokers/bybit-broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package bybit_broker

import (
"errors"
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/frankrap/bybit-api/rest"
"log"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion brokers/deribit-broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package deribit_broker
import (
"errors"
"github.com/chuckpreslar/emission"
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/frankrap/deribit-api"
"github.com/frankrap/deribit-api/models"
"time"
Expand Down
2 changes: 1 addition & 1 deletion brokers/deribit-broker/broker_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package deribit_broker

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/frankrap/deribit-api"
"log"
"testing"
Expand Down
2 changes: 1 addition & 1 deletion brokers/deribit-broker/orderbook_local.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package deribit_broker

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/frankrap/deribit-api/models"
"sort"
"strconv"
Expand Down
2 changes: 1 addition & 1 deletion brokers/deribit-broker/orderbook_manager.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package deribit_broker

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/frankrap/deribit-api/models"
"sync"
)
Expand Down
2 changes: 1 addition & 1 deletion brokers/deribit-sim-broker/helper.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package deribit_sim_broker

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
)

//im := (0.01 + sizeCurrency*0.00005) * sizeCurrency
Expand Down
2 changes: 1 addition & 1 deletion brokers/deribit-sim-broker/helper_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package deribit_sim_broker

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"testing"
)

Expand Down
6 changes: 3 additions & 3 deletions brokers/deribit-sim-broker/simbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package deribit_sim_broker
import (
"errors"
"fmt"
. "github.com/coinrust/gotrader"
"github.com/coinrust/gotrader/data"
"github.com/coinrust/gotrader/util2"
. "github.com/coinrust/crex"
"github.com/coinrust/crex/data"
"github.com/coinrust/crex/util2"
"log"
"math"
"time"
Expand Down
2 changes: 1 addition & 1 deletion brokers/deribit-sim-broker/simbroker_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package deribit_sim_broker

import (
"github.com/coinrust/gotrader/math2"
"github.com/coinrust/crex/math2"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion brokers/hbdm-broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package hbdm_broker

import (
"fmt"
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/frankrap/huobi-api/hbdm"
"strconv"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion brokers/hbdm-broker/broker_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hbdm_broker

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/spf13/viper"
"log"
"testing"
Expand Down
2 changes: 1 addition & 1 deletion brokers/okex-broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strconv"
"time"

. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/frankrap/okex-api"
)

Expand Down
2 changes: 1 addition & 1 deletion brokers/okex-broker/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"github.com/spf13/viper"
)

Expand Down
2 changes: 1 addition & 1 deletion consts.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gotrader
package crex

// TradeMode 策略模式
type TradeMode int
Expand Down
2 changes: 1 addition & 1 deletion data/csv_dataloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package data

import (
"bufio"
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
"io"
"log"
"os"
Expand Down
2 changes: 1 addition & 1 deletion data/data.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package data

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
)

type Data struct {
Expand Down
2 changes: 1 addition & 1 deletion data/dataloader.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package data

import (
. "github.com/coinrust/gotrader"
. "github.com/coinrust/crex"
)

type DataLoader interface {
Expand Down
2 changes: 1 addition & 1 deletion event.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gotrader
package crex

import "time"

Expand Down
8 changes: 4 additions & 4 deletions examples/backtest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package main

import (
"fmt"
. "github.com/coinrust/gotrader"
"github.com/coinrust/gotrader/backtest"
"github.com/coinrust/gotrader/brokers/deribit-sim-broker"
"github.com/coinrust/gotrader/data"
. "github.com/coinrust/crex"
"github.com/coinrust/crex/backtest"
"github.com/coinrust/crex/brokers/deribit-sim-broker"
"github.com/coinrust/crex/data"
)

type BasicStrategy struct {
Expand Down
4 changes: 2 additions & 2 deletions examples/live/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
. "github.com/coinrust/gotrader"
"github.com/coinrust/gotrader/brokers"
. "github.com/coinrust/crex"
"github.com/coinrust/crex/brokers"
"log"
"time"
)
Expand Down
Loading

0 comments on commit 33f4c4e

Please sign in to comment.