forked from Nyarum/betting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
betting_order.go
104 lines (86 loc) · 4.11 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
package betting
import (
"time"
"fmt"
)
type Decimal float64
func (n Decimal) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("%.2f", n)), nil
}
type PlaceInstruction struct {
OrderType EOrderType `json:"orderType,omitempty"`
SelectionID int64 `json:"selectionId,omitempty"`
Handicap Decimal `json:"handicap,omitempty"`
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 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 Decimal `json:"size,omitempty"`
Price Decimal `json:"price,omitempty"`
PersistenceType EPersistenceType `json:"persistenceType,omitempty"`
TimeInForce ETimeInForce `json:"timeInForce,omitempty"`
MinFillSize Decimal `json:"minFillSize,omitempty"`
BetTargetType EBetTargetType `json:"betTargetType,omitempty"`
BetTargetSize Decimal `json:"betTargetSize,omitempty"`
}
type LimitOnCloseOrder struct {
Liability Decimal `json:"liability,omitempty"`
Price Decimal `json:"price,omitempty"`
}
type MarketOnCloseOrder struct {
Liability Decimal `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
}
type CancelInstruction struct {
BetID string `json:"betId"`
SizeReduction Decimal `json:"sizeReduction,omitempty"`
}
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"`
CancelledDate time.Time `json:"cancelledDate,omitempty"`
SizeCancelled float64 `json:"sizeCancelled,omitempty"`
}
// CancelOrders to place new orders into market.
func (b *Betting) CancelOrders(filter CancelFilter) (cancelExecutionReport CancelExecutionReport, err error) {
err = b.Request(&cancelExecutionReport, BettingURL, "cancelOrders", &filter)
if err != nil {
return
}
return
}