forked from coinrust/crex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbroker.go
48 lines (34 loc) · 1.41 KB
/
broker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package crex
type Broker interface {
// 订阅事件
Subscribe(event string, param string, listener interface{})
// 获取账号信息
GetAccountSummary(currency string) (result AccountSummary, err error)
// 获取订单薄(OrderBook)
GetOrderBook(symbol string, depth int) (result OrderBook, err error)
// 设置合约类型
// pair: 交易对,如: BTC-USD(OKEX) BTC(HBDM)
// contractType: W1,W2,Q1,Q2
SetContractType(pair string, contractType string) (err error)
// 获取当前设置的合约ID
GetContractID() (symbol string, err error)
// 设置杠杆大小
SetLeverRate(value float64) (err error)
// 下单
PlaceOrder(symbol string, direction Direction, orderType OrderType, price float64, stopPx float64, size float64,
postOnly bool, reduceOnly bool) (result Order, err error)
// 获取活跃委托单列表
GetOpenOrders(symbol string) (result []Order, err error)
// 获取委托信息
GetOrder(symbol string, id string) (result Order, err error)
// 撤销全部委托单
CancelAllOrders(symbol string) (err error)
// 撤销单个委托单
CancelOrder(symbol string, id string) (result Order, err error)
// 修改委托
AmendOrder(symbol string, id string, price float64, size float64) (result Order, err error)
// 获取持仓
GetPosition(symbol string) (result Position, err error)
// 运行一次(回测系统调用)
RunEventLoopOnce() (err error) // Run sim match for backtest only
}