Skip to main content

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)

Source distribution for DeltaU 1.1.0
File Size Uploaded
deltau-1.1.0.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for DeltaU 1.1.0
File Interpreter ABI Platform
DeltaU-1.1.0-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page