-
Notifications
You must be signed in to change notification settings - Fork 30
/
rest_domain.go
201 lines (173 loc) · 6.85 KB
/
rest_domain.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
package sdk
import "time"
type Currency string
const (
RUB Currency = "RUB"
USD Currency = "USD"
EUR Currency = "EUR"
TRY Currency = "TRY"
JPY Currency = "JPY"
CNY Currency = "CNY"
CHF Currency = "CHF"
GBP Currency = "GBP"
HKD Currency = "HKD"
)
type OperationType string
const (
BUY OperationType = "Buy"
SELL OperationType = "Sell"
OperationTypeBrokerCommission OperationType = "BrokerCommission"
OperationTypeExchangeCommission OperationType = "ExchangeCommission"
OperationTypeServiceCommission OperationType = "ServiceCommission"
OperationTypeMarginCommission OperationType = "MarginCommission"
OperationTypeOtherCommission OperationType = "OtherCommission"
OperationTypePayIn OperationType = "PayIn"
OperationTypePayOut OperationType = "PayOut"
OperationTypeTax OperationType = "Tax"
OperationTypeTaxLucre OperationType = "TaxLucre"
OperationTypeTaxDividend OperationType = "TaxDividend"
OperationTypeTaxCoupon OperationType = "TaxCoupon"
OperationTypeTaxBack OperationType = "TaxBack"
OperationTypeRepayment OperationType = "Repayment"
OperationTypePartRepayment OperationType = "PartRepayment"
OperationTypeCoupon OperationType = "Coupon"
OperationTypeDividend OperationType = "Dividend"
OperationTypeSecurityIn OperationType = "SecurityIn"
OperationTypeSecurityOut OperationType = "SecurityOut"
OperationTypeBuyCard OperationType = "BuyCard"
)
type OrderStatus string
const (
OrderStatusNew OrderStatus = "New"
OrderStatusPartiallyFill OrderStatus = "PartiallyFill"
OrderStatusFill OrderStatus = "Fill"
OrderStatusCancelled OrderStatus = "Cancelled"
OrderStatusReplaced OrderStatus = "Replaced"
OrderStatusPendingCancel OrderStatus = "PendingCancel"
OrderStatusRejected OrderStatus = "Rejected"
OrderStatusPendingReplace OrderStatus = "PendingReplace"
OrderStatusPendingNew OrderStatus = "PendingNew"
)
type OperationStatus string
const (
OperationStatusDone OperationStatus = "Done"
OperationStatusDecline OperationStatus = "Decline"
OperationStatusProgress OperationStatus = "Progress"
)
type InstrumentType string
const (
InstrumentTypeStock InstrumentType = "Stock"
InstrumentTypeCurrency InstrumentType = "Currency"
InstrumentTypeBond InstrumentType = "Bond"
InstrumentTypeEtf InstrumentType = "Etf"
)
type OrderType string
const (
OrderTypeLimit OrderType = "Limit"
OrderTypeMarket OrderType = "Market"
)
type PlacedOrder struct {
ID string `json:"orderId"`
Operation OperationType `json:"operation"`
Status OrderStatus `json:"status"`
RejectReason string `json:"rejectReason"`
RequestedLots int `json:"requestedLots"`
ExecutedLots int `json:"executedLots"`
Commission MoneyAmount `json:"commission"`
Message string `json:"message,omitempty"`
}
type Order struct {
ID string `json:"orderId"`
FIGI string `json:"figi"`
Operation OperationType `json:"operation"`
Status OrderStatus `json:"status"`
RequestedLots int `json:"requestedLots"`
ExecutedLots int `json:"executedLots"`
Type OrderType `json:"type"`
Price float64 `json:"price"`
}
type Portfolio struct {
Positions []PositionBalance
Currencies []CurrencyBalance
}
type CurrencyBalance struct {
Currency Currency `json:"currency"`
Balance float64 `json:"balance"`
Blocked float64 `json:"blocked"`
}
type PositionBalance struct {
FIGI string `json:"figi"`
Ticker string `json:"ticker"`
ISIN string `json:"isin"`
InstrumentType InstrumentType `json:"instrumentType"`
Balance float64 `json:"balance"`
Blocked float64 `json:"blocked"`
Lots int `json:"lots"`
ExpectedYield MoneyAmount `json:"expectedYield"`
AveragePositionPrice MoneyAmount `json:"averagePositionPrice"`
AveragePositionPriceNoNkd MoneyAmount `json:"averagePositionPriceNoNkd"`
Name string `json:"name"`
}
type MoneyAmount struct {
Currency Currency `json:"currency"`
Value float64 `json:"value"`
}
type Instrument struct {
FIGI string `json:"figi"`
Ticker string `json:"ticker"`
ISIN string `json:"isin"`
Name string `json:"name"`
MinPriceIncrement float64 `json:"minPriceIncrement"`
Lot int `json:"lot"`
Currency Currency `json:"currency"`
Type InstrumentType `json:"type"`
}
type Operation struct {
ID string `json:"id"`
Status OperationStatus `json:"status"`
Trades []Trade `json:"trades"`
Commission MoneyAmount `json:"commission"`
Currency Currency `json:"currency"`
Payment float64 `json:"payment"`
Price float64 `json:"price"`
Quantity int `json:"quantity"`
QuantityExecuted int `json:"quantityExecuted"`
FIGI string `json:"figi"`
InstrumentType InstrumentType `json:"instrumentType"`
IsMarginCall bool `json:"isMarginCall"`
DateTime time.Time `json:"date"`
OperationType OperationType `json:"operationType"`
}
type Trade struct {
ID string `json:"tradeId"`
DateTime time.Time `json:"date"`
Price float64 `json:"price"`
Quantity int `json:"quantity"`
}
type RestPriceQuantity struct {
Price float64 `json:"price"`
Quantity float64 `json:"quantity"`
}
type RestOrderBook struct {
FIGI string `json:"figi"`
Depth int `json:"depth"`
Bids []RestPriceQuantity `json:"bids"`
Asks []RestPriceQuantity `json:"asks"`
TradeStatus TradingStatus `json:"tradeStatus"`
MinPriceIncrement float64 `json:"minPriceIncrement"`
LastPrice float64 `json:"lastPrice,omitempty"`
ClosePrice float64 `json:"closePrice,omitempty"`
LimitUp float64 `json:"limitUp,omitempty"`
LimitDown float64 `json:"limitDown,omitempty"`
FaceValue float64 `json:"faceValue,omitempty"`
}
type AccountType string
const (
AccountTinkoff AccountType = "Tinkoff"
AccountTinkoffIIS AccountType = "TinkoffIis"
)
type Account struct {
Type AccountType `json:"brokerAccountType"`
ID string `json:"brokerAccountId"`
}
const DefaultAccount = "" // Номер счета (по умолчанию - Тинькофф)