Skip to main content

Simulate and evaluate trading strategies

Project description

Trading Strategy Tester

A flexible Python package for simulating and evaluating algorithmic trading strategies with modular conditions, strategies, and trade simulations.

Installation

To install the Trading Strategy Tester package, you can use pip:

pip install trading-strategy-tester

If you want to install the latest development version, you can clone the repository and install it locally:

git clone https://github.com/DrDanicka/trading_strategy_tester.git

Documentation

The documentation is available in the docs directory. You can view it online at this link.

Examples

You can find examples of how to use the package in the examples tab of the user documentation. These examples cover various aspects of the package, including strategy creation, execution, and visualization or using technical indicators.

LLM Integration

The project integrates with Large Language Models to help generate trading strategies from natural language descriptions. It is available in 2 types:

  1. WEB UI: A web-based interface that allows users to input natural language prompts and visualize the results. You can find can learn more about the web app in this repository.
  2. Code interface: You can use the LLM integration directly in your Python code. This can be done via process_prompt(prompt: str, llm_model: LLMModel) function. You can do it like this:
from trading_strategy_tester import process_prompt, LLMModel

trades, graphs, stats, strategy_obj, changes = process_prompt(
    prompt="""Can you generate a long strategy for LULU that goes long when the Open Price is in a negative trend for 77 days
        and price is within a 50% fibonacci level during an uptrend is correct and sells out when the Know Sure Thing varies by
        65.99 percent over 62 days is fulfilled. Set trailing stop-loss at 27.52%. Set the start date as 2013-12-13. Set the 
        interval to 5 days. Set trade commissions to 5%.""",
    llm_model=LLMModel.LLAMA_ALL
)

You can later use the trades, graphs, stats, strategy_obj, and changes variables to visualize the results, analyze the performance, and make further modifications to the strategy.

This project uses Llama 3.2 models via Ollama framework. The models need to be installed first so that the package can use them. Follow these steps:

  1. You need to install Ollama on your machine using this link.
  2. After that, you have to download the model weights. You can do the following:
git clone https://github.com/DrDanicka/trading_strategy_tester_web_app
cd trading_strategy_tester_web_app
python init_ollama.py

This will download and initialize the Ollama models. After all of this is done, you can delete the trading_strategy_tester_web_app directory if you want to.

Now you can use the process_prompt function to generate trading strategies from natural language prompts.

To learn more about how to write prompts, and LLM integration in general, you can check the LLM Integration documentation.

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

trading_strategy_tester-0.1.7.tar.gz (122.6 kB view details)

Uploaded Source

Built Distribution

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

trading_strategy_tester-0.1.7-py3-none-any.whl (273.5 kB view details)

Uploaded Python 3

File details

Details for the file trading_strategy_tester-0.1.7.tar.gz.

File metadata

  • Download URL: trading_strategy_tester-0.1.7.tar.gz
  • Upload date:
  • Size: 122.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for trading_strategy_tester-0.1.7.tar.gz
Algorithm Hash digest
SHA256 3b973a23b58b1a8c0f305457893d2f8feee4e88ef25fd92180cd63ee203b6dbc
MD5 3724ad0cdc1ab25074803021a6b72585
BLAKE2b-256 fafa339427589da401b77f6662112167c789621b0c3a80bdad6328ad6238abd4

See more details on using hashes here.

File details

Details for the file trading_strategy_tester-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for trading_strategy_tester-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7f60a9acb63542e01d45a67710d02ed9c70a50a9a674bbe2161dc5bb90756b81
MD5 4454e7f36affd0b3eda87b9b1f873cff
BLAKE2b-256 f3cbee56f5240c8cc35eec87e34d399d2c4f95cf6fe392088c8789ea70228ef6

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