-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsdk_test.go
More file actions
665 lines (546 loc) · 17.8 KB
/
sdk_test.go
File metadata and controls
665 lines (546 loc) · 17.8 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
package futu_test
import (
"fmt"
"os"
"testing"
"time"
"github.com/hyperjiang/futu"
"github.com/hyperjiang/futu/adapt"
"github.com/hyperjiang/futu/client"
"github.com/hyperjiang/futu/pb/notify"
"github.com/hyperjiang/futu/pb/qotstockfilter"
"github.com/hyperjiang/futu/pb/trdcommon"
"github.com/hyperjiang/futu/protoid"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"google.golang.org/protobuf/proto"
)
var pubKey = []byte(`-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAMkZDkCQzZbu0CWzeqPP/18HanqPIG4oD3EbmbqfFVxcUwWqIfcHF7N0
D+ZZ+XUioVpy/w0rV+8NaTOytypfqKyaDJv+K7wh0W4ERkcirK5TAQrU3rgTWtjb
295ZSpwLtaMCrC+ux99m6ptDM/YVXI8uVtP8X2ygFv0mgq5//meLAgMBAAE=
-----END RSA PUBLIC KEY-----`)
var priKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDJGQ5AkM2W7tAls3qjz/9fB2p6jyBuKA9xG5m6nxVcXFMFqiH3
BxezdA/mWfl1IqFacv8NK1fvDWkzsrcqX6ismgyb/iu8IdFuBEZHIqyuUwEK1N64
E1rY29veWUqcC7WjAqwvrsffZuqbQzP2FVyPLlbT/F9soBb9JoKuf/5niwIDAQAB
AoGBAJvq9lbvLsfwn6grkVIDig+nE1K1OELQgrCC4t2ETK6Q0roYoD8E28aCnXVP
m4/LaulTMheG3KX3cvLnhQawpnjUxm/3NZlVPj6EEjYepVyEBMLV2gBUzulUdTeZ
HM6hEBB3YQ8BnkJG1ajbr2lmilLenOaGTj2q6rxFz1n5dlWhAkEA7QaW0h8YrS6F
6ZRHcTui13ScwFxKAxuuOg9mbV9Y2EegDpAvhRdhvbx1pNCiD9vy46s6yAFtzNtF
+PtqnNASGwJBANkyMLusENpxZ1gucYd/RDwT0a9XMn6BAOPBJxLlhoKj1fI2YMoy
QJBHAFhh7BIt+U4XomXkhwTOUp67HPgc11ECQQC5QqUvps6Kzgos/5C3mH03GhZK
49eVhlUvXEoawqOWqKUZvOjnhdcHjf4FzGxfKPM3r+ZJ3ZQMwnZ2nUw/NQJxAkAi
jKpV4CwaI3n1/AVRMXxwNhLf2nYMy4aRtDL7/YjlFRy+V8oTv+SnTrQOWx1LUwba
VkYeATk9GXjpCQi1qxjRAkEA2jPfclINKKKfVPjys7R6Juq9sBFqJSmhcFYae8Xd
ywQCvmZiU66RGeo6pCSwdH0h4NeQ8w48SjhmRqswNKKr8g==
-----END RSA PRIVATE KEY-----`)
type SDKTestSuite struct {
suite.Suite
sdk *futu.SDK
usAccount *trdcommon.TrdHeader
}
// TestSDKTestSuite runs the http client test suite
func TestSDKTestSuite(t *testing.T) {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
suite.Run(t, new(SDKTestSuite))
}
// SetupSuite run once at the very start of the testing suite, before any tests are run.
func (ts *SDKTestSuite) SetupSuite() {
var err error
ts.sdk, err = futu.NewSDK(
client.WithPrivateKey(priKey),
client.WithPublicKey(pubKey),
)
if err != nil {
ts.T().SkipNow()
}
ts.sdk.RegisterHandler(protoid.Notify, func(s2c proto.Message) error {
msg := s2c.(*notify.S2C)
log.Info().Interface("s2c", msg).Msg("custom handler")
return nil
})
ts.usAccount = adapt.NewSimulationTradeHeader(1619199, adapt.TrdMarket_US)
err = ts.sdk.Subscribe(
[]string{"HK.09988", "HK.00700"},
[]int32{
adapt.SubType_Basic,
adapt.SubType_RT,
adapt.SubType_KL_Day,
adapt.SubType_KL_3Min,
adapt.SubType_Ticker,
adapt.SubType_OrderBook,
adapt.SubType_Broker,
},
true,
)
if err != nil {
fmt.Println(err)
}
}
// TearDownSuite run once at the very end of the testing suite, after all tests have been run.
func (ts *SDKTestSuite) TearDownSuite() {
if ts.sdk != nil {
ts.sdk.Close()
}
}
func (ts *SDKTestSuite) TestGetGlobalState() {
should := require.New(ts.T())
res, err := ts.sdk.GetGlobalState()
should.NoError(err)
fmt.Println(res)
}
func (ts *SDKTestSuite) TestGetAccList() {
should := require.New(ts.T())
res, err := ts.sdk.GetAccList(adapt.With("trdCategory", adapt.TrdCategory_Security))
should.NoError(err)
for _, acc := range res {
log.Info().Interface("acc", acc).Msg("GetAccList")
}
}
func (ts *SDKTestSuite) TestUnlockTrade() {
should := require.New(ts.T())
err := ts.sdk.UnlockTrade(false, "", adapt.SecurityFirm_FutuSecurities)
should.NoError(err)
}
func (ts *SDKTestSuite) TestSubscribeAccPush() {
should := require.New(ts.T())
err := ts.sdk.SubscribeAccPush([]uint64{1619199})
should.NoError(err)
}
func (ts *SDKTestSuite) TestGetFunds() {
should := require.New(ts.T())
res, err := ts.sdk.GetFunds(ts.usAccount)
should.NoError(err)
log.Info().Interface("data", res).Msg("GetFunds")
}
func (ts *SDKTestSuite) TestGetPositionList() {
should := require.New(ts.T())
res, err := ts.sdk.GetPositionList(ts.usAccount)
should.NoError(err)
for _, pos := range res {
log.Info().Interface("position", pos).Msg("GetPositionList")
}
}
func (ts *SDKTestSuite) TestGetMaxTrdQtys() {
should := require.New(ts.T())
res, err := ts.sdk.GetMaxTrdQtys(
ts.usAccount,
adapt.OrderType_Normal,
"US.AAPL",
200,
)
should.NoError(err)
log.Info().Interface("data", res).Msg("GetMaxTrdQtys")
}
func (ts *SDKTestSuite) TestGetOpenOrderList() {
should := require.New(ts.T())
res, err := ts.sdk.GetOpenOrderList(
ts.usAccount,
adapt.With("filterStatusList", []int32{adapt.OrderStatus_Submitted}),
)
should.NoError(err)
for _, order := range res {
log.Info().Interface("open order", order).Msg("GetOpenOrderList")
}
}
func (ts *SDKTestSuite) TestPlaceOrderAndModifyOrder() {
should := require.New(ts.T())
res, err := ts.sdk.PlaceOrder(
ts.usAccount,
adapt.TrdSide_Buy,
adapt.OrderType_Market,
"US.AAPL",
1, // quantity
0, // price, 市价订单不需要设置价格
adapt.With("remark", "go sdk"),
)
should.NoError(err)
log.Info().Interface("result", res).Msg("PlaceOrder")
// cancel the order
res2, err := ts.sdk.ModifyOrder(
ts.usAccount,
res.GetOrderID(),
adapt.ModifyOrderOp_Cancel,
)
should.NoError(err)
log.Info().Interface("result", res2).Msg("ModifyOrder")
}
func (ts *SDKTestSuite) TestGetOrderFillList() {
should := require.New(ts.T())
_, err := ts.sdk.GetOrderFillList(
ts.usAccount,
)
should.Error(err) // 模拟交易不支持成交数据
}
func (ts *SDKTestSuite) TestGetHistoryOrderList() {
should := require.New(ts.T())
res, err := ts.sdk.GetHistoryOrderList(
ts.usAccount,
adapt.NewFilterConditions(
adapt.With("beginTime", time.Now().AddDate(0, 0, -7).Format(futu.TimeFormat)),
adapt.With("endTime", time.Now().Format(futu.TimeFormat)),
),
adapt.With("filterStatusList", []int32{adapt.OrderStatus_Filled_All}),
)
should.NoError(err)
for _, order := range res {
log.Info().Interface("history order", order).Msg("GetHistoryOrderList")
}
}
func (ts *SDKTestSuite) TestGetHistoryOrderFillList() {
should := require.New(ts.T())
_, err := ts.sdk.GetHistoryOrderFillList(
ts.usAccount,
adapt.NewFilterConditions(
adapt.With("beginTime", time.Now().AddDate(0, 0, -7).Format(futu.TimeFormat)),
adapt.With("endTime", time.Now().Format(futu.TimeFormat)),
),
)
should.Error(err) // 模拟交易不支持成交数据
}
func (ts *SDKTestSuite) TestGetMarginRatio() {
should := require.New(ts.T())
res, err := ts.sdk.GetMarginRatio(ts.usAccount, []string{"US.AAPL"})
should.NoError(err)
log.Info().Interface("margin ratio", res).Msg("GetMarginRatio")
}
func (ts *SDKTestSuite) TestGetOrderFee() {
should := require.New(ts.T())
_, err := ts.sdk.GetOrderFee(
ts.usAccount,
[]string{"123"},
)
should.Error(err) // 模拟交易不支持查询交易费用
}
func (ts *SDKTestSuite) TestTrdFlowSummary() {
should := require.New(ts.T())
_, err := ts.sdk.TrdFlowSummary(ts.usAccount, time.Now().Format("2006-01-02"))
should.Error(err, "模拟账户不支持查询现金流水")
}
func (ts *SDKTestSuite) TestGetSubInfo() {
should := require.New(ts.T())
res, err := ts.sdk.GetSubInfo()
should.NoError(err)
log.Info().Interface("result", res).Msg("GetSubInfo")
}
func (ts *SDKTestSuite) TestGetBasicQot() {
should := require.New(ts.T())
res, err := ts.sdk.GetBasicQot([]string{"HK.00700", "HK.09988"})
should.NoError(err)
for _, qot := range res {
log.Info().Interface("qot", qot).Msg("GetBasicQot")
}
}
func (ts *SDKTestSuite) TestGetKL() {
should := require.New(ts.T())
res, err := ts.sdk.GetKL(
"HK.09988",
adapt.KLType_Day,
adapt.With("rehabType", adapt.RehabType_Forward),
adapt.With("reqNum", 3),
)
should.NoError(err)
for _, kl := range res.GetKlList() {
log.Info().Interface("kline", kl).Msg("GetKL")
}
}
func (ts *SDKTestSuite) TestGetRT() {
should := require.New(ts.T())
res, err := ts.sdk.GetRT("HK.09988")
should.NoError(err)
should.Equal("09988", res.GetSecurity().GetCode())
log.Info().Str("stock", res.GetName()).Int("num", len(res.GetRtList())).Msg("GetRT")
}
func (ts *SDKTestSuite) TestGetTicker() {
should := require.New(ts.T())
res, err := ts.sdk.GetTicker("HK.09988")
should.NoError(err)
should.Equal("09988", res.GetSecurity().GetCode())
log.Info().Str("stock", res.GetName()).Int("num", len(res.GetTickerList())).Msg("GetTicker")
}
func (ts *SDKTestSuite) TestGetOrderBook() {
should := require.New(ts.T())
res, err := ts.sdk.GetOrderBook("HK.09988")
should.NoError(err)
should.Equal("09988", res.GetSecurity().GetCode())
log.Info().Str("stock", res.GetName()).
Int("实时卖盘", len(res.GetOrderBookAskList())).
Int("实时买盘", len(res.GetOrderBookBidList())).
Msg("GetOrderBook")
for _, ask := range res.GetOrderBookAskList() {
log.Info().Interface("data", ask).Msg("实时卖盘")
}
for _, bid := range res.GetOrderBookBidList() {
log.Info().Interface("data", bid).Msg("实时买盘")
}
}
func (ts *SDKTestSuite) TestGetBroker() {
should := require.New(ts.T())
res, err := ts.sdk.GetBroker("HK.09988")
should.NoError(err)
should.Equal("09988", res.GetSecurity().GetCode())
log.Info().Str("stock", res.GetName()).
Int("实时经纪卖盘", len(res.GetBrokerAskList())).
Int("实时经纪买盘", len(res.GetBrokerBidList())).
Msg("GetBroker")
for _, ask := range res.GetBrokerAskList() {
log.Info().Interface("data", ask).Msg("实时经纪卖盘")
}
for _, bid := range res.GetBrokerBidList() {
log.Info().Interface("data", bid).Msg("实时经纪买盘")
}
}
func (ts *SDKTestSuite) TestRequestHistoryKL() {
should := require.New(ts.T())
res, err := ts.sdk.RequestHistoryKL(
"HK.09988",
adapt.KLType_Day,
"2024-10-01",
"2024-10-15",
adapt.With("rehabType", adapt.RehabType_Forward),
adapt.With("maxAckKLNum", 3), // 每次只取3条,模拟分页
)
should.NoError(err)
should.Equal("09988", res.GetSecurity().GetCode())
for _, kl := range res.GetKlList() {
log.Info().Str("date", kl.GetTime()).Str("stock", res.GetName()).Float64("close", kl.GetClosePrice()).Msg("RequestHistoryKL")
}
next := res.GetNextReqKey()
for len(next) > 0 {
res, err = ts.sdk.RequestHistoryKL(
"HK.09988",
adapt.KLType_Day,
"2024-10-01",
"2024-10-15",
adapt.With("rehabType", adapt.RehabType_Forward),
adapt.With("maxAckKLNum", 3),
adapt.With("nextReqKey", next),
)
should.NoError(err)
for _, kl := range res.GetKlList() {
log.Info().Str("date", kl.GetTime()).Str("stock", res.GetName()).Float64("close", kl.GetClosePrice()).Msg("RequestHistoryKL")
}
next = res.GetNextReqKey()
}
}
func (ts *SDKTestSuite) TestRequestHistoryKLQuota() {
should := require.New(ts.T())
res, err := ts.sdk.RequestHistoryKLQuota(
adapt.With("bGetDetail", true), // 可选:返回详细拉取过的历史纪录
)
should.NoError(err)
log.Info().Interface("result", res).Msg("RequestHistoryKLQuota")
}
func (ts *SDKTestSuite) TestRequestRehab() {
should := require.New(ts.T())
res, err := ts.sdk.RequestRehab("HK.09988")
should.NoError(err)
for _, rehab := range res.GetRehabList() {
log.Info().Interface("rehab", rehab).Msg("RequestRehab")
}
}
func (ts *SDKTestSuite) TestGetStaticInfo() {
should := require.New(ts.T())
// use securities to filter
res, err := ts.sdk.GetStaticInfo(adapt.WithSecurities([]string{"HK.09988", "HK.00700"}))
should.NoError(err)
for _, info := range res {
log.Info().Interface("info", info).Msg("GetStaticInfo by securities")
}
// use market and secType to filter
res2, err := ts.sdk.GetStaticInfo(
adapt.With("market", adapt.QotMarket_HK),
adapt.With("secType", adapt.SecurityType_Eqty),
)
should.NoError(err)
log.Info().Int("num", len(res2)).Msg("GetStaticInfo by market")
}
func (ts *SDKTestSuite) TestGetSecuritySnapshot() {
should := require.New(ts.T())
res, err := ts.sdk.GetSecuritySnapshot([]string{"HK.09988", "HK.00700"})
should.NoError(err)
for _, snap := range res {
log.Info().Interface("snapshot", snap).Msg("GetSecuritySnapshot")
}
}
func (ts *SDKTestSuite) TestGetPlateSet() {
should := require.New(ts.T())
res, err := ts.sdk.GetPlateSet(adapt.QotMarket_HK, adapt.PlateSetType_Industry)
should.NoError(err)
for _, plate := range res {
log.Info().Str("name", plate.GetName()).
Int32("type", plate.GetPlateType()).
Interface("plate", plate.GetPlate()).
Msg("GetPlateSet")
}
}
func (ts *SDKTestSuite) TestGetPlateSecurity() {
should := require.New(ts.T())
res, err := ts.sdk.GetPlateSecurity(
"HK.LIST1059",
adapt.With("sortField", adapt.SortField_Turnover),
adapt.With("ascend", false),
)
should.NoError(err)
for _, info := range res {
log.Info().Interface("info", info).Msg("GetPlateSecurity")
}
}
func (ts *SDKTestSuite) TestGetReference() {
should := require.New(ts.T())
res, err := ts.sdk.GetReference("HK.09988", adapt.ReferenceType_Warrant)
should.NoError(err)
log.Info().Int("num", len(res)).Msg("GetReference")
}
func (ts *SDKTestSuite) TestGetOwnerPlate() {
should := require.New(ts.T())
res, err := ts.sdk.GetOwnerPlate([]string{"HK.09988"})
should.NoError(err)
log.Info().Interface("data", res).Msg("GetOwnerPlate")
}
func (ts *SDKTestSuite) TestGetOptionChain() {
should := require.New(ts.T())
beginTime := time.Now().AddDate(0, 0, -1).Format(futu.DateFormat)
endTime := time.Now().Format(futu.DateFormat)
res, err := ts.sdk.GetOptionChain("HK.09988", beginTime, endTime)
should.NoError(err)
log.Info().Int("num", len(res)).Msg("GetOptionChain")
}
func (ts *SDKTestSuite) TestGetWarrant() {
should := require.New(ts.T())
res, err := ts.sdk.GetWarrant(0, 3,
adapt.With("owner", adapt.NewSecurity("HK.00981")),
adapt.With("status", adapt.WarrantStatus_Normal),
)
should.NoError(err)
log.Info().Int32("count", res.GetAllCount()).Msg("GetWarrant")
for _, warrant := range res.GetWarrantDataList() {
log.Info().Interface("warrant", warrant).Msg("GetWarrant")
}
}
func (ts *SDKTestSuite) TestGetCapitalFlow() {
should := require.New(ts.T())
res, err := ts.sdk.GetCapitalFlow(
"HK.09988",
adapt.With("beginTime", time.Now().AddDate(0, 0, -1).Format(futu.TimeFormat)),
adapt.With("endTime", time.Now().Format(futu.TimeFormat)),
adapt.With("periodType", adapt.PeriodType_DAY),
)
should.NoError(err)
log.Info().Interface("data", res).Msg("GetCapitalFlow")
}
func (ts *SDKTestSuite) TestGetCapitalDistribution() {
should := require.New(ts.T())
res, err := ts.sdk.GetCapitalDistribution("HK.09988")
should.NoError(err)
log.Info().Interface("data", res).Msg("GetCapitalDistribution")
}
func (ts *SDKTestSuite) TestGetUserSecurity() {
should := require.New(ts.T())
res, err := ts.sdk.GetUserSecurity("特别关注")
should.NoError(err)
log.Info().Int("count", len(res)).Msg("GetUserSecurity")
}
func (ts *SDKTestSuite) TestModifyUserSecurity() {
should := require.New(ts.T())
err := ts.sdk.ModifyUserSecurity(
"特别关注",
[]string{"HK.09988"},
adapt.ModifyUserSecurityOp_Add,
)
should.Error(err) // 仅支持修改自定义分组,不支持修改系统分组
}
func (ts *SDKTestSuite) TestStockFilter() {
should := require.New(ts.T())
// f := &qotstockfilter.BaseFilter{
// FieldName: proto.Int32(int32(qotstockfilter.StockField_StockField_MarketVal)),
// FilterMin: proto.Float64(10000000000),
// SortDir: proto.Int32(int32(qotstockfilter.SortDir_SortDir_Ascend)),
// IsNoFilter: proto.Bool(false),
// }
f := adapt.NewBaseFilter(
qotstockfilter.StockField_StockField_MarketVal,
10000000000,
0,
qotstockfilter.SortDir_SortDir_Ascend,
)
res, err := ts.sdk.StockFilter(
adapt.QotMarket_HK,
adapt.With("begin", 0),
adapt.With("num", 10),
adapt.WithBaseFilters(f),
)
should.NoError(err)
log.Info().Int("count", int(res.GetAllCount())).Msg("StockFilter")
for _, stock := range res.GetDataList() {
log.Info().Interface("stock", stock).Msg("StockFilter")
}
}
func (ts *SDKTestSuite) TestGetIpoList() {
should := require.New(ts.T())
res, err := ts.sdk.GetIpoList(adapt.QotMarket_HK)
should.NoError(err)
for _, ipo := range res {
log.Info().Interface("ipo", ipo).Msg("GetIpoList")
}
}
func (ts *SDKTestSuite) TestGetFutureInfo() {
should := require.New(ts.T())
res, err := ts.sdk.GetFutureInfo([]string{"HK.TCHmain"})
should.NoError(err)
log.Info().Interface("data", res).Msg("GetFutureInfo")
}
func (ts *SDKTestSuite) TestRequestTradeDate() {
should := require.New(ts.T())
res, err := ts.sdk.RequestTradeDate(adapt.QotMarket_HK, "", "2024-12-01", "2024-12-10")
should.NoError(err)
log.Info().Interface("data", res).Msg("RequestTradeDate")
}
func (ts *SDKTestSuite) TestSetPriceReminder() {
should := require.New(ts.T())
res, err := ts.sdk.SetPriceReminder(
"HK.09988",
adapt.SetPriceReminderOp_Add,
adapt.With("type", adapt.PriceReminderType_PriceDown),
adapt.With("freq", adapt.PriceReminderFreq_OnlyOnce),
adapt.With("value", 80),
adapt.With("note", "go sdk"),
)
should.NoError(err)
log.Info().Int64("result", res).Msg("SetPriceReminder")
}
func (ts *SDKTestSuite) TestGetPriceReminder() {
should := require.New(ts.T())
res, err := ts.sdk.GetPriceReminder("", adapt.QotMarket_HK)
should.NoError(err)
log.Info().Interface("data", res).Msg("GetPriceReminder")
// remove all the reminders
for _, reminder := range res {
_, err := ts.sdk.SetPriceReminder(
adapt.SecurityToCode(reminder.GetSecurity()),
adapt.SetPriceReminderOp_DelAll,
)
should.NoError(err)
}
}
func (ts *SDKTestSuite) TestGetUserSecurityGroup() {
should := require.New(ts.T())
res, err := ts.sdk.GetUserSecurityGroup(adapt.GroupType_System)
should.NoError(err)
log.Info().Interface("data", res).Msg("GetUserSecurityGroup")
}
func (ts *SDKTestSuite) TestGetMarketState() {
should := require.New(ts.T())
res, err := ts.sdk.GetMarketState([]string{"HK.09988"})
should.NoError(err)
log.Info().Interface("data", res).Msg("GetMarketState")
}
func (ts *SDKTestSuite) TestGetOptionExpirationDate() {
should := require.New(ts.T())
res, err := ts.sdk.GetOptionExpirationDate("HK.09988")
should.NoError(err)
log.Info().Interface("data", res).Msg("GetOptionExpirationDate")
}