forked from lmx1989219/goexchange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatchService.go
94 lines (77 loc) · 1.72 KB
/
matchService.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package exchange
import (
// zmq "github.com/pebbe/zmq4"
. "gw.com.cn/dzhyun/sdk.bus.git"
)
type MatchService interface {
//撮合逻辑处理
DealMatch(list QueueService, q *DynaQuote)
}
type QueueService interface {
//初始化队列
InitList(pcode string)
//队列标识
Identify() string
//订单入队列
InsertOrder(o *CommonOrder)
//删除元素
DelOrder(bs int32)
//获取订单
GetOrder(bs int32) (c *CommonOrder)
//删除指定元素
RemoveOrderByObj(c *CommonOrder) bool
//清空队列
RemoveAll()
}
const (
RCV_QUOTE_EVENT = 1 //定义接收行情事件
PUSH_DEAL_EVENT = 2 //定义推送成交信息事件
RCV_REQ_WTXD_EVENT = 3 //定义接收委托请求下单事件
RCV_REQ_WTCD_EVENT = 3 //定义接收委托请求撤单事件
EVENT_DOFAILED = -1 //事件处理失败
EVENT_DOSUCCED = 0 //事件处理成功
MATCH_ORDER = 5
COPY_ORDER = 6
)
type BaseEvent interface {
//事件标识
EventIdentify() int
}
type RcvQuoteEvent struct {
Obj *DynaQuote
}
func (rqe *RcvQuoteEvent) EventIdentify() int {
return RCV_QUOTE_EVENT
}
type MatchEvent struct {
Obj *DynaQuote
}
func (rqe *MatchEvent) EventIdentify() int {
return RCV_QUOTE_EVENT
}
type PushDealEvent struct {
Obj *CommonOrder
}
func (rqe *PushDealEvent) EventIdentify() int {
return PUSH_DEAL_EVENT
}
type RcvWtxdEvent struct {
Obj *C2M_JSON
Socket *BusResponse
}
func (rqe *RcvWtxdEvent) EventIdentify() int {
return RCV_REQ_WTXD_EVENT
}
type RcvWtcdEvent struct {
Obj *C2M_JSON
Socket *BusResponse
}
func (rqe *RcvWtcdEvent) EventIdentify() int {
return RCV_REQ_WTCD_EVENT
}
type OrderCopyEvent struct {
Obj *CommonOrder
}
func (rqe *OrderCopyEvent) EventIdentify() int {
return COPY_ORDER
}