This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- Execution Log --- | |
| --- Starting analysis for AAPL --- | |
| Preliminary decision for AAPL: Signal=0 | |
| --- Starting analysis for MSFT --- | |
| Preliminary decision for MSFT: Signal=0 | |
| --- Starting analysis for GOOG --- | |
| Preliminary decision for GOOG: Signal=0 | |
| Portfolio Agent: No BUY signals. Allocating 0% to all tickers. | |
| Execution Agent: Submitting real trades based on portfolio plan. | |
| Execution: Fetched cash balance: $100000.00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- Market is OPEN. Starting trading loop for 2026-01-12 until 16:00:00 --- | |
| --- Running Engine Iteration at 15:32:35 --- | |
| INFO: Fetching 90 observations of 5min data for AAPL... | |
| INFO: Searching web for 10 news links about AAPL since 2026-01-12 15:22 | |
| Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY. | |
| INFO: Fetching 90 observations of 5min data for MSFT... | |
| INFO: Searching web for 10 news links about MSFT since 2026-01-12 15:22 | |
| Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (base) josgt@josgt-desktop:~/Downloads/testing11$ cd "/home/josgt/Downloads/testing11/AI-in-Trading-Workflow/LLMs/example_02_Agentic_AI_based_Portfolio_manager_using_Alpaca_API" | |
| (base) josgt@josgt-desktop:~/Downloads/testing11/AI-in-Trading-Workflow/LLMs/example_02_Agentic_AI_based_Portfolio_manager_using_Alpaca_API$ conda activate alpaca_bot | |
| (alpaca_bot) josgt@josgt-desktop:~/Downloads/testing11/AI-in-Trading-Workflow/LLMs/example_02_Agentic_AI_based_Portfolio_manager_using_Alpaca_API$ python3 main.py | |
| /home/josgt/anaconda3/envs/alpaca_bot/lib/python3.12/site-packages/pyfolio/pos.py:25: UserWarning: Module "zipline.assets" not found; multipliers will not be applied to position notionals. | |
| warnings.warn( | |
| /home/josgt/anaconda3/envs/alpaca_bot/lib/python3.12/site-packages/langchain_tavily/tavily_research.py:97: UserWarning: Field name "output_schema" in "TavilyResearch" shadows an attribute in parent "BaseTool" | |
| class TavilyResearch(BaseTool): # type: ignore[override, override] | |
| /home/josgt/anaconda3/envs/alpa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Initialize a new StateGraph with our AgentState structure. | |
| workflow = StateGraph(AgentState) | |
| # Add the functions as nodes in the graph. | |
| workflow.add_node("analysis", analysis_node) | |
| workflow.add_node("portfolio_allocator", portfolio_agent_node) | |
| workflow.add_node("executor", execution_node) | |
| workflow.add_node("email_notifier", email_notification_node) | |
| # Set the entry point of the graph, which is the first node to be called. | |
| workflow.set_entry_point("analysis") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Set the for loop | |
| for i in range(1,len(monthly_index)): | |
| print('='*100) | |
| # Set the current month-end variable | |
| current_month_end = monthly_index[(i-1)] | |
| # Set the next month-end variable | |
| next_month_end = monthly_index[i] | |
| # Set the span from the previous to the next month end | |
| span = len(data.loc[current_month_end:next_month_end,:].index) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from statsmodels.tsa.arima.model import ARIMA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pip install pandas numpy matplotlib statsmodels yfinance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pip install pandas statsmodels matplotlib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| S_3 = Df['S_3'].dropna() | |
| S_9 = Df['S_9'].dropna() | |
| # Since S_3 and S_9 are moving averages, we could check their cointegration with the original Close series | |
| close_price = Df['next_day_price'] | |
| # Conduct Engle-Granger Cointegration Test between S_3 and Close price | |
| coint_result_3 = coint(S_3, close_price) | |
| # Conduct Engle-Granger Cointegration Test between S_9 and Close price |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Plot the both buy-and-hold and the strategy cumulative returns | |
| ggplot(data=df_forecasts, aes(x = date)) + | |
| geom_line(aes(y = var_stra_cum_returns, color="VAR")) + | |
| geom_line(aes(y = tvp_var_sv_stra_cum_returns, color="TVP-VAR-SV")) + | |
| geom_line(aes(y = bnh_cum_returns,color="B&H")) + | |
| geom_line(aes(y = stra_improved_cum_returns, color="Improved TVP-VAR-SV")) + | |
| ggtitle("Buy and Hold and Strategies' Cumulative Returns") + xlab("Date") + ylab("Returns") + | |
| theme(plot.title = element_text(hjust = 0.5, size=25), legend.position="bottom", legend.text = element_text(size=20)) + | |
| scale_x_date(date_labels = "%b %y") + | |
| theme( |
NewerOlder