DeltaU
DeltaU is a backtesting and performance analysis package for quantitative trading strategies.
Installation
You can install DeltaU using `pip install DeltaU':
Usage
Example usage:
import pandas as pd
from deltau.core.backtester import Backtester, Executor
from deltau.visualization.tear_sheet import TearSheet
# Create a DataFrame
data = pd.read_csv('stock_data.csv')
# Create a strategey and generate signals
class ExampleStrategy:
def generate_signals(self, data):
# Calculate short and long moving averages
data['Short_MA'] = data['Close'].rolling(window=5).mean()
data['Long_MA'] = data['Close'].rolling(window=20).mean()
# Generate signals: 1 for Buy, -1 for Sell, 0 for Hold
signals = (data['Short_MA'] > data['Long_MA']).astype(int).diff()
return signals
# Instantiate the strategy, executor, and backtester
strategy = ExampleStrategy(window=self.window)
executor = Executor(initial_capital=600, share_size=10)
backtester = Backtester(strategy=strategy, executor=executor, data=data)
# Run the backtest
portfolio_values, final_metrics = backtester.run()
# Create a TearSheet object with the results and metrics
tear_sheet = TearSheet(backtest_results=portfolio_values, metrics=final_metrics)
# Generate the report and show plots
tear_sheet.display_report()
## In case you get an error when calling tear_sheet function while using jupyter
Copy and paste: pip install nbformat>=4.2.0 into your envrionment, restart the environment and than re-run the code.
## DeltaU mainly utilizes dataframes for trade simulation, each must contain Date, Open, High, Low, Close, Adj Close, Volume.
# I've tried my best to make things as simple as calling strategy = ExampleStrategy(window=self.window) executor = Executor(initial_capital=600, share_size=10) backtester = Backtester(strategy=strategy, executor=executor, data=data)>
# In order for the simulation to run successfully each strategy needs to generate a 1 (buy), -1 (sell), or 0 (hold) signal.
Metadata
Release files for DeltaU 1.1.0
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 |
|---|---|---|---|---|
| deltau-1.1.0.tar.gz | 7.8 kB | Without provenance | Details for deltau-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| DeltaU-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for DeltaU-1.1.0-py3-none-any.whl |
Total release size: 16.7 kB
Release files / deltau-1.1.0.tar.gz
| Download URL | deltau-1.1.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b590cbd65a84c68131303d886f059ce9d9f18eb5ca7342e025535ef33ae39ee
|
|
BLAKE2b-256 checksum How to use checksums |
116cfa1614ce44ebe071ba586ca03c7389d3ba1df3371d9ca74cbeea7e8801fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.7
|
Release files / DeltaU-1.1.0-py3-none-any.whl
| Download URL | DeltaU-1.1.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9359b224d3842f89083a3ebdd67ccb15842244082827c6c994e2515d47b8cef6
|
|
BLAKE2b-256 checksum How to use checksums |
1e29cdb5f0c5ef1ba82c47e476da72fb1d508c69caf14af64dd5c19c03f88160
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.7
|
Security for DeltaU 1.1.0
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.