FreqtradeRoutingModel#
API documentation for tradeexecutor.strategy.freqtrade.freqtrade_routing.FreqtradeRoutingModel Python class in Trading Strategy framework.
- class FreqtradeRoutingModel[source]#
Bases:
RoutingModelRoute capital deposits/withdrawals to Freqtrade instances.
Supports multiple deposit methods: - On-chain transfer: Simple ERC20 transfer (for Lagoon vault integration) - Aster: ERC20 approve + AstherusVault.deposit() on BSC - Hyperliquid: Bridge transfer on Arbitrum + SDK vault deposit - Orderly vault: ERC20 approve + Vault.deposit() with hashed params
- __init__(freqtrade_configs)[source]#
Initialise routing model.
- Args:
freqtrade_configs: Dict mapping freqtrade_id -> FreqtradeConfig
- Parameters:
freqtrade_configs (dict[str, tradeexecutor.strategy.freqtrade.config.FreqtradeConfig]) –
Methods
__init__(freqtrade_configs)Initialise routing model.
check_enter_position(routing_state, trading_pair)Check if a pair is tradeable.
convert_address_dict_to_lower(address_dict)Convert all key addresses to lowercase to avoid mix up with Ethereum address checksums
create_routing_state(universe, execution_details)Create routing state for this cycle.
get_default_trading_fee()Get the trading/LP fee applied to all trading pairs.
get_reserve_asset(pair_universe)Translate our reserve token address tok an asset description.
perform_preflight_checks_and_logging(...)"Checks the integrity of the routing.
pre_trade_assertions(reserve_asset_amount, ...)Some basic assertions made at the beginning of the trade() method on child class.
route_pair(pair_universe, trading_pair[, ...])Return Uniswap routing information (path components) for a trading pair.
settle_trade(web3, state, trade, receipts[, ...])Settle a trade after transaction broadcast.
setup_trades(state, routing_state, trades[, ...])Prepare deposit or withdrawal transactions.
- __init__(freqtrade_configs)[source]#
Initialise routing model.
- Args:
freqtrade_configs: Dict mapping freqtrade_id -> FreqtradeConfig
- Parameters:
freqtrade_configs (dict[str, tradeexecutor.strategy.freqtrade.config.FreqtradeConfig]) –
- create_routing_state(universe, execution_details)[source]#
Create routing state for this cycle.
- Args:
universe: Strategy execution universe execution_details: Dict containing tx_builder from ExecutionModel
- Returns:
FreqtradeRoutingState with tx_builder and FreqtradeClients
- Parameters:
universe (StrategyExecutionUniverse) –
execution_details (object) –
- Return type:
- setup_trades(state, routing_state, trades, check_balances=False, rebroadcast=False, **kwargs)[source]#
Prepare deposit or withdrawal transactions.
Dispatches to method-specific builders based on trade direction and exchange config.
- Args:
state: Current portfolio state routing_state: Routing state with tx_builder and clients trades: Trades to prepare check_balances: Whether to check balances (not used) rebroadcast: Whether this is a rebroadcast (not used) **kwargs: Additional arguments
- Parameters:
state (State) –
routing_state (FreqtradeRoutingState) –
trades (list[tradeexecutor.state.trade.TradeExecution]) –
check_balances (bool) –
rebroadcast (bool) –
- settle_trade(web3, state, trade, receipts, stop_on_execution_failure=False, **kwargs)[source]#
Settle a trade after transaction broadcast.
For deposits: polls Freqtrade balance until deposit confirmed. For withdrawals: polls Freqtrade balance until withdrawal confirmed. For Hyperliquid: also performs SDK vault transfer (deposit or withdrawal).
- Args:
web3: Web3 instance state: Current portfolio state trade: Trade to settle receipts: Transaction receipts stop_on_execution_failure: Whether to stop on failure **kwargs: Additional arguments
- Parameters:
web3 (Web3) –
state (State) –
trade (TradeExecution) –
stop_on_execution_failure (bool) –