PyQuant News 🐍 Profile picture
Where finance practitioners get started with Python for quant finance, algorithmic trading, and data analysis | Tweets & threads with free Python code & tools.
Ella Sanders Profile picture Red Redux V Profile picture Paul Profile picture TurkeyClubSandwich Profile picture Bruno Araujo  𝕏 Profile picture 32 subscribed
May 2 10 tweets 3 min read
You can build a stock portfolio to replicate a market index.

Here is the step-by-step process to do it with Python: Image Market indices offer investors a quick look at the overall performance of a specific market or sector.

Index replication is a strategy that lets investors mimic the performance of market indices.

Here’s how you can replicate the S&P500 using Python and Riskfolio-Lib:
Apr 27 18 tweets 4 min read
17 Python GitHub repos for quant finance: Goldman Sachs

github.com/goldmansachs
Apr 25 11 tweets 4 min read
Machine learning is magic for building portfolios.

The problem?

You need a Ph.D. to figure out how to use it.

With RiskFolio-Lib, you can build your own cutting-edge portfolio with machine learning.

No Ph.D. required: Image By reading this thread, you’ll be able to optimize a portfolio using Hierarchical Risk Parity.

HRP:

1. Groups assets using hierarchical clustering
2. Applies risk parity within identified clusters
3. Allocates weights through bisection technique

Here’s how with Python…
Apr 11 12 tweets 4 min read
Backtesting options strategies is impossible.

Why?

• Millions of contracts
• Weekly expirations
• Assignment if ITM

Not anymore.

Now, you can backtest options strategies in a few lines of code.

Here’s how: Image Optopsy is an analysis tool for options trading strategies.

• Generates strategies from raw historic data
• Uncover performance statistics for combos
• 12 strategies built in including strangles

We’ll use 5 years of historic options data on RUT for the analysis.

Let’s go!
Apr 6 11 tweets 3 min read
I learned MATLAB and Octave (wtf?) during my master's degree.

So I studied 12,556 Python code repos and taught myself Python.

99.99% of them were a complete waste of time.

But these 9 are worth more than my $90,000 master's degree: Notebooks that replicate original quantitative finance papers from Emanuel Derman.

github.com/MarcosCarreira…
Mar 28 9 tweets 3 min read
OpenAI.

OpenBB.

LangChain.

Cutting-edge sentiment analysis using generative pre-trained transformers.

All in a few lines of Python.

Here's the code: By reading this thread, you’ll use the OpenBB SDK to download news for a topic.

Then, you’ll build a prompt to predict the sentiment of a news headline.

You’ll bring it all together with LangChain.

Let's go!
Mar 26 12 tweets 3 min read
In 2011, I committed my first code to GitHub.

Since then, I've curated the best Python code for quant finance on the internet.

Here are the 9 best (bookmark this to keep it handy): python-cheatsheet

A comprehensive Python cheatsheet.

github.com/gto76/python-c…
Mar 9 12 tweets 4 min read
My PhD professors taught me MATLAB during my master's degree.

So I watched 200 YouTube videos to learn Python

96% of them were a complete waste of time.

But these 8 taught me more than all my PhD professors combined: Algorithmic Trading Using Python (4.5 hours)

Learn how to perform algorithmic trading using Python in this complete course. Algorithmic trading means using computers to make investment decisions.

Jan 30 20 tweets 2 min read
I spent $90,000 on a master's degree to learn math for finance.

These are the 16 most important stochastic processes for asset pricing (bookmark this thread for later): 1/16 Bessel Process

Models the radial part of a particle's path in motion.

Used to quantify risk in mean-reverting financial instruments.
Jan 20 17 tweets 3 min read
College completely failed to teach me market data analysis.

So I spent 10,000 hours with Python over the last 12 years.

Then, I picked the 15 best libraries for the markets.

But unlike college, these won't cost you $90,000.

Here they are for free: Image 1/15. Backtrader: A powerful platform for backtesting and trading strategies

