rqalpha 5.6.1__tar.gz → 5.6.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rqalpha-5.6.1/rqalpha.egg-info → rqalpha-5.6.3}/PKG-INFO +3 -2
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/_version.py +3 -3
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/apis/api_base.py +6 -2
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/config.yml +2 -1
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/environment.py +10 -1
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_stock.py +5 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/__init__.py +0 -1
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/mod.py +14 -5
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/plot/plot.py +3 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/report/report.py +5 -3
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_simulation/matcher.py +24 -27
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/portfolio/__init__.py +4 -2
- {rqalpha-5.6.1 → rqalpha-5.6.3/rqalpha.egg-info}/PKG-INFO +3 -2
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha.egg-info/requires.txt +6 -1
- {rqalpha-5.6.1 → rqalpha-5.6.3}/setup.cfg +1 -1
- {rqalpha-5.6.1 → rqalpha-5.6.3}/setup.py +2 -1
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/test_api_base.py +70 -1
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/test_position_queue.py +1 -1
- {rqalpha-5.6.1 → rqalpha-5.6.3}/CHANGELOG.rst +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/LICENSE +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/MANIFEST.in +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/README.rst +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/__main__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/api.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/apis/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/apis/api_abstract.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/apis/api_rqdatac.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/apis/names.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/cmds/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/cmds/bundle.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/cmds/entry.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/cmds/misc.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/cmds/mod.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/cmds/run.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/const.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/core/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/core/events.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/core/execution_context.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/core/executor.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/core/global_var.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/core/strategy.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/core/strategy_context.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/core/strategy_loader.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/core/strategy_universe.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/bar_dict_price_board.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/base_data_source/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/base_data_source/adjust.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/base_data_source/data_source.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/base_data_source/storage_interface.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/base_data_source/storages.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/bundle.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/data_proxy.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/data/trading_dates_mixin.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/IF1706_20161108.csv +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/IF_macd.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/buy_and_hold.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/data_source/get_csv_module.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/data_source/import_get_csv_module.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/data_source/read_csv_as_df.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/extend_api/rqalpha_mod_extend_api_demo.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/extend_api/test_extend_api.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/golden_cross.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/macd.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/pair_trading.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/rsi.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/run_code_demo.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/run_file_demo.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/run_func_demo.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/subscribe_event.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/test_pt.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/examples/turtle.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/interface.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/main.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_accounts/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_accounts/api/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_accounts/api/api_future.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_accounts/component_validator.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_accounts/mod.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_accounts/position_model.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_accounts/position_validator.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_accounts/validator.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/plot/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/plot/consts.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/plot/utils.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/plot_store.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/report/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/report/excel_template.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_analyser/report/templates/summary.xlsx +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_progress/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_progress/mod.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_risk/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_risk/mod.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_risk/validators/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_risk/validators/cash_validator.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_risk/validators/is_trading_validator.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_risk/validators/price_validator.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_risk/validators/self_trade_validator.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_scheduler/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_scheduler/mod.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_scheduler/scheduler.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_simulation/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_simulation/mod.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_simulation/signal_broker.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_simulation/simulation_broker.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_simulation/simulation_event_source.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_simulation/slippage.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_simulation/testing.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_simulation/validator.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_transaction_cost/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_transaction_cost/deciders.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/rqalpha_mod_sys_transaction_cost/mod.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod/utils.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/mod_config.yml +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/model/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/model/bar.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/model/instrument.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/model/order.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/model/tick.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/model/trade.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/portfolio/account.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/portfolio/position.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/resource/ricequant-logo.png +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/user_module.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/arg_checker.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/class_helper.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/click_helper.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/concurrent.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/config.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/datetime_func.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/dict_func.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/exception.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/functools.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/i18n.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/log_capture.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/logger.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/package_helper.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/persisit_helper.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/repr.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/risk_free_helper.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/rq_json.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/strategy_loader_help.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/testing/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/testing/fixtures.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/testing/mocking.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/translations/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/translations/zh_Hans_CN/LC_MESSAGES/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/translations/zh_Hans_CN/LC_MESSAGES/messages.mo +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/translations/zh_Hans_CN/LC_MESSAGES/messages.po +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/translations/zh_Hans_CN/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha/utils/typing.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha.egg-info/SOURCES.txt +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha.egg-info/dependency_links.txt +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha.egg-info/entry_points.txt +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha.egg-info/not-zip-safe +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/rqalpha.egg-info/top_level.txt +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_accounts/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_accounts/test_account_model.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_accounts/test_futures_settlement_price_type.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_accounts/test_margin_stocks.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_accounts/test_position_models.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_scheduler/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_scheduler/test_physical_time.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_scheduler/test_scheduler.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_simulation/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_simulation/test_management_fee.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_simulation/test_match.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_simulation/test_signal_broker.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_simulation/test_simulation_broker.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_simulation/test_simulation_event_source.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_transaction_cost/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/mod/sys_transaction_cost/test_commission_multiplier.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/test_api_future.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/test_api_stock.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/test_config.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/api_tests/utils.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_f_buy_and_hold.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_f_delivery.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_f_macd.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_f_macd_signal.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_f_mean_reverting.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_f_tick_size.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_s_buy_and_hold.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_s_dual_thrust.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_s_pit_tax.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_s_scheduler.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_s_tick_size.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_s_turtle.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_s_turtle_signal.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/test_sf_buy_and_hold.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/unittest/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/unittest/test_data/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/unittest/test_data/test_auto_update_bundle/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/unittest/test_data/test_auto_update_bundle/test_auto_update_bundle_mixin.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/unittest/test_data/test_instrument_mixin.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/unittest/test_data/test_trading_dates_mixin.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/unittest/test_mod/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/unittest/test_mod/test_sys_simulation/__init__.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/unittest/test_mod/test_sys_simulation/test_simulation_event_source.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/tests/utils.py +0 -0
- {rqalpha-5.6.1 → rqalpha-5.6.3}/versioneer.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rqalpha
|
|
3
|
-
Version: 5.6.
|
|
3
|
+
Version: 5.6.3
|
|
4
4
|
Summary: Ricequant Algorithm Trading System
|
|
5
5
|
Home-page: https://github.com/ricequant/rqalpha
|
|
6
6
|
Author: ricequant
|
|
@@ -19,7 +19,8 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
19
19
|
Requires-Python: >=3.6
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
Requires-Dist: requests
|
|
22
|
-
Requires-Dist: numpy<2.0.0
|
|
22
|
+
Requires-Dist: numpy<2.0.0; python_version <= "3.11"
|
|
23
|
+
Requires-Dist: numpy>=2.0.0; python_version >= "3.12"
|
|
23
24
|
Requires-Dist: pandas>=1.0.5
|
|
24
25
|
Requires-Dist: python-dateutil
|
|
25
26
|
Requires-Dist: six
|
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2025-
|
|
11
|
+
"date": "2025-09-05T11:19:11+0800",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "5.6.
|
|
14
|
+
"full-revisionid": "d0e492f70e623217ee944de8899985bc73f983fa",
|
|
15
|
+
"version": "5.6.3"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -876,7 +876,9 @@ def symbol(order_book_id, sep=", "):
|
|
|
876
876
|
EXECUTION_PHASE.ON_BAR,
|
|
877
877
|
EXECUTION_PHASE.ON_TICK,
|
|
878
878
|
EXECUTION_PHASE.SCHEDULED,
|
|
879
|
-
EXECUTION_PHASE.GLOBAL
|
|
879
|
+
EXECUTION_PHASE.GLOBAL,
|
|
880
|
+
EXECUTION_PHASE.BEFORE_TRADING,
|
|
881
|
+
EXECUTION_PHASE.AFTER_TRADING,
|
|
880
882
|
)
|
|
881
883
|
def deposit(account_type: str, amount: float, receiving_days: int = 0):
|
|
882
884
|
"""
|
|
@@ -897,7 +899,9 @@ def deposit(account_type: str, amount: float, receiving_days: int = 0):
|
|
|
897
899
|
EXECUTION_PHASE.ON_BAR,
|
|
898
900
|
EXECUTION_PHASE.ON_TICK,
|
|
899
901
|
EXECUTION_PHASE.SCHEDULED,
|
|
900
|
-
EXECUTION_PHASE.GLOBAL
|
|
902
|
+
EXECUTION_PHASE.GLOBAL,
|
|
903
|
+
EXECUTION_PHASE.BEFORE_TRADING,
|
|
904
|
+
EXECUTION_PHASE.AFTER_TRADING,
|
|
901
905
|
)
|
|
902
906
|
@apply_rules(
|
|
903
907
|
verify_that("account_type").is_in(DEFAULT_ACCOUNT_TYPE),
|
|
@@ -46,7 +46,8 @@ base:
|
|
|
46
46
|
auto_update_bundle: false
|
|
47
47
|
# 自动下载的 bundle 文件支持单独设置存储路径,若不设置则使用 data_bundle_path 路径
|
|
48
48
|
auto_update_bundle_path: ~
|
|
49
|
-
|
|
49
|
+
# 一年交易日天数,默认使用DAYS_CNT.TRADING_DAYS_A_YEAR
|
|
50
|
+
custom_trading_days_a_year: ~
|
|
50
51
|
|
|
51
52
|
extra:
|
|
52
53
|
# 选择日期的输出等级,有 `verbose` | `info` | `warning` | `error` 等选项,您可以通过设置 `verbose` 来查看最详细的日志,
|
|
@@ -22,10 +22,11 @@ from typing import TYPE_CHECKING
|
|
|
22
22
|
|
|
23
23
|
import rqalpha
|
|
24
24
|
from rqalpha.core.events import EventBus, Event, EVENT
|
|
25
|
-
from rqalpha.const import INSTRUMENT_TYPE
|
|
25
|
+
from rqalpha.const import INSTRUMENT_TYPE, DAYS_CNT
|
|
26
26
|
from rqalpha.utils.logger import system_log, user_log, user_system_log
|
|
27
27
|
from rqalpha.core.global_var import GlobalVars
|
|
28
28
|
from rqalpha.utils.i18n import gettext as _
|
|
29
|
+
from rqalpha.utils.class_helper import cached_property
|
|
29
30
|
from rqalpha.const import SIDE
|
|
30
31
|
if TYPE_CHECKING:
|
|
31
32
|
from rqalpha.model.order import Order
|
|
@@ -61,6 +62,7 @@ class Environment(object):
|
|
|
61
62
|
self._default_frontend_validators = []
|
|
62
63
|
self._transaction_cost_decider_dict = {}
|
|
63
64
|
self.rqdatac_init = rqdatac_init # type: Boolean
|
|
65
|
+
self._trading_days_a_year = None
|
|
64
66
|
|
|
65
67
|
# Environment.event_bus used in StrategyUniverse()
|
|
66
68
|
from rqalpha.core.strategy_universe import StrategyUniverse
|
|
@@ -216,3 +218,10 @@ class Environment(object):
|
|
|
216
218
|
if not v.can_submit_order(order, account):
|
|
217
219
|
return False
|
|
218
220
|
return True
|
|
221
|
+
|
|
222
|
+
@cached_property
|
|
223
|
+
def trading_days_a_year(self):
|
|
224
|
+
self._trading_days_a_year = getattr(self.config.base, 'custom_trading_days_a_year', DAYS_CNT.TRADING_DAYS_A_YEAR)
|
|
225
|
+
if self._trading_days_a_year is None:
|
|
226
|
+
self._trading_days_a_year = DAYS_CNT.TRADING_DAYS_A_YEAR
|
|
227
|
+
return self._trading_days_a_year
|
|
@@ -57,7 +57,9 @@ getcontext().prec = 10
|
|
|
57
57
|
export_as_api(industry_code, name='industry_code')
|
|
58
58
|
export_as_api(sector_code, name='sector_code')
|
|
59
59
|
|
|
60
|
+
|
|
60
61
|
KSH_MIN_AMOUNT = 200
|
|
62
|
+
BJSE_MIN_AMOUNT = 100
|
|
61
63
|
|
|
62
64
|
|
|
63
65
|
def _get_account_position_ins(id_or_ins):
|
|
@@ -76,6 +78,9 @@ def _round_order_quantity(ins, quantity, method: Callable = int) -> int:
|
|
|
76
78
|
if ins.type == "CS" and ins.board_type == "KSH":
|
|
77
79
|
# KSH can buy(sell) 201, 202 shares
|
|
78
80
|
return 0 if abs(quantity) < KSH_MIN_AMOUNT else int(quantity)
|
|
81
|
+
elif ins.type == "CS" and ins.board_type == "BJS":
|
|
82
|
+
# BJSE can buy(sell) 101, 202 shares
|
|
83
|
+
return 0 if abs(quantity) < BJSE_MIN_AMOUNT else int(quantity)
|
|
79
84
|
else:
|
|
80
85
|
round_lot = ins.round_lot
|
|
81
86
|
try:
|
|
@@ -108,7 +108,6 @@ def plot(result_pickle_file_path, show, plot_save_file, plot_open_close_points,
|
|
|
108
108
|
from .plot import plot_result
|
|
109
109
|
|
|
110
110
|
result_dict = pd.read_pickle(result_pickle_file_path)
|
|
111
|
-
print(plot_open_close_points, plot_weekly_indicators)
|
|
112
111
|
plot_result(result_dict, show, plot_save_file, plot_weekly_indicators, plot_open_close_points)
|
|
113
112
|
|
|
114
113
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
# 详细的授权流程,请联系 public@ricequant.com 获取。
|
|
17
17
|
|
|
18
18
|
import os
|
|
19
|
+
import re
|
|
19
20
|
import pandas
|
|
20
21
|
import pickle
|
|
21
22
|
import jsonpickle
|
|
@@ -26,7 +27,7 @@ from typing import Dict, Optional, List, Tuple, Union, Iterable
|
|
|
26
27
|
|
|
27
28
|
import numpy as np
|
|
28
29
|
import pandas as pd
|
|
29
|
-
from rqrisk import Risk, WEEKLY, MONTHLY
|
|
30
|
+
from rqrisk import Risk, DAILY, WEEKLY, MONTHLY
|
|
30
31
|
|
|
31
32
|
from rqalpha.const import EXIT_CODE, DEFAULT_ACCOUNT_TYPE, INSTRUMENT_TYPE, POSITION_DIRECTION
|
|
32
33
|
from rqalpha.core.events import EVENT
|
|
@@ -35,7 +36,6 @@ from rqalpha.utils.i18n import gettext as _
|
|
|
35
36
|
from rqalpha.utils import INST_TYPE_IN_STOCK_ACCOUNT
|
|
36
37
|
from rqalpha.utils.datetime_func import convert_int_to_date
|
|
37
38
|
from rqalpha.utils.logger import user_system_log
|
|
38
|
-
from rqalpha.const import DAYS_CNT
|
|
39
39
|
from rqalpha.api import export_as_api
|
|
40
40
|
from .plot.consts import DefaultPlot, PLOT_TEMPLATE
|
|
41
41
|
from .plot.utils import max_ddd as _max_ddd
|
|
@@ -51,6 +51,9 @@ def _get_yearly_risk_free_rates(
|
|
|
51
51
|
start_date = datetime.date(year + 1, 1, 1)
|
|
52
52
|
|
|
53
53
|
|
|
54
|
+
EQUITIES_OID_RE = re.compile(r"^\d{6}\.(XSHE|XSHG|BJSE)$")
|
|
55
|
+
|
|
56
|
+
|
|
54
57
|
class AnalyserMod(AbstractMod):
|
|
55
58
|
def __init__(self):
|
|
56
59
|
self._env = None
|
|
@@ -355,9 +358,10 @@ class AnalyserMod(AbstractMod):
|
|
|
355
358
|
summary["benchmark"] = ",".join(f"{o}:{w}" for o, w in self._benchmark)
|
|
356
359
|
summary["benchmark_symbol"] = ",".join(f"{self._env.data_proxy.instrument(o).symbol if o not in self.NULL_OID else 'null'}:{w}" for o, w in self._benchmark)
|
|
357
360
|
|
|
361
|
+
trading_days_a_year = self._env.trading_days_a_year
|
|
358
362
|
risk_free_rate = data_proxy.get_risk_free_rate(self._env.config.base.start_date, self._env.config.base.end_date)
|
|
359
363
|
risk = Risk(
|
|
360
|
-
np.array(self._portfolio_daily_returns), np.array(self._benchmark_daily_returns), risk_free_rate
|
|
364
|
+
np.array(self._portfolio_daily_returns), np.array(self._benchmark_daily_returns), risk_free_rate, period=DAILY, trading_days_a_year=trading_days_a_year
|
|
361
365
|
)
|
|
362
366
|
summary.update({
|
|
363
367
|
'alpha': risk.alpha,
|
|
@@ -402,7 +406,9 @@ class AnalyserMod(AbstractMod):
|
|
|
402
406
|
benchmark_total_returns = (np.array(self._benchmark_daily_returns) + 1.0).prod() - 1.0
|
|
403
407
|
summary['benchmark_total_returns'] = benchmark_total_returns
|
|
404
408
|
date_count = len(self._benchmark_daily_returns)
|
|
405
|
-
|
|
409
|
+
# 获取一年交易日天数
|
|
410
|
+
trading_days_a_year = self._env.trading_days_a_year
|
|
411
|
+
benchmark_annualized_returns = (benchmark_total_returns + 1) ** (trading_days_a_year / date_count) - 1
|
|
406
412
|
summary['benchmark_annualized_returns'] = benchmark_annualized_returns
|
|
407
413
|
|
|
408
414
|
trades = pd.DataFrame(self._trades)
|
|
@@ -412,6 +418,9 @@ class AnalyserMod(AbstractMod):
|
|
|
412
418
|
df = pd.DataFrame(self._total_portfolios)
|
|
413
419
|
df['date'] = pd.to_datetime(df['date'])
|
|
414
420
|
total_portfolios = df.set_index('date').sort_index()
|
|
421
|
+
if self._benchmark:
|
|
422
|
+
total_portfolios["benchmark_unit_net_value"] = (self._benchmark_daily_returns + 1).cumprod()
|
|
423
|
+
total_portfolios["excess_unit_net_value"] = total_portfolios["unit_net_value"] - total_portfolios["benchmark_unit_net_value"]
|
|
415
424
|
df.index = df['date']
|
|
416
425
|
weekly_nav = df.resample("W").last().set_index("date").unit_net_value.dropna()
|
|
417
426
|
monthly_nav = df.resample("M").last().set_index("date").unit_net_value.dropna()
|
|
@@ -434,7 +443,7 @@ class AnalyserMod(AbstractMod):
|
|
|
434
443
|
}
|
|
435
444
|
|
|
436
445
|
if not trades.empty and all(
|
|
437
|
-
|
|
446
|
+
EQUITIES_OID_RE.match(trade.order_book_id) for trade in trades.itertuples() # type: ignore
|
|
438
447
|
):
|
|
439
448
|
# 策略仅交易股票、指数、场内基金等品种时才计算换手率
|
|
440
449
|
trades_values = trades.last_price * trades.last_quantity
|
|
@@ -26,6 +26,7 @@ from matplotlib import gridspec, ticker, image as mpimg, pyplot
|
|
|
26
26
|
|
|
27
27
|
import rqalpha
|
|
28
28
|
from rqalpha.const import POSITION_EFFECT
|
|
29
|
+
from rqalpha.utils.logger import system_log
|
|
29
30
|
from .utils import IndicatorInfo, LineInfo, max_dd as _max_dd, SpotInfo, max_ddd as _max_ddd
|
|
30
31
|
from .utils import weekly_returns, trading_dates_index
|
|
31
32
|
from .consts import PlotTemplate, DefaultPlot
|
|
@@ -245,6 +246,8 @@ def plot_result(
|
|
|
245
246
|
|
|
246
247
|
_plot(summary["strategy_file"], sub_plots, strategy_name)
|
|
247
248
|
|
|
249
|
+
system_log.debug(f"Matplotlib backend: {pyplot.get_backend()}")
|
|
250
|
+
|
|
248
251
|
if save:
|
|
249
252
|
file_path = save
|
|
250
253
|
if os.path.isdir(save):
|
|
@@ -25,7 +25,7 @@ from collections import ChainMap, defaultdict
|
|
|
25
25
|
from pandas import Series, DataFrame
|
|
26
26
|
|
|
27
27
|
from rqrisk import Risk
|
|
28
|
-
from rqrisk import WEEKLY, MONTHLY
|
|
28
|
+
from rqrisk import DAILY, WEEKLY, MONTHLY
|
|
29
29
|
from rqalpha.environment import Environment
|
|
30
30
|
|
|
31
31
|
from rqalpha.mod.rqalpha_mod_sys_analyser.plot.utils import max_dd as _max_dd
|
|
@@ -71,7 +71,8 @@ def _yearly_indicators(
|
|
|
71
71
|
excess_nav = (p_year_returns + 1).cumprod() / (b_year_returns + 1).cumprod()
|
|
72
72
|
excess_max_dd = _max_dd(excess_nav.values, excess_nav.index)
|
|
73
73
|
max_dd = _max_dd(p_nav[year_slice].values, p_nav[year_slice].index)
|
|
74
|
-
|
|
74
|
+
trading_days_a_year = Environment.get_instance().trading_days_a_year
|
|
75
|
+
risk = Risk(p_year_returns, b_year_returns, risk_free_rates[year], period=DAILY, trading_days_a_year=trading_days_a_year)
|
|
75
76
|
data["year"].append(year)
|
|
76
77
|
data["returns"].append(risk.return_rate)
|
|
77
78
|
data["benchmark_returns"].append(risk.benchmark_return)
|
|
@@ -142,7 +143,8 @@ def _pressure_test(
|
|
|
142
143
|
else:
|
|
143
144
|
b_period_returns = Series(index=p_period_returns.index)
|
|
144
145
|
risk_free_rate = env.data_proxy.get_risk_free_rate(start, end)
|
|
145
|
-
|
|
146
|
+
trading_days_a_year = env.trading_days_a_year
|
|
147
|
+
risk = Risk(p_period_returns, b_period_returns, risk_free_rate, period=DAILY, trading_days_a_year=trading_days_a_year)
|
|
146
148
|
data["title"].append(title)
|
|
147
149
|
data["start_date"].append(str(start))
|
|
148
150
|
data["end_date"].append(str(end))
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
# 详细的授权流程,请联系 public@ricequant.com 获取。
|
|
17
17
|
import datetime
|
|
18
18
|
from collections import defaultdict
|
|
19
|
-
|
|
19
|
+
import math
|
|
20
20
|
from rqalpha.const import MATCHING_TYPE, ORDER_TYPE, POSITION_EFFECT, SIDE
|
|
21
21
|
from rqalpha.environment import Environment
|
|
22
22
|
from rqalpha.core.events import EVENT, Event
|
|
@@ -25,11 +25,26 @@ from rqalpha.model.trade import Trade
|
|
|
25
25
|
from rqalpha.model.tick import TickObject
|
|
26
26
|
from rqalpha.portfolio.account import Account
|
|
27
27
|
from rqalpha.utils import is_valid_price
|
|
28
|
+
from rqalpha.interface import AbstractPriceBoard
|
|
28
29
|
from typing import Dict
|
|
29
30
|
from rqalpha.utils.i18n import gettext as _
|
|
30
31
|
from .slippage import SlippageDecider
|
|
31
32
|
|
|
32
33
|
|
|
34
|
+
LIMIT_PRICE_VALID_THRESHOLD = 1e-7
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _price_reaches_limit(order_book_id: str, side: SIDE, deal_price: float, price_board: AbstractPriceBoard):
|
|
38
|
+
if side == SIDE.BUY:
|
|
39
|
+
limit_price = price_board.get_limit_up(order_book_id)
|
|
40
|
+
return deal_price >= limit_price or math.isclose(deal_price, limit_price, abs_tol=LIMIT_PRICE_VALID_THRESHOLD)
|
|
41
|
+
elif side == SIDE.SELL:
|
|
42
|
+
limit_price = price_board.get_limit_down(order_book_id)
|
|
43
|
+
return deal_price <= limit_price or math.isclose(deal_price, limit_price, abs_tol=LIMIT_PRICE_VALID_THRESHOLD)
|
|
44
|
+
else:
|
|
45
|
+
raise ValueError(f"Unsupport side: {side}")
|
|
46
|
+
|
|
47
|
+
|
|
33
48
|
class AbstractMatcher:
|
|
34
49
|
def match(self, account, order, open_auction):
|
|
35
50
|
# type: (Account, Order, bool) -> None
|
|
@@ -127,8 +142,6 @@ class DefaultBarMatcher(AbstractMatcher):
|
|
|
127
142
|
else:
|
|
128
143
|
# 撮合的时候无行情数据也不需要撤单,等到有行情再撮合
|
|
129
144
|
reason = None
|
|
130
|
-
# reason = _(u"Order Cancelled: current bar [{order_book_id}] miss market data.").format(
|
|
131
|
-
# order_book_id=order.order_book_id)
|
|
132
145
|
if reason:
|
|
133
146
|
order.mark_rejected(reason)
|
|
134
147
|
return
|
|
@@ -141,22 +154,14 @@ class DefaultBarMatcher(AbstractMatcher):
|
|
|
141
154
|
return
|
|
142
155
|
# 是否限制涨跌停不成交
|
|
143
156
|
if self._price_limit:
|
|
144
|
-
if order.side
|
|
145
|
-
return
|
|
146
|
-
if order.side == SIDE.SELL and deal_price <= price_board.get_limit_down(order_book_id):
|
|
157
|
+
if _price_reaches_limit(order_book_id, order.side, deal_price, price_board):
|
|
147
158
|
return
|
|
148
159
|
else:
|
|
149
160
|
if self._price_limit:
|
|
150
|
-
if order.side
|
|
151
|
-
reason = _(
|
|
152
|
-
"Order Cancelled: current bar [{order_book_id}] reach the limit_up price."
|
|
153
|
-
).format(order_book_id=order.order_book_id)
|
|
154
|
-
order.mark_rejected(reason)
|
|
155
|
-
return
|
|
156
|
-
if order.side == SIDE.SELL and deal_price <= price_board.get_limit_down(order_book_id):
|
|
161
|
+
if _price_reaches_limit(order_book_id, order.side, deal_price, price_board):
|
|
157
162
|
reason = _(
|
|
158
|
-
"Order Cancelled: current bar [{order_book_id}] reach the
|
|
159
|
-
).format(order_book_id=order.order_book_id)
|
|
163
|
+
"Order Cancelled: current bar [{order_book_id}] reach the {limit_up_or_down} price."
|
|
164
|
+
).format(order_book_id=order.order_book_id, limit_up_or_down="limit_up" if order.side == SIDE.BUY else "limit_down")
|
|
160
165
|
order.mark_rejected(reason)
|
|
161
166
|
return
|
|
162
167
|
|
|
@@ -372,9 +377,7 @@ class DefaultTickMatcher(AbstractMatcher):
|
|
|
372
377
|
return
|
|
373
378
|
# 是否限制涨跌停不成交
|
|
374
379
|
if self._price_limit:
|
|
375
|
-
if order.side
|
|
376
|
-
return
|
|
377
|
-
if order.side == SIDE.SELL and deal_price <= price_board.get_limit_down(order_book_id):
|
|
380
|
+
if _price_reaches_limit(order_book_id, order.side, deal_price, price_board):
|
|
378
381
|
return
|
|
379
382
|
if self._liquidity_limit:
|
|
380
383
|
if order.side == SIDE.BUY and price_board.get_a1(order_book_id) == 0:
|
|
@@ -383,16 +386,10 @@ class DefaultTickMatcher(AbstractMatcher):
|
|
|
383
386
|
return
|
|
384
387
|
else:
|
|
385
388
|
if self._price_limit:
|
|
386
|
-
if order.side
|
|
387
|
-
reason = _(
|
|
388
|
-
"Order Cancelled: current tick [{order_book_id}] reach the limit_up price."
|
|
389
|
-
).format(order_book_id=order.order_book_id)
|
|
390
|
-
order.mark_rejected(reason)
|
|
391
|
-
return
|
|
392
|
-
if order.side == SIDE.SELL and deal_price <= price_board.get_limit_down(order_book_id):
|
|
389
|
+
if _price_reaches_limit(order_book_id, order.side, deal_price, price_board):
|
|
393
390
|
reason = _(
|
|
394
|
-
"Order Cancelled: current tick [{order_book_id}] reach the
|
|
395
|
-
).format(order_book_id=order.order_book_id)
|
|
391
|
+
"Order Cancelled: current tick [{order_book_id}] reach the {limit_up_or_down} price."
|
|
392
|
+
).format(order_book_id=order.order_book_id, limit_up_or_down="limit_up" if order.side == SIDE.BUY else "limit_down")
|
|
396
393
|
order.mark_rejected(reason)
|
|
397
394
|
return
|
|
398
395
|
if self._liquidity_limit:
|
|
@@ -24,7 +24,7 @@ import jsonpickle
|
|
|
24
24
|
import numpy as np
|
|
25
25
|
import six
|
|
26
26
|
|
|
27
|
-
from rqalpha.const import
|
|
27
|
+
from rqalpha.const import DEFAULT_ACCOUNT_TYPE, POSITION_DIRECTION, RUN_TYPE
|
|
28
28
|
from rqalpha.environment import Environment
|
|
29
29
|
from rqalpha.core.events import EVENT, EventBus
|
|
30
30
|
from rqalpha.interface import AbstractPosition
|
|
@@ -194,7 +194,8 @@ class Portfolio(object, metaclass=PropertyReprMeta):
|
|
|
194
194
|
|
|
195
195
|
env = Environment.get_instance()
|
|
196
196
|
date_count = float(env.data_proxy.count_trading_dates(env.config.base.start_date, env.trading_dt.date()))
|
|
197
|
-
|
|
197
|
+
trading_days_a_year = env.trading_days_a_year
|
|
198
|
+
return self.unit_net_value ** (trading_days_a_year / date_count) - 1
|
|
198
199
|
|
|
199
200
|
@property
|
|
200
201
|
def total_value(self):
|
|
@@ -274,6 +275,7 @@ class Portfolio(object, metaclass=PropertyReprMeta):
|
|
|
274
275
|
"""出入金"""
|
|
275
276
|
# 入金 现金增加,份额增加,总权益增加,单位净值不变
|
|
276
277
|
# 出金 现金减少,份额减少,总权益减少,单位净值不变
|
|
278
|
+
account_type = account_type.upper()
|
|
277
279
|
if account_type not in self._accounts:
|
|
278
280
|
raise ValueError(_("invalid account type {}, choose in {}".format(account_type, list(self._accounts.keys()))))
|
|
279
281
|
unit_net_value = self.unit_net_value
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rqalpha
|
|
3
|
-
Version: 5.6.
|
|
3
|
+
Version: 5.6.3
|
|
4
4
|
Summary: Ricequant Algorithm Trading System
|
|
5
5
|
Home-page: https://github.com/ricequant/rqalpha
|
|
6
6
|
Author: ricequant
|
|
@@ -19,7 +19,8 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
19
19
|
Requires-Python: >=3.6
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
Requires-Dist: requests
|
|
22
|
-
Requires-Dist: numpy<2.0.0
|
|
22
|
+
Requires-Dist: numpy<2.0.0; python_version <= "3.11"
|
|
23
|
+
Requires-Dist: numpy>=2.0.0; python_version >= "3.12"
|
|
23
24
|
Requires-Dist: pandas>=1.0.5
|
|
24
25
|
Requires-Dist: python-dateutil
|
|
25
26
|
Requires-Dist: six
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
requests
|
|
2
|
-
numpy<2.0.0
|
|
3
2
|
pandas>=1.0.5
|
|
4
3
|
python-dateutil
|
|
5
4
|
six
|
|
@@ -16,5 +15,11 @@ openpyxl
|
|
|
16
15
|
methodtools
|
|
17
16
|
filelock
|
|
18
17
|
|
|
18
|
+
[:python_version <= "3.11"]
|
|
19
|
+
numpy<2.0.0
|
|
20
|
+
|
|
21
|
+
[:python_version >= "3.12"]
|
|
22
|
+
numpy>=2.0.0
|
|
23
|
+
|
|
19
24
|
[profiler]
|
|
20
25
|
line_profiler
|
|
@@ -448,7 +448,7 @@ def test_order_to():
|
|
|
448
448
|
return locals()
|
|
449
449
|
|
|
450
450
|
|
|
451
|
-
def
|
|
451
|
+
def test_deposit_and_withdraw():
|
|
452
452
|
__config__ = {
|
|
453
453
|
"base": {
|
|
454
454
|
"accounts": {
|
|
@@ -506,3 +506,72 @@ def test_deposit():
|
|
|
506
506
|
assert int(context.portfolio.accounts["STOCK"].cash) == int(context.cash) + 10000
|
|
507
507
|
|
|
508
508
|
return locals()
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
def test_deposit_withdraw_before_and_after_trading():
|
|
512
|
+
__config__ = {
|
|
513
|
+
"base": {
|
|
514
|
+
"accounts": {
|
|
515
|
+
"stock": 100000000,
|
|
516
|
+
"future": 100000000,
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
def init(context):
|
|
522
|
+
context.counter = 0
|
|
523
|
+
|
|
524
|
+
context.stock = '000001.XSHE'
|
|
525
|
+
context.future = 'IF88'
|
|
526
|
+
|
|
527
|
+
def before_trading(context):
|
|
528
|
+
context.counter += 1
|
|
529
|
+
if context.counter == 2:
|
|
530
|
+
unit_net_value = context.portfolio.unit_net_value
|
|
531
|
+
units = context.portfolio.units
|
|
532
|
+
total_value = context.portfolio.total_value
|
|
533
|
+
cash = context.portfolio.accounts["STOCK"].cash
|
|
534
|
+
deposit("STOCK", 50000000)
|
|
535
|
+
assert int(context.portfolio.accounts["STOCK"].cash) == int(cash) + 50000000
|
|
536
|
+
assert context.portfolio.units > units
|
|
537
|
+
assert context.portfolio.total_value > total_value
|
|
538
|
+
assert context.portfolio.unit_net_value == unit_net_value
|
|
539
|
+
elif context.counter == 3:
|
|
540
|
+
unit_net_value = context.portfolio.unit_net_value
|
|
541
|
+
units = context.portfolio.units
|
|
542
|
+
total_value = context.portfolio.total_value
|
|
543
|
+
cash = context.portfolio.accounts["FUTURE"].cash
|
|
544
|
+
flag = withdraw("FUTURE", 50000000)
|
|
545
|
+
assert context.portfolio.accounts["FUTURE"].cash == cash - 50000000
|
|
546
|
+
assert context.portfolio.units < units
|
|
547
|
+
assert context.portfolio.total_value < total_value
|
|
548
|
+
assert context.portfolio.unit_net_value == unit_net_value
|
|
549
|
+
|
|
550
|
+
def handle_bar(context, bar_dict):
|
|
551
|
+
if context.counter == 1:
|
|
552
|
+
order(context.stock, 200)
|
|
553
|
+
order(context.future, -100)
|
|
554
|
+
|
|
555
|
+
def after_trading(context):
|
|
556
|
+
if context.counter == 4:
|
|
557
|
+
unit_net_value = context.portfolio.unit_net_value
|
|
558
|
+
units = context.portfolio.units
|
|
559
|
+
total_value = context.portfolio.total_value
|
|
560
|
+
cash = context.portfolio.accounts["STOCK"].cash
|
|
561
|
+
withdraw("STOCK", 50000000)
|
|
562
|
+
assert context.portfolio.accounts["STOCK"].cash == cash - 50000000
|
|
563
|
+
assert context.portfolio.units < units
|
|
564
|
+
assert context.portfolio.total_value < total_value
|
|
565
|
+
assert context.portfolio.unit_net_value == unit_net_value
|
|
566
|
+
elif context.counter == 5:
|
|
567
|
+
unit_net_value = context.portfolio.unit_net_value
|
|
568
|
+
units = context.portfolio.units
|
|
569
|
+
total_value = context.portfolio.total_value
|
|
570
|
+
cash = context.portfolio.accounts["FUTURE"].cash
|
|
571
|
+
deposit("FUTURE", 50000000)
|
|
572
|
+
assert context.portfolio.accounts["FUTURE"].cash == cash + 50000000
|
|
573
|
+
assert context.portfolio.units > units
|
|
574
|
+
assert context.portfolio.total_value > total_value
|
|
575
|
+
assert context.portfolio.unit_net_value == unit_net_value
|
|
576
|
+
|
|
577
|
+
return locals()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|