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.6.tar.gz (122.5 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.6-py3-none-any.whl (273.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trading_strategy_tester-0.1.6.tar.gz
  • Upload date:
  • Size: 122.5 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.6.tar.gz
Algorithm Hash digest
SHA256 32a48dbdfac35d20aa09d00b888b4080116ebfb253db6957ac9780be7249cdf9
MD5 f95a2d3e9a4236e530182471a94853ed
BLAKE2b-256 e0beca609acdcdbe7d178519640661bef469315ce16aa24e2340b25b2c7b667f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trading_strategy_tester-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 05abdc21874a39234d66a5fdb57904fd6c8f784e6db2c4993606b820fc89f2f5
MD5 c68244548b11f76cce41b9cb1a3bd8b6
BLAKE2b-256 60fcac71d3432c30c32882b5966148c1cdbb8547d14214364bb1dfb42bc93294

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