[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-Kismuz--btgym":3,"tool-Kismuz--btgym":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",160784,2,"2026-04-19T11:32:54",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",109154,"2026-04-18T11:18:24",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":77,"owner_email":78,"owner_twitter":76,"owner_website":79,"owner_url":80,"languages":81,"stars":97,"forks":98,"last_commit_at":99,"license":100,"difficulty_score":101,"env_os":102,"env_gpu":103,"env_ram":103,"env_deps":104,"category_tags":112,"github_topics":113,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":131,"updated_at":132,"faqs":133,"releases":165},9608,"Kismuz\u002Fbtgym","btgym","Scalable, event-driven, deep-learning-friendly backtesting library","btgym 是一个专为强化学习研究设计的可扩展回测库，旨在搭建连接算法交易与人工智能的桥梁。它巧妙地将成熟的量化回测框架 Backtrader 与 OpenAI Gym 的标准环境接口相结合，让开发者能够在一个接近真实市场的复杂、非平稳随机环境中，高效地训练和验证深度强化学习策略。\n\n该工具主要解决了传统回测系统难以直接适配现代深度学习算法的痛点。通过提供标准化的“状态 - 动作 - 奖励”交互机制，btgym 支持离散动作空间设置，允许用户同时处理风险资产价格序列及宏观经济指标等外部数据，从而最小化对未来经验预测的误差，使智能体能在模拟交易中不断进化。\n\n需要注意的是，btgym 并非开箱即用的自动盈利软件，也不提供现成的收敛解决方案。它更像是一个强大的实验框架，要求使用者具备扎实的编程能力以及对强化学习理论的深入理解。因此，它非常适合从事量化金融研究的科研人员、算法工程师以及希望探索 AI 在交易领域应用的高级开发者使用。如果你正准备在可控环境下进行严肃的算法交易实验，btgym 将是一个值得尝试的研究级工具。","```\n...Minimizing the mean square error on future experience.  - Richard S. Sutton\n```\n\n## \u003Ca name=\"title\">\u003C\u002Fa>BTGym\nScalable event-driven RL-friendly backtesting library. Build on top of Backtrader with OpenAI Gym environment API.\n\n\n_Backtrader_ is open-source algorithmic trading library:  \nGitHub: http:\u002F\u002Fgithub.com\u002Fmementum\u002Fbacktrader   \nDocumentation and community:  \nhttp:\u002F\u002Fwww.backtrader.com\u002F  \n\n_OpenAI Gym_ is...,\nwell, everyone knows Gym:   \nGitHub: http:\u002F\u002Fgithub.com\u002Fopenai\u002Fgym   \nDocumentation and community:  \nhttps:\u002F\u002Fgym.openai.com\u002F  \n\n****\n\n### \u003Ca name=\"outline\">\u003C\u002Fa>Outline\n\nGeneral purpose of this project is to provide gym-integrated framework for\nrunning reinforcement learning experiments\nin [close to] real world algorithmic trading environments.\n\n```\nDISCLAIMER:\nCode presented here is research\u002Fdevelopment grade.\nCan be unstable, buggy, poor performing and is subject to change.\n\nNote that this package is neither out-of-the-box-moneymaker, nor it provides ready-to-converge RL solutions.\nThink of it as framework for setting experiments with complex non-stationary stochastic environments.\n\nAs a research project BTGym in its current stage can hardly deliver easy end-user experience in as sense that\nsetting meaninfull  experiments will require some practical programming experience as well as general knowledge\nof reinforcement learning theory.\n```\n****\n\n### [News and update notes](#news)\n\n****\n### \u003Ca name=\"contents\">\u003C\u002Fa>Contents\n- [Installation](#install)\n- [Quickstart](#start)\n- [Description](#description)\n    - [Problem setting](#problem)\n    - [Data sampling approaches](#data)\n- [Documentation and community](#reference)\n- [Known bugs and limitations](#issues)\n- [Roadmap](#roadmap)\n- [Update news](#news)\n\n\n****\n### \u003Ca name=\"install\">\u003C\u002Fa>[Installation](#contents)\nIt is highly recommended to run BTGym in designated virtual environment.\n\nClone or copy btgym repository to local disk, cd to it and run: `pip install -e .` to install package and all dependencies:\n\n    git clone https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym.git\n\n    cd btgym\n\n    pip install -e .\n\nTo update to latest version::\n\n    cd btgym\n\n    git pull\n\n    pip install --upgrade -e .\n\n##### Notes:\n1. BTGym requres **Matplotlib version 2.0.2**, downgrade your installation if you have version 2.1:\n\n    pip install matplotlib==2.0.2\n\n2. **LSOF utility** should be installed to your OS, which can not be the default case for some Linux distributives,\nsee: https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FLsof\n\n****\n### \u003Ca name=\"start\">\u003C\u002Fa>[Quickstart](#contents)\nMaking gym environment with all parmeters set to defaults is as simple as:\n\n```python\nfrom btgym import BTgymEnv\n\nMyEnvironment = BTgymEnv(filename='..\u002Fexamples\u002Fdata\u002FDAT_ASCII_EURUSD_M1_2016.csv',)\n```\nAdding more controls may look like:\n```python\nfrom gym import spaces\nfrom btgym import BTgymEnv\n\nMyEnvironment = BTgymEnv(filename='..\u002Fexamples\u002Fdata\u002FDAT_ASCII_EURUSD_M1_2016.csv',\n                         episode_duration={'days': 2, 'hours': 23, 'minutes': 55},\n                         drawdown_call=50,\n                         state_shape=dict(raw=spaces.Box(low=0,high=1,shape=(30,4))),\n                         port=5555,\n                         verbose=1,\n                         )\n```\n\n##### See more options at [Documentation: Quickstart >>](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fintro.html#quickstart)\n\n##### and how-to's in [Examples directory >>](.\u002Fexamples).\n****\n### \u003Ca name=\"description\">\u003C\u002Fa> [General description](#contents)\n#### \u003Ca name=\"problem\">\u003C\u002Fa> Problem setting\n\n- **Discrete actions setup:** consider setup with one riskless asset acting as broker account cash and K (by default - one) risky assets.\nFor every risky asset there exists track of historic price records referred as `data-line`.\nApart from assets data lines there [optionally] exists number of exogenous data lines holding some\ninformation and statistics, e.g. economic indexes, encoded news, macroeconomic indicators, weather forecasts\netc. which are considered relevant to decision-making.\nIt is supposed for this setup that:\n    1. there is no interest rates for any asset;\n    2. broker actions are fixed-size market orders (`buy`, `sell`, `close`); short selling is permitted;\n    3. transaction costs are modelled via broker commission;\n    4. 'market liquidity' and 'capital impact' assumptions are met;\n    6. time indexes match for all data lines provided;\n- The problem is modelled as discrete-time finite-horizon partially observable Markov decision process for equity\u002Fcurrency trading:\n    - *for every asset* traded agent action space is discrete `(0: `hold` [do nothing], 1:`buy`, 2: `sell`, 3:`close` [position])`;\n    - environment is episodic: maximum  episode duration and episode termination conditions\n      are set;\n    - for every timestep of the episode agent is given environment state observation as tensor of last\n      `m` time-embedded preprocessed values for every data-line included and emits actions according some stochastic policy.\n    - agent's goal is to maximize expected cumulative capital by learning optimal policy;\n\n- **Continuous actions setup[BETA]:** this setup closely relates to continuous portfolio optimisation problem definition;\nit differs from setup above in:\n    1. base broker actions are real numbers: `a[i] in [0,1], 0\u003C=i\u003C=K, SUM{a[i]} = 1`  for `K` risky assets added;\n       each action is a market target order to adjust portfolio to get share `a[i]*100%` for `i`-th  asset;\n    2. entire single-step broker action is dictionary of form:\n       `{cash_name: a[0], asset_name_1: a[1], ..., asset_name_K: a[K]}`;\n    3. short selling is not permitted;\n- For RL it implies having continuous action space as `K+1` dim vector.\n\n\n#### \u003Ca name=\"data\">\u003C\u002Fa> Data selection options for backtest agent training:\n_Notice: data shaping approach is under development, expect some changes. [7.01.18]_\n- random sampling:\n  historic price change dataset is divided to training, cross-validation and testing subsets.\n  Since agent actions do not influence market, it is possible to randomly sample continuous subset\n  of training data for every episode. [Seems to be] most data-efficient method.\n  Cross-validation and testing performed later as usual on most \"recent\" data;\n- sequential sampling:\n  full dataset is feeded sequentially as if agent is performing real-time trading,\n  episode by episode. Most reality-like, least data-efficient, natural non-stationarity remedy.\n- sliding time-window sampling:\n  mixture of above, episde is sampled randomly from comparatively short time period, sliding from\n  furthest to most recent training data. Should be less prone to overfitting than random sampling.\n\n****\n### \u003Ca name=\"reference\">\u003C\u002Fa>[Documentation and Community](#title)\n\n- Read **[Docs and API Reference](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002F)**.\n- Browse **[Development Wiki](https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fwiki)**.\n- Review opened and closed **[Issues](https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fissues?utf8=%E2%9C%93&q=)**.\n- Go to **[BTGym Slack channel](https:\u002F\u002Fbtgym.slack.com)**. If you are new -\n[use this invite link](https:\u002F\u002Fjoin.slack.com\u002Ft\u002Fbtgym\u002Fshared_invite\u002Fzt-750fx9ky-hT0o6diVw1f4Oa1FGZLf4A)\n to join.\n\n\n****\n### \u003Ca name=\"issues\">\u003C\u002Fa> [Known bugs and limitations:](#title)\n- requres Matplotlib version 2.0.2;\n- matplotlib backend warning: appears when importing pyplot and using `%matplotlib inline` magic\n  before btgym import. It's recommended to import btacktrader and btgym first to ensure proper backend\n  choice;\n- not tested with Python \u003C 3.5;\n- doesn't seem to work correctly under Windows; partially done\n- by default, is configured to accept Forex 1 min. data from www.HistData.com;\n- ~~only random data sampling is implemented;~~\n- ~~no built-in dataset splitting to training\u002Fcv\u002Ftesting subsets;~~ done\n- ~~only one equity\u002Fcurrency pair can be traded~~ done\n- ~~no 'skip-frames' implementation within environment;~~ done\n- ~~no plotting features, except if using pycharm integration observer.~~\n    ~~Not sure if it is suited for intraday strategies.~~ [partially] done\n- ~~making new environment kills all processes using specified network port. Watch out your jupyter kernels.~~ fixed\n\n****\n### \u003Ca name=\"roadmap\">\u003C\u002Fa> [TODO's and Road Map:](#title)\n - [x] refine logic for parameters applying priority (engine vs strategy vs kwargs vs defaults);\n - [X] API reference;\n - [x] examples;\n - [x] frame-skipping feature;\n - [x] dataset tr\u002Fcv\u002Ft approach;\n - [x] state rendering;\n - [x] proper rendering for entire episode;\n - [x] tensorboard integration;\n - [x] multiply agents asynchronous operation feature (e.g for A3C):\n - [x] dedicated data server;\n - [x] multi-modal observation space shape;\n - [x] A3C implementation for BTgym;\n - [x] UNREAL implementation for BTgym;\n - [x] PPO implementation for BTgym;\n - [ ] RL^2 \u002F MAML \u002F DARLA adaptations - IN PROGRESS;\n - [x] learning from demonstrations; -  partially done\n - [ ] risk-sensitive agents implementation;\n - [x] sequential and sliding time-window sampling;\n - [x] multiply instruments trading;\n - [x] docker image; - CPU version, `Signalprime` contribution, \n - [ ] TF serving model serialisation functionality;\n\n\n### \u003Ca name=\"news\">\u003C\u002Fa>[News and updates:](#title)\n- 10.01.2019:\n    - **docker CPU version** is now available, contributed by `Signalprime`, \n    (https:\u002F\u002Fgithub.com\u002Fsignalprime), see `btgym\u002Fdocker\u002FREADME.md` for details;\n\n- 9.02.2019:\n    - **Introduction to analytic data model** notebook added to [model_based_stat_arb](.\u002Fexamples\u002Fmodel_based_stat_arb\u002F) examples folder.\n\n- 25.01.2019: updates:\n    - **lstm_policy** class now requires both `internal` and `external` observation sub-spaces to be present and allows both be one-level nested\n        sub-spaces itself (was only true for `external`); all declared sub-spaces got encoded by separate convolution encoders;\n    - **policy deterministic action** option is implemented for discrete action spaces and can be utilised by `syncro_runner`;\n        by default it is enabled for test episodes;\n    - **data_feed** classes now accept `pd.dataframes` as historic data dource via `dataframe` kwarg (was: `.csv` files only);\n\n- 18.01.2019: updates:\n    - **data model** classes are under active development to power model-based framework:\n        - common statistics incremental estimator classes has been added (mean, variance, covariance, linear regression etc.);\n        - incremental Singular Spectrum Analysis class implemented;\n        - for a pair of asset prices, two-factor state-space model is proposed\n    - new **data_feed** iterator classes has been added to provide training framework with synthetic data generated by model mentioned above;\n    - **strategy_gen_6** data handling and pre-processing has been redesigned:\n        - market data SSA decomposition;\n        - data model state as additional input to policy\n        - variance-based normalisation for broker statistics\n\n- 11.12.2018: updates and fixes:\n    - **training Launcher class** got convenience features to save and reload model parameters,\n        see https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fblob\u002Fmaster\u002Fexamples\u002Funreal_stacked_lstm_strat_4_11.ipynb for details\n    - **combined model-based\u002Fmodel-free** aproach package in early development stage is added to `btgym.reserach`\n\n- 17.11.2018: updates and fixes:\n    - **minor fixes to base data provider** class episode sampling\n    - **update to btgym.datafeed.synthetic** subpackage: new stochastic processes generators added etc.\n    - **new btgym.research.startegy_gen_5 subpackage:**\n        efficient parameter-free signal preprocessing implemented, other minor improvements\n\n- 30.10.2018: updates and fixes:\n    - **fixed numpy random state issue** causing replicating of seeds among workers on POSIX os\n    - **new synthetic datafeed generators** - added simple Ornshtein-Uhlenbeck process data generating classes;\n        see `btgym\u002Fdatafeed\u002Fsynthetic\u002Fou.py` and `btgym\u002Fresearch\u002Fou_params_space_eval` for details;\n\n- 14.10.2018: update:\n    - **base reward function redesign** -> noticeable algorithms performance gain;\n\n- 20.07.2018: major update to package:\n    - **enchancements to agent architecture**:\n        - casual convolution state encoder with attention for LSTM agent;\n        - dropout regularization added for conv. and LSTM layers;\n    - **base strategy update**: new convention for naming `get_state` methods,  see `BaseStrategy` class for details;\n\n    - **multiply datafeeds and assets trading** implemented in two flavors:\n        - **discrete actions** space via MultiDiscreteEnv class;\n        - **continious actions** space via PortfolioEnv which is closely related to\n          contionious portfolio optimisation problem setup;\n            - description and docs:\n                - **MultiDataFeed:** https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.datafeed.html#btgym.datafeed.multi.BTgymMultiData\n                - **ActionSpace:** https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.html#btgym.spaces.ActionDictSpace\n                - **MultiDiscreteEnv:** https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.envs.html#btgym.envs.multidiscrete.MultiDiscreteEnv\n                - **PortfolioEnv:** https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.envs.html#btgym.envs.portfolio.PortfolioEnv\n\n            - examples:\n                - **MultiDiscreteEnv:** https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fblob\u002Fmaster\u002Fexamples\u002Fmulti_discrete_setup_intro.ipynb\n                - **PortfolioEnv:** https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fblob\u002Fmaster\u002Fexamples\u002Fportfolio_setup_BETA.ipynb\n        - **Notes on multi-asset setup**:\n            - adding these features forced substantial package redesign;\n              expect bugs, some backward incompatibility, broken examples etc - please report;\n            - current algorithms and agents architectures are ok with multiply data lines but seem not to cope well with multi-asset setup.\n              It is especially evident in case of continuous actions, where agents completely fail to converge on train data;\n            - current reward function design seems inappropriate; need to reshape;\n            - continuous space in `beta` and still needs some improvement, esp. for broker order execution logic as well as\n              action sampling routine for continuous A3C (which is Dirichlet process by now);\n            - multi-discrete space is more consistent but severely limited in number of portfolio assets (but not data-lines)\n              due to exponential rise of action space cardinality;\n              the option is to as use many datalines as desired while limiting portfolio to 1 - 4 assets;\n            - no Guided Policy available for multi-asset setup yet - in progress;\n            - all but `episode` rendering modes are temporally disabled;\n            - whole thing is shamelessly resource-hungry;\n\n- 17.02.18: First results on applying guided policy search ideas (GPS) to btgym setup can be seen\n           [here](.\u002Fexamples\u002Fguided_a3c.ipynb).  \n    - tensorboard summaries are updated with additional renderings:\n      actions distribution, value function and LSTM_state; presented in the same notebook.\n\n- 6.02.18: Common update to all a3c agents architectures:\n    - all dense layers are now Noisy-Net ones,\n      see: [Noisy Networks for Exploration](https:\u002F\u002Farxiv.org\u002Fabs\u002F1706.10295) paper by Fortunato at al.;\n    - note that entropy regularization is still here, kept in ~0.01 to ensure proper exploration;\n    - policy output distribution is 'centered' using layer normalisation technique;\n\n        - all of the above results in about 2x training speedup in terms of train iterations;\n\n- 20.01.18: Project [Wiki pages](https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fwiki) added;\n\n- 12.01.18: Minor fixes to logging, enabled BTgymDataset train\u002Ftest data split. AAC framework train\u002Ftest cycle enabled\n            via\n            [`episode_train_test_cycle`](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.algorithms.html#module-btgym.algorithms.aac)\n            kwarg.\n\n- 7.01.18: Update:\n    - Major data pipe redesign. `Domain -> Trial -> Episode` sampling routine implemented. For motivation and\n      formal definitions refer to\n      [Section 1.Data of this DRAFT](https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fblob\u002Fmaster\u002Fdocs\u002Fpapers\u002Fbtgym_formalism_draft.pdf),\n      API [Documentation](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.datafeed.html#btgym-datafeed-package)\n      and [Intro example](.\u002Fexamples\u002Fdata_domain_api_intro.ipynb). Changes should be backward compatible.\n      In brief, it is necessry framework for upcoming meta-learning algorithms.\n    - logging changes: now relying in python `logbook` module. Should eliminate errors under Windows.\n    - Stacked_LSTM_Policy agent implemented. Based on NAV_A3C from\n      [DeepMind paper](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1611.03673.pdf) with some minor mods. Basic usage\n      [Example is here](.\u002Fexamples\u002Funreal_stacked_lstm_strat_4_11.ipynb).\n      Still in research code area and need further tuning; yet faster than simple LSTM agent,\n      able to converge on 6-month 1m dataset.\n\n- 5.12.17: Inner btgym comm. fixes >> speedup ~5%.\n\n- 02.12.17: Basic `sliding time-window train\u002Ftest` framework implemented via\n            [BTgymSequentialTrial()](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.html#btgym.datafeed.BTgymSequentialTrial)\n            class. UPD: replaced by `BTgymSequentialDataDomain` class.\n\n- 29.11.17: Basic meta-learning RL^2 functionality implemented.\n    - See [Trial_Iterator Class](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.html#btgym.datafeed.BTgymRandomTrial) and\n    [RL^2 policy](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.research.html#btgym.research.policy_rl2.AacRL2Policy)\n    for description.\n    - Effectiveness is not tested yet, examples are to follow.\n\n- 24.11.17: A3C\u002FUNREAL finally adapted to work with BTGym environments.\n    - Examples with synthetic simple data(sine wawe) and historic financial data added,\n      see [examples directory](.\u002Fexamples\u002F);\n    - Results on potential-based functions reward shaping in `\u002Fresearch\u002FDevStartegy_4_6`;\n    - Work on Sequential\u002Frandom Trials Data iterators (kind of sliding time-window) in progress,\n      start approaching the toughest part: non-stationarity battle is ahead.\n\n- 14.11.17: BaseAAC framework refraction; added per worker batch-training option and LSTM time_flatten option; Atari\n            examples updated; see [Documentation](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002F) for details.\n\n- 30.10.17: Major update, some backward incompatibility:\n    - BTGym now can be thougt as two-part package: one is environment itself and the other one is\n      RL algoritms tuned for solving algo-trading tasks. Some basic work on shaping of later is done. Three advantage\n      actor-critic style algorithms are implemented: A3C itself, it's UNREAL extension and PPO. Core logic of these seems\n      to be implemented correctly but further extensive BTGym-tuning is ahead.\n      For now one can check [atari tests](.\u002Fexamples\u002Fatari_tests).\n    - Finally, basic [documentation and API reference](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002F) is now available.\n\n- 27.09.17: A3C [test_4.2](.\u002Fexamples\u002Fa3c\u002Fa3c_test_4_2_no_feature_signal_conv1d.ipynb) added:\n    - some progress on estimator architecture search, state and reward shaping;\n\n- 22.09.17: A3C [test_4](.\u002Fexamples\u002Fa3c\u002Fa3c_test_4_sma_bank_features.ipynb) added:\n    - passing train convergence test on small (1 month) dataset of EURUSD 1-minute bar data;\n\n- 20.09.17: A3C optimised sine-wave test added [here.](.\u002Fexamples\u002Fa3c\u002Fa3c_reject_test_3_sine_conv1d_sma_log_grad.ipynb)\n    - This notebook presents some basic ideas on state presentation, reward shaping,\n      model architecture and hyperparameters choice.\n      With those tweaks sine-wave sanity test is converging faster and with greater stability.\n\n- 31.08.17: Basic implementation of A3C algorithm is done and moved inside BTgym package.\n    - algorithm logic consistency tests are passed;\n    - still work in early stage, experiments with obs. state features and policy estimator architecture ahead;\n    - check out [`examples\u002Fa3c`](.\u002Fexamples\u002Fa3c) directory.\n\n- 23.08.17: `filename` arg in environment\u002Fdataset specification now can be list of csv files.\n    - handy for bigger dataset creation;\n    - data from all files are concatenated and sampled uniformly;\n    - no record duplication and format consistency checks preformed.\n\n- 21.08.17: UPDATE: BTgym is now using multi-modal observation space.\n     - space used is simple extension of gym: `DictSpace(gym.Space)` - dictionary (not nested yet) of core gym spaces.\n     - defined in `btgym\u002Fspaces.py`.\n     - `raw_state` is default Box space of OHLC prices. Subclass BTgymStrategy and override `get_state()` method to\n            compute alll parts of env. observation.\n     - rendering can now be performed for avery entry in observation dictionary as long as it is Box ranked \u003C=3\n            and same key is passed in reneder_modes kwarg of environment.\n            'Agent' mode renamed to 'state'. See updated examples.\n\n\n- 07.08.17: BTgym is now optimized for asynchronous operation with multiply environment instances.\n     - dedicated data_server is used for dataset management;\n     - improved overall internal network connection stability and error handling;\n     - see example `async_btgym_workers.ipynb` in [`examples`](.\u002Fexamples) directory.\n\n- 15.07.17: UPDATE, BACKWARD INCOMPATIBILITY: now state observation can be tensor of any rank.\n     - Consequently, dim. ordering convention has changed to ensure compatibility with\n            existing tf models: time embedding is first dimension from now on, e.g. state\n            with shape (30, 20, 4) is 30x steps time embedded with 20 features and 4 'channels'.\n            For the sake of 2d visualisation only one 'cannel' can be rendered, can be\n            chosen by setting env. kwarg `render_agent_channel=0`;\n     - examples are updated;\n     - better now than later.\n\n- 11.07.17: Rendering battle continues: improved stability while low in memory,\n            added environment kwarg `render_enabled=True`; when set to `False`\n             - all renderings are disabled. Can help with performance.\n\n- 5.07.17:  Tensorboard monitoring wrapper added; pyplot memory leak fixed.\n\n- 30.06.17: EXAMPLES updated with 'Setting up: full throttle' how-to.\n\n- 29.06.17: UPGRADE: be sure to run `pip install --upgrade -e .`\n    - major rendering rebuild: updated with modes: `human`, `agent`, `episode`;\n      render process now performed by server and returned to environment as `rgb numpy array`.\n      Pictures can be shown either via matplolib or as pillow.Image(preferred).\n    - 'Rendering HowTo' added, 'Basic Settings' example updated.\n    - internal changes: env. state divided on `raw_state`  - price data,\n      and `state` - featurized representation. `get_raw_state()` method added to strategy.\n    - new packages requirements: `matplotlib` and `pillow`.\n\n- 25.06.17:\n  Basic rendering implemented.\n\n- 23.06.17:\n  alpha 0.0.4:\n  added skip-frame feature,\n  redefined parameters inheritance logic,\n  refined overall stability;\n\n- 17.06.17:\n  first working alpha v0.0.2.\n\n\n\u003Ca href=\"https:\u002F\u002Fstackexchange.com\u002Fusers\u002F10204071\u002Fandrew-muzikin\">\u003Cimg src=\"https:\u002F\u002Fstackexchange.com\u002Fusers\u002Fflair\u002F10204071.png\" width=\"208\" height=\"58\" alt=\"profile for Andrew Muzikin on Stack Exchange, a network of free, community-driven Q&amp;A sites\" title=\"profile for Andrew Muzikin on Stack Exchange, a network of free, community-driven Q&amp;A sites\" \u002F>\u003C\u002Fa>\n","```\n...最小化未来经验上的均方误差。 - 理查德·S·萨顿\n```\n\n## \u003Ca name=\"title\">\u003C\u002Fa>BTGym\n可扩展的事件驱动型、适合强化学习的回测库。基于Backtrader构建，提供OpenAI Gym环境API。\n\n\n_Backtrader_ 是一个开源的算法交易库：  \nGitHub: http:\u002F\u002Fgithub.com\u002Fmementum\u002Fbacktrader   \n文档与社区：  \nhttp:\u002F\u002Fwww.backtrader.com\u002F  \n\n_OpenAI Gym_ 是……嗯，大家都知道Gym：   \nGitHub: http:\u002F\u002Fgithub.com\u002Fopenai\u002Fgym   \n文档与社区：  \nhttps:\u002F\u002Fgym.openai.com\u002F  \n\n****\n\n### \u003Ca name=\"outline\">\u003C\u002Fa>概要\n\n本项目的总体目标是提供一个集成Gym的框架，用于在[接近]真实世界的算法交易环境中运行强化学习实验。\n\n```\n免责声明：\n此处提供的代码属于研究\u002F开发级别。\n可能不稳定、存在错误、性能不佳，并且可能会发生变化。\n\n请注意，该软件包既不是开箱即用的盈利工具，也不提供可以直接收敛的强化学习解决方案。\n可以将其视为一个用于设置复杂非平稳随机环境实验的框架。\n\n作为一项研究项目，目前阶段的BTGym很难为终端用户提供简单的使用体验，因为要设置有意义的实验，需要一定的编程实践经验以及对强化学习理论的基本了解。\n```\n****\n\n### [新闻与更新说明](#news)\n\n****\n### \u003Ca name=\"contents\">\u003C\u002Fa>目录\n- [安装](#install)\n- [快速入门](#start)\n- [描述](#description)\n    - [问题设定](#problem)\n    - [数据采样方法](#data)\n- [文档与社区](#reference)\n- [已知缺陷与限制](#issues)\n- [路线图](#roadmap)\n- [更新消息](#news)\n\n\n****\n### \u003Ca name=\"install\">\u003C\u002Fa>[安装](#contents)\n强烈建议在专用的虚拟环境中运行BTGym。\n\n将btgym仓库克隆或复制到本地磁盘，进入该目录并运行：`pip install -e .`以安装软件包及其所有依赖项：\n\n    git clone https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym.git\n\n    cd btgym\n\n    pip install -e .\n\n要更新到最新版本：\n\n    cd btgym\n\n    git pull\n\n    pip install --upgrade -e .\n\n##### 注意事项：\n1. BTGym需要**Matplotlib 2.0.2版本**，如果你的版本是2.1，请降级安装：\n\n    pip install matplotlib==2.0.2\n\n2. **LSOF工具**应安装在你的操作系统中，但某些Linux发行版默认并未安装，详情请参见：https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FLsof\n\n****\n### \u003Ca name=\"start\">\u003C\u002Fa>[快速入门](#contents)\n使用所有默认参数创建Gym环境非常简单：\n\n```python\nfrom btgym import BTgymEnv\n\nMyEnvironment = BTgymEnv(filename='..\u002Fexamples\u002Fdata\u002FDAT_ASCII_EURUSD_M1_2016.csv',)\n```\n添加更多控制选项可能如下所示：\n```python\nfrom gym import spaces\nfrom btgym import BTgymEnv\n\nMyEnvironment = BTgymEnv(filename='..\u002Fexamples\u002Fdata\u002FDAT_ASCII_EURUSD_M1_2016.csv',\n                         episode_duration={'days': 2, 'hours': 23, 'minutes': 55},\n                         drawdown_call=50,\n                         state_shape=dict(raw=spaces.Box(low=0,high=1,shape=(30,4))),\n                         port=5555,\n                         verbose=1,\n                         )\n```\n\n##### 更多选项请参阅[文档：快速入门 >>](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fintro.html#quickstart)\n\n##### 详细教程请查看[示例目录 >>](.\u002Fexamples)。\n****\n### \u003Ca name=\"description\">\u003C\u002Fa> [一般描述](#contents)\n#### \u003Ca name=\"problem\">\u003C\u002Fa> 问题设定\n\n- **离散动作设置：** 考虑一种设置，其中有一项无风险资产充当经纪账户现金，另有K项（默认为1项）风险资产。对于每项风险资产，都有一条历史价格记录线，称为“数据线”。除了资产数据线之外，还可以选择性地包含若干外生数据线，这些数据线承载着一些信息和统计数据，例如经济指数、编码后的新闻、宏观经济指标、天气预报等，它们被认为与决策相关。在此设置下假设：\n    1. 所有资产均无利率；\n    2. 经纪商的操作均为固定规模的市价单（“买入”、“卖出”、“平仓”），允许做空；\n    3. 交易成本通过经纪商佣金进行建模；\n    4. 满足“市场流动性”和“资本冲击”的假设；\n    6. 所有提供的数据线的时间索引一致；\n- 该问题被建模为针对股票\u002F外汇交易的离散时间有限 horizon 部分可观测马尔可夫决策过程：\n    - *对于每项资产*，交易代理的动作空间是离散的（0：保持不动；1：买入；2：卖出；3：平仓）；\n    - 环境是分段式的：设置了最大回合时长及回合终止条件；\n    - 在每个回合的每个时间步，代理会收到一个状态观测值，该观测值是一个张量，包含了所包含的每条数据线最近`m`个时间嵌入式预处理后的数值，并根据某种随机策略发出动作；\n    - 代理的目标是通过学习最优策略来最大化预期累计资本；\n\n- **连续动作设置[测试版]：** 该设置与连续投资组合优化问题的定义密切相关；它与上述设置的不同之处在于：\n    1. 基础经纪商操作是实数：对于添加的`K`项风险资产，`a[i]`的取值范围为[0,1]，且`0\u003C=i\u003C=K`，同时满足`SUM{a[i]} = 1`。每个动作都是一个市场目标订单，用于调整投资组合，使第`i`项资产的权重达到`a[i]*100%`；\n    2. 整个单步经纪商操作是一个字典，形式为：`{cash_name: a[0], asset_name_1: a[1], ..., asset_name_K: a[K]}`；\n    3. 不允许做空；\n- 对于强化学习而言，这意味着拥有一个`K+1`维的连续动作空间。\n\n\n#### \u003Ca name=\"data\">\u003C\u002Fa> 回测代理训练的数据选择选项：\n*注意：数据处理方式仍在开发中，可能会有所变化。[2018年1月7日]*\n- 随机采样：\n  将历史价格变动数据集划分为训练集、交叉验证集和测试集。由于代理的行为不会影响市场，因此可以在每次回合中从训练数据集中随机抽取一段连续的数据。这似乎是数据效率最高的方法。交叉验证和测试则像往常一样，在“最近”的数据上进行；\n- 顺序采样：\n  将整个数据集按顺序输入，就像代理正在进行实时交易一样，逐个回合地进行。这种方法最接近现实，但数据效率最低，同时也是解决非平稳性的自然方式；\n- 滑动时间窗采样：\n  结合了上述两种方法，每个回合从相对较短的时间段内随机采样，然后从最远端向最近端滑动。相比随机采样，这种方法应该更不容易导致过拟合。\n\n****\n\n### \u003Ca name=\"reference\">\u003C\u002Fa>[文档与社区](#title)\n\n- 阅读 **[文档与 API 参考](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002F)**。\n- 浏览 **[开发 Wiki](https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fwiki)**。\n- 查看已打开和已关闭的 **[问题](https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fissues?utf8=%E2%9C%93&q=)**。\n- 前往 **[BTGym Slack 频道](https:\u002F\u002Fbtgym.slack.com)**。如果您是新用户，请使用此邀请链接 [https:\u002F\u002Fjoin.slack.com\u002Ft\u002Fbtgym\u002Fshared_invite\u002Fzt-750fx9ky-hT0o6diVw1f4Oa1FGZLf4A](https:\u002F\u002Fjoin.slack.com\u002Ft\u002Fbtgym\u002Fshared_invite\u002Fzt-750fx9ky-hT0o6diVw1f4Oa1FGZLf4A) 加入。\n\n\n****\n### \u003Ca name=\"issues\">\u003C\u002Fa> [已知的 bug 和限制：](#title)\n- 需要 Matplotlib 2.0.2 版本；\n- 导入 pyplot 并在导入 btgym 之前使用 `%matplotlib inline` magic 时会出现 matplotlib 后端警告。建议先导入 btacktrader 和 btgym，以确保选择正确的后端；\n- 尚未在 Python \u003C 3.5 的环境中测试过；\n- 在 Windows 下似乎无法正常工作；部分已完成\n- 默认配置为接受来自 www.HistData.com 的外汇 1 分钟数据；\n- ~~目前仅实现了随机数据采样；~~\n- ~~没有内置的数据集拆分功能，用于划分训练\u002F验证\u002F测试子集；~~ 已完成\n- ~~目前只能交易一种股票或货币对~~ 已完成\n- ~~环境中尚未实现“跳帧”功能；~~ 已完成\n- ~~除了使用 PyCharm 集成观察器外，没有绘图功能。~~ ~~不确定是否适用于日内策略。~~ [部分] 已完成\n- ~~创建新环境会终止所有使用指定网络端口的进程。请注意您的 Jupyter 内核。~~ 已修复\n\n****\n### \u003Ca name=\"roadmap\">\u003C\u002Fa> [待办事项与路线图：](#title)\n - [x] 完善参数应用优先级的逻辑（引擎 vs 策略 vs kwargs vs 默认值）；\n - [X] API 参考；\n - [x] 示例；\n - [x] 跳帧功能；\n - [x] 数据集的 tr\u002Fcv\u002Ft 划分方法；\n - [x] 状态渲染；\n - [x] 整个 episode 的正确渲染；\n - [x] TensorBoard 集成；\n - [x] 多智能体异步操作功能（例如用于 A3C）：\n - [x] 专用数据服务器；\n - [x] 多模态观测空间形状；\n - [x] BTgym 的 A3C 实现；\n - [x] BTgym 的 UNREAL 实现；\n - [x] BTgym 的 PPO 实现；\n - [ ] RL^2 \u002F MAML \u002F DARLA 的适配——正在进行中；\n - [x] 从示范中学习；——部分完成\n - [ ] 风险敏感型智能体的实现；\n - [x] 顺序和滑动时间窗采样；\n - [x] 多种工具的交易；\n - [x] Docker 镜像；——CPU 版本，由 `Signalprime` 贡献，\n - [ ] TF Serving 模型序列化功能；\n\n\n### \u003Ca name=\"news\">\u003C\u002Fa>[新闻与更新：](#title)\n- 2019年1月10日：\n    - 现已提供由 `Signalprime`（https:\u002F\u002Fgithub.com\u002Fsignalprime）贡献的 **Docker CPU 版本**，详情请参阅 `btgym\u002Fdocker\u002FREADME.md`；\n\n- 2019年2月9日：\n    - 在 [model_based_stat_arb](.\u002Fexamples\u002Fmodel_based_stat_arb\u002F) 示例文件夹中新增了 **分析数据模型介绍** 笔记本。\n\n- 2019年1月25日：更新内容：\n    - **lstm_policy** 类现在要求同时存在 `internal` 和 `external` 观测子空间，并且允许两者均为单层嵌套子空间（之前仅对外部子空间适用）；所有声明的子空间均由独立的卷积编码器进行编码；\n    - **policy deterministic action** 选项现已针对离散动作空间实现，可由 `syncro_runner` 使用；默认情况下，该选项在测试 episode 中启用；\n    - **data_feed** 类现在可通过 `dataframe` 关键字参数接受 `pd.dataframes` 作为历史数据源（之前仅支持 `.csv` 文件）；\n\n- 2019年1月18日：更新内容：\n    - **数据模型** 类正在积极开发中，以支持基于模型的框架：\n        - 新增了常用统计量的增量估计器类（均值、方差、协方差、线性回归等）；\n        - 实现了增量式奇异谱分析类；\n        - 针对一对资产价格，提出了双因素状态空间模型；\n    - 新增了 **data_feed** 迭代器类，用于向训练框架提供由上述模型生成的合成数据；\n    - **strategy_gen_6** 的数据处理和预处理流程已被重新设计：\n        - 对市场数据进行 SSA 分解；\n        - 将数据模型状态作为策略的额外输入；\n        - 基于方差的经纪人统计数据归一化处理；\n\n- 2018年12月11日：更新与修复：\n    - **training Launcher 类** 增加了保存和重新加载模型参数的便捷功能，详情请参阅 https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fblob\u002Fmaster\u002Fexamples\u002Funreal_stacked_lstm_strat_4_11.ipynb；\n    - **基于模型\u002F无模型结合** 方法包处于早期开发阶段，现已加入 `btgym.reserach`；\n\n- 2018年11月17日：更新与修复：\n    - **对基础数据提供者类的 episode 采样进行了小幅修复**；\n    - **btgym.datafeed.synthetic 子包更新**：新增了随机过程生成器等；\n    - **新的 btgym.research.startegy_gen_5 子包：**\n        实现了高效的无参数信号预处理，以及其他小幅改进；\n\n- 2018年10月30日：更新与修复：\n    - **修复了 numpy 随机状态问题**，该问题导致在 POSIX 操作系统上多个工作进程之间种子重复；\n    - **新增合成数据馈送生成器**——添加了简单的 Ornstein-Uhlenbeck 过程数据生成类；详情请参阅 `btgym\u002Fdatafeed\u002Fsynthetic\u002Fou.py` 和 `btgym\u002Fresearch\u002Fou_params_space_eval`；\n\n- 2018年10月14日：更新：\n    - **基础奖励函数重新设计** -> 算法性能显著提升；\n\n- 2018年7月20日：软件包重大更新：\n    - **智能体架构增强**：\n        - 为 LSTM 智能体配备了带有注意力机制的卷积状态编码器；\n        - 在卷积层和 LSTM 层中增加了 dropout 正则化；\n    - **基础策略更新**：为 `get_state` 方法命名引入新规范，详情请参阅 `BaseStrategy` 类；\n\n    - **多数据源和多资产交易** 以两种方式实现：\n        - 通过 MultiDiscreteEnv 类实现 **离散动作** 空间；\n        - 通过 PortfolioEnv 类实现 **连续动作** 空间，该环境与连续投资组合优化问题密切相关；\n            - 描述和文档：\n                - **MultiDataFeed:** https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.datafeed.html#btgym.datafeed.multi.BTgymMultiData\n                - **ActionSpace:** https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.html#btgym.spaces.ActionDictSpace\n                - **MultiDiscreteEnv:** https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.envs.html#btgym.envs.multidiscrete.MultiDiscreteEnv\n                - **PortfolioEnv:** https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.envs.html#btgym.envs.portfolio.PortfolioEnv\n\n- 示例：\n                - **MultiDiscreteEnv:** https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fblob\u002Fmaster\u002Fexamples\u002Fmulti_discrete_setup_intro.ipynb\n                - **PortfolioEnv:** https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fblob\u002Fmaster\u002Fexamples\u002Fportfolio_setup_BETA.ipynb\n        - **多资产设置注意事项**：\n            - 添加这些功能迫使对整个软件包进行了大幅重构；\n              预计会出现一些 bug、部分向后不兼容以及示例失效等问题——请务必报告；\n            - 当前的算法和智能体架构在处理多条数据线时表现尚可，但在多资产设置下却难以应对。\n              尤其是在连续动作的情况下，智能体几乎无法在训练数据上实现收敛；\n            - 目前的奖励函数设计似乎并不合适，需要重新调整；\n            - `beta` 版本中的连续动作空间仍需改进，特别是在经纪商订单执行逻辑以及连续 A3C 的动作采样流程方面（目前采用的是狄利克雷过程）；\n            - 多离散动作空间更为一致，但受动作空间基数呈指数级增长的影响，投资组合资产数量受到严重限制（而数据线数量则不受此限）。\n              一种可行方案是根据需求使用尽可能多的数据线，同时将投资组合资产数量限制在 1 到 4 个之间；\n            - 目前尚未提供适用于多资产设置的引导策略——仍在开发中；\n            - 所有除 `episode` 渲染模式之外的其他模式均已暂时禁用；\n            - 整个系统对资源的需求极其庞大；\n\n- 2018年2月17日：首次将引导策略搜索思想（GPS）应用于 btgym 设置的结果可见\n           [此处](.\u002Fexamples\u002Fguided_a3c.ipynb)。  \n    - TensorBoard 摘要已更新，增加了额外的可视化内容：\n      包括动作分布、价值函数和 LSTM 状态；这些内容均在同一份笔记本中展示。\n\n- 2018年2月6日：对所有 A3C 智能体架构进行统一更新：\n    - 所有全连接层现均已替换为噪声网络层，\n      参见 Fortunato 等人发表的论文《用于探索的噪声网络》（https:\u002F\u002Farxiv.org\u002Fabs\u002F1706.10295）；\n    - 需要注意的是，熵正则化仍然保留，其值维持在约 0.01 左右，以确保充分的探索能力；\n    - 策略输出分布通过层归一化技术进行“居中”处理；\n\n        - 上述改进使训练迭代速度提升了约两倍；\n\n- 2018年1月20日：新增项目[维基页面](https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fwiki)；\n\n- 2018年1月12日：对日志记录进行了小幅修复，并启用了 BTgymDataset 的训练\u002F测试数据划分。同时，通过\n            [`episode_train_test_cycle`](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.algorithms.html#module-btgym.algorithms.aac)\n            关键字参数，实现了 AAC 框架的训练\u002F测试循环。\n\n- 2018年1月7日：更新内容：\n    - 对数据管道进行了重大重构。实现了“领域 → 试验 → 赛局”的采样流程。有关动机及正式定义，请参阅\n      [本草稿第 1 节数据部分](https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fblob\u002Fmaster\u002Fdocs\u002Fpapers\u002Fbtgym_formalism_draft.pdf)、API\n      [文档](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.datafeed.html#btgym-datafeed-package)以及\n      [入门示例](.\u002Fexamples\u002Fdata_domain_api_intro.ipynb)。此次更改应保持向后兼容性。\n      简而言之，这是为即将到来的元学习算法所必需的基础框架。\n    - 日志记录方面：现已改用 Python 的 `logbook` 模块。此举应能消除 Windows 系统下的错误。\n    - 实现了堆叠 LSTM 策略智能体。该智能体基于 DeepMind 论文\n      （https:\u002F\u002Farxiv.org\u002Fpdf\u002F1611.03673.pdf）中的 NAV_A3C，并做了一些小修改。基本用法\n      可参见 [示例](.\u002Fexamples\u002Funreal_stacked_lstm_strat_4_11.ipynb)。\n      目前仍处于研究阶段，需进一步调优；不过其速度已快于简单的 LSTM 智能体，\n      能够在 6 个月的 1 分钟数据集上实现收敛。\n\n- 2017年12月5日：btgym 内部通信优化 >> 速度提升约 5%。\n\n- 2017年12月2日：通过\n            [BTgymSequentialTrial()](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.html#btgym.datafeed.BTgymSequentialTrial)\n            类实现了基础的“滑动时间窗训练\u002F测试”框架。更新：现已替换为 `BTgymSequentialDataDomain` 类。\n\n- 2017年11月29日：实现了基础的元学习 RL^2 功能。\n    - 有关说明请参阅\n      [Trial_Iterator 类](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.html#btgym.datafeed.BTgymRandomTrial) 和\n      [RL^2 策略](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002Fbtgym.research.html#btgym.research.policy_rl2.AacRL2Policy)。\n    - 其有效性尚未经过测试，后续将提供更多示例。\n\n- 2017年11月24日：A3C\u002FUNREAL 终于适配了 BTGym 环境。\n    - 新增了使用合成简单数据（正弦波）和历史金融数据的示例，\n      详见 [示例目录](.\u002Fexamples\u002F)；\n    - 在 `\u002Fresearch\u002FDevStartegy_4_6` 中展示了基于潜在函数的奖励塑造结果；\n    - 正在进行顺序\u002F随机试验数据迭代器的开发工作（类似于滑动时间窗），目前已进入最困难的部分：对抗非平稳性的挑战即将到来。\n\n- 2017年11月14日：BaseAAC 框架进行了重构；新增了按工作者批次训练选项和 LSTM 时间展平选项；Atari 示例也已更新；详情请参阅\n      [文档](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002F)。\n\n- 2017年10月30日：重大更新，存在部分向后不兼容：\n    - BTGym 现在可以被视为一个由两部分组成的软件包：一部分是环境本身，另一部分则是专为解决算法交易任务而优化的强化学习算法。后者的基础工作已完成。目前已实现三种优势演员-评论家风格的算法：A3C 本身、其 UNREAL 扩展以及 PPO。这些算法的核心逻辑似乎已经实现正确，但仍需进一步深入调试 BTGym。\n      目前可以查看 [Atari 测试](.\u002Fexamples\u002Fatari_tests)。\n    - 最终，基础的 [文档和 API 参考](https:\u002F\u002Fkismuz.github.io\u002Fbtgym\u002F) 现已发布。\n\n- 2017年9月27日：新增 A3C [test_4.2](.\u002Fexamples\u002Fa3c\u002Fa3c_test_4_2_no_feature_signal_conv1d.ipynb)：\n    - 在估计器架构搜索、状态表示和奖励塑造方面取得了一些进展；\n\n- 2017年9月22日：新增 A3C [test_4](.\u002Fexamples\u002Fa3c\u002Fa3c_test_4_sma_bank_features.ipynb)：\n    - 通过了在小型（1 个月）EURUSD 1 分钟柱状图数据集上的训练收敛测试；\n\n- 2017年9月20日：新增优化后的正弦波测试\n      [在此处](.\u002Fexamples\u002Fa3c\u002Fa3c_reject_test_3_sine_conv1d_sma_log_grad.ipynb)。\n    - 该笔记本介绍了一些关于状态表示、奖励塑造、模型架构和超参数选择的基本思路。\n      通过这些调整，正弦波的合理性测试能够更快且更稳定地收敛。\n\n- 2017年8月31日：A3C 算法的基本实现已完成，并被整合到 BTgym 软件包中。\n    - 算法逻辑一致性测试已通过；\n    - 目前仍处于早期阶段，接下来将开展观测状态特征和策略估计器架构方面的实验；\n    - 请查看 [`examples\u002Fa3c`](.\u002Fexamples\u002Fa3c) 目录。\n\n- 23.08.17：环境\u002F数据集规范中的 `filename` 参数现在可以是一个 CSV 文件列表。\n    - 对于创建较大的数据集非常方便；\n    - 所有文件中的数据会被拼接在一起，并进行均匀采样；\n    - 不会进行记录重复检查或格式一致性检查。\n\n- 21.08.17：更新：BTgym 现在使用多模态观测空间。\n     - 使用的空间是 gym 的简单扩展：`DictSpace(gym.Space)`——一个核心 gym 空间组成的字典（目前尚未嵌套）。\n     - 定义在 `btgym\u002Fspaces.py` 中。\n     - `raw_state` 是默认的 OHLC 价格 Box 空间。继承 `BTgymStrategy` 类并重写 `get_state()` 方法，以计算环境观测的所有部分。\n     - 只要观测字典中的每个条目都是秩不超过 3 的 Box 空间，并且在环境的 `render_modes` 关键字参数中传递相同的键，就可以对观测字典中的每个条目进行渲染。\n            “Agent” 模式已更名为“state”。请参阅更新后的示例。\n\n\n- 07.08.17：BTgym 现在针对多环境实例的异步操作进行了优化。\n     - 使用专门的数据服务器来管理数据集；\n     - 整体内部网络连接的稳定性和错误处理得到了改进；\n     - 请参阅 [`examples`](.\u002Fexamples) 目录下的示例 `async_btgym_workers.ipynb`。\n\n- 15.07.17：更新，向后不兼容：现在状态观测可以是任意秩的张量。\n     - 因此，维度顺序约定发生了变化，以确保与现有 TensorFlow 模型的兼容性：时间嵌入从现在起成为第一个维度，例如，形状为 (30, 20, 4) 的状态表示 30 步的时间嵌入，包含 20 个特征和 4 个“通道”。为了仅进行二维可视化，只能渲染其中一个“通道”，可通过设置环境关键字参数 `render_agent_channel=0` 来选择；\n     - 示例已更新；\n     - 现在做好比以后再做更好。\n\n- 11.07.17：渲染大战仍在继续：在内存占用较低的情况下提高了稳定性，\n            新增了环境关键字参数 `render_enabled=True`；当设置为 `False` 时\n             - 所有渲染功能都会被禁用。这有助于提升性能。\n\n- 5.07.17：添加了 TensorBoard 监控包装器；修复了 pyplot 的内存泄漏问题。\n\n- 30.06.17：示例更新，新增了“设置：全速前进”的操作指南。\n\n- 29.06.17：升级：请务必运行 `pip install --upgrade -e .`\n    - 重大渲染重构：新增了 `human`、`agent`、`episode` 等模式；渲染过程现在由服务器执行，并以 `rgb numpy 数组` 的形式返回给环境。图像可以通过 matplotlib 或 pillow.Image（推荐）显示。\n    - 新增了“渲染操作指南”，并更新了“基本设置”示例。\n    - 内部改动：环境状态分为 `raw_state`（价格数据）和 `state`（特征化表示）。策略类中新增了 `get_raw_state()` 方法。\n    - 新的软件包依赖：`matplotlib` 和 `pillow`。\n\n- 25.06.17：\n  实现了基础渲染功能。\n\n- 23.06.17：\n  alpha 0.0.4：\n  添加了跳帧功能，\n  重新定义了参数继承逻辑，\n  提升了整体稳定性；\n\n- 17.06.17：\n  首个可用的 alpha 版本 v0.0.2。\n\n\n\u003Ca href=\"https:\u002F\u002Fstackexchange.com\u002Fusers\u002F10204071\u002Fandrew-muzikin\">\u003Cimg src=\"https:\u002F\u002Fstackexchange.com\u002Fusers\u002Fflair\u002F10204071.png\" width=\"208\" height=\"58\" alt=\"profile for Andrew Muzikin on Stack Exchange, a network of free, community-driven Q&amp;A sites\" title=\"profile for Andrew Muzikin on Stack Exchange, a network of free, community-driven Q&amp;A sites\" \u002F>\u003C\u002Fa>","# BTGym 快速上手指南\n\nBTGym 是一个基于 Backtrader 构建、兼容 OpenAI Gym API 的可扩展事件驱动强化学习回测库。它旨在为算法交易环境中的强化学习实验提供框架支持。\n\n> **注意**：本项目处于研究\u002F开发阶段，代码可能不稳定且随时变动。它并非“开箱即用”的盈利工具，使用者需具备一定的编程能力及强化学习理论基础。\n\n## 1. 环境准备\n\n在开始之前，请确保您的系统满足以下要求：\n\n*   **操作系统**：推荐 Linux 或 macOS（Windows 支持尚不完善）。\n*   **Python 版本**：Python 3.5 或更高版本。\n*   **系统工具**：必须安装 `lsof` 实用程序（部分 Linux 发行版默认未安装，可通过包管理器安装，如 `sudo apt-get install lsof`）。\n*   **关键依赖版本**：**Matplotlib 必须为 2.0.2 版本**。如果您已安装 2.1 或更高版本，请先降级，否则会导致运行错误。\n\n## 2. 安装步骤\n\n建议在专用的虚拟环境中运行 BTGym 以避免依赖冲突。\n\n### 第一步：克隆仓库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym.git\ncd btgym\n```\n\n### 第二步：调整 Matplotlib 版本\n在安装主程序前，强制安装指定版本的 Matplotlib：\n```bash\npip install matplotlib==2.0.2\n```\n*(国内用户可使用清华源加速：`pip install matplotlib==2.0.2 -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple`)*\n\n### 第三步：安装 BTGym 及依赖\n使用编辑模式安装，以便后续开发或更新：\n```bash\npip install -e .\n```\n*(国内用户可使用清华源加速：`pip install -e . -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple`)*\n\n### 升级现有安装\n如果需要更新到最新版本：\n```bash\ncd btgym\ngit pull\npip install --upgrade -e .\n```\n\n## 3. 基本使用\n\nBTGym 的核心是创建一个继承自 Gym 环境的交易环境。以下是两种最常用的初始化方式。\n\n### 最小化示例（默认参数）\n使用默认配置快速加载一个外汇数据文件并创建环境：\n\n```python\nfrom btgym import BTgymEnv\n\nMyEnvironment = BTgymEnv(filename='..\u002Fexamples\u002Fdata\u002FDAT_ASCII_EURUSD_M1_2016.csv')\n```\n\n### 自定义配置示例\n通过传递参数控制回测时长、最大回撤阈值、状态空间形状等：\n\n```python\nfrom gym import spaces\nfrom btgym import BTgymEnv\n\nMyEnvironment = BTgymEnv(\n    filename='..\u002Fexamples\u002Fdata\u002FDAT_ASCII_EURUSD_M1_2016.csv',\n    episode_duration={'days': 2, 'hours': 23, 'minutes': 55},  # 设置单集时长\n    drawdown_call=50,                                         # 设置最大回撤阈值\n    state_shape=dict(raw=spaces.Box(low=0, high=1, shape=(30, 4))), # 定义状态空间\n    port=5555,                                                # 指定端口\n    verbose=1,                                                # 开启详细日志\n)\n```\n\n**下一步建议**：\n初始化环境后，您可以像使用标准 OpenAI Gym 一样调用 `reset()`, `step(action)`, 和 `render()` 方法来训练您的强化学习代理。更多高级用法请参考项目 `examples` 目录下的示例代码。","某量化团队正尝试利用深度强化学习（DRL）训练一个能自适应市场变化的外汇交易机器人，需处理海量历史行情与复杂的状态空间。\n\n### 没有 btgym 时\n- **环境搭建割裂**：开发者需手动编写代码桥接 Backtrader 回测引擎与 OpenAI Gym 接口，耗费数周时间处理数据对齐与状态重置逻辑。\n- **实验扩展性差**：难以模拟真实交易中的非平稳随机环境，一旦加入宏观经济指标等外部数据源，原有架构极易崩溃。\n- **调试成本高昂**：缺乏标准化的事件驱动机制，导致智能体在长周期回测中难以复现特定市场情境下的决策错误。\n- **算法适配困难**：主流深度学习框架无法直接调用回测环境，研究人员需反复转换数据格式，严重拖慢模型迭代速度。\n\n### 使用 btgym 后\n- **无缝集成架构**：btgym 原生封装了 Backtrader 与 Gym API，仅需几行代码即可将 EURUSD 分钟级数据转化为标准的强化学习环境。\n- **灵活场景定义**：支持自定义状态空间形状与外部数据流（如新闻情绪指数），轻松构建包含无风险资产与多风险资产的复杂交易场景。\n- **高效事件驱动**：内置可扩展的事件驱动机制，允许智能体在长达数天的回测片段中稳定运行，快速定位策略失效点。\n- **深度学习友好**：直接输出符合 TensorFlow 或 PyTorch 输入的张量格式，让团队能专注于优化神经网络结构而非数据管道。\n\nbtgym 通过标准化回测环境与强化学习的交互接口，将原本数月的环境搭建工作缩短至几天，使团队能专注于核心策略的算法创新。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FKismuz_btgym_8fade04c.png","Kismuz","Andrew","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FKismuz_3b934daf.jpg","Applied mathematics and machine learning Research and Software Engineer with focus on deep reinforcement learning and quantitative finance domain. ",null,"Moscow","muzikinae@gmail.com","https:\u002F\u002Fwww.linkedin.com\u002Fin\u002F%D0%B0%D0%BD%D0%B4%D1%80%D0%B5%D0%B9-%D0%BC%D1%83%D0%B7%D1%8B%D0%BA%D0%B8%D0%BD-06102294\u002F","https:\u002F\u002Fgithub.com\u002FKismuz",[82,86,90,94],{"name":83,"color":84,"percentage":85},"Python","#3572A5",97.5,{"name":87,"color":88,"percentage":89},"Jupyter Notebook","#DA5B0B",2.4,{"name":91,"color":92,"percentage":93},"Dockerfile","#384d54",0.1,{"name":95,"color":96,"percentage":93},"Shell","#89e051",1031,258,"2026-04-13T08:57:33","LGPL-3.0",4,"Linux, macOS","未说明",{"notes":105,"python":106,"dependencies":107},"1. 必须将 Matplotlib 版本降级至 2.0.2，版本 2.1 及以上不兼容。\n2. 操作系统需安装 'lsof' 实用工具（部分 Linux 发行版默认未安装）。\n3. 未在 Windows 上进行测试，可能无法正常工作。\n4. 该项目处于研究\u002F开发阶段，代码可能不稳定且存在缺陷。\n5. 导入顺序很重要：建议先导入 backtrader 和 btgym，再导入 pyplot，以避免 matplotlib 后端警告。","3.5+",[108,109,110,111],"backtrader","gym","matplotlib==2.0.2","lsof (system utility)",[14],[114,115,116,117,118,119,120,121,122,108,123,124,125,126,127,128,129,130],"reinforcement-learning","deep-reinforcement-learning","gym-environment","openai-gym","backtesting-trading-strategies","algorithmic-trading-library","time-series","a3c","tensorflow","unreal","advantage-actor-critic","policy-optimisation","policy-gradient","quantitive-finance","algoritmic-trading","statistical-arbitrage","hacktoberfest","2026-03-27T02:49:30.150509","2026-04-20T04:06:37.391045",[134,139,144,148,152,156,160],{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},43113,"如果我想使用重采样后的低频数据（如 5 分钟或 30 分钟）而不是 1 分钟数据，是否只需更改 BTgymRandomDataDomain 初始化时的 timeframe 参数？","是的，对于 `BTgymDataset` 类，处理方式是一样的。你可以使用 pandas.resample() 将历史数据下采样到更低频率（例如 5 分钟），然后在初始化 `BTgymRandomDataDomain` 时仅更改 `timeframe` 参数即可。维护者确认该想法是可行的。","https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fissues\u002F54",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},43114,"如何在策略中实现多个编码器（Separate Encoders）？是否需要将外部状态形状定义为嵌套字典？","是的，必须将外部状态形状（external state shape）声明为嵌套字典。同时，从 `get_external_state()` 方法返回一个字典也是可以的，因为系统尚未实现自动的嵌套方法查找。具体实现可参考源码中的策略文件（strategy.py），其中展示了如何定义嵌套字典形状以及如何返回字典以分离编码器。","https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fissues\u002F35",{"id":145,"question_zh":146,"answer_zh":147,"source_url":143},43115,"使用多个共享参数的编码器与使用单个编码器有什么区别？","两者略有不同。如果将几个相似的信号堆叠起来输入单个编码器，它们会在通道维度上混合。而如果将相同的信号输入到共享编码器中，整个系统的行为会更像“信号可分离卷积”（signal-wise separable convolutions）。理论上虽然等价，但实际上学习到的激活值和特征会有所不同。",{"id":149,"question_zh":150,"answer_zh":151,"source_url":143},43116,"在 Windows 上运行 A3C 示例时遇到\"[WinError 2] The system cannot find the file specified\"错误怎么办？","这是一个已知的兼容性问题。虽然 Issue 中未直接给出修复命令，但该类错误通常与路径配置或缺少依赖有关。建议检查 TensorFlow 在 Windows 上的 GPU 支持配置，并确保所有环境变量和文件路径正确。如果是多进程问题，可能需要调整启动方法或检查 Python 多进程在 Windows 下的兼容性设置（如使用 'spawn' 启动模式）。",{"id":153,"question_zh":154,"answer_zh":155,"source_url":143},43117,"在使用自定义数据（如股票数据）时遇到 tanh(x_sma) 溢出问题，将 T2 值从 2000 改为 1 是否正确？","将 T2 值从 2000 调整为 1 可以解决溢出问题，这通常是因为输入数据的尺度（scale）过大导致激活函数饱和。虽然这是一个有效的临时修复，但更推荐的做法是对输入数据进行适当的归一化或缩放处理，以确保数值稳定性，而不仅仅是硬编码修改超参数。",{"id":157,"question_zh":158,"answer_zh":159,"source_url":143},43118,"如何处理非 24\u002F7 交易的数据（如美股只在特定时间段交易）导致的数据一致性问题？","当使用非连续交易数据（如美股早盘到晚盘）替代 Forex 的 24\u002F7 数据时，可能会出现数据一致性错误。建议在数据预处理阶段填充缺失的时间戳或使用掩码（masking）来处理非交易时段，确保输入到环境中的数据序列在时间索引上是连续的，或者调整环境配置以接受不规则的时间间隔。",{"id":161,"question_zh":162,"answer_zh":163,"source_url":164},43119,"在使用 BTgymMultiData 和过滤器时遇到\"too many values to unpack (expected 4)\"或\"No \u003Cctrl> key received\"错误是什么原因？","这是一个与环境状态重置相关的 Bug，特别是在使用多个数据源（BTgymMultiData）并结合 backtrader 过滤器时容易发生。维护者指出这与修复其他问题时引入的\"hanging done\"状态有关。解决方案是确保在每次运行开始前正确调用 `reset()` 或 `reset_data()` 方法，并检查是否已更新到修复了该问题的最新版本。","https:\u002F\u002Fgithub.com\u002FKismuz\u002Fbtgym\u002Fissues\u002F95",[]]