YieldManager#

API documentation for tradeexecutor.strategy.pandas_trader.yield_manager.YieldManager Python class in Trading Strategy framework.

class YieldManager[source]#

Bases: object

Generate yield on cash.

  • Park cash to profitable positions outside direactional trading

  • Extract cash when needed

Example:

# Move cash in and out yield managed to cover spot positions
if parameters.use_managed_yield:

    yield_manager = YieldManager(
        position_manager=position_manager,
        rules=create_yield_rules(parameters, strategy_universe),
    )

    yield_input = YieldDecisionInput(
        execution_mode=input.execution_context.mode,
        cycle=input.cycle,
        timestamp=timestamp,
        total_equity=state.portfolio.get_total_equity(),
        directional_trades=trades,
        size_risk_model=size_risk_model,
        pending_redemptions=position_manager.get_pending_redemptions(),
    )

    yield_result = yield_manager.calculate_yield_management(yield_input)
    trades += yield_result.trades
__init__(position_manager, rules)[source]#
Parameters:

Methods

__init__(position_manager, rules)

param position_manager:

calculate_cash_needed_to_cover_directional_trades(...)

How much cash we need ton this cycle.

calculate_yield_management(input)

Calculate trades for the yield management.

calculate_yield_positions(execution_mode, ...)

Calculate cash positions we are allowed to take.

gather_current_yield_positions()

Get map of our non-directional positions.

generate_rebalance_trades(cycle, timestamp, ...)

Create trades to adjust yield positions.

Attributes

cash_pair

portfolio

__init__(position_manager, rules)[source]#
Parameters:
gather_current_yield_positions()[source]#

Get map of our non-directional positions.

  • Note that this is called in planning phase, so there may be pending positions

Returns:

List of positions that are used to generate yield.

Return type:

dict[tradeexecutor.state.identifier.TradingPairIdentifier, tradeexecutor.state.generic_position.GenericPosition | None]

generate_rebalance_trades(cycle, timestamp, current_yield_positions, desired_yield_positions)[source]#

Create trades to adjust yield positions.

Parameters:
Return type:

list[tradeexecutor.state.trade.TradeExecution]

calculate_yield_positions(execution_mode, timestamp, cycle, cash_available_for_yield, current_positions, size_risk_model=None, usd_assert_epsilon=0.01)[source]#

Calculate cash positions we are allowed to take.

  • Simple first in, first out, fill earier rules to their max weight

Parameters:
Return type:

dict[tradeexecutor.state.identifier.TradingPairIdentifier, tradeexecutor.strategy.pandas_trader.yield_manager.YieldDecision]

calculate_cash_needed_to_cover_directional_trades(input, available_cash, already_deposited)[source]#

How much cash we need ton this cycle.

  • We have a strategy that uses Aave for USDC credit yield, or similar yield farming service

  • We need to know how much new cash we need to release

Note

Only call this after you have set up all the other trades in this cycle.

See also manage_credit_flow()

Returns:

Positive: This much of cash must be released from credit supplied. Negative: This much of cash be deposited to Aave at the end of the cycle.

Parameters:
calculate_yield_management(input)[source]#

Calculate trades for the yield management.

Parameters:

input (YieldDecisionInput) –

Return type:

YieldResult