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.
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)- create(pair, quantity, price)[source]#
Open a new trade.
- Parameters:
pair (TradingPairIdentifier) –
quantity (Decimal) –
price (float) –
- Return type:
- 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:
quantity (Decimal) – How much to redeem, in the spot units hold.
timestamp (datetime) –
portfolio (Portfolio) –
position (TradingPosition) –
- Return type: