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

Uploaded Python 3

File details

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

File metadata

  • Download URL: trading_strategy_tester-0.1.4.tar.gz
  • Upload date:
  • Size: 113.8 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.4.tar.gz
Algorithm Hash digest
SHA256 d0350a3d217754342ff949fe4716899a1bde158d7703c7e8332b5615416a2b9e
MD5 7ca7c2b867ddc41e369af0a9cecb78a0
BLAKE2b-256 81b8c4b43ee8543d83032ea91f9bc4c62aa6d45e91be76601640c8ab29dd13f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trading_strategy_tester-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 307521d0d9b78f12d61de839ddf6d459d1346fa672afcacb60f2ca91fd2eb1c8
MD5 c10a2f9f046ec87eb0c4fca32498d690
BLAKE2b-256 a542452336f35d21e8d573995e79ce3f72f2140c7a20036bd57dc8effcd6f79e

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