-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathorder_state.go
137 lines (124 loc) · 4.84 KB
/
order_state.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
131
132
133
134
135
136
137
package ibapi
import (
"fmt"
)
// OrderAllocation .
type OrderAllocation struct {
Account string
Position Decimal // UNSET_DECIMAL
PositionDesired Decimal // UNSET_DECIMAL
PositionAfter Decimal // UNSET_DECIMAL
DesiredAllocQty Decimal // UNSET_DECIMAL
AllowedAllocQty Decimal // UNSET_DECIMAL
IsMonetary bool
}
func NewOrderAllocation() *OrderAllocation {
oa := &OrderAllocation{}
oa.Position = UNSET_DECIMAL
oa.PositionDesired = UNSET_DECIMAL
oa.PositionAfter = UNSET_DECIMAL
oa.DesiredAllocQty = UNSET_DECIMAL
oa.AllowedAllocQty = UNSET_DECIMAL
return oa
}
func (oa OrderAllocation) String() string {
return fmt.Sprint(
"Account: ", oa.Account,
", Position: ", DecimalMaxString(oa.Position),
", PositionDesired: ", DecimalMaxString(oa.PositionDesired),
", PositionAfter: ", DecimalMaxString(oa.PositionAfter),
", DesiredAllocQty: ", DecimalMaxString(oa.DesiredAllocQty),
", AllowedAllocQty: ", DecimalMaxString(oa.AllowedAllocQty),
", IsMonetary: ", oa.IsMonetary,
)
}
// OrderState .
type OrderState struct {
Status string
InitMarginBefore string
MaintMarginBefore string
EquityWithLoanBefore string
InitMarginChange string
MaintMarginChange string
EquityWithLoanChange string
InitMarginAfter string
MaintMarginAfter string
EquityWithLoanAfter string
CommissionAndFees float64 // UNSET_FLOAT
MinCommissionAndFees float64 // UNSET_FLOAT
MaxCommissionAndFees float64 // UNSET_FLOAT
CommissionAndFeesCurrency string
MarginCurrency string
InitMarginBeforeOutsideRTH float64 // UNSET_FLOAT
MaintMarginBeforeOutsideRTH float64 // UNSET_FLOAT
EquityWithLoanBeforeOutsideRTH float64 // UNSET_FLOAT
InitMarginChangeOutsideRTH float64 // UNSET_FLOAT
MaintMarginChangeOutsideRTH float64 // UNSET_FLOAT
EquityWithLoanChangeOutsideRTH float64 // UNSET_FLOAT
InitMarginAfterOutsideRTH float64 // UNSET_FLOAT
MaintMarginAfterOutsideRTH float64 // UNSET_FLOAT
EquityWithLoanAfterOutsideRTH float64 // UNSET_FLOAT
SuggestedSize Decimal // UNSET_DECIMAL
RejectReason string
OrderAllocations []*OrderAllocation
WarningText string
CompletedTime string
CompletedStatus string
}
func NewOrderState() *OrderState {
os := &OrderState{}
os.CommissionAndFees = UNSET_FLOAT
os.MinCommissionAndFees = UNSET_FLOAT
os.MaxCommissionAndFees = UNSET_FLOAT
os.InitMarginBeforeOutsideRTH = UNSET_FLOAT
os.MaintMarginBeforeOutsideRTH = UNSET_FLOAT
os.EquityWithLoanBeforeOutsideRTH = UNSET_FLOAT
os.InitMarginChangeOutsideRTH = UNSET_FLOAT
os.MaintMarginChangeOutsideRTH = UNSET_FLOAT
os.EquityWithLoanChangeOutsideRTH = UNSET_FLOAT
os.InitMarginAfterOutsideRTH = UNSET_FLOAT
os.MaintMarginAfterOutsideRTH = UNSET_FLOAT
os.EquityWithLoanAfterOutsideRTH = UNSET_FLOAT
os.SuggestedSize = UNSET_DECIMAL
return os
}
func (os OrderState) String() string {
s := fmt.Sprint(
"Status: ", os.Status,
", InitMarginBefore: ", os.InitMarginBefore,
", MaintMarginBefore: ", os.MaintMarginBefore,
", EquityWithLoanBefore: ", os.EquityWithLoanBefore,
", InitMarginChange: ", os.InitMarginChange,
", MaintMarginChange: ", os.MaintMarginChange,
", EquityWithLoanChange: ", os.EquityWithLoanChange,
", InitMarginAfter: ", os.InitMarginAfter,
", MaintMarginAfter: ", os.MaintMarginAfter,
", EquityWithLoanAfter: ", os.EquityWithLoanAfter,
", CommissionAndFees: ", FloatMaxString(os.CommissionAndFees),
", MinCommissionAndFees: ", FloatMaxString(os.MinCommissionAndFees),
", MaxCommissionAndFees: ", FloatMaxString(os.MaxCommissionAndFees),
", CommissionAndFeesCurrency: ", os.CommissionAndFeesCurrency,
", MarginCurrency: ", os.MarginCurrency,
", InitMarginBeforeOutsideRTH: ", FloatMaxString(os.InitMarginBeforeOutsideRTH),
", MaintMarginBeforeOutsideRTH: ", FloatMaxString(os.MaintMarginBeforeOutsideRTH),
", EquityWithLoanBeforeOutsideRTH: ", FloatMaxString(os.EquityWithLoanBeforeOutsideRTH),
", InitMarginChangeOutsideRTH: ", FloatMaxString(os.InitMarginChangeOutsideRTH),
", MaintMarginChangeOutsideRTH: ", FloatMaxString(os.MaintMarginChangeOutsideRTH),
", EquityWithLoanChangeOutsideRTH: ", FloatMaxString(os.EquityWithLoanChangeOutsideRTH),
", InitMarginAfterOutsideRTH: ", FloatMaxString(os.InitMarginAfterOutsideRTH),
", MaintMarginAfterOutsideRTH: ", FloatMaxString(os.MaintMarginAfterOutsideRTH),
", EquityWithLoanAfterOutsideRTH: ", FloatMaxString(os.EquityWithLoanAfterOutsideRTH),
", SuggestedSize: ", DecimalMaxString(os.SuggestedSize),
", RejectReason: ", os.RejectReason,
", WarningText: ", os.WarningText,
", CompletedTime: ", os.CompletedTime,
", CompletedStatus: ", os.CompletedStatus,
)
if os.OrderAllocations != nil {
s += ", OrderAllocations: "
for _, oa := range os.OrderAllocations {
s += "[" + oa.String() + "]"
}
}
return s
}