Skip to content

Rqsdk 789 #922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
Expand Down
14 changes: 9 additions & 5 deletions rqalpha/apis/api_rqdatac.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ def get_securities_margin(
order_book_ids, # type: Union[str, Iterable[str]]
count=1, # type: Optional[int]
fields=None, # type: Optional[str]
expect_df=False # type: Optional[bool]
): # type: (...) -> Union[pd.Series, pd.DataFrame, pd.Panel]
expect_df=True # type: Optional[bool]
): # type: (...) -> Union[pd.Series, pd.DataFrame]
"""
获取融资融券信息。包括 `深证融资融券数据 <http://www.szse.cn/main/disclosure/rzrqxx/rzrqjy/>`_ 以及 `上证融资融券数据 <http://www.sse.com.cn/market/othersdata/margin/detail/>`_ 情况。既包括个股数据,也包括市场整体数据。需要注意,融资融券的开始日期为2010年3月31日。

Expand Down Expand Up @@ -524,11 +524,15 @@ def get_securities_margin(
start_dt = dt
else:
start_dt = data_proxy.get_previous_trading_date(dt, count - 1)


overall_code = {"XSHG", "XSHE", "sh", "sz"}
if isinstance(order_book_ids, six.string_types):
order_book_ids = assure_order_book_id(order_book_ids)
if order_book_ids not in overall_code:
order_book_ids = assure_order_book_id(order_book_ids)
else:
order_book_ids = [assure_order_book_id(i) for i in order_book_ids]
overall_code_list = [i for i in order_book_ids if i in overall_code]
order_book_ids = [assure_order_book_id(i) for i in order_book_ids if i not in overall_code]
order_book_ids = order_book_ids + overall_code_list

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

Expand Down
Binary file modified tests/outs/test_f_mean_reverting.pkl
Binary file not shown.
Binary file modified tests/outs/test_f_tick_size.pkl
Binary file not shown.