• Create and backtest trading strategies
• Optimize strategies using machine learning
• Support for multiple data feeds and brokers
Jan 16 15 tweets 5 min read
12 of the best books on building trading systems (bookmark this thread): Image Quantitative Trading

Introduction to basic quantitative trading on a retail level. Image
Jan 9 13 tweets 3 min read
In 2011, I committed my first code to GitHub.

Since then, I've starred the best Python repos for quant finance on the internet.

Here's the 9 best (*definitely* bookmark this): python-cheatsheet

A comprehensive Python cheatsheet.

github.com/gto76/python-c…
Dec 28, 2023 13 tweets 4 min read
A strategy with a Sharpe of 0.94 (and 513.8% cumulative return).

A strategy only Goldman Sachs can trade?

The secret behind their $8.3 billion 2022 net income?

Nope.

Backest a VIX-based futures strategy and demolishes the benchmark.

Just like the pros: Image With SigTech.

Here's a primer in case you're unfamiliar with SigTech:

• Quant tech for institutional investors
• Provides data and tools to hedge funds
• Customers with $5 trillion in assets under management

SigTech was built for institutions.

Now you can have it too:
Dec 26, 2023 24 tweets 7 min read
20 Python libraries for market data everyone should know (that you probably never heard of): googlefinance

Python module to get stock data from Google Finance API. This module provides no delay, real time stock data in NYSE & NASDAQ.

github.com/hongtaocai/goo…
Dec 23, 2023 19 tweets 6 min read
ChatGPT is overhyped for Python.

That's what I told myself after 6 months of frustration.

Turns out I was just a bad prompt writer.

But I've now spent 200+ hours with it.

And it's my Python developer.

Here's how: Image From the beginning, I expected ChatGPT to "know" how to code (and trade).

That was the critical mistake.

I gave it 1-sentence prompts and expected it to write code for me.

But garbage in = garbage out.

So I reframed it:
Dec 21, 2023 9 tweets 2 min read
Use ChatGPT for sentiment analysis on stocks.

The step-by-step guide with code and prompts: After reading this thread, you’ll be able to:

• Download news headlines in one line of code
• Build a prompt to predict sentiment of the headline
• Bring it all together with LangChain

Let’s do it!
Dec 19, 2023 12 tweets 4 min read
One way to get started with algorithmic trading:

Buying a $120,000 master's degree from MIT.

The other way:

YouTube.

The 10 YouTube videos to get you up and running today: Algorithmic Trading Using Python - Full Course

A comprehensive course on algorithmic trading using Python.

Dec 16, 2023 22 tweets 7 min read
Google "algorithmic trading" and get 88,300,000 results.

Google "python tutorial" and get 717,000,000 results.

Utterly exhausting.

Impossible to navigate.

So I took 805,300,000 search results, added in 22+ years of experience, and had a baby.

This is what I named it: Image Getting Started With Python for Quant Finance.

Get up and running with Python fast:

• Copy-paste code to apply immediately
• Help to debug code and ask questions
• Practical experience you can use now
• Get the Python Quant Stack installed

Here's what's packed inside:
Dec 14, 2023 5 tweets 1 min read
Hedge funds are secretive about their strategies.

This PDF exposes their most successful ones.

Grab it here: Image The paper discusses two types of strategies:

1. Arbitrage strategies
2. Macro fund strategies

Here are the details:
Dec 9, 2023 12 tweets 3 min read
I learned MATLAB and Octave (wtf?) during my master's degree.

So I studied 82,112 Python code repos and taught myself Python.

99.9% of them were a complete waste of time.

But these 9 are worth more than my $90,000 master's degree: Notebooks that replicate original quantitative finance papers from Emanuel Derman.

github.com/MarcosCarreira…
Dec 2, 2023 8 tweets 2 min read
The Python Quant Stack:

1. Research environments
2. Numerical computing & stats
3. Data acquisition & manipulation
4. Risk, pricing, & optimization
5. Backtesting & trading

The $0 cost Python Quant Staci: Image 1. Research environments

Where you go to find and test ideas.

• Jupyter Notebook
• OpenBB Terminal