# How to Initialize the AutoHedge System with Custom Parameters

> Learn to initialize the AutoHedge system with custom parameters like name, description, and output settings. Tailor your autonomous trading experience effortlessly.

- Repository: [Swarms/AutoHedge](https://github.com/The-Swarm-Corporation/AutoHedge)
- Tags: how-to-guide
- Published: 2026-09-08

---

**TLDR:** The `AutoHedge` class in [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py) accepts optional constructor arguments—including `name`, `description`, `output_dir`, `output_file_path`, and `output_type`—that let you customize the system's identity, file locations, and return formats before running autonomous trading cycles.

The AutoHedge system from The-Swarm-Corporation/AutoHedge repository provides a fully autonomous hedge fund framework. Learning how to initialize the AutoHedge system with custom parameters allows you to tailor output destinations, naming conventions, and data formats to fit your deployment pipeline. The entry point is the `AutoHedge` class constructor located in [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py), which configures the logger and conversation handlers before orchestrating the agent swarm.

## AutoHedge Constructor Parameters

The `AutoHedge` constructor defined on lines 9-22 of [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py) exposes five optional parameters that control instance behavior:

- **`name`** – Identifier for the hedge fund instance. Defaults to `"autohedge"`.
- **`description`** – Human-readable description of the system. Defaults to `"fully autonomous hedgefund"`.
- **`output_dir`** – Directory path where generated files are stored. The system creates this directory automatically if it does not exist. Defaults to `"outputs"`.
- **`output_file_path`** – Optional explicit file path for single-file output. When provided, the system writes to this specific location instead of the `output_dir` folder. Defaults to `None`.
- **`output_type`** – Controls the return format of the `run()` method. Accepts `"list"`, `"dict"`, or `"str"`. Defaults to `"list"`.

## Initialization Internals

During instantiation, the constructor performs critical setup operations on lines 30-32 of [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py). It initializes a **Loguru** logger for runtime event tracking and creates a **Swarms** `Conversation` object that logs dialogue between agents throughout the trading cycle. These components are essential for monitoring the autonomous decision-making process and debugging agent interactions.

## Output Configuration and Return Formats

The `output_type` parameter directly influences the return value processing logic found on lines 52-60 of [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py). Selecting `"list"` returns conversation turns as a list structure, `"dict"` returns a dictionary mapping participants to responses, and `"str"` returns a plain text transcript. When you specify `output_file_path`, the system writes results to that explicit location rather than generating filenames within `output_dir`.

## Practical Initialization Examples

Use these patterns to instantiate `AutoHedge` with different configuration profiles.

Default initialization with no custom arguments:

```python
from autohedge import AutoHedge

system = AutoHedge()
print(system.run("Analyze AAPL for 20k allocation"))

```

Custom identity with dictionary output format:

```python
from autohedge import AutoHedge

system = AutoHedge(
    name="my_custom_hedge",
    description="My bespoke autonomous fund",
    output_type="dict",
    output_dir="my_outputs",
)
result = system.run("Analyze TSLA for 50k allocation")
print(result)  # → {'user': ..., 'director': ..., ...}

```

Directing output to a specific file path:

```python
from autohedge import AutoHedge

system = AutoHedge(
    output_file_path="reports/tsla_report.txt",
    output_type="str",
)

report = system.run("Analyze TSLA for 50k allocation")
with open(system.output_file_path, "w") as f:
    f.write(report)

```

## Integration with the Agent Pipeline

After initialization, the `AutoHedge` instance manages the task workflow by interfacing with the **Director Agent** defined in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) (lines 1-20). This agent receives the task string and drives the remainder of the analysis pipeline. For command-line deployments, [`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py) provides the `run_repl` function (lines 73-77) which creates a default `AutoHedge` instance, though you can bypass the CLI entirely by instantiating the class directly in your Python scripts. Environment variables required for agent operation are loaded via [`autohedge/env_loader.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/env_loader.py).

## Summary

- The `AutoHedge` class accepts five key parameters—`name`, `description`, `output_dir`, `output_file_path`, and `output_type`—to customize initialization.
- The `output_type` parameter controls whether the `run()` method returns a list, dictionary, or plain string according to lines 52-60 of [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py).
- Custom `output_dir` and `output_file_path` values let you redirect file operations to specific locations, with automatic directory creation handled by the constructor.
- The initialization process sets up Loguru logging and a Swarms `Conversation` object on lines 30-32 of [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py).
- Initialized instances pass tasks to the Director Agent defined in [`autohedge/workers.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/workers.py) to execute the autonomous trading analysis.

## Frequently Asked Questions

### What is the default output format when initializing AutoHedge?

The default `output_type` is `"list"`, which returns conversation turns as a list structure. You can override this with `"dict"` for dictionary formatting or `"str"` for plain string output suitable for file writing.

### How do I specify a custom directory for AutoHedge output files?

Pass the `output_dir` parameter to the constructor with your desired path string. The system automatically creates the directory if it does not exist. Alternatively, use `output_file_path` to specify an exact file location instead of a folder when you need precise control over the destination.

### What dependencies does AutoHedge initialize during construction?

According to [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py) lines 30-32, the constructor sets up a Loguru logger for runtime events and a Swarms `Conversation` object to track dialogue between agents. These dependencies are essential for the logging and agent coordination pipeline.

### Can I use AutoHedge without the command-line interface?

Yes. While [`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py) provides a `run_repl` function for CLI usage (lines 73-77), you can instantiate `AutoHedge` directly in Python scripts with custom parameters and call the `run()` method programmatically to integrate the system into larger applications.