@@ -279,6 +279,9 @@ async def test_get_holdings_ratio(backtesting_trader):
279279 exchange_manager .client_symbols = [symbol ]
280280 exchange_manager .exchange_personal_data .portfolio_manager .portfolio_value_holder .\
281281 value_converter .last_prices_by_trading_pair [symbol ] = decimal .Decimal ("1000" )
282+ # Also add the futures symbol price for value conversion
283+ exchange_manager .exchange_personal_data .portfolio_manager .portfolio_value_holder .\
284+ value_converter .last_prices_by_trading_pair ["BTC/USDT:USDT" ] = decimal .Decimal ("1000" )
282285 exchange_manager .exchange_personal_data .portfolio_manager .portfolio_value_holder .\
283286 portfolio_current_value = decimal .Decimal ("11" )
284287 exchange_manager .exchange_personal_data .portfolio_manager .portfolio .portfolio = {}
@@ -295,7 +298,8 @@ def mock_get_or_create_position_impl(symbol, side):
295298 mock_pos .margin = constants .ZERO
296299 mock_pos .is_idle .return_value = True
297300 else :
298- mock_pos .margin = decimal .Decimal ("1" )
301+ # margin in USDT (settlement currency), which converts to 1 BTC at 1000 USDT/BTC
302+ mock_pos .margin = decimal .Decimal ("1000" )
299303 mock_pos .is_idle .return_value = False
300304 elif symbol == "BTC/XYZ:XYZ" :
301305 mock_pos .margin = decimal .Decimal ("0" )
@@ -395,13 +399,13 @@ def mock_get_or_create_position_impl(symbol, side):
395399 mock_pos .margin = decimal .Decimal ("10" ) # equivalent to the 10 BTC in the spot portfolio
396400 mock_pos .is_idle .return_value = False
397401 if symbol == "BTC/USDT:USDT" :
398- mock_pos .margin = decimal .Decimal ("1 " ) # equivalent to the 1000 USDT vs BTC in the spot portfolio
402+ mock_pos .margin = decimal .Decimal ("1000 " ) # 1000 USDT margin, converts to 1 BTC at 1000 USDT/BTC
399403 mock_pos .is_idle .return_value = False
400404 elif symbol == "ETH/USDT:BTC" :
401- mock_pos .margin = decimal .Decimal ("100 " ) if has_eth_position else constants .ZERO # equivalent to the 10 ETH vs BTC in the spot portfolio
405+ mock_pos .margin = decimal .Decimal ("1 " ) if has_eth_position else constants .ZERO # 1 BTC margin (settlement is BTC)
402406 mock_pos .is_idle .return_value = False
403407 elif symbol == "ETH/BTC:BTC" :
404- mock_pos .margin = decimal .Decimal ("1" ) if has_eth_position else constants .ZERO # equivalent to the 10 ETH vs BTC in the spot portfolio
408+ mock_pos .margin = decimal .Decimal ("1" ) if has_eth_position else constants .ZERO # 1 BTC margin (settlement is BTC)
405409 mock_pos .is_idle .return_value = False
406410 else :
407411 raise errors .ContractExistsError (f"Contract { symbol } does not exist" )
0 commit comments