FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi/python/src/quote/context.rs at main · noneback/openapi · GitHub
noneback
/
openapi
Public
forked from
longbridge/openapi
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
openapi
/
python
/
src
/
quote
/
context.rs
Copy path
More file actions
More file actions
Latest commit
History
History
History
620 lines (569 loc) · 19.1 KB
Breadcrumbs
openapi
/
python
/
src
/
quote
/
context.rs
Copy path
File metadata and controls
620 lines (569 loc) · 19.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
use
std
::
sync
::
Arc
;
use
longport
::
{
blocking
::
QuoteContextSync
,
quote
::
{
RequestCreateWatchlistGroup
,
RequestUpdateWatchlistGroup
}
,
}
;
use
parking_lot
::
Mutex
;
use
pyo3
::
prelude
::
*
;
use
time
::
PrimitiveDateTime
;
use
crate
::
{
config
::
Config
,
error
::
ErrorNewType
,
quote
::
{
push
::
handle_push_event
,
types
::
{
AdjustType
,
CalcIndex
,
Candlestick
,
CapitalDistributionResponse
,
CapitalFlowLine
,
FilterWarrantExpiryDate
,
FilterWarrantInOutBoundsType
,
HistoryMarketTemperatureResponse
,
IntradayLine
,
IssuerInfo
,
MarketTemperature
,
MarketTradingDays
,
MarketTradingSession
,
OptionQuote
,
ParticipantInfo
,
Period
,
QuotePackageDetail
,
RealtimeQuote
,
SecuritiesUpdateMode
,
Security
,
SecurityBrokers
,
SecurityCalcIndex
,
SecurityDepth
,
SecurityListCategory
,
SecurityQuote
,
SecurityStaticInfo
,
SortOrderType
,
StrikePriceInfo
,
SubType
,
SubTypes
,
Subscription
,
Trade
,
TradeSessions
,
WarrantInfo
,
WarrantQuote
,
WarrantSortBy
,
WarrantStatus
,
WarrantType
,
WatchlistGroup
,
}
,
}
,
time
::
{
PyDateWrapper
,
PyOffsetDateTimeWrapper
}
,
types
::
Market
,
}
;
#
[
derive
(
Debug
,
Default
)
]
pub
(
crate
)
struct
Callbacks
{
pub
(
crate
)
quote
:
Option
<
PyObject
>
,
pub
(
crate
)
depth
:
Option
<
PyObject
>
,
pub
(
crate
)
brokers
:
Option
<
PyObject
>
,
pub
(
crate
)
trades
:
Option
<
PyObject
>
,
pub
(
crate
)
candlestick
:
Option
<
PyObject
>
,
}
#
[
pyclass
]
pub
(
crate
)
struct
QuoteContext
{
ctx
:
QuoteContextSync
,
callbacks
:
Arc
<
Mutex
<
Callbacks
>
>
,
}
#
[
pymethods
]
impl
QuoteContext
{
#
[
new
]
fn
new
(
config
:
&
Config
)
->
PyResult
<
Self
>
{
let
callbacks =
Arc
::
new
(
Mutex
::
new
(
Callbacks
::
default
(
)
)
)
;
let
ctx =
QuoteContextSync
::
try_new
(
Arc
::
new
(
config
.
0
.
clone
(
)
)
,
{
let
callbacks = callbacks
.
clone
(
)
;
move
|event|
{
handle_push_event
(
&
callbacks
.
lock
(
)
,
event
)
;
}
}
)
.
map_err
(
ErrorNewType
)
?
;
Ok
(
Self
{
ctx
,
callbacks
}
)
}
/// Returns the member ID
fn
member_id
(
&
self
)
->
PyResult
<
i64
>
{
Ok
(
self
.
ctx
.
member_id
(
)
.
map_err
(
ErrorNewType
)
?
)
}
/// Returns the quote level
fn
quote_level
(
&
self
)
->
PyResult
<
String
>
{
Ok
(
self
.
ctx
.
quote_level
(
)
.
map_err
(
ErrorNewType
)
?
)
}
/// Returns the quote package details
fn
quote_package_details
(
&
self
)
->
PyResult
<
Vec
<
QuotePackageDetail
>
>
{
self
.
ctx
.
quote_package_details
(
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Set quote callback, after receiving the quote data push, it
/// will call back to this function.
fn
set_on_quote
(
&
self
,
py
:
Python
<
'
_
>
,
callback
:
PyObject
)
{
if
callback
.
is_none
(
py
)
{
self
.
callbacks
.
lock
(
)
.
quote
=
None
;
}
else
{
self
.
callbacks
.
lock
(
)
.
quote
=
Some
(
callback
)
;
}
}
/// Set depth callback, after receiving the depth data push, it
/// will call back to this function.
fn
set_on_depth
(
&
self
,
py
:
Python
<
'
_
>
,
callback
:
PyObject
)
{
if
callback
.
is_none
(
py
)
{
self
.
callbacks
.
lock
(
)
.
depth
=
None
;
}
else
{
self
.
callbacks
.
lock
(
)
.
depth
=
Some
(
callback
)
;
}
}
/// Set brokers callback, after receiving the brokers data push, it
/// will call back to this function.
fn
set_on_brokers
(
&
self
,
py
:
Python
<
'
_
>
,
callback
:
PyObject
)
{
if
callback
.
is_none
(
py
)
{
self
.
callbacks
.
lock
(
)
.
brokers
=
None
;
}
else
{
self
.
callbacks
.
lock
(
)
.
brokers
=
Some
(
callback
)
;
}
}
/// Set trades callback, after receiving the trades data push, it
/// will call back to this function.
fn
set_on_trades
(
&
self
,
py
:
Python
<
'
_
>
,
callback
:
PyObject
)
{
if
callback
.
is_none
(
py
)
{
self
.
callbacks
.
lock
(
)
.
trades
=
None
;
}
else
{
self
.
callbacks
.
lock
(
)
.
trades
=
Some
(
callback
)
;
}
}
/// Set candlestick callback, after receiving the candlestick updated event,
/// it will call back to this function.
fn
set_on_candlestick
(
&
self
,
py
:
Python
<
'
_
>
,
callback
:
PyObject
)
{
if
callback
.
is_none
(
py
)
{
self
.
callbacks
.
lock
(
)
.
candlestick
=
None
;
}
else
{
self
.
callbacks
.
lock
(
)
.
candlestick
=
Some
(
callback
)
;
}
}
/// Subscribe
#
[
pyo3
(
signature =
(
symbols
,
sub_types
,
is_first_push =
false
)
)
]
fn
subscribe
(
&
self
,
symbols
:
Vec
<
String
>
,
sub_types
:
Vec
<
SubType
>
,
is_first_push
:
bool
,
)
->
PyResult
<
(
)
>
{
self
.
ctx
.
subscribe
(
symbols
,
SubTypes
(
sub_types
)
,
is_first_push
)
.
map_err
(
ErrorNewType
)
?
;
Ok
(
(
)
)
}
/// Unsubscribe
fn
unsubscribe
(
&
self
,
symbols
:
Vec
<
String
>
,
sub_types
:
Vec
<
SubType
>
)
->
PyResult
<
(
)
>
{
self
.
ctx
.
unsubscribe
(
symbols
,
SubTypes
(
sub_types
)
)
.
map_err
(
ErrorNewType
)
?
;
Ok
(
(
)
)
}
/// Subscribe security candlesticks
#
[
pyo3
(
signature =
(
symbol
,
period
,
trade_sessions =
TradeSessions
::
Intraday
)
)
]
fn
subscribe_candlesticks
(
&
self
,
symbol
:
String
,
period
:
Period
,
trade_sessions
:
TradeSessions
,
)
->
PyResult
<
Vec
<
Candlestick
>
>
{
self
.
ctx
.
subscribe_candlesticks
(
symbol
,
period
.
into
(
)
,
trade_sessions
.
into
(
)
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Subscribe security candlesticks
fn
unsubscribe_candlesticks
(
&
self
,
symbol
:
String
,
period
:
Period
)
->
PyResult
<
(
)
>
{
self
.
ctx
.
unsubscribe_candlesticks
(
symbol
,
period
.
into
(
)
)
.
map_err
(
ErrorNewType
)
?
;
Ok
(
(
)
)
}
/// Get subscription information
fn
subscriptions
(
&
self
)
->
PyResult
<
Vec
<
Subscription
>
>
{
self
.
ctx
.
subscriptions
(
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get basic information of securities
fn
static_info
(
&
self
,
symbols
:
Vec
<
String
>
)
->
PyResult
<
Vec
<
SecurityStaticInfo
>
>
{
self
.
ctx
.
static_info
(
symbols
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get quote of securities
fn
quote
(
&
self
,
symbols
:
Vec
<
String
>
)
->
PyResult
<
Vec
<
SecurityQuote
>
>
{
self
.
ctx
.
quote
(
symbols
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get quote of option securities
fn
option_quote
(
&
self
,
symbols
:
Vec
<
String
>
)
->
PyResult
<
Vec
<
OptionQuote
>
>
{
self
.
ctx
.
option_quote
(
symbols
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get quote of warrant securities
fn
warrant_quote
(
&
self
,
symbols
:
Vec
<
String
>
)
->
PyResult
<
Vec
<
WarrantQuote
>
>
{
self
.
ctx
.
warrant_quote
(
symbols
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get security depth
fn
depth
(
&
self
,
symbol
:
String
)
->
PyResult
<
SecurityDepth
>
{
self
.
ctx
.
depth
(
symbol
)
.
map_err
(
ErrorNewType
)
?
.
try_into
(
)
}
/// Get security brokers
fn
brokers
(
&
self
,
symbol
:
String
)
->
PyResult
<
SecurityBrokers
>
{
self
.
ctx
.
brokers
(
symbol
)
.
map_err
(
ErrorNewType
)
?
.
try_into
(
)
}
/// Get participants
fn
participants
(
&
self
)
->
PyResult
<
Vec
<
ParticipantInfo
>
>
{
self
.
ctx
.
participants
(
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get security trades
fn
trades
(
&
self
,
symbol
:
String
,
count
:
usize
)
->
PyResult
<
Vec
<
Trade
>
>
{
self
.
ctx
.
trades
(
symbol
,
count
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get security intraday
fn
intraday
(
&
self
,
symbol
:
String
)
->
PyResult
<
Vec
<
IntradayLine
>
>
{
self
.
ctx
.
intraday
(
symbol
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get security candlesticks
#
[
pyo3
(
signature =
(
symbol
,
period
,
count
,
adjust_type
,
trade_sessions =
TradeSessions
::
Intraday
)
)
]
fn
candlesticks
(
&
self
,
symbol
:
String
,
period
:
Period
,
count
:
usize
,
adjust_type
:
AdjustType
,
trade_sessions
:
TradeSessions
,
)
->
PyResult
<
Vec
<
Candlestick
>
>
{
self
.
ctx
.
candlesticks
(
symbol
,
period
.
into
(
)
,
count
,
adjust_type
.
into
(
)
,
trade_sessions
.
into
(
)
,
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get security history candlesticks by offset
#
[
pyo3
(
signature =
(
symbol
,
period
,
adjust_type
,
forward
,
count
,
time =
None
,
trade_sessions =
TradeSessions
::
Intraday
)
)
]
#
[
allow
(
clippy
::
too_many_arguments
)
]
fn
history_candlesticks_by_offset
(
&
self
,
symbol
:
String
,
period
:
Period
,
adjust_type
:
AdjustType
,
forward
:
bool
,
count
:
usize
,
time
:
Option
<
PyOffsetDateTimeWrapper
>
,
trade_sessions
:
TradeSessions
,
)
->
PyResult
<
Vec
<
Candlestick
>
>
{
self
.
ctx
.
history_candlesticks_by_offset
(
symbol
,
period
.
into
(
)
,
adjust_type
.
into
(
)
,
forward
,
time
.
map
(
|time|
PrimitiveDateTime
::
new
(
time
.
0
.
date
(
)
,
time
.
0
.
time
(
)
)
)
,
count
,
trade_sessions
.
into
(
)
,
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get security history candlesticks by offset
#
[
pyo3
(
signature =
(
symbol
,
period
,
adjust_type
,
start =
None
,
end =
None
,
trade_sessions =
TradeSessions
::
Intraday
)
)
]
fn
history_candlesticks_by_date
(
&
self
,
symbol
:
String
,
period
:
Period
,
adjust_type
:
AdjustType
,
start
:
Option
<
PyDateWrapper
>
,
end
:
Option
<
PyDateWrapper
>
,
trade_sessions
:
TradeSessions
,
)
->
PyResult
<
Vec
<
Candlestick
>
>
{
self
.
ctx
.
history_candlesticks_by_date
(
symbol
,
period
.
into
(
)
,
adjust_type
.
into
(
)
,
start
.
map
(
|d| d
.
0
)
,
end
.
map
(
|d| d
.
0
)
,
trade_sessions
.
into
(
)
,
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get option chain expiry date list
fn
option_chain_expiry_date_list
(
&
self
,
symbol
:
String
)
->
PyResult
<
Vec
<
PyDateWrapper
>
>
{
Ok
(
self
.
ctx
.
option_chain_expiry_date_list
(
symbol
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
Into
::
into
)
.
collect
(
)
)
}
/// Get option chain info by date
fn
option_chain_info_by_date
(
&
self
,
symbol
:
String
,
expiry_date
:
PyDateWrapper
,
)
->
PyResult
<
Vec
<
StrikePriceInfo
>
>
{
self
.
ctx
.
option_chain_info_by_date
(
symbol
,
expiry_date
.
0
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get warrant issuers
fn
warrant_issuers
(
&
self
)
->
PyResult
<
Vec
<
IssuerInfo
>
>
{
self
.
ctx
.
warrant_issuers
(
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Query warrant list
#
[
pyo3
(
signature =
(
symbol
,
sort_by
,
sort_order
,
warrant_type =
None
,
issuer =
None
,
expiry_date =
None
,
price_type =
None
,
status =
None
)
)
]
#
[
allow
(
clippy
::
too_many_arguments
)
]
fn
warrant_list
(
&
self
,
symbol
:
String
,
sort_by
:
WarrantSortBy
,
sort_order
:
SortOrderType
,
warrant_type
:
Option
<
Vec
<
WarrantType
>
>
,
issuer
:
Option
<
Vec
<
i32
>
>
,
expiry_date
:
Option
<
Vec
<
FilterWarrantExpiryDate
>
>
,
price_type
:
Option
<
Vec
<
FilterWarrantInOutBoundsType
>
>
,
status
:
Option
<
Vec
<
WarrantStatus
>
>
,
)
->
PyResult
<
Vec
<
WarrantInfo
>
>
{
let
warrant_type
:
Option
<
Vec
<
longport
::
quote
::
WarrantType
>
>
=
warrant_type
.
map
(
|v| v
.
into_iter
(
)
.
map
(
Into
::
into
)
.
collect
(
)
)
;
let
expiry_date
:
Option
<
Vec
<
longport
::
quote
::
FilterWarrantExpiryDate
>
>
=
expiry_date
.
map
(
|v| v
.
into_iter
(
)
.
map
(
Into
::
into
)
.
collect
(
)
)
;
let
price_type
:
Option
<
Vec
<
longport
::
quote
::
FilterWarrantInOutBoundsType
>
>
=
price_type
.
map
(
|v| v
.
into_iter
(
)
.
map
(
Into
::
into
)
.
collect
(
)
)
;
let
status
:
Option
<
Vec
<
longport
::
quote
::
WarrantStatus
>
>
=
status
.
map
(
|v| v
.
into_iter
(
)
.
map
(
Into
::
into
)
.
collect
(
)
)
;
self
.
ctx
.
warrant_list
(
symbol
,
sort_by
.
into
(
)
,
sort_order
.
into
(
)
,
warrant_type
.
as_deref
(
)
,
issuer
.
as_deref
(
)
,
expiry_date
.
as_deref
(
)
,
price_type
.
as_deref
(
)
,
status
.
as_deref
(
)
,
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get trading session of the day
fn
trading_session
(
&
self
)
->
PyResult
<
Vec
<
MarketTradingSession
>
>
{
self
.
ctx
.
trading_session
(
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get trading session of the day
fn
trading_days
(
&
self
,
market
:
Market
,
begin
:
PyDateWrapper
,
end
:
PyDateWrapper
,
)
->
PyResult
<
MarketTradingDays
>
{
self
.
ctx
.
trading_days
(
market
.
into
(
)
,
begin
.
0
,
end
.
0
)
.
map_err
(
ErrorNewType
)
?
.
try_into
(
)
}
/// Get capital flow intraday
fn
capital_flow
(
&
self
,
symbol
:
String
)
->
PyResult
<
Vec
<
CapitalFlowLine
>
>
{
self
.
ctx
.
capital_flow
(
symbol
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get capital distribution
fn
capital_distribution
(
&
self
,
symbol
:
String
)
->
PyResult
<
CapitalDistributionResponse
>
{
self
.
ctx
.
capital_distribution
(
symbol
)
.
map_err
(
ErrorNewType
)
?
.
try_into
(
)
}
/// Get calc indexes
fn
calc_indexes
(
&
self
,
symbols
:
Vec
<
String
>
,
indexes
:
Vec
<
CalcIndex
>
,
)
->
PyResult
<
Vec
<
SecurityCalcIndex
>
>
{
self
.
ctx
.
calc_indexes
(
symbols
,
indexes
.
into_iter
(
)
.
map
(
Into
::
into
)
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get watch list
fn
watchlist
(
&
self
)
->
PyResult
<
Vec
<
WatchlistGroup
>
>
{
self
.
ctx
.
watchlist
(
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Create watchlist group
#
[
pyo3
(
signature =
(
name
,
securities =
None
)
)
]
fn
create_watchlist_group
(
&
self
,
name
:
String
,
securities
:
Option
<
Vec
<
String
>
>
,
)
->
PyResult
<
i64
>
{
let
mut
req =
RequestCreateWatchlistGroup
::
new
(
name
)
;
if
let
Some
(
securities
)
= securities
{
req = req
.
securities
(
securities
)
;
}
let
id =
self
.
ctx
.
create_watchlist_group
(
req
)
.
map_err
(
ErrorNewType
)
?
;
Ok
(
id
)
}
/// Delete watchlist group
#
[
pyo3
(
signature=
(
id
,
purge =
false
)
)
]
fn
delete_watchlist_group
(
&
self
,
id
:
i64
,
purge
:
bool
)
->
PyResult
<
(
)
>
{
self
.
ctx
.
delete_watchlist_group
(
id
,
purge
)
.
map_err
(
ErrorNewType
)
?
;
Ok
(
(
)
)
}
/// Update watchlist group
#
[
pyo3
(
signature =
(
id
,
name =
None
,
securities =
None
,
mode =
None
)
)
]
fn
update_watchlist_group
(
&
self
,
id
:
i64
,
name
:
Option
<
String
>
,
securities
:
Option
<
Vec
<
String
>
>
,
mode
:
Option
<
SecuritiesUpdateMode
>
,
)
->
PyResult
<
(
)
>
{
let
mut
req =
RequestUpdateWatchlistGroup
::
new
(
id
)
;
if
let
Some
(
name
)
= name
{
req = req
.
name
(
name
)
;
}
if
let
Some
(
securities
)
= securities
{
req = req
.
securities
(
securities
)
;
}
if
let
Some
(
mode
)
= mode
{
req = req
.
mode
(
mode
.
into
(
)
)
;
}
self
.
ctx
.
update_watchlist_group
(
req
)
.
map_err
(
ErrorNewType
)
?
;
Ok
(
(
)
)
}
/// Get security list
pub
fn
security_list
(
&
self
,
market
:
Market
,
category
:
SecurityListCategory
,
)
->
PyResult
<
Vec
<
Security
>
>
{
self
.
ctx
.
security_list
(
market
.
into
(
)
,
category
.
into
(
)
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get current market temperature
pub
fn
market_temperature
(
&
self
,
market
:
Market
)
->
PyResult
<
MarketTemperature
>
{
self
.
ctx
.
market_temperature
(
market
.
into
(
)
)
.
map_err
(
ErrorNewType
)
?
.
try_into
(
)
}
/// Get historical market temperature
pub
fn
history_market_temperature
(
&
self
,
market
:
Market
,
start_date
:
PyDateWrapper
,
end
:
PyDateWrapper
,
)
->
PyResult
<
HistoryMarketTemperatureResponse
>
{
self
.
ctx
.
history_market_temperature
(
market
.
into
(
)
,
start_date
.
0
,
end
.
0
)
.
map_err
(
ErrorNewType
)
?
.
try_into
(
)
}
/// Get real-time quote
fn
realtime_quote
(
&
self
,
symbols
:
Vec
<
String
>
)
->
PyResult
<
Vec
<
RealtimeQuote
>
>
{
self
.
ctx
.
realtime_quote
(
symbols
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get real-time depth
fn
realtime_depth
(
&
self
,
symbol
:
String
)
->
PyResult
<
SecurityDepth
>
{
self
.
ctx
.
realtime_depth
(
symbol
)
.
map_err
(
ErrorNewType
)
?
.
try_into
(
)
}
/// Get real-time brokers
fn
realtime_brokers
(
&
self
,
symbol
:
String
)
->
PyResult
<
SecurityBrokers
>
{
self
.
ctx
.
realtime_brokers
(
symbol
)
.
map_err
(
ErrorNewType
)
?
.
try_into
(
)
}
/// Get real-time trades
#
[
pyo3
(
signature =
(
symbol
,
count =
500
)
)
]
fn
realtime_trades
(
&
self
,
symbol
:
String
,
count
:
usize
)
->
PyResult
<
Vec
<
Trade
>
>
{
self
.
ctx
.
realtime_trades
(
symbol
,
count
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
/// Get real-time candlesticks
#
[
pyo3
(
signature =
(
symbol
,
period
,
count =
500
)
)
]
fn
realtime_candlesticks
(
&
self
,
symbol
:
String
,
period
:
Period
,
count
:
usize
,
)
->
PyResult
<
Vec
<
Candlestick
>
>
{
self
.
ctx
.
realtime_candlesticks
(
symbol
,
period
.
into
(
)
,
count
)
.
map_err
(
ErrorNewType
)
?
.
into_iter
(
)
.
map
(
TryInto
::
try_into
)
.
collect
(
)
}
}
Back
|
FazBrowse Home
|
New Git URL