This repository was archived by the owner on Nov 18, 2024. It is now read-only.
File tree 1 file changed +27
-1
lines changed
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -445,7 +445,7 @@ def get_last_option(
445
445
right : OptionRight ,
446
446
) -> pd .DataFrame :
447
447
"""
448
- Get the most recent option data .
448
+ Get the most recent option tick .
449
449
450
450
:param req: The request type.
451
451
:param root: The root symbol.
@@ -470,7 +470,33 @@ def get_last_option(
470
470
body : DataFrame = TickBody .parse (
471
471
hist_msg , header , self ._recv (header .size )
472
472
)
473
+ return body
474
+
475
+ def get_last_stock (
476
+ self ,
477
+ req : StockReqType ,
478
+ root : str ,
479
+ ) -> pd .DataFrame :
480
+ """
481
+ Get the most recent stock tick.
482
+
483
+ :param req: The request type.
484
+ :param root: The root symbol.
485
+
486
+ :return: The requested data as a pandas DataFrame.
487
+ :raises ResponseError: If the request failed.
488
+ """
489
+ assert self ._server is not None , _NOT_CONNECTED_MSG
490
+
491
+ # send request
492
+ hist_msg = f"MSG_CODE={ MessageType .LAST .value } &root={ root } &sec={ SecType .STOCK .value } &req={ req .value } \n "
493
+ self ._server .sendall (hist_msg .encode ("utf-8" ))
473
494
495
+ # parse response
496
+ header : Header = Header .parse (hist_msg , self ._server .recv (20 ))
497
+ body : DataFrame = TickBody .parse (
498
+ hist_msg , header , self ._recv (header .size )
499
+ )
474
500
return body
475
501
476
502
def get_req (
You can’t perform that action at this time.
0 commit comments