Video Summary

I Turned Claude Opus 4.7 Into a 24/7 Trader

Nate Herk | AI Automation

Main takeaways
01

Claude Opus 4.7 + Cloud Code routines enable a 24/7 agentic trading workflow.

02

Five scheduled remote routines cover pre-market, market-open, midday, end-of-day, and a Friday weekly review.

03

Alpaca API executes trades (use paper trading for tests); Perplexity or web fetch handles research.

04

Agent memory lives in markdown files on the repo main branch and is updated by routines.

05

Secure API keys with environment variables; avoid embedding secrets in chats or commits.

Key moments
Questions answered

How many routines does the trading agent use and what do they do?

The setup uses five scheduled remote routines: pre-market research, market-open execution, a midday scan/management routine, an end-of-day summary, and a Friday weekly review. Each routine runs on cron (weekdays) and handles research, trade placement, risk management, journaling, or portfolio review.

Which AI model and tooling power the automated trader?

Claude Opus 4.7 is the AI model (designed for agentic workflows and self-verifying outputs). Cloud Code routines act as the scheduler/orchestrator, Alpaca handles trade execution, Perplexity is used for market research (or native web fetch as an alternative), and ClickUp is used for daily notifications.

Where does the agent store memory and how does it learn over time?

Memory is stored as markdown files (e.g., sold.mmd, agents.mmd) on the GitHub main branch. Each routine reads and writes these files so the agent retains context, journals decisions, and iteratively improves strategies across runs.

What safety and testing precautions are recommended?

Use Alpaca's paper trading account to test without real funds, run routines multiple times to validate behavior, keep API keys in environment variables (not in chats or committed files), and limit strategy risk (the tutorial focuses on swing/long-term strategies, not high-risk day trading).

How are API keys and environment configuration handled?

API keys for Alpaca, Perplexity, and ClickUp are retrieved from each platform's settings and added to the Cloud Code environment as environment variables. Correct spelling and matching variable names are critical to avoid runtime errors.

Overview of Claude Opus 4.6 and New Features in 4.7 00:00

"Claude Opus 4.7 introduces key enhancements that can boost trading efficiency, particularly with its new routines feature."

  • The release of Claude Opus 4.7 is significant, especially when compared to the previous version, 4.6, which had demonstrated an upswing in performance metrics, such as a 4% jump in Agentic Financial Analysis.

  • In a prior challenge, the creator succeeded in trading stocks over 30 days using Opus 4.6 and outperformed the S&P by 8%, highlighted by a visual comparison of trading charts.

  • The main goal for the current tutorial is to demonstrate how to build a 24/7 AI trading agent using the capabilities of Claude Code with the new features of Opus 4.7.

Setting Up the 24/7 Trading Agent 01:01

"We are building a cloud code project that operates on a schedule to perform market analyses and execute trades."

  • The intended trading agent will operate on a consistent schedule for market activities, including the pre-market, market open, midday, and market close.

  • It will utilize the Alpaca API to manage trade placements while journaling activities for context learning, ultimately sending a daily summary to ClickUp to monitor performance against the S&P.

  • The creator clarifies that the approach focuses on long-term investment rather than high-risk day trading or cryptocurrencies.

Tools and Tech Stack Required for Implementation 02:07

"Key tools for this project include Cloud Code routines as the scheduler and Opus 4.7 as the AI model."

  • The essential tech stack involves Cloud Code routines for scheduling, Opus 4.7 for the AI trading model, and incorporating specific APIs for additional functionalities.

  • Tools such as the Alpaca API will serve as the brokerage for executing trades, while the Perplexity API is selected for conducting market research, although alternatives like native web fetching are available.

  • The creator opts for ClickUp for notifications instead of other platforms, emphasizing user preference in setting up notifications for agent activities.

Steps to Access Necessary Tools 02:45

"Getting your API and configuration set correctly is crucial for smooth functionality of your trading agent."

  • Signing up for an account with Alpaca is the first step, which offers a paper trading environment ideal for testing the trading agent without financial risk.

  • Users need to generate API keys from the Alpaca account settings, which will be crucial for connecting the trading functionalities later on.

  • Instructions follow for setting up ClickUp and the Perplexity API, guiding users to locate their API keys within corresponding platform settings.

Understanding the Mental Model of Agent Design 05:41

