Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ta4j backtesting #135

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

MarcDahlem
Copy link
Contributor

@MarcDahlem MarcDahlem commented Apr 22, 2021

Added an adapter which allows to backtest a strategy with ta4j given a recorded ta4j baseseries as json.

Some remarks/limitations:

  • The simulation adapter is based on a current "tick", which is increased every time the "getTicker" is called
    • This means especially, that a strategy must call getTicker in its execute phase at all
    • This means especially, that a strategy most not call getTicker multiple times in the same execution phase
  • JSON handling
    • It is assumed, that the recorded base series (and stored as json) added every ticker update from the real market in an own "bar"
    • Furthermore it is assumed, that the getHigh of each bar contains the ask-price
    • Furthermore it is assumed, that the getLow of each bar contains the bid-price
    • An example on how to capture a barseries and how to store it to json will be added in an example strategy
  • ta4j can't differentiate costs for sell and buy orders, thats why only one fee can be configured
  • one can configure if the recorded and backtested orders should be printed to a graph. This needs a display (x11) to be available for the java runtime
  • For comparison reasons, a rudimentary "optimal order" calculation is added
  • As the backend cannot be stopped normaly (as far as I saw), the ta4j-simulation adapter throws a tradingApiException as soon as the end of the available barseries is reached
  • Orders are "recorded" in ta4j rules as execution indexes for buy and sell order. This concept only works, if a strategy places only at least one order at a execution phase
    • Only one open order is allowed at a time tick. Normal flow: place BUY order, wait for BUY to fulfill, place SELL order, wait for SELL order to fulfill
  • As the gradle build was very slow, I added the following as suggested by many answers on stack overflow and co. https://docs.spring.io/dependency-management-plugin/docs/current/reference/html/#maven-exclusions-disabling

@MarcDahlem MarcDahlem changed the title Feature/ta4j backtesting WIP: Feature/ta4j backtesting Apr 22, 2021
@MarcDahlem MarcDahlem changed the title WIP: Feature/ta4j backtesting Feature/ta4j backtesting Apr 22, 2021
@MarcDahlem MarcDahlem mentioned this pull request May 5, 2021
@gazbert gazbert assigned gazbert and MarcDahlem and unassigned gazbert May 8, 2021
@gazbert gazbert added this to the Ta4j Backtesting Capability milestone May 8, 2021
@gazbert gazbert added this to In Progress in BX-bot May 8, 2021
@gazbert gazbert moved this from In Progress to TODO in BX-bot Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

None yet

2 participants