vsaveris / trading-technical-indicators

Trading Technical Indicators python library
https://www.trading-technical-indicators.org/
MIT License
121 stars 34 forks source link

runSimulation method is replaced by the new getTiSimulation method #11

Closed vsaveris closed 3 years ago

vsaveris commented 3 years ago

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:

Testing Tasks:

vsaveris commented 3 years ago

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.
vsaveris commented 3 years ago

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

vsaveris commented 3 years ago

Regression testing executed.