stocksimpy
Easy Python backtesting for stocks — fast and simple
stocksimpy lets you prototype trading ideas with minimal boilerplate. Everything is explicit — load data, define rules, run a backtest. No configuration sprawl, no hidden state, and no magic methods.. Perfect for beginners and anyone who wants results fast.
(Disclaimer: This is an early alpha, API might change in the future updates)
🎯 Quick Features
- Load stock prices from
yfinanceor your own database in seconds. - Run fixed or dynamic backtests in just a few lines of code.
- Built-in example strategies like SMA/EMA crossover, RSI, and price action.
- Clear and simple design — no hidden magic, everything is easy to read.
- Beginner-friendly: start experimenting immediately.
⚡ Quick Start
1. Install stocksimpy (and yfinance for convenient data input)
pip install stocksimpy yfinance
2. Imports
from stocksimpy import StockData, Backtester, Visualize, Performance
3. Load Data
# If you want to load your own data from .csv, .sqlite or similar, use appropriate functions built into `StockData()`
data = StockData().from_yfinance([your_stock_symbol], your_starting_date, your_end_date)
4. Define Your Strategy
def sma_crossover(prices):
# Don't do any trades until long range
if(len(prices) < 50):
return "hold"
short = prices["Close"].rolling(20).mean()
long = prices["Close"].rolling(50).mean()
# Buy when short crosses above long, sell when it crosses below
if short > long:
return "buy"
else:
return "sell"
5. Run Backtest
# You can use your own strategy or one of the built-in ones for testing (e.g. Strategy.rsi_momentum_fixed())
bt = Backtester('AAPL', data, sma_crossover)
# Depending on your strategy you may need to run bt.run_backtest_dynamic(), see more on the documentation
bt.run_backtest_fixed()
6. Evaluate the Results
# View performance metrics like max drawdown and sharpe ratio
perf = Performance(bt)
print(perf.generate_risk_report())
7. Visualize
# Visualize the graph
graph = Visualize(bt)
graph.visualize_backtest().show() # You can use .savefig(...) instead of .show() to record the graph in disk
And thats it, you just ran your first backtest 🚀
🤝 Contributions
Ideas, strategies, or improvements? We welcome all contributions! Check out CONTRIBUTING.md for a more detailed information about contributing
📃 Docs
More in depth explanation on how to use this library can be found in ReadTheDocs.
Metadata
Release files for stocksimpy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stocksimpy-0.1.1.tar.gz | 46.2 kB | Without provenance | Details for stocksimpy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stocksimpy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for stocksimpy-0.1.1-py3-none-any.whl |
Total release size: 78.5 kB
Release files / stocksimpy-0.1.1.tar.gz
| Download URL | stocksimpy-0.1.1.tar.gz |
|---|---|
| Size | 46.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b104dc46b3a497e7eb87fb7fb622ee7cb01d1e9663e5b252c248f59632770e9
|
|
BLAKE2b-256 checksum How to use checksums |
0589dfaaef3de9b6b046e3310c00ce3e88edfd5c73bf768f27f220f69bbc6f75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / stocksimpy-0.1.1-py3-none-any.whl
| Download URL | stocksimpy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 32.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa1cb38d0367c6e30278bcd7349335ba4fc6ef7ab83159a292bb1a427c3ae102
|
|
BLAKE2b-256 checksum How to use checksums |
05d73beca55c986cebfc7d155de7608502b729e40dc3616db404aa487c637aad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for stocksimpy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.