[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-saeed349--Microservices-Based-Algorithmic-Trading-System":3,"tool-saeed349--Microservices-Based-Algorithmic-Trading-System":62},[4,18,26,36,46,54],{"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 真正成长为懂上",159267,2,"2026-04-17T11:29:14",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":42,"last_commit_at":43,"category_tags":44,"status":17},8272,"opencode","anomalyco\u002Fopencode","OpenCode 是一款开源的 AI 编程助手（Coding Agent），旨在像一位智能搭档一样融入您的开发流程。它不仅仅是一个代码补全插件，而是一个能够理解项目上下文、自主规划任务并执行复杂编码操作的智能体。无论是生成全新功能、重构现有代码，还是排查难以定位的 Bug，OpenCode 都能通过自然语言交互高效完成，显著减少开发者在重复性劳动和上下文切换上的时间消耗。\n\n这款工具专为软件开发者、工程师及技术研究人员设计，特别适合希望利用大模型能力来提升编码效率、加速原型开发或处理遗留代码维护的专业人群。其核心亮点在于完全开源的架构，这意味着用户可以审查代码逻辑、自定义行为策略，甚至私有化部署以保障数据安全，彻底打破了传统闭源 AI 助手的“黑盒”限制。\n\n在技术体验上，OpenCode 提供了灵活的终端界面（Terminal UI）和正在测试中的桌面应用程序，支持 macOS、Windows 及 Linux 全平台。它兼容多种包管理工具，安装便捷，并能无缝集成到现有的开发环境中。无论您是追求极致控制权的资深极客，还是渴望提升产出的独立开发者，OpenCode 都提供了一个透明、可信",144296,1,"2026-04-16T14:50:03",[13,45],"插件",{"id":47,"name":48,"github_repo":49,"description_zh":50,"stars":51,"difficulty_score":32,"last_commit_at":52,"category_tags":53,"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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[14,15,13],{"id":55,"name":56,"github_repo":57,"description_zh":58,"stars":59,"difficulty_score":32,"last_commit_at":60,"category_tags":61,"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",[45,13,15,14],{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":78,"owner_email":79,"owner_twitter":77,"owner_website":77,"owner_url":80,"languages":81,"stars":101,"forks":102,"last_commit_at":103,"license":104,"difficulty_score":105,"env_os":106,"env_gpu":107,"env_ram":107,"env_deps":108,"category_tags":120,"github_topics":77,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":121,"updated_at":122,"faqs":123,"releases":151},8665,"saeed349\u002FMicroservices-Based-Algorithmic-Trading-System","Microservices-Based-Algorithmic-Trading-System","MBATS is a docker based platform for developing, testing and deploying Algorthmic Trading strategies with a focus on Machine Learning based algorithms.","Microservices-Based-Algorithmic-Trading-System（简称 MBATS）是一个基于 Docker 容器化技术构建的微服务量化交易平台，专为开发和部署机器学习驱动的程序化交易策略而设计。它旨在解决量化研究员在搭建交易基础设施时面临的繁琐痛点，通过整合一系列成熟的开源工具，让用户能在几分钟内将交易想法从概念验证推进到生产环境。\n\n该平台非常适合量化开发者、数据科学家以及算法交易研究人员使用。其核心亮点在于高度模块化的架构：利用 Backtrader 进行策略回测，借助 MLflow 高效管理机器学习模型生命周期，使用 PostgreSQL 存储市场数据，并通过 Minio 对象存储处理文件。此外，MBATS 利用 Apache Airflow 编排复杂任务流程，配合 Superset 实现策略性能的可视化监控。用户只需一条命令即可在本地或云端启动包含 Jupyter Notebook、PgAdmin 等全套组件的开发环境，极大地降低了构建专业级量化系统的技术门槛和时间成本，让创作者能更专注于策略逻辑本身而非底层运维。","\u003Cp align=\"center\">\n    \u003Ca target=\"_blank\">\u003Cimg width=\"200\" height=\"50\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_1340a4c8397c.png\" alt=\"MBATS Logo\">\u003C\u002Fa>\n    \u003Cbr \u002F>\n    \u003Cbr \u002F>\n    \u003Cb>Microservices Based Algorithmic Trading System\u003C\u002Fb>\n    \u003Cbr \u002F>\n    \u003Cbr \u002F>\n\u003C\u002Fp>\n\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-BSD%203--Clause-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FBSD-3-Clause)\n\n---\n\nMBATS is a docker based platform for developing, testing and deploying Algorthmic Trading strategies with a focus on Machine Learning based algorithms.\n\nMBATS aim to make a Quant's life a lot easier by providing a modular easy to setup trading infrastrucutre based on open source tools that can get his\u002Fher trading strategy from idea to production within few minutes.\n\nUsing MBATS, you can easily create Trading Strategies in Backtrader, manage Machine Learning models with MLflow, use Postgres database with pgAdmin for storing and querying Market data. Store files and objects in Minio and use Superset to visualize performance of backtested and live strategies. And tie all the different components together and orchestrate jobs using Airflow and many more features to help you get started from idea to live trading faster and with least effort.\n\n[Linkedin Article about MBATS](https:\u002F\u002Fwww.linkedin.com\u002Fpulse\u002Fmicroservices-based-algorithmic-trading-system-saeed-rahman\u002F?trackingId=dsWm4zZBRIe3%2FznJMBaBHQ%3D%3D)\n\nUpdates:\n- 2024 - [Quant Infra Design](https:\u002F\u002Fgithub.com\u002Fsaeed349\u002Fquant_infra\u002Fwiki) and [Linkedin Article](https:\u002F\u002Fwww.linkedin.com\u002Fpulse\u002Fquant-platform-cash-equities-saeed-rahman-txw3c\u002F)\n- 2021 - [MBATS V2.0](https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FMicroservices-Based-Algorithmic-Trading-System-V-2.0) and [Cloud Version](https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FQuant-Trading-Cloud-Infrastructure) are now available.\nAlso,[Linkedin Article on scaling MBATS to the cloud using Terraform](https:\u002F\u002Fwww.linkedin.com\u002Fpost\u002Fedit\u002F6619730514188267520\u002F) \u003Cbr>\n\n\n\n![MBATS](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_89ccafade374.png)\n\nTable of Contents:\n\n- [Quickstart](#Quickstart)\n- [Getting Started](#getting-started)\n  - [Backtrader](#Backtrader)\n  - [MLflow](#MLflow)\n  - [Airflow](#Apache-Airflow)\n  - [Superset](#Apache-Superset)\n  - [Minio](#Minio)\n  - [PostgreSQL](#Postgres)\n- [Cloud](#Cloud)\n- [Current Features](#Current-Features)\n- [Planned Features](#Planned-Features)\n- [Contributing](#Contributing)\n- [License](#License)\n- [Authors](#Authors)\n- [Acknowledgments](#Acknowledgments)\n      \n## Quickstart\nCheck out the video below to see the platform in action  \n[\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_5a8d13a00e2a.jpg\" width=\"80%\">](https:\u002F\u002Fyoutu.be\u002FhLSGgW4-WC8)\n\n\nMBATS is based on Docker containers. Running your Infrastructure is as easy as running one command from your terminal. You can either run MBATS on your local machine or on the cloud using docker-compose. The easiest way to setup MBATS is by running the docker-compose file. Before running the installation command make sure you have [Docker](https:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-desktop) installed on your machine. \n\n\n1. Downlod\u002FClone the Github Repository (Make sure your Docker Machine has access to the location):  \n  ```git clone https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FMicroservices-Based-Algorithmic-Trading-System.git```\n2. Update the 'WD' variable in .env file to the location of the Cloned directory.\n3. Run docker compose:  \n ```docker-compose up -d --build```  \nFirst run would take some time as all the Docker base images need to be downloaded.  \nOnce its is running, you can access the following components from the webaddress\n    * Jupyter Notebook:http:\u002F\u002Flocalhost:8888\n    * Airflow: http:\u002F\u002Flocalhost:8080\n    * MLflow: http:\u002F\u002Flocalhost:5500\n    * PgAdmin: http:\u002F\u002Flocalhost:1234\n    * Superset: http:\u002F\u002Flocalhost:8088\n    * Minio: http:\u002F\u002Flocalhost:9000\n\n4. Run the script to setup up the database schema   \n```.\\starter_script.bat```\n5. All the infrastructure and business logic is in *Storage* folder and the necessary components are shared across containers.  \n    - [Trading Strategies](.\u002FStorage\u002Fq_pack\u002Fq_strategies)\n    - [Analyzers](.\u002FStorage\u002Fq_pack\u002Fq_analyzers)\n    - [Datafeed Connectors](.\u002FStorage\u002Fq_pack\u002Fq_datafeeds)\n    - [Airflow DAGS](.\u002FStorage\u002Fairflow\u002Fdags)\n    - [Supporting files for Airflow](.\u002FStorage\u002Fminio\u002Fstorage\u002Fairflow-files)\n    - [Minio Storage](.\u002FStorage\u002Fminio)\n    - [DB Schema builder code](.\u002FStorage\u002Fq_pack\u002Fdb_pack)\n    - [Machine Learning input files](.\u002FStorage\u002Fminio\u002Fstorage\u002Fmodel-support-files)(.\u002FStorage\u002Fminio\u002Fstorage\u002Fmodel-support-files)\n    - [MLflow artifacts](.\u002FStorage\u002Fminio\u002Fstorage\u002Fmlflow-models)\n    \n6. You can choose what Securities to download by listing it in [*interested_tickers.xlsx*](.\u002FStorage\u002Fminio\u002Fstorage\u002Fairflow-files\u002F)\nThe *daily* tab for listing the Securities for which EOD data is to be downloaded and *minute* tab for downloading at 1 minute interval. \n7. Turn on the [*fx_data_download*](.\u002FStorage\u002Fairflow\u002Fdags\u002Fdag_fx_data_download.py)  DAG in Airflow(http:\u002F\u002Flocalhost:8080) and this will download the Daily and Minute data for Securities you have set in the *interested_tickers.xlsx*\n8. Go to Jupyter Notebook (http:\u002F\u002Flocalhost:8888) and use the Notebook [*Example.ipynb*](.\u002FStorage\u002Fnotebooks\u002FExample.ipynb) to run through the example strategy implementation where you can \n    - Run Backtrader trading strategies (Backtest or Live)\n    - Preprocess the logs (Market Data and Indicator for each run) for preparing for Machine Learning model. \n    - Run Machine Learning models on the preprocessed data and track it to MLflow.\n    - Serve the Machine Learning Artifcat(model) via MLflow\n    - Bonus features of MLflow (Packaging and Serving via Rest API)\n9. To check the Backtest or Live trading results go to Superset:http:\u002F\u002Flocalhost:8088\n10. You can schedule Live trading strategies by using the [strategy.csv](.\u002FStorage\u002Fminio\u002Fstorage\u002Fairflow-files) and the dynamic DAG [dag_strategy_dynamic](.\u002FStorage\u002Fairflow\u002Fdags\u002Fdag_strategy_dynamic.py) \n\n\n\n## Architecture\n\n![MBATS Architecture](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_9e883b6ba3d0.png)\n\nMBATS is a collection of 9 docker containers acting synchronously to create an environment to develop and productionise trading strategies with ease. The main parts of MBATS are as follows.\n\n### [Backtrader](https:\u002F\u002Fwww.backtrader.com\u002F)\nBacktrader is a python based opensource event-driven trading strategy backtester with support for live trading. The reason why I choose Backtrader over other opensource backtesters like  [Zipline](https:\u002F\u002Fgithub.com\u002Fquantopian\u002Fzipline) and [QuantConnect](https:\u002F\u002Fgithub.com\u002FQuantConnect\u002FLean) is because of the good documentation and its community support.\nHere's a list of submodules I have written for this project that are derived from Backtrader package. \n* [**Run**](.\u002FStorage\u002Fq_pack\u002Fq_run\u002Frun_BT.py) - Script that combines the strategy, analyzers and the datafeeds. \n* [**Strategy**](.\u002FStorage\u002Fq_pack\u002Fq_strategies\u002Fsimple_strategy_2.py) - A simple Daily trading strategy that initiates bracket orders based on RSI and Stochastic Indicator.\n* [**Logger Analyzer**](.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_logger_analyzer.py) - Logs the price data and the indicator which is then used for training the Machine Learning model\n* [**Strategy Performance Analyzer**](.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_strat_perform_analyzer.py) - Measures  the performance of the strategy and save it in the database which is later consumed in BI tool (Superset).\n* [**Round trip trade Performance Analyzer**](.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_pos_perform_analyzer.py) - Measures difference performance metrics of round trip trades and save it in the database which is later consumed in BI tool (Superset).\n* [**Transaction Analyzer**](.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_pos_perform_analyzer.py) - Records the executed orders into the database. \n* [**Stategy ID Analyzer**](h.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_pos_perform_analyzer.py) - Keep a record of the metadata of the backtest or live strategy ran.\n* [**Oanda Broker Store**](https:\u002F\u002Fgithub.com\u002Fftomassetti\u002Fbacktrader-oandav20) - Oanda Broker Integration for Backtrader live trading\n* [**Postgress Data Feed**](.\u002FStorage\u002Fq_pack\u002Fq_datafeeds\u002Fbt_datafeed_postgres.py)\n\n\u003Cp align=\"center\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_5f20dfdfcd6f.png\" width=\"700\" height=\"500\"\u002F>\u003C\u002Fp>\n\n\n### [MLflow](https:\u002F\u002FMLflow.org\u002F)\n\nAnyone who has worked in the Datascience field would have heard about [Spark](https:\u002F\u002Fspark.apache.org\u002F), well the founders of Spark have brought a similar disruptive tool to revolutionize the Machine Learning landscape and that is MLflow. MLflow is an open source platform to manage the ML lifecycle, including experimentation, reproducibility and deployment. It currently offers four components:\n* MLflow Tracking\n* MLflow Projects\n* MLflow Models\n* MLflow Registry\n\nThere are a few other organizations that try to address this problem but what seperates MLflow from the likes of [Google-TFX](https:\u002F\u002Fwww.tensorflow.org\u002Ftfx), [Facebook-FBLearner Flow](https:\u002F\u002Fengineering.fb.com\u002Fcore-data\u002Fintroducing-fblearner-flow-facebook-s-ai-backbone\u002F) and [Uber-Michelangelo](https:\u002F\u002Feng.uber.com\u002Fmichelangelo\u002F) is that MLflow try to address the concerns of the crowd rather than a single organization and therefore they are universal and community driven to an extend that [AWS](https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fmachine-learning\u002Fbuild-end-to-end-machine-learning-workflows-with-amazon-sagemaker-and-apache-airflow\u002F) and [Azure](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fazure\u002Fmachine-learning\u002Fhow-to-use-MLflow) has provided integration for MLflow. \n\nIn this project all the ML model can be tracked by the MLflow Tracker and the model artifacts are stored in Minio, the main reason for doing so is that later on I can swap Minio for a Cloud object store like S3. The ML models are then served using MLflow pyfunc. We also have the option to serve the model as Rest API using MLflow (code in sample jupyter notebook)\n    \n## [Apache Airflow](https:\u002F\u002Fairflow.apache.org\u002F)\nApache Airflow is an open-source workflow management platform, basically Chron on steroids and it has wide array of integration with popular platforms and data stores. \nIn this this project we use airflow for scheduling two tasks mainly. One [DAG](.\u002FStorage\u002Fairflow\u002Fdags\u002Fdag_fx_data_download.py) for downloading daily and minute data into the Database controlled by an excel file and another [Dynamic DAG](.\u002FStorage\u002Fairflow\u002Fdags\u002Fdag_strategy_dynamic.py) for schedulling live strategies controlled by a csv file. \n\n## [Apache Superset](https:\u002F\u002Fsuperset.apache.org\u002F)\nFrom the creators of Apache Airflow, Apache Superset is a Data Visualization tool initially designed by Airbnb and later open sourced for the community.\nSuperset is an interactive Data Exploration tool that will let you slice, dice and visualize data. Why pay for Tableau and PowerBi when you can use something that is opensource. We use Superset to visualize Backtesting and Live trading performance.  \n\nUsername:guest  \nPassword:guest \n\nThe dashboards and user details are stored in Storage\u002Fsuperset\u002Fsuperset.db   \nIf you want to reset the credentials and create reset, just delete this sqlite [superset.db](.\u002FStorage\u002Fsuperset\u002F) and create a new one with  \n```touch superset.db```  \nThen once the container is up and running execute  \n```docker exec -it superset superset-init```\n\n![Superset Dashboard](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_e1dd71f7ce4f.png)\n## [Minio](https:\u002F\u002Fmin.io\u002F)\nMinIO is pioneering high performance object storage. With READ\u002FWRITE speeds of 55 GB\u002Fs and 35 GB\u002Fs on standard hardware, object storage can operate as the primary storage tier for a diverse set of workloads. Amazon’s S3 API is the defacto standard in the object storage world and represents the most modern storage API in the market. MinIO adopted S3 compatibiity early on and was the first to extend it to support S3 Select. Because of this S3 Compatibility by using Minio we have an upper hand of moving this object store towards cloud (AWS S3, Google Cloud Storage, Azure Storage) with minimal change to the codebase.\n\n## [PostgreSQL](https:\u002F\u002Fwww.postgresql.org\u002F)\nWe have 2 Databases in our PosgresSQL server, 1 is the Security Master database that stores the Daily and Minute data for Forex Symbols in 2 seperate tables. \nAnother Database is used for storing the position information and the performance metrics. \nThe Databases can be managed through PgAdmin  \nUsername:guest  \nPass:guest\n\n## Cloud\nMEvery technology used in this project has a analogues managed service offered in the cloud. And the best part of scaling a microservices based architecture is that you can approach it in many ways to fits your need. Whether you want to move one functionality to the cloud or if you want to offload the workload of a component to the Cloud but keep all the critical parts on premise, the migration is quite easy when compared to a monolithic architecture. Moreover if the Cloud service is using the same technology then the migration is effortless. A simple example for this is GCP Cloud Composer which is built on top of Apache Airflow and Kubernetes which means that all the tasks\u002FDAG's that we are using in this project can be used in Cloud Composer as well. In general I have found GCP has a better strategy and technology in place for building a hybrid Cloud infrastructure and for that reason here's an architecture if this project has to be transferred entirely into the GCP platform.\n![MBATS Cloud Architecture](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_26dfada8fa41.png)\n\n## Current-Features\n* Infrastructure as Code – less than 5 minutes from scratch to a fully functional trading infrastructure.\n* Backtesting and Live trading Forex using Oanda Broker API (Can be easily be modified to accommodate IB for Equity).\n* Machine Learning model development and deployment using MLflow.\n* Multiple symbol strategy support.\n* Multiple strategy support.\n* Superset BI Dashboard for real-time monitoring of Live trading and backtesting performance results.\n* Easily extensible to support any kind of structured data.\n* Full code base in Python except for docker-compose setup.\n\n\n## Planned-Features\n\n* Support for Equity Database (Backtrader supports [Interactive Brokers out of the box](https:\u002F\u002Fwww.backtrader.com\u002Fdocu\u002Flive\u002Fib\u002Fib\u002F))\n* Celery\u002FKubernetes cluster support for Airflow\n* More performance and trade analytics dashboards on Superset \n* Dynamic DAG for model retraining.\n* More Backtrader Examples involving -\n    - Custom Indicators.\n    - Alternative Data (Unstructured Data Pipeline)\n    - [Reinforcement Learning](https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FDeep-Reinforcement-Learning-in-Trading).\n* Use [MLflow Model Registry](https:\u002F\u002Fwww.MLflow.org\u002Fdocs\u002Flatest\u002Fmodel-registry.html).\n* Integrate [Alpaca API Store](https:\u002F\u002Falpaca.markets\u002F)\n* Automatic Model Selection for Strategies based on ML performance metrics.\n\n## Built With\nThis project has been devloped and tested on 2 Docker environments\n* [WSL](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fwindows\u002Fwsl\u002Fabout)\n* [Docker Toolbox](https:\u002F\u002Fdocs.docker.com\u002Ftoolbox\u002Ftoolbox_install_windows\u002F). \n* IDE - Visual Studio Code: Main reason being the [Container Debugger Feature](https:\u002F\u002Fcode.visualstudio.com\u002Fdocs\u002Fremote\u002Fcontainers#_debugging-in-a-container) \n\n\n## Contributing\n\nAll code contributions must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code.\n\n## License\n\nThis repository is available under the [BSD 3-Clause License](.\u002FLICENSE).\n\n## Authors\n\n* **Saeed Rahman** - [LinkedIn](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fsaeed-349\u002F)\n\n\n## Acknowledgments\n\n* [Backtrader community](https:\u002F\u002Fcommunity.backtrader.com\u002F)\n* [Backtest-rookies](https:\u002F\u002Fbacktest-rookies.com\u002Fcategory\u002Fbacktrader\u002F)  \n* [Backtrader Oanda V20 Store](https:\u002F\u002Fgithub.com\u002Fftomassetti\u002Fbacktrader-oandav20)\n* [Beyond Jupyter notebook - Udemy course](https:\u002F\u002Fwww.udemy.com\u002Fcourse\u002Fbeyond-jupyter-notebooks\u002F)\n* [Quantstart](https:\u002F\u002Fwww.quantstart.com\u002F)\n","\u003Cp align=\"center\">\n    \u003Ca target=\"_blank\">\u003Cimg width=\"200\" height=\"50\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_1340a4c8397c.png\" alt=\"MBATS Logo\">\u003C\u002Fa>\n    \u003Cbr \u002F>\n    \u003Cbr \u002F>\n    \u003Cb>基于微服务的算法交易系统\u003C\u002Fb>\n    \u003Cbr \u002F>\n    \u003Cbr \u002F>\n\u003C\u002Fp>\n\n[![许可证](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-BSD%203--Clause-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FBSD-3-Clause)\n\n---\n\nMBATS 是一个基于 Docker 的平台，用于开发、测试和部署算法交易策略，尤其专注于基于机器学习的算法。\n\nMBATS 的目标是通过提供一套模块化且易于搭建的开源工具组成的交易基础设施，帮助量化交易员将他们的交易策略从想法快速落地到生产环境，从而大大简化工作流程。\n\n使用 MBATS，您可以轻松地在 Backtrader 中创建交易策略，用 MLflow 管理机器学习模型，利用 Postgres 数据库和 pgAdmin 存储及查询市场数据。您还可以将文件和对象存储在 Minio 中，并使用 Superset 可视化回测和实盘策略的表现。此外，借助 Airflow 将各个组件串联起来并编排任务，以及更多功能，帮助您以最少的努力更快地实现从策略构思到实盘交易的过程。\n\n[关于 MBATS 的 LinkedIn 文章](https:\u002F\u002Fwww.linkedin.com\u002Fpulse\u002Fmicroservices-based-algorithmic-trading-system-saeed-rahman\u002F?trackingId=dsWm4zZBRIe3%2FznJMBaBHQ%3D%3D)\n\n更新：\n- 2024 年 - [量化基础设施设计](https:\u002F\u002Fgithub.com\u002Fsaeed349\u002Fquant_infra\u002Fwiki) 和 [LinkedIn 文章](https:\u002F\u002Fwww.linkedin.com\u002Fpulse\u002Fquant-platform-cash-equities-saeed-rahman-txw3c\u002F)\n- 2021 年 - [MBATS V2.0](https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FMicroservices-Based-Algorithmic-Trading-System-V-2.0) 和 [云版本](https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FQuant-Trading-Cloud-Infrastructure) 现已发布。\n同时，[关于如何使用 Terraform 将 MBATS 扩展到云端的 LinkedIn 文章](https:\u002F\u002Fwww.linkedin.com\u002Fpost\u002Fedit\u002F6619730514188267520\u002F) \u003Cbr>\n\n\n\n![MBATS](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_89ccafade374.png)\n\n目录：\n\n- [快速入门](#Quickstart)\n- [开始使用](#getting-started)\n  - [Backtrader](#Backtrader)\n  - [MLflow](#MLflow)\n  - [Airflow](#Apache-Airflow)\n  - [Superset](#Apache-Superset)\n  - [Minio](#Minio)\n  - [PostgreSQL](#Postgres)\n- [云](#Cloud)\n- [当前功能](#Current-Features)\n- [计划功能](#Planned-Features)\n- [贡献](#Contributing)\n- [许可证](#License)\n- [作者](#Authors)\n- [致谢](#Acknowledgments)\n      \n## 快速入门\n请观看下方视频，了解平台的实际运行情况  \n[\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_5a8d13a00e2a.jpg\" width=\"80%\">](https:\u002F\u002Fyoutu.be\u002FhLSGgW4-WC8)\n\n\nMBATS 基于 Docker 容器。运行您的基础设施就像在终端中执行一条命令一样简单。您可以在本地机器上或云端使用 docker-compose 运行 MBATS。设置 MBATS 的最简单方法就是运行 docker-compose 文件。在执行安装命令之前，请确保您的机器上已安装 [Docker](https:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-desktop)。\n\n\n1. 下载\u002F克隆 GitHub 仓库（请确保您的 Docker 机器可以访问该位置）：  \n  ```git clone https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FMicroservices-Based-Algorithmic-Trading-System.git```\n2. 将 .env 文件中的 'WD' 变量更新为克隆目录的路径。\n3. 运行 docker compose：  \n ```docker-compose up -d --build```  \n首次运行可能需要一些时间，因为所有 Docker 基础镜像都需要下载。  \n一旦启动，您可以通过以下网址访问各个组件：\n    * Jupyter Notebook：http:\u002F\u002Flocalhost:8888\n    * Airflow：http:\u002F\u002Flocalhost:8080\n    * MLflow：http:\u002F\u002Flocalhost:5500\n    * PgAdmin：http:\u002F\u002Flocalhost:1234\n    * Superset：http:\u002F\u002Flocalhost:8088\n    * Minio：http:\u002F\u002Flocalhost:9000\n\n4. 运行脚本以设置数据库模式   \n```.\\starter_script.bat```\n5. 所有的基础设施和业务逻辑都位于 *Storage* 文件夹中，必要的组件在各个容器之间共享。  \n    - [交易策略](.\u002FStorage\u002Fq_pack\u002Fq_strategies)\n    - [分析器](.\u002FStorage\u002Fq_pack\u002Fq_analyzers)\n    - [数据源连接器](.\u002FStorage\u002Fq_pack\u002Fq_datafeeds)\n    - [Airflow DAG](.\u002FStorage\u002Fairflow\u002Fdags)\n    - [Airflow 支持文件](.\u002FStorage\u002Fminio\u002Fstorage\u002Fairflow-files)\n    - [Minio 存储](.\u002FStorage\u002Fminio)\n    - [数据库模式构建代码](.\u002FStorage\u002Fq_pack\u002Fdb_pack)\n    - [机器学习输入文件](.\u002FStorage\u002Fminio\u002Fstorage\u002Fmodel-support-files)(.\u002FStorage\u002Fminio\u002Fstorage\u002Fmodel-support-files)\n    - [MLflow 工件](.\u002FStorage\u002Fminio\u002Fstorage\u002Fmlflow-models)\n    \n6. 您可以通过在 [*interested_tickers.xlsx*](.\u002FStorage\u002Fminio\u002Fstorage\u002Fairflow-files\u002F) 中列出证券来选择要下载的内容。\n“daily”选项卡用于列出需要下载收盘后数据的证券，“minute”选项卡则用于以每分钟为间隔下载数据。\n7. 在 Airflow（http:\u002F\u002Flocalhost:8080）中启用 [*fx_data_download*](.\u002FStorage\u002Fairflow\u002Fdags\u002Fdag_fx_data_download.py) DAG，它将为您在 *interested_tickers.xlsx* 中设置的证券下载每日和每分钟的数据。\n8. 打开 Jupyter Notebook（http:\u002F\u002Flocalhost:8888），使用笔记本 [*Example.ipynb*](.\u002FStorage\u002Fnotebooks\u002FExample.ipynb) 来运行示例策略实现，您可以在其中：\n    - 运行 Backtrader 交易策略（回测或实盘）\n    - 对日志数据（每次运行的市场数据和指标）进行预处理，以便为机器学习模型做准备。\n    - 在预处理后的数据上运行机器学习模型，并将其跟踪到 MLflow 中。\n    - 通过 MLflow 提供机器学习工件（模型）。\n    - MLflow 的附加功能（打包并通过 Rest API 提供服务）。\n9. 要查看回测或实盘交易结果，请前往 Superset：http:\u002F\u002Flocalhost:8088。\n10. 您可以通过使用 [strategy.csv](.\u002FStorage\u002Fminio\u002Fstorage\u002Fairflow-files) 和动态 DAG [dag_strategy_dynamic](.\u002FStorage\u002Fairflow\u002Fdags\u002Fdag_strategy_dynamic.py) 来安排实盘交易。\n\n\n\n## 架构\n\n![MBATS 架构](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_9e883b6ba3d0.png)\n\nMBATS 是由 9 个 Docker 容器组成的集合，它们同步协作，创建一个轻松开发和部署交易策略的环境。MBATS 的主要组成部分如下。\n\n### [Backtrader](https:\u002F\u002Fwww.backtrader.com\u002F)\nBacktrader 是一个基于 Python 的开源事件驱动型交易策略回测框架，同时也支持实盘交易。我之所以选择 Backtrader 而不是其他开源回测工具，如 [Zipline](https:\u002F\u002Fgithub.com\u002Fquantopian\u002Fzipline) 和 [QuantConnect](https:\u002F\u002Fgithub.com\u002FQuantConnect\u002FLean)，主要是因为它拥有完善的文档和活跃的社区支持。\n以下是我在该项目中基于 Backtrader 框架开发的一些子模块：\n* [**Run**](.\u002FStorage\u002Fq_pack\u002Fq_run\u002Frun_BT.py) - 用于整合策略、分析器和数据源的脚本。\n* [**Strategy**](.\u002FStorage\u002Fq_pack\u002Fq_strategies\u002Fsimple_strategy_2.py) - 一种简单的日线交易策略，根据 RSI 和随机指标发出括号单。\n* [**Logger Analyzer**](.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_logger_analyzer.py) - 记录价格数据和指标，供后续机器学习模型训练使用。\n* [**Strategy Performance Analyzer**](.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_strat_perform_analyzer.py) - 评估策略表现并将其保存到数据库中，供 BI 工具（Superset）调用。\n* [**Round trip trade Performance Analyzer**](.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_pos_perform_analyzer.py) - 对往返交易的不同绩效指标进行测量，并将结果存入数据库，供 BI 工具（Superset）使用。\n* [**Transaction Analyzer**](.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_pos_perform_analyzer.py) - 将已执行的订单记录到数据库中。\n* [**Stategy ID Analyzer**](h.\u002FStorage\u002Fq_pack\u002Fq_analyzers\u002Fbt_pos_perform_analyzer.py) - 用于记录回测或实盘策略的元数据。\n* [**Oanda Broker Store**](https:\u002F\u002Fgithub.com\u002Fftomassetti\u002Fbacktrader-oandav20) - Backtrader 实盘交易中的 Oanda 交易所集成。\n* [**Postgress Data Feed**](.\u002FStorage\u002Fq_pack\u002Fq_datafeeds\u002Fbt_datafeed_postgres.py)\n\n\u003Cp align=\"center\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_5f20dfdfcd6f.png\" width=\"700\" height=\"500\"\u002F>\u003C\u002Fp>\n\n\n### [MLflow](https:\u002F\u002FMLflow.org\u002F)\n\n任何从事数据科学领域的人都应该听说过 [Spark](https:\u002F\u002Fspark.apache.org\u002F)，而 Spark 的创始人又推出了一款类似的颠覆性工具——MLflow，旨在革新机器学习领域。MLflow 是一个开源平台，用于管理机器学习的整个生命周期，包括实验、可重复性和部署。它目前包含四个主要组件：\n* MLflow Tracking\n* MLflow Projects\n* MLflow Models\n* MLflow Registry\n\n尽管还有其他组织也在尝试解决类似问题，但 MLflow 与 [Google-TFX](https:\u002F\u002Fwww.tensorflow.org\u002Ftfx)、[Facebook-FBLearner Flow](https:\u002F\u002Fengineering.fb.com\u002Fcore-data\u002Fintroducing-fblearner-flow-facebook-s-ai-backbone\u002F) 和 [Uber-Michelangelo](https:\u002F\u002Feng.uber.com\u002Fmichelangelo\u002F) 等工具的不同之处在于，MLflow 更注重满足广泛用户群体的需求，而非单一组织的特定需求，因此它具有普适性和社区驱动的特点。正因如此，[AWS](https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fmachine-learning\u002Fbuild-end-to-end-machine-learning-workflows-with-amazon-sagemaker-and-apache-airflow\u002F) 和 [Azure](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fazure\u002Fmachine-learning\u002Fhow-to-use-MLflow) 都为 MLflow 提供了集成支持。\n\n在本项目中，所有机器学习模型都可以通过 MLflow Tracker 进行跟踪，模型工件则存储在 Minio 中。这样做的主要原因是，未来我可以轻松地将 Minio 替换为 S3 等云对象存储服务。随后，这些模型将通过 MLflow pyfunc 提供服务。此外，我们还可以选择使用 MLflow 将模型作为 REST API 提供（代码见示例 Jupyter Notebook）。\n\n## [Apache Airflow](https:\u002F\u002Fairflow.apache.org\u002F)\nApache Airflow 是一个开源的工作流管理平台，可以说是功能更强大的 Chron，它能够与众多流行平台和数据存储系统实现广泛的集成。\n在本项目中，我们主要利用 Airflow 来调度两项任务：一个是 [DAG](.\u002FStorage\u002Fairflow\u002Fdags\u002Fdag_fx_data_download.py)，用于根据 Excel 文件控制每天和每分钟的数据下载至数据库；另一个是 [Dynamic DAG](.\u002FStorage\u002Fairflow\u002Fdags\u002Fdag_strategy_dynamic.py)，用于根据 CSV 文件动态调度实盘策略。\n\n## [Apache Superset](https:\u002F\u002Fsuperset.apache.org\u002F)\nApache Superset 是由 Apache Airflow 的创建者推出的一款数据可视化工具，最初由 Airbnb 开发，后来向社区开源。\nSuperset 是一款交互式的数据探索工具，可以帮助用户对数据进行切片、切块和可视化。既然有开源的选择，为什么还要花钱购买 Tableau 或 Power BI 呢？我们使用 Superset 来可视化回测和实盘交易的表现。\n\n用户名：guest  \n密码：guest  \n\n仪表板和用户信息存储在 Storage\u002Fsuperset\u002Fsuperset.db 中。  \n如果需要重置凭据并重新初始化，只需删除此 SQLite 文件 [superset.db](.\u002FStorage\u002Fsuperset\u002F) 并创建一个新的文件：  \n```touch superset.db```  \n然后在容器启动并运行后，执行以下命令：  \n```docker exec -it superset superset-init```\n\n![Superset 仪表板](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_e1dd71f7ce4f.png)\n## [Minio](https:\u002F\u002Fmin.io\u002F)\nMinIO 是高性能对象存储领域的先驱。在标准硬件上，其读写速度分别可达 55 GB\u002Fs 和 35 GB\u002Fs，使得对象存储可以作为多种工作负载的主要存储层。Amazon S3 API 是对象存储领域的事实标准，也是当前市场上最先进的存储 API。MinIO 很早就采用了 S3 兼容性，并且率先扩展支持 S3 Select 功能。正是由于这种 S3 兼容性，使用 MinIO 可以让我们在几乎不修改代码的情况下，轻松地将存储迁移到云端（如 AWS S3、Google Cloud Storage、Azure Storage）。\n\n## [PostgreSQL](https:\u002F\u002Fwww.postgresql.org\u002F)\n我们的 PostgreSQL 服务器中有两个数据库：一个是安全主数据库，其中包含外汇品种的日线和分钟级数据，分别存储在两张不同的表中。\n另一个数据库则用于存储仓位信息和绩效指标。  \n这些数据库可以通过 PgAdmin 进行管理。  \n用户名：guest  \n密码：guest\n\n## 云\n本项目中使用的每项技术在云端都有对应的托管服务。基于微服务架构的优势在于，你可以根据自身需求选择多种扩展方式。无论是将某项功能迁移到云端，还是将某个组件的工作负载卸载到云端而将关键部分保留在本地，与单体架构相比，这种迁移都相对容易。此外，如果云服务采用相同的技术栈，迁移几乎无需额外工作。一个简单的例子就是 Google Cloud Composer，它构建在 Apache Airflow 和 Kubernetes 之上，这意味着我们在项目中使用的所有任务和 DAG 都可以直接在 Cloud Composer 中运行。总体而言，我发现 Google Cloud 在构建混合云基础设施方面拥有更优的策略和技术方案。因此，如果需要将整个项目完全迁移到 GCP 平台，可以参考以下架构图。\n![MBATS 云架构](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_readme_26dfada8fa41.png)\n\n## 当前功能\n* 基础设施即代码——从零开始不到 5 分钟即可搭建起一套完整的交易基础设施。\n* 使用 Oanda 交易所 API 进行外汇回测与实盘交易（可轻松修改以支持盈透证券的股票交易）。\n* 使用 MLflow 开发并部署机器学习模型。\n* 支持多品种策略。\n* 支持多策略。\n* 使用 Superset 构建 BI 大屏，实时监控实盘交易及回测表现。\n* 易于扩展，可支持任何类型的结构化数据。\n* 除 Docker Compose 配置外，代码全部采用 Python 编写。\n\n## 计划功能\n* 支持股票数据库（Backtrader 已开箱支持 [Interactive Brokers](https:\u002F\u002Fwww.backtrader.com\u002Fdocu\u002Flive\u002Fib\u002Fib\u002F)）。\n* 为 Airflow 提供 Celery\u002FKubernetes 集群支持。\n* 在 Superset 上构建更多性能与交易分析仪表板。\n* 动态 DAG 实现模型重新训练。\n* 更多 Backtrader 示例，包括：\n    - 自定义指标。\n    - 替代数据（非结构化数据处理流程）。\n    - [强化学习](https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FDeep-Reinforcement-Learning-in-Trading)。\n* 使用 [MLflow 模型注册表](https:\u002F\u002Fwww.MLflow.org\u002Fdocs\u002Flatest\u002Fmodel-registry.html)。\n* 集成 [Alpaca API Store](https:\u002F\u002Falpaca.markets\u002F)。\n* 根据机器学习性能指标自动选择最佳策略。\n\n## 技术栈\n本项目已在两种 Docker 环境中开发和测试：\n* [WSL](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fwindows\u002Fwsl\u002Fabout)\n* [Docker Toolbox](https:\u002F\u002Fdocs.docker.com\u002Ftoolbox\u002Ftoolbox_install_windows\u002F)。\n* IDE：Visual Studio Code，主要原因是其提供的 [容器调试功能](https:\u002F\u002Fcode.visualstudio.com\u002Fdocs\u002Fremote\u002Fcontainers#_debugging-in-a-container)。\n\n## 贡献\n所有代码贡献必须通过 Pull Request 提交，并经核心开发者批准后方可合并。此举旨在确保对所有代码进行充分审查。\n\n## 许可证\n本仓库遵循 [BSD 3-Clause 许可证](.\u002FLICENSE)。\n\n## 作者\n* **Saeed Rahman** - [LinkedIn](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fsaeed-349\u002F)\n\n## 致谢\n* Backtrader 社区 ([community.backtrader.com](https:\u002F\u002Fcommunity.backtrader.com\u002F))\n* Backtest-rookies ([backtest-rookies.com\u002Fcategory\u002Fbacktrader\u002F](https:\u002F\u002Fbacktest-rookies.com\u002Fcategory\u002Fbacktrader\u002F))\n* Backtrader Oanda V20 存储库 ([github.com\u002Fftomassetti\u002Fbacktrader-oandav20](https:\u002F\u002Fgithub.com\u002Fftomassetti\u002Fbacktrader-oandav20))\n* Udemy 课程《超越 Jupyter Notebook》([www.udemy.com\u002Fcourse\u002Fbeyond-jupyter-notebooks\u002F](https:\u002F\u002Fwww.udemy.com\u002Fcourse\u002Fbeyond-jupyter-notebooks\u002F))\n* Quantstart ([www.quantstart.com](https:\u002F\u002Fwww.quantstart.com\u002F))","# Microservices-Based-Algorithmic-Trading-System (MBATS) 快速上手指南\n\nMBATS 是一个基于 Docker 的微服务算法交易平台，专为量化交易者设计。它整合了 Backtrader（策略回测）、MLflow（机器学习管理）、Airflow（任务调度）、Superset（数据可视化）等开源工具，帮助用户快速将交易策略从想法转化为生产环境。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**：Linux、macOS 或 Windows (需安装 WSL2 或 Docker Desktop)。\n*   **核心依赖**：\n    *   [Docker](https:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-desktop)：必须安装并正在运行。\n    *   [Git](https:\u002F\u002Fgit-scm.com\u002F)：用于克隆代码仓库。\n    *   [Docker Compose](https:\u002F\u002Fdocs.docker.com\u002Fcompose\u002F)：通常随 Docker Desktop 一起安装。\n*   **网络要求**：由于需要拉取多个大型 Docker 镜像，建议确保网络连接稳定。国内用户若遇到拉取缓慢问题，可配置 Docker 镜像加速器（如阿里云、腾讯云等提供的加速地址）。\n\n## 安装步骤\n\n### 1. 克隆项目仓库\n打开终端，执行以下命令下载源代码：\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FMicroservices-Based-Algorithmic-Trading-System.git\ncd Microservices-Based-Algorithmic-Trading-System\n```\n\n### 2. 配置环境变量\n编辑项目根目录下的 `.env` 文件，将 `WD` 变量更新为您当前克隆目录的绝对路径。\n*   **Linux\u002FmacOS**: 使用 `vim .env` 或 `nano .env` 编辑。\n*   **Windows**: 使用记事本或 VS Code 编辑。\n\n示例（假设路径为 `\u002Fhome\u002Fuser\u002FMBATS`）：\n```text\nWD=\u002Fhome\u002Fuser\u002FMBATS\n```\n\n### 3. 启动服务\n执行以下命令构建并启动所有 Docker 容器。首次运行需要下载基础镜像，耗时较长，请耐心等待：\n```bash\ndocker-compose up -d --build\n```\n\n启动完成后，您可以通过浏览器访问以下组件：\n*   **Jupyter Notebook**: http:\u002F\u002Flocalhost:8888\n*   **Apache Airflow**: http:\u002F\u002Flocalhost:8080\n*   **MLflow**: http:\u002F\u002Flocalhost:5500\n*   **PgAdmin**: http:\u002F\u002Flocalhost:1234\n*   **Apache Superset**: http:\u002F\u002Flocalhost:8088 (默认账号\u002F密码：`guest` \u002F `guest`)\n*   **Minio**: http:\u002F\u002Flocalhost:9000\n\n### 4. 初始化数据库架构\n运行提供的脚本以创建必要的数据库表结构：\n*   **Windows**:\n    ```cmd\n    .\\starter_script.bat\n    ```\n*   **Linux\u002FmacOS**:\n    请查看 `starter_script.bat` 内容，通常对应执行内部的 SQL 初始化逻辑或直接运行容器内的初始化命令。\n\n## 基本使用\n\n以下是最简单的端到端使用流程，涵盖数据下载、策略回测及结果可视化。\n\n### 第一步：配置感兴趣的投资标的\n编辑 Excel 文件 `.\u002FStorage\u002Fminio\u002Fstorage\u002Fairflow-files\u002Finterested_tickers.xlsx`：\n*   **daily** 工作表：填入需要下载日线数据的股票代码。\n*   **minute** 工作表：填入需要下载分钟线数据的股票代码。\n\n### 第二步：下载市场数据\n1.  登录 Airflow 界面：http:\u002F\u002Flocalhost:8080\n2.  找到名为 `fx_data_download` 的任务流 (DAG)。\n3.  点击开关将其启用（Turn On），系统将自动根据 Excel 配置下载数据至 PostgreSQL 数据库。\n\n### 第三步：运行策略与机器学习模型\n1.  登录 Jupyter Notebook：http:\u002F\u002Flocalhost:8888\n2.  打开示例笔记本书 `.\u002FStorage\u002Fnotebooks\u002FExample.ipynb`。\n3.  依次运行单元格，您将体验到：\n    *   使用 **Backtrader** 运行交易策略（回测或实盘模拟）。\n    *   预处理日志数据（市场价格和指标），为机器学习做准备。\n    *   训练 **机器学习模型** 并将实验追踪记录到 **MLflow**。\n    *   通过 MLflow 部署模型服务。\n\n### 第四步：可视化交易结果\n1.  登录 Superset：http:\u002F\u002Flocalhost:8088 (用户名：`guest`, 密码：`guest`)\n2.  查看预设的仪表盘，分析回测或实盘策略的性能指标（如收益率、最大回撤等）。\n\n### 进阶：调度实盘策略\n若需定时运行实盘策略：\n1.  编辑 `.\u002FStorage\u002Fminio\u002Fstorage\u002Fairflow-files\u002Fstrategy.csv` 配置策略列表。\n2.  在 Airflow 中启用 `dag_strategy_dynamic` 任务流，系统将自动调度执行。\n\n---\n*注：所有业务逻辑代码、策略文件及配置文件均位于 `Storage` 文件夹下，并在各容器间共享。*","某量化研究员急需在两周内将一个新的机器学习选股策略从概念验证推向实盘交易，但受限于繁琐的基础设施搭建。\n\n### 没有 Microservices-Based-Algorithmic-Trading-System 时\n- **环境配置耗时极长**：需要手动安装并配置 Backtrader、PostgreSQL、Airflow 等多个独立组件，解决依赖冲突往往耗费数天时间。\n- **模型管理混乱**：缺乏统一的 MLflow 集成，导致机器学习模型的版本迭代、参数记录难以追踪，复现历史实验极其困难。\n- **数据孤岛严重**：市场数据存储于本地文件，未与数据库和可视化看板打通，无法实时查询或监控策略表现。\n- **部署流程断裂**：从回测到实盘的代码迁移需要大量人工干预，缺乏自动化编排，极易因环境差异导致生产事故。\n\n### 使用 Microservices-Based-Algorithmic-Trading-System 后\n- **一键启动全栈环境**：仅需一条 `docker-compose` 命令，即可在几分钟内拉起包含 Jupyter、Airflow、Superset 在内的完整微服务架构。\n- **模型生命周期标准化**：内置 MLflow 自动接管模型训练与注册，研究员可轻松对比不同算法版本的效果并快速部署最优模型。\n- **数据流无缝集成**：PostgreSQL 与 Minio 预配置完成，市场数据自动入库，Superset 直接连接数据库生成实时的策略绩效仪表盘。\n- **自动化作业编排**：利用 Airflow 预设的工作流，将数据获取、模型推理、订单执行串联成自动化流水线，实现从想法到实盘的分钟级上线。\n\nMicroservices-Based-Algorithmic-Trading-System 通过模块化的 Docker 架构，将量化策略的研发周期从数周压缩至数小时，让研究员能专注于核心算法而非运维琐事。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsaeed349_Microservices-Based-Algorithmic-Trading-System_e1dd71f7.png","saeed349","Saeed Rahman","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fsaeed349_f779507e.jpg","Welcome to Saeed's laboratory.\r\nLife purpose: Making sense out of data using glorified function approximators.\r\n",null,"New York, USA","saeed349@gmail.com","https:\u002F\u002Fgithub.com\u002Fsaeed349",[82,86,90,94,98],{"name":83,"color":84,"percentage":85},"Python","#3572A5",76,{"name":87,"color":88,"percentage":89},"Jupyter Notebook","#DA5B0B",22.8,{"name":91,"color":92,"percentage":93},"Dockerfile","#384d54",0.8,{"name":95,"color":96,"percentage":97},"Batchfile","#C1F12E",0.2,{"name":99,"color":100,"percentage":97},"Shell","#89e051",539,155,"2026-04-12T08:09:06","BSD-3-Clause",4,"Linux, macOS, Windows","未说明",{"notes":109,"python":107,"dependencies":110},"该项目基于 Docker 容器化部署，运行前必须安装 Docker 和 Docker Compose。支持在本地机器或云端运行。首次运行需下载多个 Docker 基础镜像，耗时较长。数据存储和配置文件位于 'Storage' 文件夹中，需确保 Docker 有访问权限。通过修改 .env 文件中的 'WD' 变量指定克隆目录路径。",[111,112,113,114,115,116,117,118,119],"Docker","Docker Compose","Backtrader","MLflow","Apache Airflow","Apache Superset","Minio","PostgreSQL","pgAdmin",[14,16,13],"2026-03-27T02:49:30.150509","2026-04-18T03:33:04.826500",[124,129,134,139,143,147],{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},38808,"在 Windows 上运行 docker-compose 时遇到 'docker-credential-desktop' 或 'wincred.exe' 错误怎么办？","这是一个常见的 Docker 凭据存储配置问题。解决方法是编辑 ~\u002F.docker\u002Fconfig.json 文件，删除包含 '\"credsStore\": \"desktop\"' 的行。保存后重新运行 docker-compose 命令即可。此外，确保在 BIOS 中启用了 Hyper-V 和虚拟化技术，且无需安装 Visual Studio，直接使用 PowerShell 和 Docker Desktop 即可。","https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FMicroservices-Based-Algorithmic-Trading-System\u002Fissues\u002F3",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},38809,"运行 starter_script.bat 时出现 'Insufficient authorization to perform request' (Oanda API 授权不足) 错误如何解决？","这是因为缺少有效的 Oanda API 凭证。解决步骤如下：\n1. 在 Oanda 官网创建模拟或真实账户。\n2. 生成 API Key 并获取账户 ID。\n3. 将凭证复制到项目目录下的 YOUR_DIRECTORY\\Storage\\q_pack\\q_credentials\\oanda_cred.py 文件中。\n4. 修改该文件内容，填入你的 ID 和 Token：\nacc_id_practice = \"your id\"\ntoken_practice = \"your token\"","https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FMicroservices-Based-Algorithmic-Trading-System\u002Fissues\u002F4",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},38810,"执行 starter_script.bat 时报错 'python: can't open file ... No such file or directory' 找不到脚本文件怎么办？","这通常是因为脚本中引用的文件路径与实际容器内的路径不一致。需要手动编辑 starter_script.bat 文件，将执行命令修正为正确的路径。确保使用以下命令序列：\ndocker exec -it jupyter-image \u002Fbin\u002Fsh -c \"python \u002Fhome\u002Fjovyan\u002Fwork\u002Fq_pack\u002Fdb_pack\u002Fschema\u002Fsecmaster_db_schema_builder.py\"\ndocker exec -it jupyter-image \u002Fbin\u002Fsh -c \"python \u002Fhome\u002Fjovyan\u002Fwork\u002Fq_pack\u002Fdb_pack\u002Fschema\u002Fsecmaster_db_symbol_loader.py\"\ndocker exec -it jupyter-image \u002Fbin\u002Fsh -c \"python \u002Fhome\u002Fjovyan\u002Fwork\u002Fq_pack\u002Fdb_pack\u002Fschema\u002Frisk_db_schema_builder.py\"","https:\u002F\u002Fgithub.com\u002Fsaeed349\u002FMicroservices-Based-Algorithmic-Trading-System\u002Fissues\u002F8",{"id":140,"question_zh":141,"answer_zh":142,"source_url":128},38811,"Windows 用户首次使用该项目的 Docker 环境有哪些注意事项？","Windows 10 用户不需要安装 Visual Studio。只需安装 Docker Desktop 并使用 PowerShell 控制台即可。关键检查点包括：\n1. 确保 BIOS 中已启用虚拟化技术 (Virtualization)。\n2. 确保 Hyper-V 功能已开启。\n3. 如果遇到构建错误，尝试先运行 `docker-compose up -d --build` 而不设置额外的环境变量（如 MAPBOX_API_KEY 可暂时留空）。",{"id":144,"question_zh":145,"answer_zh":146,"source_url":128},38812,"Minio 容器构建失败提示 'image operating system linux cannot be used on this platform' 是什么原因？","这通常发生在解决了凭据存储错误之后。原因是 Docker 桌面版默认可能未切换到 Linux 容器模式，或者镜像架构不匹配。请确保 Docker Desktop 设置为运行 Linux 容器（右键点击任务栏 Docker 图标，选择 'Switch to Linux containers'）。如果问题依旧，检查是否因之前的配置错误导致构建上下文异常，通常在修复 config.json 并重启 Docker 服务后可解决。",{"id":148,"question_zh":149,"answer_zh":150,"source_url":138},38813,"项目启动脚本中涉及的数据库初始化顺序是什么？","根据修复后的 starter_script.bat，正确的数据库初始化和数据加载顺序如下：\n1. 首先运行 secmaster_db_schema_builder.py 创建证券主数据库表结构。\n2. 接着运行 secmaster_db_symbol_loader.py 加载交易符号数据（需配置好 Oanda API）。\n3. 最后运行 risk_db_schema_builder.py 创建风险数据库表结构。\n必须严格按此顺序执行，以避免依赖缺失导致的报错。",[]]