How to make a simple algorithmic trading strategy with a 472% return using Python.
A thread. 🧵

This strategy takes advantage of "flow effects", which is how certain points in time influence the value of an asset.
This strategy uses a simple temporal shift to determine when trades should exit relative to their entry for monthly boundary conditions.
This strategy uses a simple temporal shift to determine when trades should exit relative to their entry for monthly boundary conditions.

The signals for when to go short, when to cover shorts, when to go long, and when to close longs are all linked to these recurring monthly cycles.
This periodic "flow" of signals—month-in, month-out—creates a systematic pattern.
This periodic "flow" of signals—month-in, month-out—creates a systematic pattern.

1. Load the libraries and data
Import these libraries. Then run the code to ingest price data on TLT.
Import these libraries. Then run the code to ingest price data on TLT.

2. Generate Signals
We'll first set up an empty data frame to track the long/short signals.
Then we create short entry signals on each new month's 1st and 5th day.
Similarly, we make long signals 7 days and 1 day before the end of each month.
We'll first set up an empty data frame to track the long/short signals.
Then we create short entry signals on each new month's 1st and 5th day.
Similarly, we make long signals 7 days and 1 day before the end of each month.

3. Run this code to get the Trade PnL
Use vbt.Portfolio.from_signals().
Use vbt.Portfolio.from_signals().

Use pf.stats() to return the portfolio stats summary tear sheet.

🚨Want to learn Algorithmic Trading Strategies (that actually work)?
On June 25th, we are hosting a free workshop to help you get started with algorithmic trading with Python.

Register here (500 seats): learn.quantscience.io/join
On June 25th, we are hosting a free workshop to help you get started with algorithmic trading with Python.

Register here (500 seats): learn.quantscience.io/join

That's a wrap! Over the next 24 days, I'm sharing my top 24 algorithmic trading concepts to help you get started.
If you enjoyed this thread:
1. Follow me @quantscience_ for more of these
2. RT the tweet below to share this thread with your audience
If you enjoyed this thread:
1. Follow me @quantscience_ for more of these
2. RT the tweet below to share this thread with your audience
View Tweet
P.S. - Want Algorithmic Trading with Python tutorials every Sunday?
Register here to join our Sunday Quant Scientist Newsletter (it's free): learn.quantscience.io/quant-scientis…
Register here to join our Sunday Quant Scientist Newsletter (it's free): learn.quantscience.io/quant-scientis…
Generated by Thread Navigator
Press ⌘ + S to quick-export
