Skip to content

Commit 5430118

Browse files
committed
Merge branch 'dev'
2 parents 0c6e9c2 + 8a277fd commit 5430118

24 files changed

+438
-337
lines changed

.vscode/launch.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

Const.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,16 @@ const (
155155
COINBENE = "coinbene.com"
156156
ATOP = "a.top"
157157
)
158+
159+
const (
160+
SUB_ACCOUNT = iota //子账户
161+
SPOT // 币币交易
162+
_
163+
FUTURE //交割合约
164+
C2C //法币
165+
SPOT_MARGIN //币币杠杆交易
166+
WALLET // 资金账户
167+
_
168+
TIPS //余币宝
169+
SWAP //永续合约
170+
)

FutureRestAPI.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ type FutureRestAPI interface {
5151
*/
5252
PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error)
5353

54+
LimitFuturesOrder(currencyPair CurrencyPair, contractType, price, amount string, openType int) (*FutureOrder, error)
55+
5456
/**
5557
* 取消订单
5658
* @param symbol btc_usd:比特币 ltc_usd :莱特币

Models.go

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ import (
66
)
77

88
type Order struct {
9-
Price float64
10-
Amount float64
11-
AvgPrice float64
12-
DealAmount float64
13-
Fee float64
14-
Cid string //客户端自定义ID
15-
OrderID2 string
16-
OrderID int //deprecated
17-
OrderTime int
18-
Status TradeStatus
19-
Currency CurrencyPair
20-
Side TradeSide
21-
Type string //limit / market
22-
OrderType int //0:default,1:maker,2:fok,3:ioc
9+
Price float64
10+
Amount float64
11+
AvgPrice float64
12+
DealAmount float64
13+
Fee float64
14+
Cid string //客户端自定义ID
15+
OrderID2 string
16+
OrderID int //deprecated
17+
Status TradeStatus
18+
Currency CurrencyPair
19+
Side TradeSide
20+
Type string //limit / market
21+
OrderType int //0:default,1:maker,2:fok,3:ioc
22+
OrderTime int // create timestamp
23+
FinishedTime int64 //finished timestamp
2324
}
2425

2526
type Trade struct {
@@ -75,7 +76,7 @@ type Ticker struct {
7576
type FutureTicker struct {
7677
*Ticker
7778
ContractType string `json:"omitempty"`
78-
ContractId int `json:"contractId"`
79+
ContractId string `json:"contractId"`
7980
LimitHigh float64 `json:"limitHigh,string"`
8081
LimitLow float64 `json:"limitLow,string"`
8182
HoldAmount float64 `json:"hold_amount,string"`
@@ -102,7 +103,8 @@ func (dr DepthRecords) Less(i, j int) bool {
102103
}
103104

104105
type Depth struct {
105-
ContractType string //for future
106+
ContractType string `json:"contract_type,omitempty"` //for futures
107+
ContractId string `json:"contract_id,omitempty"` // for futures
106108
Pair CurrencyPair
107109
UTime time.Time
108110
AskList DepthRecords // Descending order
@@ -164,6 +166,7 @@ type FutureOrder struct {
164166
LeverRate int //倍数
165167
Fee float64 //手续费
166168
ContractName string
169+
FinishedTime int64 // finished timestamp
167170
}
168171

169172
type FuturePosition struct {
@@ -202,8 +205,8 @@ type TickSize struct {
202205
type FuturesContractInfo struct {
203206
*TickSize
204207
ContractVal float64 //合约面值(美元)
205-
Delivery string //交割日期
206-
ContractType string // 本周 this_week 次周 next_week 季度 quarter
208+
Delivery string //交割日期
209+
ContractType string // 本周 this_week 次周 next_week 季度 quarter
207210
}
208211

209212
//api parameter struct
@@ -218,3 +221,37 @@ type RepaymentParameter struct {
218221
BorrowParameter
219222
BorrowId string
220223
}
224+
225+
226+
type TransferParameter struct {
227+
Currency string `json:"currency"`
228+
From int `json:"from"`
229+
To int `json:"to"`
230+
Amount float64 `json:"amount"`
231+
SubAccount string `json:"sub_account"`
232+
InstrumentId string `json:"instrument_id"`
233+
ToInstrumentId string `json:"to_instrument_id"`
234+
}
235+
236+
type WithdrawParameter struct {
237+
Currency string `json:"currency"`
238+
Amount float64 `json:"amount,string"`
239+
Destination int `json:"destination"` //提币到(2:OKCoin国际 3:OKEx 4:数字货币地址)
240+
ToAddress string `json:"to_address"`
241+
TradePwd string `json:"trade_pwd"`
242+
Fee string `json:"fee"`
243+
}
244+
245+
246+
type DepositWithdrawHistory struct {
247+
WithdrawalId string `json:"withdrawal_id,omitempty"`
248+
Currency string `json:"currency"`
249+
Txid string `json:"txid"`
250+
Amount float64 `json:"amount,string"`
251+
From string `json:"from,omitempty"`
252+
To string `json:"to"`
253+
Memo string `json:"memo,omitempty"`
254+
Fee string `json:"fee"`
255+
Status int `json:"status,string"`
256+
Timestamp time.Time `json:"timestamp"`
257+
}

README.md

Lines changed: 8 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<div align="center">
22
<img width="409" heigth="205" src="https://upload-images.jianshu.io/upload_images/6760989-dec7dc747846880e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="goex">
33
<img src="https://travis-ci.org/nntaoli-project/goex.svg?branch=dev"/>
4-
<br/>
5-
[![](logo.png)] (https://www.jetbrains.com/?from=goex)
64
</div>
75

86
### goex目标
@@ -15,119 +13,44 @@ goex项目是为了统一并标准化各个数字资产交易平台的接口而
1513

1614
| 交易所 | 行情接口 | 交易接口 | 版本号 |
1715
| --- | --- | --- | --- |
18-
| hbg.com | Y | Y | 1 |
19-
| hbdm.com | Y| Y | 1 |
20-
| okex.com | Y | Y | 3 |
16+
| huobi.pro | Y | Y | 1 |
17+
| hbdm.com | Y (REST / WS)| Y | 1 |
18+
| okex.com (spot/future)| Y (REST / WS) | Y | 1 |
19+
| okex.com (swap future) | Y | Y | 2 |
2120
| binance.com | Y | Y | 1 |
2221
| kucoin.com | Y | Y | 1 |
2322
| bitstamp.net | Y | Y | 1 |
2423
| bitfinex.com | Y | Y | 1 |
2524
| zb.com | Y | Y | 1 |
2625
| kraken.com | Y | Y | * |
27-
| poloniex.com | Y | Y | * |
28-
| aacoin.com | Y | Y | 1 |
29-
| allcoin.ca | Y | Y | * |
26+
| poloniex.com | Y | Y | * |
3027
| big.one | Y | Y | 2\|3 |
31-
| fcoin.com | Y | Y | 2 |
3228
| hitbtc.com | Y | Y | * |
3329
| coinex.com | Y | Y | 1 |
3430
| exx.com | Y | Y | 1 |
3531
| bithumb.com | Y | Y | * |
3632
| gate.io | Y | N | 1 |
37-
| btcbox.co.jp | Y | N | * |
38-
| coinbig.com | Y | Y | * |
39-
|coinbene.com|Y|Y|*|
33+
| bittrex.com | Y | N | 1.1 |
4034

4135
### 安装goex库
36+
> go get
4237
4338
``` go get github.com/nntaoli-project/goex ```
4439

4540
>建议go mod 管理依赖
4641
```
4742
require (
48-
github.com/nntaoli-project/goex v1.0.4
43+
github.com/nntaoli-project/goex latest
4944
)
5045
```
5146

52-
### 例子
53-
54-
```golang
55-
56-
package main
57-
58-
import (
59-
"github.com/nntaoli-project/goex"
60-
"github.com/nntaoli-project/goex/builder"
61-
"log"
62-
"time"
63-
)
64-
65-
func main() {
66-
apiBuilder := builder.NewAPIBuilder().HttpTimeout(5 * time.Second)
67-
//apiBuilder := builder.NewAPIBuilder().HttpTimeout(5 * time.Second).HttpProxy("socks5://127.0.0.1:1080")
68-
69-
//build spot api
70-
//api := apiBuilder.APIKey("").APISecretkey("").ClientID("123").Build(goex.BITSTAMP)
71-
api := apiBuilder.APIKey("").APISecretkey("").Build(goex.HUOBI_PRO)
72-
log.Println(api.GetExchangeName())
73-
log.Println(api.GetTicker(goex.BTC_USD))
74-
log.Println(api.GetDepth(2, goex.BTC_USD))
75-
//log.Println(api.GetAccount())
76-
//log.Println(api.GetUnfinishOrders(goex.BTC_USD))
77-
78-
//build future api
79-
futureApi := apiBuilder.APIKey("").APISecretkey("").BuildFuture(goex.HBDM)
80-
log.Println(futureApi.GetExchangeName())
81-
log.Println(futureApi.GetFutureTicker(goex.BTC_USD, goex.QUARTER_CONTRACT))
82-
log.Println(futureApi.GetFutureDepth(goex.BTC_USD, goex.QUARTER_CONTRACT, 5))
83-
//log.Println(futureApi.GetFutureUserinfo()) // account
84-
//log.Println(futureApi.GetFuturePosition(goex.BTC_USD , goex.QUARTER_CONTRACT))//position info
85-
}
86-
87-
```
88-
89-
### websocket 使用例子
90-
91-
```golang
92-
import (
93-
"github.com/nntaoli-project/goex"
94-
"github.com/nntaoli-project/goex/huobi"
95-
//"github.com/nntaoli-project/goex/okcoin"
96-
"log"
97-
)
98-
99-
func main() {
100-
101-
//ws := okcoin.NewOKExFutureWs() //ok期货
102-
ws := huobi.NewHbdmWs() //huobi期货
103-
//设置回调函数
104-
ws.SetCallbacks(func(ticker *goex.FutureTicker) {
105-
log.Println(ticker)
106-
}, func(depth *goex.Depth) {
107-
log.Println(depth)
108-
}, func(trade *goex.Trade, contract string) {
109-
log.Println(contract, trade)
110-
})
111-
//订阅行情
112-
ws.SubscribeTrade(goex.BTC_USDT, goex.NEXT_WEEK_CONTRACT)
113-
ws.SubscribeDepth(goex.BTC_USDT, goex.QUARTER_CONTRACT, 5)
114-
ws.SubscribeTicker(goex.BTC_USDT, goex.QUARTER_CONTRACT)
115-
}
116-
117-
```
118-
119-
### 更多文档
120-
121-
[goex.TOP](https://goex.top)
122-
12347
### 注意事项
12448

12549
1. 推荐使用GoLand开发。
12650
2. 推荐关闭自动格式化功能,代码请使用go fmt 格式化.
12751
3. 不建议对现已存在的文件进行重新格式化,这样会导致commit特别糟糕。
12852
4. 请用OrderID2这个字段代替OrderID
12953
5. 请不要使用deprecated关键字标注的方法和字段,后面版本可能随时删除的
130-
6. 交流QQ群:574829125
13154
-----------------
13255

13356
donate

0 commit comments

Comments
 (0)