Repository overview | Agent Framework | Semantic Kernel workflow | AutoGen reference | Agent Framework patterns | Terminal dashboard | Framework comparison
This is the AutoGen reference implementation.
The Semantic Kernel workflow provides the maintained deterministic pipeline. This implementation remains available for framework comparison and migration study.
It has an independent Poetry project requiring Python 3.11–3.12. It is incompatible with this repository's Python 3.13 root environment; use a separate environment if you need to run it.
| Aspect | AutoGen reference | Microsoft Agent Framework |
|---|---|---|
| Orchestration | GroupChat + select_speaker |
WorkflowBuilder + edges |
| Message Flow | Broadcast to all agents | Data flows through edges |
| Agents | AssistantAgent, ConversableAgent |
ChatAgent (stateless) |
| Tools | FunctionTool class |
class or @ai_function decorator |
| State | Built into agents | AgentThread for context |
| Pattern | Control-flow (event-driven) | Data-flow (workflow-based) |
| Routing | Custom logic in manager | Conditional edges |
flowchart TD
classDef user fill:#e6e6fa,stroke:#333,stroke-width:2px
classDef orchestrator fill:#f0fff0,stroke:#999,stroke-width:1px
classDef agent fill:#f0f8ff,stroke:#333,stroke-width:2px
A[User Input]:::user --> B[UserProxyAgent]:::user
B --> C[GroupChatManager<br/>Custom speaker selection]:::orchestrator
C --> D[Stock Analysis Agent]:::agent
C --> E[Signal Analysis Agent<br/>Python code executor]:::agent
C --> F[Code Executor Agent]:::agent
D --> G[Tools]:::user
E --> G
F --> G
G --> H[Manual Result Collection]:::orchestrator
💸Agent-based stock analysis and investment strategy application using 🎰AutoGen framework.
- Review and backtest the historical stock performance for a specific ticker and date range.
- Autogen Agents for finding the best timing to invest.
- To run the main workflow:
python agent_workflow_e2e.py - Generated AutoGen artifacts are written to output/autogen. Both executable entry points print this directory when they start.
Important: The code in this repository was developed during a hackathon and implemented within a limited timeframe. It is intended for proof-of-concept purposes only.
sequenceDiagram
%% User
participant User
%% Generates Investing Strategies
participant StrategyIdeaAgent
%% Generates CAGR/MDD graph
participant StockReportAgent
%% Manages group chat discussions
participant GroupChatManager
%% Executes code to create signal data
participant UserProxyAgent
%% Fetches price data from Yahoo Finance and performs backtesting
participant StockAnalysisAgent
%% Generates code for creating buy/sell signals for backtesting
participant SignalAnalysisAgent
%% Public API for fetching stock price data for specified periods
participant YahooFinanceAPI
%% Public web search for finding technical indicators and investing strategies
participant BingSearch
autonumber
rect rgb(204, 255, 204)
User ->> StrategyIdeaAgent: Request to create investment strategies
StrategyIdeaAgent ->> StrategyIdeaAgent: Stores investment strategies as 'strategy_ideas.json'
end
loop Iterate through investment strategies
User ->> GroupChatManager: Sends an investment strategy to group chat
GroupChatManager ->> GroupChatManager: Initializes group chat
GroupChatManager ->> StockAnalysisAgent: Calls StockAnalysisAgent
StockAnalysisAgent ->> YahooFinanceAPI: Fetches stock data from Yahoo Finance
YahooFinanceAPI -->> StockAnalysisAgent: Provides stock data
StockAnalysisAgent ->> StockAnalysisAgent: Stores stock price dataset as 'stock_data.csv'
StockAnalysisAgent -->> GroupChatManager: Notifies GroupChatManager of task completion
GroupChatManager ->> SignalAnalysisAgent: Calls SignalAnalysisAgent
SignalAnalysisAgent ->> SignalAnalysisAgent: Generates code for creating buy/sell signals
opt
SignalAnalysisAgent ->> BingSearch: Searches for examples using the `ta` library
BingSearch -->> SignalAnalysisAgent: Provides examples
end
SignalAnalysisAgent -->> GroupChatManager: Notifies GroupChatManager of task completion
GroupChatManager ->> UserProxyAgent: Calls UserProxyAgent
UserProxyAgent ->> UserProxyAgent: Executes code created by SignalAnalysisAgent
UserProxyAgent ->> UserProxyAgent: Stores buy/sell signal dataset as 'stock_signals.csv'
UserProxyAgent -->> GroupChatManager: Notifies GroupChatManager of task completion
GroupChatManager ->> StockAnalysisAgent: Calls StockAnalysisAgent
StockAnalysisAgent ->> StockAnalysisAgent: Performs backtesting using 'stock_data.csv' and 'stock_signals.csv'
opt
StockAnalysisAgent ->> BingSearch: Searches for descriptions of indicators
BingSearch -->> StockAnalysisAgent: Provides descriptions
end
StockAnalysisAgent ->> User: Sends a summary of the investment strategy performance
end
rect rgb(230, 242, 255)
User ->> StockReportAgent: Requests creation of a graph
StockReportAgent ->> StockReportAgent: Generates CAGR/MDD graph
end
- User Input
Run complete stock analysis for MSFT from 1995-01-01 to today.
Generate buy/sell signals using 20-day Moving Average, TRIX, UO.
Based on the generated signals, backtest the strategy and provide performance metrics.- Output
### Strategy Performance Summary
**Indicators Used:**
- 20-day Moving Average (MA)
- TRIX (Triple Exponential Average)
- Ultimate Oscillator (UO)
**Strategy Summary:**
The strategy employs a combination of technical indicators to generate buy and sell signals. The 20-day Moving Average smooths price data to identify trends, while the TRIX indicator assesses momentum and potential trend reversals. The Ultimate Oscillator helps gauge market momentum by considering multiple time frames.
Buy signals are generated when the stock price is above the 20-day MA, TRIX is positive, and UO is below 50, indicating a potential upward trend. Conversely, sell signals are triggered when the price is below the 20-day MA, TRIX is negative, and UO is above 50, suggesting a downward trend. This strategy aims to capture momentum while managing risk effectively.
### Performance Metrics
| Metric | Value |
|----------------------|----------|
| **Cumulative Return** | 188.17% |
| **CAGR** | 2.15% |
| **Maximum Drawdown** | -4.47% |
| **Sharpe Ratio** | 0.04 |-
Most backtrading systems already integrate buy/sell signals and CAGR (Compound Annual Growth Rate) calculation into a single interface. However, this approach limits the flexibility to use custom signals for CAGR calculation.
-
To resolve this issue, the app uses an approach that separates signal generation and CAGR calculation.
-
Assumptions
-
To streamline the process, we make the following assumptions:
- All trading decisions are based on the signal generated from the previous day's data.
- The calculation of daily returns depends on the type of signal and the price movement:
-
Buy Signal: On the trading day, the daily return is calculated as the change of the Adjusted Close price.
-
Sell Signal: On the trading day, the daily return is calculated as the gap between the previous day's Close price and the current day's Open price:
Daily Return = ({Open} / {Prev Day Close}) - 1
-
-
Signal Validation
-
Each trade checks the validity of the signal:
- A sell signal cannot be executed without a preceding buy signal.
- Consecutive identical signals (e.g., multiple buy signals in a row) are treated as a Hold action, where no new trade is initiated.
-
-
poetry install --no-root- This application library supports
ta, which provides commonly used indicators (pure Python). - Another backtesting framework will be supported in the future.
- Rename
.env.templateto.envandOAI_CONFIG_LIST.template.jsontoOAI_CONFIG_LIST.json. Then, set your Bing Search API and OpenAI keys.
- Zipline: Maintained and updated by the community after Quantopian shut down. git
- backtrader: Python Backtesting library for trading strategies git
- QuantStats: git
- fastquant: git
- TA-Lib Official Site: 200 indicators such as ADX, MACD, RSI, Stochastic, Bollinger Bands etc. Candlestick patterns. Faster (C-based). recognition. git
- TA-Lib python wrapper should be downloaded by manual.
- unofficial TA-Lib wheels for Python on Windows: https://github.com/cgohlke/talib-build
python -m pip install TA_Lib-0.4.32-cp311-cp311-win_amd64.whl