This repository was archived by the owner on Nov 18, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
Expand file tree Collapse file tree 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(
445445 right : OptionRight ,
446446 ) -> pd .DataFrame :
447447 """
448- Get the most recent option data .
448+ Get the most recent option tick .
449449
450450 :param req: The request type.
451451 :param root: The root symbol.
@@ -470,7 +470,33 @@ def get_last_option(
470470 body : DataFrame = TickBody .parse (
471471 hist_msg , header , self ._recv (header .size )
472472 )
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" ))
473494
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+ )
474500 return body
475501
476502 def get_req (
You can’t perform that action at this time.
0 commit comments