- GuruFinance Insights
- Posts
- Why I’m Hooked on Backtesting with Python and fastquant
Why I’m Hooked on Backtesting with Python and fastquant
Powerful Python backtesting secrets that pros are using to supercharge trading strategies 🐍📈
There’s a reason 400,000 professionals read this daily.
Join 400,000+ professionals at Google, Microsoft, OpenAI, and more who start their day with The AI Report — the #1 B2B AI newsletter. We cut through the noise and show you exactly how to use AI tools to save time, boost productivity, and stay ahead at work.
No hype. No fluff. Just real-world use cases, expert prompts, and actionable tools.
🚀 Your Investing Journey Just Got Better: Premium Subscriptions Are Here! 🚀
It’s been 4 months since we launched our premium subscription plans at GuruFinance Insights, and the results have been phenomenal! Now, we’re making it even better for you to take your investing game to the next level. Whether you’re just starting out or you’re a seasoned trader, our updated plans are designed to give you the tools, insights, and support you need to succeed.
Here’s what you’ll get as a premium member:
Exclusive Trading Strategies: Unlock proven methods to maximize your returns.
In-Depth Research Analysis: Stay ahead with insights from the latest market trends.
Ad-Free Experience: Focus on what matters most—your investments.
Monthly AMA Sessions: Get your questions answered by top industry experts.
Coding Tutorials: Learn how to automate your trading strategies like a pro.
Masterclasses & One-on-One Consultations: Elevate your skills with personalized guidance.
Our three tailored plans—Starter Investor, Pro Trader, and Elite Investor—are designed to fit your unique needs and goals. Whether you’re looking for foundational tools or advanced strategies, we’ve got you covered.
Don’t wait any longer to transform your investment strategy. The last 4 months have shown just how powerful these tools can be—now it’s your turn to experience the difference.
I’ve always been that guy who loves messing with trading ideas. You know, dreaming up ways to beat the market, then wondering if they’d actually work. Backtesting’s my jam — it’s like sneaking a peek at yesterday’s lottery numbers. And lately, I’ve been obsessed with Python and this thing called fastquant. Get this: you can test a strategy in three lines. Three! Let’s dig in.

Python’s My New Best Friend
A while back, I was that dope trying to crunch numbers in Excel. Total mess — sheets everywhere, formulas breaking, and me pretending I knew what I was doing. Then Python strolled in. It’s quick, it’s chill, and it’s got all these tools that make trading stuff easy. I was sold.
fastquant is the real MVP, though. It’s like someone said, “Hey, let’s make backtesting simple for regular folks like us.” And they nailed it. No finance degree needed — just a laptop and some curiosity.

Getting It Going
To start, you gotta grab fastquant. Open your terminal — or that weird command box — and type:
pip install fastquant
Done. That’s it. Now let’s play with some data.
Snagging Prices
I wanted to see how Jollibee stock (it’s “JFC”) did a few years ago. Easy peasy:
from fastquant import get_stock_data
df = get_stock_data("JFC", "2018-01-01", "2019-01-01")
print(df.head())
You get this:
dt close
2019-01-01 293.0
2019-01-02 292.0
2019-01-03 309.0
Crypto’s my other thing — Bitcoin especially. Here’s how to pull that:
from fastquant import get_crypto_data
crypto = get_crypto_data("BTC/USDT", "2018-12-01", "2019-12-31")
print(crypto.head())
And bam:
dt open high low close
2018-12-01 4041 4299 3963 4190
It’s raw prices, straight up. Love it.

Testing in Three Lines
Okay, here’s the fun part. I dig this thing called SMAC — short average crosses the long one, you buy; flips back, you sell. Check it:
from fastquant import backtest
backtest("smac", df, fast_period=15, slow_period=40)
And it spits out:
Start cash: 100000
End cash: 102272
Three lines, and I made a couple grand on Jollibee. Not huge, but cool for a quick goof-around.
More Tricks to Try
fastquant isn’t stingy — it’s got a bunch of strategies. Here’s two I messed with:
RSI
Buy when it’s cheap, sell when it’s high. Like this:
backtest("rsi", df, rsi_period=14, rsi_upper=70, rsi_lower=30)
Boom:
Start: 100000
End: 132967
That’s a fat win — 30% up!
Bollinger Bands
This one’s about catching wild price jumps:
backtest("bbands", df, period=20, devfactor=2)
Eh:
Start: 100000
End: 97060
Lost a bit. Oh well — can’t win ’em all.
Fiddling Around
I’m nosy, so I wondered if 15 and 40 were the best for SMAC. Let’s try a bunch:
res = backtest("smac", df, fast_period=range(15, 30, 3), slow_period=range(40, 55, 3), verbose=False)
print(res[['fast_period', 'slow_period', 'final_value']].head())Here’s what I got:
fast slow cash
15 40 102272
21 40 9884715 and 40 still rule. Nice to know.
No-Code Option
My pal Dave hates code — he’s all “just give me buttons!” So I told him about Hawksight. It’s new, it’s free, and it’s from the fastquant folks. No typing, just clicking. I might sneak a peek myself when I’m lazy.
Getting Crazy with Predictions
One night, I got nuts and tried predicting Bitcoin with this Prophet thing. It’s a bit of a slog, but here’s the short version:
from fbprophet import Prophet
from fastquant import get_crypto_data, backtest
df = get_crypto_data("BTC/USDT", "2019-01-01", "2020-05-31")
ts = df.reset_index()[["dt", "close"]]
ts.columns = ["ds", "y"]
m = Prophet().fit(ts)
forecast = m.make_future_dataframe(periods=0)
pred = m.predict(forecast)
returns = pred.set_index("ds").yhat.pct_change().shift(-1).multiply(100)
df["custom"] = returns.multiply(-1)
backtest("custom", df.dropna(), upper_limit=1.5, lower_limit=-1.5)
It’s me guessing Bitcoin’s next move and trading off that. Total geek move, but fun.

Backtesting used to scare me — felt like I needed a math degree. But fastquant? It’s a game-changer. I can test ideas in minutes, whether I’m keeping it basic or going full nerd. Hawksight’s there if I’m feeling lazy too. Trading’s getting fun again.