"The trading strategy is only part of the work; creating a robust memory architecture is critical to success."

  • A thorough understanding of the mental model is essential, emphasizing that every routine operates statelessly, requiring a strategy for maintaining discipline and memory through context and file management.

  • The design includes establishing a framework where the agent "wakes up," processes tasks, and records important lessons for the next cycle, effectively learning over time.

  • The concept of a "context budget" is introduced, suggesting that efficiency in reading and writing files is key due to associated costs with each routine's operations, thus encouraging optimal token management for performance.

Understanding Trading Automation and Strategy Development 07:30

"You can't expect to just throw a kid on a bike and it's instantly going to be magic. So maybe you want to start with paper trading."

  • Effective trading, especially in volatile markets, requires a well-thought-out strategy and gradual learning. It is important to view the development of a trading strategy as a step-by-step teaching process, similar to teaching a child to ride a bike.

  • Begin by understanding the fundamentals of trading, including the importance of research and decision-making signals that can influence when to buy or sell.

  • For inexperienced traders, starting with paper trading allows for practice without risking real money. It's crucial to approach trading as an experiment and not to risk everything based on initial forays.

Strategy Implementation and Learning Over Time 08:22

"The more of your gut intuition and your routine about trading that you can get into this cloud code project, the better."

  • Extracting and documenting personal trading strategies and routines will enhance the learning process of automated trading agents. This includes detailing how often to check the news and identifying signals that suggest trading actions.

  • Over time, these automated systems will learn from past mistakes through iteration, improving their trading strategies.

  • Anecdotal evidence suggests that setting clear experiments, such as a 30-day challenge, can lead to effective trading solutions, as the automated agent learns to conduct research and devise strategies on behalf of the trader.

Benchmark Analysis Against Competitors 09:38

"This benchmark rewards models that can digest filings and write coherent, fundamentals-driven theses, which map to long-term or swing or fundamentals-driven strategies, not day trading."

  • The performance of trading automation models is evaluated against established benchmarks, which inform users of their effectiveness compared to industry standards.

  • Although certain models may excel in financial analysis and reasoning, they aren’t necessarily equipped for the nuanced demands of day trading or real-time decision-making.

  • Understanding the capabilities and limitations of the model being used is crucial; users should align their strategies with what the model performs best at, such as long-term investment strategies rather than rapid trading.

Setting Up Your Trading Environment 10:50

"The reason why we're starting here in VS Code is because I want to get started in a place where I can see all of my files on this left-hand side."

  • Proper setup of the trading environment is essential for effective management of trading strategies and data. Utilizing tools like VS Code enables better visualization and organization of files and scripts related to the trading project.

  • Migrating strategies and past trading learnings from one framework to another can enhance the efficiency of the setup process and give a new trading agent access to valuable historical data.

  • Resources, such as downloadable PDFs with structured guidance, can assist in setting up the trading routine and infrastructure, aiding in the successful implementation of trading automation projects.

Understanding Your Trading Project 14:18

"It's really important that you're ingesting this information and you're understanding it; then you're helping yourself organize this project in a way that makes the most sense to you."

  • When migrating strategies and signals from an OpenClaw agent, it is essential to retain all knowledge and insights gained. Focus on extracting key insights and adapting them to your project.

  • Begin by brainstorming how you trade, essentially treating the AI as your best trading ally. Write down your trading strategy in a Google Doc or on paper to clarify your thoughts.

  • After documenting your approach, integrate this information into cloud code, which ultimately organizes your project efficiently. The more context you provide at this stage, the better the AI can tailor its questions and functionalities to suit your needs.

Security Considerations in Migration 16:10

"Be careful when you're migrating stuff or feeding in API keys directly to a chat."

  • During the migration process, it's crucial to address any security concerns associated with API keys. Avoid including sensitive information directly in chat or documents.

  • Instead, manage your API keys through environment variables. This practice helps ensure that sensitive data isn't exposed in public repositories like GitHub.

  • Always double-check and rotate API keys to maintain security integrity as you transition your trading bot to a new setup.

Finalizing Project Structure and Routine Setup 17:25

"The goal of this migration is to make Cloud Code a first-class home for this bot."

  • Aim for a structured project where files are organized logically, allowing the AI to utilize memory effectively. This organization will result in a smoother operation where routines can easily access necessary data.

  • As you plan the routines for your trading bot, establish daily triggers tailored to your trading schedule. Consider that the market operates only five days a week, so not all routines need to execute daily.

  • Utilize brainstorming techniques to explore various triggers and routines. This includes delineating tasks for different market hours, such as pre-market, during market hours, and after-hours tasks.

