Quant Science Profile picture
Jun 19 10 tweets 3 min read Read on X
Automate your trading strategies in Python

How to build your first trading bot:

(a thread) Image
1. What is a trading bot?

A trading bot is a software program that automates buying and selling financial assets like stocks and cryptocurrencies based on pre-defined strategies and rules.

These automated systems can manage portfolios without human intervention, operating 24/7.
2. Let's make a Bitcoin Trading bot

We'll use investing-algorithm-framework in Python Image
Step 1: Setup

We need to specify how often our trading bot runs and which market data it's going to use Image
Step 2: Trading Strategy

We will implement a simple strategy that buys Bitcoin when there is a golden cross between a fast and slow-moving average Image
Step 3: Backtest the Strategy

Now that we have implemented our trading strategy, we can test it. To test our strategy, we will use the backtesting functionality of the investing algorithm framework. Image
Step 4: Analyze the Backtest Results

This trading strategy is profitable with a growth rate of 17% on its closed trades. Image
Step 5: Deploy the Trading Bot

Once we have found a profitable trading strategy, we can deploy the trading app in the cloud. Image
🚨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/joinImage
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

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Quant Science

Quant Science Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @quantscience_

Jun 12
The secret of hedge funds is revealed in a 41-page PDF:

This paper analyzed 464 stocks that 10X-ed over a 24-year period.

Here are the best factors that drive outperformance: (number 3 is the best 🧵) Image
1. Size Effect

"Small-cap stocks outperform medium and large companies in 11 out of 12 cases"

Smaller stocks tend to perform better, but it's not the only contributor. Image
2. Value Effect

"A low book-to-market value (B/M < 1), i.e., low equity and relatively high market cap, implies that investors are paying more for a company than its net assets are worth."

Don't overpay - Overpaying tends to drive underperformance. Image
Read 7 tweets
May 9
A 23-page research paper reveals the number 1 method Hedge Funds use to beat the market:

Time Series Momentum

This is how: 🧵 Image
1. What Is Time Series Momentum?

Time Series Momentum (TSMOM) bets on trends continuing. If a stock’s up, buy more; if down, sell. A 2011 study of 58 assets proved it works! Image
2. The Data Behind the Strategy

The TSMOM paper analyzed equities, currencies & more. T-stats showed consistent profits across 1-month lookbacks! Image
Read 9 tweets
Apr 30
🚨BREAKING: A new open-source multi-agent LLM trading framework in Python

It's called TradingAgents.

Here's what it does (and how to get it for FREE): 🧵 Image
1. What is TradingAgents

TradingAgents is a multi-agent trading framework that mirrors the dynamics of real-world hedge funds.
2. How it works

By deploying specialized LLM-powered agents: from fundamental analysts, sentiment experts, and technical analysts, to trader, risk management team, the platform collaboratively evaluates market conditions and informs trading decisions
Read 8 tweets
Apr 27
A Bloomberg Terminal costs $30,000 a year.

Here's how to build 90% of it for free.

Wall Street doesn't advertise this. But every function that matters has a free alternative in Python.

Here's the DIY version (with Python): Image
━━━━━━━━━━━━━━━━━
🔹 REAL-TIME PRICES & CHARTS
━━━━━━━━━━━━━━━━━
Bloomberg: GP
Python: yfinance + Plotly

yfinance pulls live and historical price data for any ticker in seconds. Plotly turns it into interactive charts. Add your own indicators, overlays, and alerts. No subscription needed.
━━━━━━━━━━━━━━━━━
🔹 FINANCIAL STATEMENTS & RATIOS
━━━━━━━━━━━━━━━━━
Bloomberg: FA
Python: yfinance + pandas

yfinance exposes full income statements, balance sheets, and cash flow statements directly. Pull any company's financials into a DataFrame, calculate your own ratios, and build custom models — all in a notebook.
Read 10 tweets
Apr 27
The secret of hedge funds is revealed in a 41-page PDF:

This paper analyzed 464 stocks that 10X-ed over a 24-year period.

Here are the best factors that drive outperformance: (number 3 is the best 🧵) Image
1. Size Effect

"Small-cap stocks outperform medium and large companies in 11 out of 12 cases"

Smaller stocks tend to perform better, but it's not the only contributor. Image
2. Value Effect

"A low book-to-market value (B/M < 1), i.e., low equity and relatively high market cap, implies that investors are paying more for a company than its net assets are worth."

Don't overpay - Overpaying tends to drive underperformance. Image
Read 8 tweets
Apr 20
A 23-page research paper reveals the number 1 method Hedge Funds use to beat the market:

Time Series Momentum

This is how: 🧵 Image
1. What Is Time Series Momentum?

Time Series Momentum (TSMOM) bets on trends continuing. If a stock’s up, buy more; if down, sell. A 2011 study of 58 assets proved it works! Image
2. The Data Behind the Strategy

The TSMOM paper analyzed equities, currencies & more. T-stats showed consistent profits across 1-month lookbacks! Image
Read 9 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(