-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtypes.go
More file actions
807 lines (734 loc) · 23.7 KB
/
Copy pathtypes.go
File metadata and controls
807 lines (734 loc) · 23.7 KB
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
package quote
import (
"time"
quotev1 "github.com/longbridge/openapi-protobufs/gen/go/quote"
"github.com/shopspring/decimal"
"github.com/longbridge/openapi-go"
"github.com/longbridge/openapi-go/internal/util"
"github.com/longbridge/openapi-go/quote/jsontypes"
)
type (
TradeStatus int32
TradeSession int32
TradeSessionType int32
EventType int8
SubType uint8
Period int32
AdjustType int32
CalcIndex int32
WarrantStatus int32
WarrantSortBy int32
WarrantSortOrder int32
WarrantType int32
WarrantExpiryDateType int32
WarrantInOutBoundsType int32
WarrantLanguage int32
SecurityListCategory string
WatchlistUpdateMode string
CandlestickTradeSession int32
PinnedMode int32
)
const (
// SubType
SubTypeUnknown SubType = SubType(quotev1.SubType_UNKNOWN_TYPE)
SubTypeQuote SubType = SubType(quotev1.SubType_QUOTE)
SubTypeDepth SubType = SubType(quotev1.SubType_DEPTH)
SubTypeBrokers SubType = SubType(quotev1.SubType_BROKERS)
SubTypeTrade SubType = SubType(quotev1.SubType_TRADE)
// SubEvent
EventQuote EventType = iota
EventBroker
EventTrade
EventDepth
// Period
PeriodOneMinute = Period(quotev1.Period_ONE_MINUTE)
PeriodFiveMinute = Period(quotev1.Period_FIVE_MINUTE)
PeriodFifteenMinute = Period(quotev1.Period_FIFTEEN_MINUTE)
PeriodThirtyMinute = Period(quotev1.Period_THIRTY_MINUTE)
PeriodSixtyMinute = Period(quotev1.Period_SIXTY_MINUTE)
PeriodDay = Period(quotev1.Period_DAY)
PeriodWeek = Period(quotev1.Period_WEEK)
PeriodMonth = Period(quotev1.Period_MONTH)
PeriodYear = Period(quotev1.Period_YEAR)
// AdjustType
AdjustTypeNo = AdjustType(quotev1.AdjustType_NO_ADJUST)
AdjustTypeForward = AdjustType(quotev1.AdjustType_FORWARD_ADJUST)
// TradeSession
TradeSessionNormal = TradeSession(quotev1.TradeSession_NORMAL_TRADE)
TradeSessionPreTrade = TradeSession(quotev1.TradeSession_PRE_TRADE)
TradeSessionPostTrade = TradeSession(quotev1.TradeSession_POST_TRADE)
TradeSessionOvernight = TradeSession(quotev1.TradeSession_OVERNIGHT_TRADE)
// CandlestickTradeSessionNormal includes normal trade session
CandlestickTradeSessionNormal = CandlestickTradeSession(0)
// CandlestickTradeSessionAll includes all trade sessions
CandlestickTradeSessionAll = CandlestickTradeSession(100)
// CalcIndex
CalcIndexUnknown CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_UNKNOWN)
CalcIndexLastDone CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_LAST_DONE)
CalcIndexChangeVal CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CHANGE_VAL)
CalcIndexChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CHANGE_RATE)
CalcIndexVolume CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_VOLUME)
CalcIndexTurnover CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TURNOVER)
CalcIndexYtdChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_YTD_CHANGE_RATE)
CalcIndexTurnoverRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TURNOVER_RATE)
CalcIndexTotalMarketValue CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TOTAL_MARKET_VALUE)
CalcIndexCapitalFlow CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CAPITAL_FLOW)
CalcIndexAmplitude CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_AMPLITUDE)
CalcIndexVolumeRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_VOLUME_RATIO)
CalcIndexPeTTMRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_PE_TTM_RATIO)
CalcIndexPbRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_PB_RATIO)
CalcIndexDividendRatioTTM CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_DIVIDEND_RATIO_TTM)
CalcIndexFiveDayChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_FIVE_DAY_CHANGE_RATE)
CalcIndexTenDayChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TEN_DAY_CHANGE_RATE)
CalcIndexHalfYearChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_HALF_YEAR_CHANGE_RATE)
CalcIndexFiveMinutesChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_FIVE_MINUTES_CHANGE_RATE)
CalcIndexExpiryDate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_EXPIRY_DATE)
CalcIndexStrikePrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_STRIKE_PRICE)
CalcIndexUpperStrikePrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_UPPER_STRIKE_PRICE)
CalcIndexLowerStrikePrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_LOWER_STRIKE_PRICE)
CalcIndexOutstandingQTY CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_OUTSTANDING_QTY)
CalcIndexOutstandingRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_OUTSTANDING_RATIO)
CalcIndexPremium CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_PREMIUM)
CalcIndexItmOtm CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_ITM_OTM)
CalcIndexImpliedVolatility CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_IMPLIED_VOLATILITY)
CalcIndexWarrantDelta CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_WARRANT_DELTA)
CalcIndexCallPrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CALL_PRICE)
CalcIndexToCallPrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TO_CALL_PRICE)
CalcIndexEffectiveLeverage CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_EFFECTIVE_LEVERAGE)
CalcIndexLeverageRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_LEVERAGE_RATIO)
CalcIndexConversionRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CONVERSION_RATIO)
CalcIndexBalancePoint CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_BALANCE_POINT)
CalcIndexOpenInterest CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_OPEN_INTEREST)
CalcIndexDELTA CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_DELTA)
CalcIndexGAMMA CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_GAMMA)
CalcIndexTHETA CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_THETA)
CalcIndexVEGA CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_VEGA)
CalcIndexRHO CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_RHO)
)
// Warrant status
const (
WarrantSuspend WarrantStatus = iota + 2 // can't trade
WarrantPapareList // wait to be listed
WarrantNormal // Tradable
)
const (
WarrantLastDone WarrantSortBy = iota
WarrantChangeRate
WarrantChangeVal
WarrantVolume
WarrantTurnover
WarrantExpiryDate
WarrantStrikePrice
WarrantUpperStrikePrice
WarrantLowerStrikePrice
WarrantOutstandingQty
WarrantOutstandingRatio
WarrantPremiun
WarrantItmOtm
WarrantImpliedVolatility
WarrantDelta
WarrantCallPrice
WarrantToCallPrice
WarrantEffectiveLeverage
WarrantLeverageRatio
WarrantConversionRatio
WarrantBalancePoint
WarrantSortStatus
)
const (
WarrantAsc WarrantSortOrder = iota
WarrantDesc
)
const (
WarrantCall WarrantType = iota
WarrantPut
WarrantBull
WarrantBear
WarrantInline
)
const (
WarrantLT3 WarrantExpiryDateType = iota + 1 // Less than three months
WarrantBT3_6 // between three and six months
WarrantBT6_12 // between six and twelve months
WarrantGT12 // greate than twelve months
)
const (
WarrantInBounds WarrantInOutBoundsType = iota + 1
WarrantOutBounds
)
const (
WarrantZH_CN WarrantLanguage = iota
WarrantEN
WarrantHK_CN
)
const (
Overnight SecurityListCategory = "Overnight"
)
const (
// AddWatchlist will add securities to watchlist group
AddWatchlist WatchlistUpdateMode = "add"
// RemoveWatchlist will remove securities from watchlist group
RemoveWatchlist WatchlistUpdateMode = "remove"
// ReplaceWatchlist will replace securities in watchlist group
// For example:
// If the original group contains APPL.US, BABA.US, TSLA.US,
// and it is updated with ["BABA.US", "AAPL.US", "MSFT.US"],
// it will become BABA.US, AAPL.US, MSFT.US,
// removing TSLA.US and adding MSFT.US, while adjusting the order of BABA.US and AAPL.US.
ReplaceWatchlist WatchlistUpdateMode = "replace"
)
// PushQuote is quote info push from server
type PushQuote struct {
Symbol string
Sequence int64
LastDone *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
TradeSession TradeSessionType
}
// PushDepth is depth info push from server
type PushDepth struct {
Symbol string
Sequence int64
Ask []*Depth
Bid []*Depth
}
// PushBrokers is brokers info push from server
type PushBrokers struct {
Symbol string
Sequence int64
AskBrokers []*Brokers
BidBrokers []*Brokers
}
// PushTrade is trade info push from server
type PushTrade struct {
Symbol string
Sequence int64
Trade []*Trade
}
// Depth store depth details
type Depth struct {
Position int32
Price *decimal.Decimal
Volume int64
OrderNum int64
}
type Brokers struct {
Position int32
BrokerIds []int32
}
// Trade store trade details
type Trade struct {
Price string
Volume int64
Timestamp int64
// TradeType
// HK
//
// - `*` - Overseas trade
// - `D` - Odd-lot trade
// - `M` - Non-direct off-exchange trade
// - `P` - Late trade (Off-exchange previous day)
// - `U` - Auction trade
// - `X` - Direct off-exchange trade
// - `Y` - Automatch internalized
// - `<empty string>` - Automatch normal
//
// US
//
// - `<empty string>` - Regular sale
// - `A` - Acquisition
// - `B` - Bunched trade
// - `D` - Distribution
// - `F` - Intermarket sweep
// - `G` - Bunched sold trades
// - `H` - Price variation trade
// - `I` - Odd lot trade
// - `K` - Rule 155 trde(NYSE MKT)
// - `M` - Market center close price
// - `P` - Prior reference price
// - `Q` - Market center open price
// - `S` - Split trade
// - `V` - Contingent trade
// - `W` - Average price trade
// - `X` - Cross trade
// - `1` - Stopped stock(Regular trade)
TradeType string
Direction int32
TradeSession TradeSession
}
// StaticInfo store static details
type StaticInfo struct {
Symbol string
NameCn string
NameEn string
NameHk string
Exchange string
Currency string
LotSize int32
TotalShares int64
CirculatingShares int64
HkShares int64
Eps *decimal.Decimal
EpsTtm *decimal.Decimal
Bps *decimal.Decimal
DividendYield string
StockDerivatives []int32
}
// Issuer to save issuer id
type Issuer struct {
ID int32
NameCn string
NameEn string
NameHk string
}
// OptionQuote to option quote details
type OptionQuote struct {
Symbol string
LastDone *decimal.Decimal
PrevClose *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
OptionExtend *OptionExtend
}
// OptionExtend is option extended properties
type OptionExtend struct {
ImpliedVolatility string
OpenInterest int64
ExpiryDate string // YYMMDD
StrikePrice *decimal.Decimal
ContractMultiplier string
ContractType string
ContractSize string
Direction string
HistoricalVolatility string
UnderlyingSymbol string
}
// StrikePriceInfo is strike price details
type StrikePriceInfo struct {
Price *decimal.Decimal
CallSymbol string
PutSymbol string
Standard bool
}
// WarrantExtend is warrant extended properties
type WarrantExtend struct {
ImpliedVolatility string
ExpiryDate string
LastTradeDate string
OutstandingRatio string
OutstandingQty int64
ConversionRatio string
Category string
StrikePrice *decimal.Decimal
UpperStrikePrice *decimal.Decimal
LowerStrikePrice *decimal.Decimal
CallPrice *decimal.Decimal
UnderlyingSymbol string
}
// WarrantQuote is warrant quote details
type WarrantQuote struct {
Symbol string
LastDone *decimal.Decimal
PrevClose *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
WarrantExtend *WarrantExtend
}
type WarrantFilter struct {
SortBy WarrantSortBy
SortOrder WarrantSortOrder
SortOffset int32
SortCount int32
Type []WarrantType
Issuer []int32
ExpiryDate []WarrantExpiryDateType
PriceType []WarrantInOutBoundsType
Status []WarrantStatus
Language WarrantLanguage
}
// WarrantInfo is info of warrant asset
type WarrantInfo struct {
Symbol string
Name string
LastDone *decimal.Decimal
ChangeRate *decimal.Decimal
ChangeVal *decimal.Decimal
Volume int64
Turnover *decimal.Decimal
ExpiryDate string
StrikePrice *decimal.Decimal
UpperStrikePrice *decimal.Decimal
LowerStrikePrice *decimal.Decimal
OutstandingQty *decimal.Decimal
OutstandingRatio *decimal.Decimal
Premium *decimal.Decimal
ItmOtm *decimal.Decimal
ImpliedVolatility *decimal.Decimal
Delta *decimal.Decimal
CallPrice *decimal.Decimal
ToCallPrice *decimal.Decimal
EffectiveLeverage *decimal.Decimal
LeverageRatio *decimal.Decimal
ConversionRatio *decimal.Decimal
BalancePoint *decimal.Decimal
Status WarrantStatus
}
// TradeDate
type TradeDate struct {
Date string
TradeDateType int32 // 0 full day, 1 morning only, 2 afternoon only(not happened before)
}
// Candlestick is candlestick details
type Candlestick struct {
Close *decimal.Decimal
Open *decimal.Decimal
Low *decimal.Decimal
High *decimal.Decimal
Volume int64
Turnover *decimal.Decimal
Timestamp int64
}
// Quote is quote details
type Quote struct {
Symbol string
LastDone *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
TradeSession TradeSessionType
}
// SecurityQuote is quote details with pre market and post market
type SecurityQuote struct {
Symbol string
LastDone *decimal.Decimal
PrevClose *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
PreMarketQuote *PrePostQuote
PostMarketQuote *PrePostQuote
OverNightQuote *PrePostQuote
}
// PrePostQuote is pre or post quote details
type PrePostQuote struct {
LastDone *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
PrevClose *decimal.Decimal
}
// SecurityDepth
type SecurityDepth struct {
Symbol string
Ask []*Depth
Bid []*Depth
}
// SecurityBrokers is security brokers details
type SecurityBrokers struct {
Symbol string
AskBrokers []*Brokers
BidBrokers []*Brokers
}
// ParticipantInfo has all participant brokers
type ParticipantInfo struct {
BrokerIds []int32
ParticipantNameCn string
ParticipantNameEn string
ParticipantNameHk string
}
// IntradayLine is k line
type IntradayLine struct {
Price *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
AvgPrice *decimal.Decimal
}
// IssuerInfo is issuer infomation
type IssuerInfo struct {
Id int32
NameCn string
NameEn string
NameHk string
}
// MarketTradingSession is market's session details
type MarketTradingSession struct {
Market openapi.Market
TradeSession []*TradePeriod
}
// TradePeriod
type TradePeriod struct {
BegTime int32
EndTime int32
TradeSession TradeSession
}
// MarketTradingDay contains market open trade days
type MarketTradingDay struct {
TradeDay []time.Time
HalfTradeDay []time.Time
}
// WatchedSecurity the security is watched
type WatchedSecurity struct {
Symbol string
Market string
Name string
Price *decimal.Decimal
WatchedAt int64 // timestamp
IsPinned bool
}
// WatchedGroup a group of the security is watched
type WatchedGroup struct {
Id int64 // group id
Name string // group name
Securites []*WatchedSecurity
}
// CapitalDistribution information
type CapitalDistribution struct {
Symbol string
Timestamp int64 // data update timestamp
CapitalIn Capital // inflow capital data
CapitalOut Capital // outflow capital data
}
// Capital infomartion
type Capital struct {
Large *decimal.Decimal
Medium *decimal.Decimal
Small *decimal.Decimal
}
// CapitalFlowLine
type CapitalFlowLine struct {
Inflow *decimal.Decimal
Timestamp int64
}
// SecurityCalcIndex the infomation of calculate indexes's security
type SecurityCalcIndex struct {
Symbol string
LastDone *decimal.Decimal
ChangeVal *decimal.Decimal
ChangeRate *decimal.Decimal
Volume int64
Turnover *decimal.Decimal
YtdChangeRate *decimal.Decimal
TurnoverRate *decimal.Decimal
TotalMarketValue *decimal.Decimal
CapitalFlow *decimal.Decimal
Amplitude *decimal.Decimal
VolumeRatio *decimal.Decimal
PeTtmRatio *decimal.Decimal
PbRatio *decimal.Decimal
DividendRatioTtm *decimal.Decimal
FiveDayChangeRate *decimal.Decimal
TenDayChangeRate *decimal.Decimal
HalfYearChangeRate *decimal.Decimal
FiveMinutesChangeRate *decimal.Decimal
ExpiryDate string
StrikePrice *decimal.Decimal
UpperStrikePrice *decimal.Decimal
LowerStrikePrice *decimal.Decimal
OutstandingQty *decimal.Decimal
OutstandingRatio *decimal.Decimal
Premium *decimal.Decimal
ItmOtm *decimal.Decimal
ImpliedVolatility *decimal.Decimal
WarrantDelta *decimal.Decimal
CallPrice *decimal.Decimal
ToCallPrice *decimal.Decimal
EffectiveLeverage *decimal.Decimal
LeverageRatio *decimal.Decimal
ConversionRatio *decimal.Decimal
BalancePoint *decimal.Decimal
OpenInterest int64
Delta *decimal.Decimal
Gamma *decimal.Decimal
Theta *decimal.Decimal
Vega *decimal.Decimal
Rho *decimal.Decimal
}
// Security is base info contains symbol and name
type Security = jsontypes.Security
// FilingItem is a filing document for a security
type FilingItem struct {
// Filing ID
Id string
// Title
Title string
// Description
Description string
// File name
FileName string
// File URLs
FileUrls []string
// Published time
PublishAt time.Time
}
// doRatio process some ratio fields
func doRatio(calcIndex *SecurityCalcIndex) {
calcIndex.ChangeRate = util.Percent(calcIndex.ChangeRate)
calcIndex.YtdChangeRate = util.Percent(calcIndex.YtdChangeRate)
calcIndex.Turnover = util.Percent(calcIndex.TurnoverRate)
calcIndex.Amplitude = util.Percent(calcIndex.Amplitude)
calcIndex.FiveDayChangeRate = util.Percent(calcIndex.FiveDayChangeRate)
calcIndex.TenDayChangeRate = util.Percent(calcIndex.TenDayChangeRate)
calcIndex.HalfYearChangeRate = util.Percent(calcIndex.HalfYearChangeRate)
calcIndex.FiveMinutesChangeRate = util.Percent(calcIndex.FiveMinutesChangeRate)
calcIndex.OutstandingRatio = util.Percent(calcIndex.OutstandingRatio)
calcIndex.Premium = util.Percent(calcIndex.Premium)
calcIndex.ItmOtm = util.Percent(calcIndex.ItmOtm)
calcIndex.ImpliedVolatility = util.Percent(calcIndex.ImpliedVolatility)
calcIndex.ToCallPrice = util.Percent(calcIndex.ToCallPrice)
}
type UserProfile struct {
MemberId int64
QuoteLevel string
SubscribeLimit int32
HistoryCandlestickLimit int32
RateLimit []*RateLimit
QuoteLevelDetail *UserQuoteLevelDetail
}
type RateLimit struct {
Cmd uint32
Limit int32
Burst int32
}
type UserQuoteLevelDetail struct {
ByPackageKey map[string]*PackageDetail
ByMarketCode map[string]*MarketPackageDetail
}
type PackageDetail struct {
PackageKey string
Limit int32
Burst int32
}
type MarketPackageDetail struct {
MarketCode string
Limit int32
Burst int32
}
// PinnedMode constants for UpdatePinned
const (
// PinnedModeAdd pins securities to the top of the watchlist
PinnedModeAdd PinnedMode = iota
// PinnedModeRemove unpins securities from the top of the watchlist
PinnedModeRemove
)
func (m PinnedMode) String() string {
if m == PinnedModeRemove {
return "remove"
}
return "add"
}
// ShortPositionsItem is one short-position record, unified for US and HK.
// US-specific fields (CurrentSharesShort, AvgDailyShareVolume, DaysToCover)
// are empty for HK records. HK-specific fields (Amount, Balance, Cost) are
// empty for US records.
type ShortPositionsItem struct {
// Timestamp — RFC 3339 (e.g. "2024-01-15T00:00:00Z")
Timestamp string
// Rate — short ratio
Rate string
// Close — closing price
Close string
// [US only] CurrentSharesShort — number of short shares outstanding
CurrentSharesShort string
// [US only] AvgDailyShareVolume — average daily share volume
AvgDailyShareVolume string
// [US only] DaysToCover — days-to-cover ratio
DaysToCover string
// [HK only] Amount — short sale amount (HKD)
Amount string
// [HK only] Balance — short position balance
Balance string
// [HK only] Cost — closing price (HK naming)
Cost string
}
// ShortPositionsResponse is the response for QuoteContext.ShortPositions.
type ShortPositionsResponse struct {
Data []*ShortPositionsItem
}
// OptionVolumeStats contains aggregated call/put volume for a security
type OptionVolumeStats struct {
// Total call volume
CallVolume string
// Total put volume
PutVolume string
}
// DailyOptionVolume is a single daily option volume data point
type DailyOptionVolume struct {
// Underlying security symbol
Symbol string
// Settlement date (unix timestamp string)
Timestamp string
// Total option volume (calls + puts)
TotalVolume string
// Total put volume
TotalPutVolume string
// Total call volume
TotalCallVolume string
// Put/call volume ratio
PutCallVolumeRatio string
// Total open interest
TotalOpenInterest string
// Total put open interest
TotalPutOpenInterest string
// Total call open interest
TotalCallOpenInterest string
// Put/call open interest ratio
PutCallOpenInterestRatio string
}
// CandlestickRequestOption is the option for the candlestick request
type CandlestickRequestOption func(*quotev1.SecurityHistoryCandlestickRequest)
// CandlestickRequestTradeSession sets the trade session of the candlestick request
func CandlestickRequestTradeSession(session CandlestickTradeSession) CandlestickRequestOption {
return func(req *quotev1.SecurityHistoryCandlestickRequest) {
req.TradeSession = int32(session)
}
}
// ShortTradesItem is one short-trade record, unified for US and HK.
type ShortTradesItem struct {
// Timestamp — RFC 3339
Timestamp string
// Rate — short ratio
Rate string
// Close — closing price
Close string
// [US only] NusAmount — NASDAQ short sale volume
NusAmount string
// [US only] NyAmount — NYSE short sale volume
NyAmount string
// [US only] TotalAmount — total trading volume
TotalAmount string
// [HK only] Amount — short sale turnover amount (HKD)
Amount string
// [HK only] Balance — short position balance
Balance string
}
// ShortTradesResponse is the response for QuoteContext.ShortTrades.
type ShortTradesResponse struct {
Data []*ShortTradesItem
}