vsaveris / trading-technical-indicators

Trading Technical Indicators python library

Home Page:https://www.trading-technical-indicators.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

runSimulation method is replaced by the new getTiSimulation method

vsaveris opened this issue · comments

The runSimulation method of thetti.indicators package will become deprecated in the next beta release. it will be replaced by the new method getTiSimulation. Details about the new method will be added here.

Development Tasks:

  • Implement deprecated exception for the runSimulation method (will be removed in the first stable release)
  • Implement the new getTiSimulation method in the tti.indicators package
  • Rework the not-released class TradingSimulation of the tti.utils package

Testing Tasks:

  • Add test for the deprecated method in the test_indicators_common.py and remove the existing tests for this method
  • Rework the test_utils_trading_simulation.py for matching the new implementation
  • Execute unit testing for the TradingSimulation class
  • Add tests for the getTiSimulation method in the test_indicators_common.py
  • Execute regression testing for the tti package

Description of the new getTiSimulation(close_values, max_exposure=None, short_exposure_factor=1.5) method:

Executes trading simulation based on the trading signals produced by
the technical indicator, by applying an Active trading strategy. With
a ``buy`` trading signal a new ``long`` position is opened. With a
``sell`` trading signal a new ``short`` position is opened. Opened
positions are scanned on each simulation round, and if conditions are
met (current stock price > bought price for opened ``long`` positions
and current stock price < bought price for opened ``short`` positions)
the positions are being closed. Only one stock piece is used in each
open transaction.

Args:
    close_values (pandas.DataFrame): The close prices of the stock, for
        the whole simulation period. Index is of type DateTimeIndex
        with same values as the input to the indicator data. It
        contains one column ``close``.

    max_exposure(float, default=None): Maximum allowed exposure for all
        the opened positions (``short`` and ``long``). If the exposure
        reaches this threshold, no further positions are being opened.
        A new position can be opened again only when exposure reduces
        through a position close. If set to None, then there is no
        upper limit for the opened positions (exposure). When a new
        ``long`` position is opened, exposure is increased by the
        ``stock_price``. When a ``short`` position is opened, exposure
        is increased by the ``short_exposure_factor * stock_price``.
        Values >0.0 or None are supported.

    short_exposure_factor (float, default=1.5): The exposure factor
        when a new ``short`` position is opened. Usually is above 1.0
        and it is used as security when a short position is opened.
        Values >=1.0 are supported.

Unit tests developed and executed (Ran 39 tests in 3.120s, code coverage 100%).

Regression testing executed.