forked from Nyarum/betting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
betting_order.go
130 lines (104 loc) · 5.23 KB
/
betting_order.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package betting
import "time"
type PlaceInstruction struct {
OrderType EOrderType `json:"orderType,omitempty"`
SelectionID int64 `json:"selectionId,omitempty"`
Handicap float64 `json:"handicap"`
Side ESide `json:"side,omitempty"`
LimitOrder LimitOrder `json:"limitOrder,omitempty"`
//LimitOnCloseOrder LimitOnCloseOrder `json:"limitOnCloseOrder,omitempty"`
//MarketOnCloseOrder MarketOnCloseOrder `json:"marketOnCloseOrder,omitempty"`
CustomerOrderRef string `json:"customerOrderRef,omitempty"`
}
type PlaceExecutionReport struct {
CustomerRef string `json:"customerRef,omitempty"`
Status EExecutionReportStatus `json:"status,omitempty"`
ErrorCode EExecutionReportErrorCode `json:"errorCode,omitempty"`
MarketID string `json:"marketId,omitempty"`
InstructionReports []PlaceInstructionReport `json:"instructionReports,omitempty"`
}
type ReplaceExecutionReport struct {
CustomerRef string `json:"customerRef,omitempty"`
Status EExecutionReportStatus `json:"status,omitempty"`
ErrorCode EExecutionReportErrorCode `json:"errorCode,omitempty"`
MarketID string `json:"marketId,omitempty"`
InstructionReports []ReplaceInstructionReport `json:"instructionReports,omitempty"`
}
type CancelInstruction struct {
BetID string `json:"betId,omitempty"`
// SizeReduction float64 `json:"sizeReduction"`
}
type CancelExecutionReport struct {
CustomerRef string `json:"customerRef,omitempty"`
Status EExecutionReportStatus `json:"status,omitempty"`
ErrorCode EExecutionReportErrorCode `json:"errorCode,omitempty"`
MarketID string `json:"marketId,omitempty"`
InstructionReports []CancelInstructionReport `json:"instructionReports,omitempty"`
}
type CancelInstructionReport struct {
Status EInstructionReportStatus `json:"status,omitempty"`
ErrorCode EInstructionReportErrorCode `json:"errorCode,omitempty"`
Instruction CancelInstruction `json:"instruction,omitempty"`
SizeCancelled float64 `json:"sizeCancelled,omitempty"`
CancelledDate time.Time `json:"cancelledDate,omitempty"`
}
type ReplaceInstruction struct {
BetID string `json:"betId,omitempty"`
NewPrice float64 `json:"newPrice,omitempty"`
}
type ReplaceInstructionReport struct {
Status EInstructionReportStatus `json:"status,omitempty"`
ErrorCode EInstructionReportErrorCode `json:"errorCode,omitempty"`
CancelInstructionReport CancelInstructionReport `json:"cancelInstructionReport,omitempty"`
PlaceInstructionReport PlaceInstructionReport `json:"placeInstructionReport,omitempty"`
}
type PlaceInstructionReport struct {
Status EInstructionReportStatus `json:"status,omitempty"`
ErrorCode EInstructionReportErrorCode `json:"errorCode,omitempty"`
OrderStatus EOrderStatus `json:"orderStatus,omitempty"`
Instruction PlaceInstruction `json:"instruction,omitempty"`
BetID string `json:"betId,omitempty"`
PlacedDate time.Time `json:"placedDate,omitempty"`
AveragePriceMatched float64 `json:"averagePriceMatched,omitempty"`
SizeMatched float64 `json:"sizeMatched,omitempty"`
}
type LimitOrder struct {
Size float64 `json:"size,omitempty"`
Price float64 `json:"price,omitempty"`
PersistenceType EPersistenceType `json:"persistenceType,omitempty"`
TimeInForce ETimeInForce `json:"timeInForce,omitempty"`
MinFillSize float64 `json:"minFillSize,omitempty"`
BetTargetType EBetTargetType `json:"betTargetType,omitempty"`
BetTargetSize float64 `json:"betTargetSize,omitempty"`
}
type LimitOnCloseOrder struct {
Liability float64 `json:"liability,omitempty"`
Price float64 `json:"price,omitempty"`
}
type MarketOnCloseOrder struct {
Liability float64 `json:"liability,omitempty"`
}
// PlaceOrders to place new orders into market.
func (b *Betting) PlaceOrders(filter Filter) (placeExecutionReport PlaceExecutionReport, err error) {
err = b.Request(&placeExecutionReport, BettingURL, "placeOrders", &filter)
if err != nil {
return
}
return
}
// PlaceOrders to place new orders into market.
func (b *Betting) ReplaceOrders(filter ReplaceFilter) (replaceExecutionReport ReplaceExecutionReport, err error) {
err = b.ReplaceRequest(&replaceExecutionReport, BettingURL, "replaceOrders", &filter)
if err != nil {
return
}
return
}
// PlaceOrders to place new orders into market.
func (b *Betting) CancelOrders(filter CancelFilter) (cancelExecutionReport CancelExecutionReport, err error) {
err = b.CancelRequest(&cancelExecutionReport, BettingURL, "cancelOrders", &filter)
if err != nil {
return
}
return
}