Skip to main content

This project is based on pybacktestchain but new functionalities have been added!

Project description

Project: python_project_RD

Purposes

Improve the package pybacktestchain by:

  1. Adding new asset allocation strategies (extra_modules.py):
    • Added RiskParity class as a subclass to the Information class from pybacktestchain,
    • Added MinimumVariancePortfolio class as a subclass to the Information class from pybacktestchain.
  2. Extending the analysis for the user (extra_broker.py):
    • Created the CustomBroker subclass from the Broker class of pybacktestchain in order to modify the execute_portfolio function,
    • Developed the AnalysisTool class, which computes different statistics for portfolio analysis,
    • Modified Backtest class so that after running the run_backtest() function, CSV, PNG, and TXT files are saved in the \python_project_RD\backtest_analysis directory, providing users with additional analysis on the backtest.
  3. Being participative and user-friendly (user_function.py):
    • Created strategy_choice() function to allow users to choose a strategy for the backtest among several options,
    • Created ask_user_for_comment() function enabling users to leave a comment on the project's discussions page on GitHub,
    • Created get_initial_parameter() function for users to select parameters for running the backtest, such as the initial cash, the stop loss threshold, the start date and the end date of the backtest.

Overall, this package enables users to create tailored and bespoke backtests on Equity and provides tools for comparing different backtests.

Installation

$ pip install python_project_RD

Usage

from src.python_project_RD.extra_broker import Backtest
from pybacktestchain.broker import StopLoss
from src.python_project_RD.user_function import get_initial_parameter, strategy_choice, ask_user_for_comment

# Enable or disable logging verbosity
verbose = False  # Set to True to enable logging, or False to suppress it


initial_cash, stop_loss_threshold, start_date, end_date = get_initial_parameter()# Gather initial parameters from the user
strategy, strategy_name = strategy_choice()# Allow the user to choose a trading strategy and store the selected strategy name
ask_user_for_comment() # Prompt the user for additional comments regarding the backtest setup

# Create a customized backtest instance with user-defined parameters
backtest = Backtest(
    initial_date=start_date,          
    final_date=end_date,              
    initial_cash=initial_cash,        
    threshold=stop_loss_threshold,     
    information_class=strategy,       
    strategy_name=strategy_name,      
    risk_model=StopLoss,               
    name_blockchain='backtest',        
    verbose=verbose                 
)

# Execute the backtest with the specified parameters
backtest.run_backtest()

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

python_project_RD was created by Rosalie Dechance. This same package is based on the pybacktestchain package created by by Juan F. Imbet as part of a project for the course Python Programming for Finance at Paris Dauphine University - PSL.

It is licensed under the terms of the MIT license.

Credits

python_project_RD was created with cookiecutter and the py-pkgs-cookiecutter template.

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

python_project_rd-0.5.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

python_project_rd-0.5.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file python_project_rd-0.5.0.tar.gz.

File metadata

  • Download URL: python_project_rd-0.5.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.10 Windows/10

File hashes

Hashes for python_project_rd-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1263a99c05a90975e86669d5bee25e160bb1d471ac126920a12a52ff939fb871
MD5 f5d1681ce2ee6d969fdfd87e1890a47d
BLAKE2b-256 da2f4aa3e257f47628fd088b65212ff09c62f941620cd376fa7b4738c1932d28

See more details on using hashes here.

File details

Details for the file python_project_rd-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: python_project_rd-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.10 Windows/10

File hashes

Hashes for python_project_rd-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 382d363118e880ba3203120a6338a6983f63a975f731c47c363077eb2679660d
MD5 4a1ece1f4bb172329970e2c59a6914bb
BLAKE2b-256 9422bd149dc62baee919840262ef6a987d73eda5dab16a8dc3dc0c7d748f686f

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