Please note that this article is for educational purposes only. Alpaca does not recommend any specific securities or investment strategies.
TradeSpotter (@tipperbeats) is a Twitter account created in April 2021 for the purpose of sharing and tracking real-time trading signals. The signals are generated by an algorithm developed over several years that attempts to capture short-term retracement moves in US equities.
The development approach to the algorithm was different from most algorithmic traders, in that we didn’t start with the data and look for patterns but rather with a trading thesis. We started our careers as traders. As such, we often have short-term opinions on stocks, based on their chart pattern and general market environment. What we did was capture those in the form of conditions that express the setup we see in the chart. We then back-tested that setup over stocks traded in the last 20 years or so. This approach helped us minimize data mining, as we began with a speculative approach that we tested as opposed to finding a pattern and attempting to explain it with a thesis.
The algorithm generates both long and short signals, making price predictions with a time frame of between a few hours up to one day ahead. To date, the hit ratio is over 60%, profit ratio is over 65%, yearly rate of return over 70% with a Sharpe of 3. In an effort to be fully transparent, we track and log the performance of all of the signals shared, the log can be found here.
The algorithm does not require lightning-speed execution since the signals are generated from what we believe are anomalies that could take several hours to correct. However, it wasn’t long until some followers started asking about a tool that might assist in execution. Thus the idea for the Modular Trade Execution Engine Bot was born.
The goal was to create a program that would monitor the Twitter account, determine when a signal was being sent, translate these Tweets into orders and execute them automatically. However, it was important for us to broaden the potential scope of the tool to allow for others to participate: we decided it should be open-source so that it could be modified to include other Twitter accounts (and possibly other mediums of signal sharing) by other algorithm-developers and also to include additional brokers.
Alpaca was the first broker chosen since Alpaca’s execution API offers a very straightforward way to operate a fully automated active portfolio of the assets we trade. The trade execution engine can be found here.
This approach has the potential to create a modular decentralized algorithmic hedge fund by breaking it down to its basic components. Traders/developers can focus on algorithm development, and end-users can execute automatically while allowing their risk profile to inform position sizing, profit target, and stop losses. It does not require any third-party intervention. If an algo proves to be profitable, its creator can grow a following and monetize via subscriptions, etc.
I will now demonstrate some of the features of the program, how to set it up, and how it can be modified and personalized:
Once the program is started up, the trade execution engine runs in the background, and listens for TradeSpotter’s tweets:
At 4:30 pm a tweet is sent:
It is then detected by the execution engine:
It checks the tweet to make sure all expected fields are present, parses, and translates into an order:
And sends it for execution:
Finally, we get the trade confirmation:
And on Alpaca, we can see the trade in the Order History:
And the account status:
Once you clone this repository run:
npm install to install all dependencies
Once dependencies are installed run:
npm start in your terminal
You will need two accounts:
From the Twitter Developer account you will need to get:
From the Alpaca Paper Trading Account, you will need to get
Once you have all the credentials, open the src/settings.ts file and add your credentials
You can adjust the USD amount traded per signal here as well.
TipperBeats does not provide an explicit stop loss, rather positions are intended to be held until the end of the day regardless of the outcome. Nevertheless, a stop loss is set to be equal distance from the entry price to the profit target. In addition, the program is set up to exit all open positions 5 mins before the market closes. This can be adjusted and modified based on your risk tolerance.
In this article, I discussed the background of the Twitter account TradeSpotter (@tipperbeats), the features of the open-source Modular Trade Execution Engine Bot, and instructions on the integration between the two. Now you are just steps away from connecting a Twitter account to your Alpaca Brokerage account.
In summary, find TradeSpotter (@tipperbeats) here
And the open-source trading engine here
Neither the Twitter signals nor the execution engine is financial advisors. USE AT YOUR OWN RISK.
The signals and software are provided as-is. If you choose to use either, you are responsible for any financial loss or gain.
Alpaca Learn | Developer-First API for Crypto and Stocks Newsletter
Join the newsletter to receive the latest updates in your inbox.