Skip to main content

A backtesting and performance analysis package

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deltau-1.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

DeltaU-1.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file deltau-1.1.0.tar.gz.

File metadata

  • Download URL: deltau-1.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.7

File hashes

Hashes for deltau-1.1.0.tar.gz
Algorithm Hash digest
SHA256 0b590cbd65a84c68131303d886f059ce9d9f18eb5ca7342e025535ef33ae39ee
MD5 47529c7b82c45c4e0ef94767050dc243
BLAKE2b-256 116cfa1614ce44ebe071ba586ca03c7389d3ba1df3371d9ca74cbeea7e8801fc

See more details on using hashes here.

File details

Details for the file DeltaU-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: DeltaU-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.7

File hashes

Hashes for DeltaU-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9359b224d3842f89083a3ebdd67ccb15842244082827c6c994e2515d47b8cef6
MD5 e74b9d7c3a6bfc42301e75ded684e281
BLAKE2b-256 1e29cdb5f0c5ef1ba82c47e476da72fb1d508c69caf14af64dd5c19c03f88160

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page