A foundational trading strategy framework for simulating and managing financial trades with customizable profit tracking and balance management.
Project description
Backtester Machine
A framework for backtesting financial strategies.
Table of Contents
Installation
To install backtester_machine
, clone the repository and install the package using pip:
git clone https://github.com/yourusername/backtester_machine.git
cd backtester_machine
pip install .
Or install directly from PyPI (if available):
pip install backtester_machine
For development purposes, install the extra dependencies:
pip install backtester_machine[dev]
Examples
Example 1: Simple Backtest
from backtester_machine import Backtester, Strategy
# Define a simple strategy
class SimpleStrategy(Strategy):
def generate_signals(self, data):
return data['price'].rolling(3).mean() > data['price']
# Create backtester instance
bt = Backtester(SimpleStrategy())
# Run backtest on data
results = bt.run(data)
print(results)
Example 2: Advanced Backtest
from backtester_machine import Backtester, Strategy
# Define more advanced strategy
class AdvancedStrategy(Strategy):
def generate_signals(self, data):
return data['price'].rolling(5).mean() < data['price']
# Run with different parameters
bt = Backtester(AdvancedStrategy(), start_cash=10000, commission=0.001)
results = bt.run(data, from_date='2020-01-01', to_date='2023-01-01')
print(results)
Features
- Customizable strategies: Define your own trading strategies with ease.
- Multiple asset support: Backtest on various asset classes like stocks, crypto, etc.
- Performance metrics: Built-in evaluation metrics such as returns, volatility, and drawdowns.
- Modular design: Easily extend or modify the framework to suit your needs.
Contributions
Contributions are welcome! Please check out the contribution guidelines for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file backtester_machine-0.1.2.tar.gz
.
File metadata
- Download URL: backtester_machine-0.1.2.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc3eb60a86ce47d256e834893e9a10896edb40fbbef86b59f1eda0dfe6e88473 |
|
MD5 | dd7c5db5c80b782fa7ebc17e5b903abf |
|
BLAKE2b-256 | 5b98573178fe22cc36c7eb62c6b9f99ba7a3ecb6316e64d6272fb8fc25cf8659 |
File details
Details for the file backtester_machine-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: backtester_machine-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d56fd1568f86672c3bf942d5f97f822ef8066e5ef2649ed48e71783cc99f8eea |
|
MD5 | beaf27014eb47fb67345d85beb38c3bc |
|
BLAKE2b-256 | 0c5523fdce8f8f7e6577275cb5adc7e8796f0853544984a5ac673a312b1a77e5 |