Skip to content

trading_agent.doctor.checks.trading_mode_check

Says whether orders are dry runs or live.

Typical usage example:

result = TradingModeCheck('dry_run').run()

TradingModeCheck

TradingModeCheck(mode)

Bases: DoctorCheck

Reports trading_agent.toml's mode.

Creates the check.

Parameters:

Name Type Description Default
mode str

"dry_run" or "live".

required
Source code in src/trading_agent/doctor/checks/trading_mode_check.py
def __init__(self, mode: str):
    """Creates the check.

    Args:
        mode (str): "dry_run" or "live".
    """
    self._mode = mode

run

run()

Reports the mode.

Returns:

Type Description
CheckResult

OK when live; a warning in dry_run, which is the last switch to throw once everything else passes.

Source code in src/trading_agent/doctor/checks/trading_mode_check.py
def run(self) -> doctor_check.CheckResult:
    """Reports the mode.

    Returns:
        doctor_check.CheckResult: OK when live; a warning in dry_run, which is the last switch to throw once everything else passes.
    """
    if self._mode == 'live':
        return doctor_check.CheckResult(
            doctor_check.CheckStatus.OK,
            'LIVE: orders go to the brokers through UBI.',
        )
    return doctor_check.CheckResult(
        doctor_check.CheckStatus.WARNING,
        'dry_run: UBI checks every order and sends none. When everything else passes, set mode = "live" in trading_agent.toml and restart the service.',
    )