
    %j                     f    d dl Zd dlmc mZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d Zd Zd ZdS )	    N)Decimal)	CostModelTradeCostInput)PaperExecutor)OrderIntentc                      t          di ddddddddd	d
dddddt          d          dd dd dt          d          dd dddddt          d          dt          d          S )Nstrategy_id)candidate_v76_hl_confirmed_squeeze_hybridsymbolzBTC/USDC:USDCcoinBTCsidebuyreduce_onlyF
order_typemarkettifIocsizez0.001pricetrigger_price	stop_loss99000take_profitclient_order_idzv76-BTC-cost-1reason
cost_modelrisk_usdz1.25estimated_notional_usd100 )r   r   r!       Q/home/agent/projects/CryptoTradingBot/Crypto_Agent/tests/test_paper_cost_model.py_intentr$      s       ?? U U	
 E 8 E W d d '""" D )( |    'u~~~! r"   c                     t          t          d          t          d                    } |                     t          t          d          t          d          t          d          t          d          t          d          	                    }|j        }d
}||u }|st          j        d|fd||f          dt          j                    v st          j	        |          rt          j
        |          ndt          j
        |          t          j
        |          dz  }dd|iz  }t          t          j        |                    d x}x}}|j        }d}||k    }|st          j        d|fd||f          dt          j                    v st          j	        |          rt          j
        |          ndt          j
        |          t          j
        |          dz  }dd|iz  }t          t          j        |                    d x}x}}|j        }d}t          |          }||k    }|st          j        d|fd||f          dt          j                    v st          j	        |          rt          j
        |          ndt          j
        |          dt          j                    v st          j	        t                    rt          j
        t                    ndt          j
        |          t          j
        |          dz  }	dd|	iz  }
t          t          j        |
                    d x}x}x}}d S )Nz0.000450.02)taker_fee_ratemin_slippage_pctr    z0.10z0.03z0.010)notional_usdexpected_move_pcthalf_spread_pctdepth_penalty_pct
hold_hoursFis)z/%(py2)s
{%(py2)s = %(py0)s.allowed
} is %(py5)sdecisionpy0py2py5assert %(py7)spy7%expected_move_below_3x_roundtrip_cost)==)z.%(py2)s
{%(py2)s = %(py0)s.reason
} == %(py5)s>)zW%(py2)s
{%(py2)s = %(py0)s.roundtrip_cost_pct
} > %(py8)s
{%(py8)s = %(py4)s(%(py6)s)
}r   )r3   r4   py4py6py8zassert %(py10)spy10)r   r   estimater   allowed
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationr   roundtrip_cost_pct)modelr1   @py_assert1@py_assert4@py_assert3@py_format6@py_format8@py_assert5@py_assert7@py_format9@py_format11s              r#   <test_cost_model_blocks_expected_move_below_3x_roundtrip_costrU      sy   WY%7%7'RX//ZZZE~~ %foo#FOO%foos||	
 	
 	
 H $u$u$$$$$$$$$$u$$$$$$$$$$$$8$$$$$8$$$$$$$$$$u$$$$$$$$$$$$$$$$$$$$$$$$$$$?EEE?EEEEEEEEEEE?EEEEEEEEEEEEE8EEEEE8EEEEEE?EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE&555&5555555555&5555555555558555558555555&555555555555555555555555555555555555555555555555555555555r"   c                  \   t          t                                } |                     t                      t	          d          t	          d          t	          d                    }|j        }d}||k    }|st          j        d|fd||f          d	t          j	                    v st          j
        |          rt          j        |          nd	t          j        |          t          j        |          d
z  }dd|iz  }t          t          j        |                    d x}x}}|j        }d}||k    }|st          j        d|fd||f          d	t          j	                    v st          j
        |          rt          j        |          nd	t          j        |          t          j        |          d
z  }dd|iz  }t          t          j        |                    d x}x}}|j        }d}||k    }|st          j        d|fd||f          d	t          j	                    v st          j
        |          rt          j        |          nd	t          j        |          t          j        |          d
z  }dd|iz  }t          t          j        |                    d x}x}}|j        }d}||k    }|st          j        d|fd||f          d	t          j	                    v st          j
        |          rt          j        |          nd	t          j        |          t          j        |          d
z  }dd|iz  }t          t          j        |                    d x}x}}|j        }d}||u }|st          j        d|fd||f          d	t          j	                    v st          j
        |          rt          j        |          nd	t          j        |          t          j        |          d
z  }dd|iz  }t          t          j        |                    d x}x}}d S )N)r   100000r&   z1.0)
mark_pricer,   r+   r   r:   )z4%(py2)s
{%(py2)s = %(py0)s.entry_fee_usd
} > %(py5)sfillr2   r6   r7   )z6%(py2)s
{%(py2)s = %(py0)s.spread_cost_usd
} > %(py5)s)z8%(py2)s
{%(py2)s = %(py0)s.slippage_cost_usd
} > %(py5)s)zC%(py2)s
{%(py2)s = %(py0)s.estimated_roundtrip_cost_pct
} > %(py5)sFr/   )z7%(py2)s
{%(py2)s = %(py0)s.blocked_by_cost
} is %(py5)s)r   r   executer$   r   entry_fee_usdrB   rC   rD   rE   rF   rG   rH   rI   spread_cost_usdslippage_cost_usdestimated_roundtrip_cost_pctblocked_by_cost)executorrY   rL   rM   rN   rO   rP   s          r#   1test_paper_executor_reports_realistic_cost_fieldsra   .   s   	444HGII'(2C2CU\]cUdUdx  AF  yG  yG  H  HD!!!!!!!!!!!!!!!!!!!!!!!!4!!!!!4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#!#!##########!############4#####4##########!###########################!%A%!A%%%%%%%%%%!A%%%%%%%%%%%%4%%%%%4%%%%%%!%%%%A%%%%%%%%%%%%%%%%%%%%%%%%%%%,0q0,q0000000000,q0000000000004000004000000,0000q000000000000000000000000000(5(5((((((((((5((((((((((((4(((((4((((((((((5(((((((((((((((((((((((((((((r"   )builtinsrD   _pytest.assertion.rewrite	assertionrewriterB   decimalr   src.execution.cost_modelr   r   src.execution.paper_executorr   src.execution.order_intentr   r$   rU   ra   r!   r"   r#   <module>rj      s                        > > > > > > > > 6 6 6 6 6 6 2 2 2 2 2 2  *6 6 6"	) 	) 	) 	) 	)r"   