TradeFlag#

API documentation for tradeexecutor.state.trade.TradeFlag Python class in Trading Strategy framework.

class TradeFlag[source]#

Bases: Enum

Trade execution flags.

Added on TradeExecution.flags to give the execution more context about this trade.

A trade can have multiple flags. E.g. open and increase should be always set together.

__init__(*args, **kwds)#

Attributes

open

This trade opens a position

close

This trade closes a position

increase

Increase existing position exposure

reduce

Reduce existing position exposure

close_protocol_last

This trade closes a last position in the protocol.

test_trade

This is a test trade made when testing out trade executor infrastructure.

triggered

This trade is a trigger order.

missing_position_repair

The trade was made to associate unknown tokens to a position

partial_take_profit

This trade is a partial take profit

ignore_open

If there is an existing open position, do not try to match the trade for an open position.

open = 'open'#

This trade opens a position

close = 'close'#

This trade closes a position

increase = 'increase'#

Increase existing position exposure

reduce = 'reduce'#

Reduce existing position exposure

close_protocol_last = 'close_protocol_last'#

This trade closes a last position in the protocol.

Used to release collateral interest from Aave.

test_trade = 'test_trade'#

This is a test trade made when testing out trade executor infrastructure.

The trade was performed by perform-test-trade command line command, not a strategy itself.

Test trades should not count towards strategy success metrics.

triggered = 'triggered'#

This trade is a trigger order.

Set when TradeExecution.triggers is filled

missing_position_repair = 'missing_position_repair'#

The trade was made to associate unknown tokens to a position

partial_take_profit = 'partial_take_profit'#

This trade is a partial take profit

ignore_open = 'ignore_open'#

If there is an existing open position, do not try to match the trade for an open position.

We trade by pair. If in same cycle we close and open position for the same pair, the trade would count against the closed pair and not correctly accounted for.

This is for the case that we recall all Aave credit at the start of the cycle, then put it back at the end of the cycle.