Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Trader

Overview

A trader is responsible for creating orders and managing the risk. It can create orders based on the signals it receives that are created by a Strategy, but it can also create orders based on the latest version of the account.

API

The Trader API has 1 single method called create_orders that needs to be implemented:

Some of the typical logic found in a trader:

SimpleTrader

The SimpleTrader is the default trader implementation in roboquant.

As the name suggests, it implements a simple set of rules. This makes it easier to understand what is going on, although not suitable for all use cases.

Key characteristics:

FlexTrader

FlexTrader uses a percentage of the equity to determine the desired order sizes. So if your equity grows during a back test, so does the average order size.

Some of the features:

Custom Trader

If you have custom risk policies, you’ll have to implement a custom trader. It requires a lot of testing to see if all edge cases are handled.

A very basic and naive implementation would look something like this:

But this handles none of the challenges:

Below is an example how risk management could be implemented for open positions that are loosing too much money.