Configuration

Haymaker is highly configurable. Parameters can be set in the following order of priority:

  1. Command-line options (highest priority).

  2. System environment variables.

  3. User-provided configuration YAML file.

  4. Default configuration YAML file (fallback for undefined variables).

Default Configuration Files

Sensible starting configurations are defined in default configuration files located here:

  • For the Execution Module:

https://github.com/t1user/haymaker/blob/master/haymaker/config/base_config.yaml

  • For the Dataloader Module:

https://github.com/t1user/haymaker/blob/master/haymaker/config/dataloader_base_config.yaml

User-Provided Configuration File

The easiest way to create an override YAML file is to copy the default file and modify the desired values. Haymaker must be directed to the location of the overridden config file in one of two ways:

  • From the command line using the --file or -f option.

  • Via environment variables: HAYMAKER_HAYMAKER_CONFIG_OVERRIDES for the execution module or HAYMAKER_DATALOADER_CONFIG_OVERRIDES for the dataloader module.

Environment Variables

All Haymaker-related environment variables are prefixed with HAYMAKER_. This prefix is removed when reading the variables, signaling to the framework which variables to load into its configuration environment. This prevents Haymaker from importing unrelated variables.

Note

Environment variable names are case-insensitive.

Warning

For nested variables, only top-level settings can be overridden via CLI or environment variables. These are intended for quick overrides; the framework is primarily configured via YAML files.

Overriding Defaults - Examples

To override defaults, copy a configuration file, modify the desired parameters, and pass the new file’s location to Haymaker via:

  • Environment variable:

    Setting the config override via environment variable
    export HAYMAKER_HAYMAKER_CONFIG_OVERRIDES=config.yaml
    
  • Command-line argument:

    Passing the config file via CLI
    dataloader --file config.yaml
    

Note

Command-line arguments take precedence over environment variables.

Passing Key-Value Pairs from Command Line

Use -s or --set-option to temporarily override parameters. For example, to specify a data source:

Overriding a parameter via CLI
dataloader -s source my_list.csv

Available command-line options can be listed with:

Displaying help for CLI options
module_name --help

CLI Options

Assuming your strategy is in your_module.py and imports haymaker.app.App, the following options are available from the command line:

Primary way to set up appplication is through a yaml file, or environment variables. Command line options listed here overridethose default settings.

usage: dataloader.py [-h] [-s ARG ARG] [-f FILE] [-r] [-z] [-c] [-n] [source]

Positional Arguments

source

Optional file with source data.

Named Arguments

-s, --set_option

Use provided KEY VALUE pair to set parameter KEY to VALUE.

-f, --file

Name of .yaml file with settings (which must exist in the current directory).

-r, --reset

On startup close all existing positions and cancel orders.

Default: False

-z, --zero

On startup zero-out all records.

Default: False

-c, --coldstart

Start programme without reading state from database.

Default: False

-n, --nuke

Cancel all orders and close positions then stop trading.

Default: False

Defaults will be used for all unset parameters.

Examples

Running a strategy with a config override
python my_strategy.py -f config_overrides.yaml

This runs the strategy defined in my_strategy.py with configuration overrides from config_overrides.yaml in the current directory.

Triggering the emergency circuit breaker
python my_strategy.py --nuke

This activates the emergency circuit breaker, closing all open positions, canceling resting orders, and preventing new positions.

Changing the log location
python my_strategy.py -s logging_path /path/to/log

This changes the log location to /path/to/log.

Dataloader CLI Options

Dataloader options differ from those of other modules:

Primary way to set up appplication is through a yaml file, or environment variables. Command line options listed here overridethose default settings.

usage: dataloader.py [-h] [-s ARG ARG] [-f FILE] [-g] [-w] [source]

Positional Arguments

source

Optional file with source data.

Named Arguments

-s, --set_option

Use provided KEY VALUE pair to set parameter KEY to VALUE.

-f, --file

Name of .yaml file with settings (which must exist in the current directory).

-g, --fill_gaps

Whether dataloader should attempt to patch any existing gap in data.

Default: False

-w, --watchdog

Whether watchdog should be used to monitor ib_gateway.

Default: False

Defaults will be used for all unset parameters.

Examples

Collecting historical data from a CSV
dataloader my_list.csv

This runs the dataloader to collect historical data for contracts defined in my_list.csv.

Running dataloader with a custom settings file
dataloader -f settings.yaml

This runs the dataloader with settings from settings.yaml in the current directory. This file should be a modified copy of:

https://github/t1user/haymaker/blob/master/haymaker/config/dataloader_base_config.yaml

specifying the source file with defined contracts, data type, frequency, etc.