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 (LLMs) 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.5.tar.gz (113.9 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.5-py3-none-any.whl (255.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trading_strategy_tester-0.1.5.tar.gz
  • Upload date:
  • Size: 113.9 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.5.tar.gz
Algorithm Hash digest
SHA256 1567a95a6d11b128da4e6138aaedbeb04868452b424e53b105b0a1e385f0fb7e
MD5 e925be7074bccf535ed7660984bc5754
BLAKE2b-256 01435c9af7552e0c527cf528f198bd7fc1d32c6086fcf906a4352016c3fce8c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trading_strategy_tester-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3a0c464a632d3d424bacc76d8c5983650d093ff98fbeb963eae2d44b479881d2
MD5 a74864fdd18c37951dc6e6bcda283b06
BLAKE2b-256 979c7f0cd12ae47da7493301f306bf222a2184ed949e4624356ecde17a1925f4

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