Trade Planning and Routine Automation 21:12

"We need to conduct research, potentially make a trade, and then update all of the memory files so that the next agent understands what is going on."

  • The trading system requires ongoing research and analysis to form trade decisions. It is essential to document these decisions by updating memory files to ensure that subsequent agents can build on this knowledge.

  • The goal is to establish the right structure for cron jobs, which will automate tasks related to trading during market hours on weekdays, helping to streamline the trading process.

Automation Triggers for Trading 21:42

"We were able to analyze our strategy and build a solid plan for automated trading."

  • The proposed plan includes five recurring cron jobs specifically designed to handle various trading functions. These jobs will only run during the weekdays, with a unique schedule for a weekly review on Fridays.

  • Key automation triggers include:

    • Pre-market: Research catalysts and draft trade ideas without unnecessary notifications.

    • Market open: Execute planned trades and set trailing stops.

    • Midday: Manage losing investments by cutting off at minus 7% and tightening stops on profitable trades.

Environment Setup for Cloud Code 24:17

"When you create remote routines, those can run even when your computer is off, as they operate in the cloud."

  • There is a distinction between local and remote routines in cloud code. Local routines depend on your machine being operational, while remote routines run uninterrupted in the cloud, making them more reliable for ongoing trading tasks.

  • To utilize remote routines effectively, a GitHub repository must be set up, ensuring that changes made during the trades are pushed back to the main branch to maintain continuity for future sessions.

Pushing Changes to GitHub 25:02

"It's crucial to push all changes to the GitHub repository so that the trading routine can access the necessary files."

  • After creating trading scripts and configurations, it’s important to commit all changes to the GitHub repository. This step ensures that all components needed for trading are up to date and accessible for ongoing operations.

  • Using GitHub allows for collaborative and seamless updates to the trading code and configurations, providing a safety net for the system's integrity and effectiveness.

Setting Up Routines and Cloud Environment 27:01

"Always ensure that you fully understand the task before moving on to implementation."

  • During the setup of routines in cloud code, an appropriate environment must be linked to the routines. This involves adding API keys and ensuring full network access to facilitate executions within the trading system.

  • Establishing a confident understanding of the trading routines and their interactions with the cloud environment is crucial for success in automating trading processes.

Setting Up Trading Routines 28:29

"We have these new five routines for Bull, and these are all remote."

  • The speaker outlines the trading routines set up for a 24/7 trading system, active from 6:00 a.m. Monday through Friday with specific times for trading activity at 8:30 a.m., noon, 3 p.m., and 4 p.m. on Fridays.

  • In the routines, it is essential to allow unrestricted branch pushes, which enables the Claude AI to push changes to any branch in the GitHub environment, not just specific ones. This setting must be activated for all five routines.

Testing and Troubleshooting 29:21

"You should always do a run now at least a few times to make sure that they are working as expected."

  • When setting up new routines, it is a best practice to run them several times to ensure functionality.

  • During testing, an issue arose where the AI could not find the API key due to mismatching spelling in environment variables. The speaker corrected these variables to ensure compatibility.

Reviewing Weekly Performance 30:21

"The weekly review has been run, and it was able to push these actual commits to this repo."

  • After addressing the API key issue, the Claude AI successfully executed a weekly performance review, updating and committing changes in the GitHub repository.

  • The review included a summary of the portfolio performance compared to the S&P, any trades that occurred, and Claude’s self-assessment, giving itself a grade of C for the week.

Automation and Context Management 31:31

"If I were to set up all of these cron jobs and have the same sort of autonomy and agentic workflows...that would be more expensive than what I've got set up here."

  • The speaker discusses the potential concerns about session limits due to the numerous automated routines but emphasizes that effective context management can mitigate these issues.

  • A full video is planned to address managing context within workflows. The speaker reveals that using the current automation setup is not significantly affecting cost or performance.

Orchestrating Agent Workflows 32:37

"Files aren't just memory; they are essentially the agent's full personality and discipline."

  • The organization of files, such as sold.mmd and agents.mmd, plays a crucial role in enabling the AI to access necessary information when needed.

  • The speaker highlights the importance of properly orchestrating these files to create an efficient and effective trading agent system, thus ensuring seamless operations.