Skip to content

Commit d1d2a26

Browse files
Lin-DongzhaoCuizi7
andauthored
Rqsdk 789 (#922)
* fix get_secutities_margin * update test workflow ubuntu version * 修改测试数据 --------- Co-authored-by: Cuizi7 <[email protected]>
1 parent 1651703 commit d1d2a26

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on: [push, pull_request]
33

44
jobs:
55
test:
6-
runs-on: ubuntu-20.04
6+
runs-on: ubuntu-22.04
77
strategy:
88
matrix:
99
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

rqalpha/apis/api_rqdatac.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ def get_securities_margin(
429429
order_book_ids, # type: Union[str, Iterable[str]]
430430
count=1, # type: Optional[int]
431431
fields=None, # type: Optional[str]
432-
expect_df=False # type: Optional[bool]
433-
): # type: (...) -> Union[pd.Series, pd.DataFrame, pd.Panel]
432+
expect_df=True # type: Optional[bool]
433+
): # type: (...) -> Union[pd.Series, pd.DataFrame]
434434
"""
435435
获取融资融券信息。包括 `深证融资融券数据 <http://www.szse.cn/main/disclosure/rzrqxx/rzrqjy/>`_ 以及 `上证融资融券数据 <http://www.sse.com.cn/market/othersdata/margin/detail/>`_ 情况。既包括个股数据,也包括市场整体数据。需要注意,融资融券的开始日期为2010年3月31日。
436436
@@ -524,11 +524,15 @@ def get_securities_margin(
524524
start_dt = dt
525525
else:
526526
start_dt = data_proxy.get_previous_trading_date(dt, count - 1)
527-
527+
528+
overall_code = {"XSHG", "XSHE", "sh", "sz"}
528529
if isinstance(order_book_ids, six.string_types):
529-
order_book_ids = assure_order_book_id(order_book_ids)
530+
if order_book_ids not in overall_code:
531+
order_book_ids = assure_order_book_id(order_book_ids)
530532
else:
531-
order_book_ids = [assure_order_book_id(i) for i in order_book_ids]
533+
overall_code_list = [i for i in order_book_ids if i in overall_code]
534+
order_book_ids = [assure_order_book_id(i) for i in order_book_ids if i not in overall_code]
535+
order_book_ids = order_book_ids + overall_code_list
532536

533537
return rqdatac.get_securities_margin(order_book_ids, start_dt, dt, fields=fields, expect_df=expect_df)
534538

tests/outs/test_f_mean_reverting.pkl

-732 Bytes
Binary file not shown.

tests/outs/test_f_tick_size.pkl

5 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)