Back to projects

Algorithmic Trading Bot

A fully automated, cloud-hosted trading bot that executes an Opening Range Breakout strategy across highly volatile stocks like Tesla and Nvidia.

👉 Check out the widget on this page to see the bot's real-time live portfolio!

Project Overview

I built a fully automated trading bot that runs 24/7 on Oracle Cloud. It connects directly to the Alpaca brokerage API to trade an Opening Range Breakout strategy on highly volatile stocks. From analyzing pre-market data to managing active trades and liquidating positions before the market closes, the entire system runs completely on its own without any human intervention.

The Problem

Most home-built trading bots fail as soon as they go live. This usually happens for a few reasons:

I built this bot specifically to tackle those live-environment challenges.

Opening Range Take Profit ORB High ORB Low 9:30 AM 9:45 AM STOP LOSS BUY SIGNAL FILLED

How it Trades

The bot trades an Opening Range Breakout strategy, which is designed to catch big price moves right after the market opens. For the first few minutes of the day, it watches a stock and maps out its highest and lowest prices (the "opening range").

Entering Trades: If the stock breaks out above that high (or below that low) and has strong momentum, the bot automatically jumps in.

Managing Risk: Every time the bot enters a trade, it instantly places safety nets (stop-loss and take-profit orders) to protect the account. If a trade drags on into the afternoon, the bot automatically tightens its targets so it can exit safely. By 3:55 PM, it sells everything so no money is left at risk overnight.

Engineering Highlights

Building a bot that just buys a stock is easy. Building one that can run safely and autonomously for months requires solving a lot of tricky engineering problems.

Mid-Day Crash Recovery

Problem: If the server restarts while trades are open, the bot wakes up completely blind.
Solution: When the bot turns on, it directly asks the broker API what is currently happening and rebuilds its internal memory from scratch.

Preventing "Phantom" Trades

Problem: Sometimes the bot tries to cancel a trade at the exact millisecond the broker fills it, causing confusion.
Solution: The bot constantly double-checks its own memory against the live broker account every 30 seconds to make sure they match perfectly.

Handling Simultaneous Trades

Problem: If three stocks break out at the exact same time, the bot could accidentally spend more money than it has.
Solution: The system detects these simultaneous triggers in real-time and perfectly splits the remaining account balance between them.

Corrupt-Proof Memory

Problem: If the power cuts out while the bot is saving its memory file, the file gets corrupted.
Solution: The bot saves its memory to a temporary file first, and only replaces the real file once the save is 100% complete.

Working with AI to Optimize Strategy

A huge part of this project was using AI pair-programming to help run massive backtests and figure out the best settings. Instead of just guessing what numbers to use, we ran thousands of simulations to find what actually works.

The Power of Cross-Compounding: We found that trading a basket of stocks all from the same pool of money is incredibly powerful. If one stock makes a profit in the morning, that extra cash is immediately used to buy a larger position in a different stock in the afternoon, snowballing the returns.

Customizing for Directions: Through all those simulations, we discovered that stocks behave very differently when they go up versus when they go down. The bot now uses completely different rules for "Long" (buying) and "Short" (selling) trades to maximize its win rate on every individual stock.

Technology Stack & Resources

Core Language: Python 3
Data Manipulation: pandas
Brokerage API: alpaca-trade-api
Infrastructure: Oracle Cloud (Ubuntu ARM), PM2 process manager
Notifications: Discord webhook integration

Live Engine Source Code

Disclaimer: To protect the proprietary trading logic for live deployment, certain configurations, alpha filters, and infrastructure details have been redacted from the public source code.