Backtesting.initial_conditions

Initial conditions configuration for backtesting.

InitialConditions

Static methods for accessing backtest configuration.

Source code in Backtesting/initial_conditions.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class InitialConditions:
    """Static methods for accessing backtest configuration."""

    @staticmethod
    def get_initial_time() -> datetime:
        """Get backtest start time.

        Returns:
            Start datetime for backtest.
        """
        return initial_time

    @staticmethod
    def get_final_time() -> datetime:
        """Get backtest end time.

        Returns:
            End datetime for backtest.
        """
        return final_time

    @staticmethod
    def get_time_step_size() -> int:
        """Get time step size in seconds.

        Returns:
            Time step size in seconds.
        """
        return time_step_size

    @staticmethod
    def get_positions() -> dict:
        """Get initial portfolio positions.

        Returns:
            Dictionary mapping stock symbols to share counts.
        """
        return positions

    @staticmethod
    def get_cash() -> float:
        """Get initial cash amount.

        Returns:
            Starting cash amount.
        """
        return cash

    @staticmethod
    def get_save_file() -> str:
        """Get results output file path.

        Returns:
            File path for saving backtest results.
        """
        return save_file

get_cash() staticmethod

Get initial cash amount.

Returns:
  • float

    Starting cash amount.

Source code in Backtesting/initial_conditions.py
50
51
52
53
54
55
56
57
@staticmethod
def get_cash() -> float:
    """Get initial cash amount.

    Returns:
        Starting cash amount.
    """
    return cash

get_final_time() staticmethod

Get backtest end time.

Returns:
  • datetime

    End datetime for backtest.

Source code in Backtesting/initial_conditions.py
23
24
25
26
27
28
29
30
@staticmethod
def get_final_time() -> datetime:
    """Get backtest end time.

    Returns:
        End datetime for backtest.
    """
    return final_time

get_initial_time() staticmethod

Get backtest start time.

Returns:
  • datetime

    Start datetime for backtest.

Source code in Backtesting/initial_conditions.py
14
15
16
17
18
19
20
21
@staticmethod
def get_initial_time() -> datetime:
    """Get backtest start time.

    Returns:
        Start datetime for backtest.
    """
    return initial_time

get_positions() staticmethod

Get initial portfolio positions.

Returns:
  • dict

    Dictionary mapping stock symbols to share counts.

Source code in Backtesting/initial_conditions.py
41
42
43
44
45
46
47
48
@staticmethod
def get_positions() -> dict:
    """Get initial portfolio positions.

    Returns:
        Dictionary mapping stock symbols to share counts.
    """
    return positions

get_save_file() staticmethod

Get results output file path.

Returns:
  • str

    File path for saving backtest results.

Source code in Backtesting/initial_conditions.py
59
60
61
62
63
64
65
66
@staticmethod
def get_save_file() -> str:
    """Get results output file path.

    Returns:
        File path for saving backtest results.
    """
    return save_file

get_time_step_size() staticmethod

Get time step size in seconds.

Returns:
  • int

    Time step size in seconds.

Source code in Backtesting/initial_conditions.py
32
33
34
35
36
37
38
39
@staticmethod
def get_time_step_size() -> int:
    """Get time step size in seconds.

    Returns:
        Time step size in seconds.
    """
    return time_step_size