UnitTestTrader#

API documentation for tradeexecutor.testing.unit_test_trader.UnitTestTrader Python class in Trading Strategy framework.

class UnitTestTrader[source]#

Bases: object

Helper class to generate and settle trades in unit tests.

This trade helper is not connected to any blockchain - it just simulates txid and nonce values.

__init__(state, lp_fees=2.5, price_impact=0.99)[source]#
Parameters:

state (State) –

Methods

__init__(state[, lp_fees, price_impact])

buy(pair, quantity, price)

buy_with_price_data(pair, quantity, ...)

close_short(pair, quantity, price[, leverage])

create(pair, quantity, price)

Open a new trade.

create_and_execute(pair, quantity, price[, ...])

open_short(pair, quantity, price[, leverage])

prepare_buy(pair, quantity, price)

redeem_in_kind(timestamp, portfolio, ...[, ...])

Simulate in-kind redemption.

sell(pair, quantity, price)

sell_with_price_data(pair, quantity, ...)

set_perfectly_executed(trade[, triggered])

Sets trade to a executed state.

time_travel(timestamp)

__init__(state, lp_fees=2.5, price_impact=0.99)[source]#
Parameters:

state (State) –

create(pair, quantity, price)[source]#

Open a new trade.

Parameters:
Return type:

Tuple[TradingPosition, TradeExecution]

set_perfectly_executed(trade, triggered=False)[source]#

Sets trade to a executed state.

  • There are no checks whether the wallet contains relevant balances or not

Parameters:

trade (TradeExecution) –

redeem_in_kind(timestamp, portfolio, position, quantity, redeemer='0x0000000000000000000000000000000000000000')[source]#

Simulate in-kind redemption.

Parameters:
Return type:

BalanceUpdate