
    %j!                        d dl mZ d dlmZ d dlmZ d dlmZmZ d dl	m
Z
  ed           G d d	                      Z G d
 d          ZdS )    )annotations)	dataclass)Decimal)	CostModelTradeCostInput)OrderIntentT)frozenc                     e Zd ZU ded<   ded<   ded<   ded<   ded<    ed          Zded	<    ed          Zded
<    ed          Zded<    ed          Zded<    ed          Z	ded<    ed          Z
ded<   dZded<   dZded<   dS )	PaperFillr   intentr   
fill_pricefee_usdslippage_usdnet_notional_usd0entry_fee_usdexit_fee_usdspread_cost_usdslippage_cost_usdfunding_cost_usdestimated_roundtrip_cost_pctFboolblocked_by_costokstrblocked_reasonN)__name__
__module____qualname____annotations__r   r   r   r   r   r   r   r   r        R/home/agent/projects/CryptoTradingBot/Crypto_Agent/src/execution/paper_executor.pyr   r   
   s	        $WS\\M))))#GCLLL((((&ws||O++++!(---- ',,,,,3GCLL 8888!O!!!!Nr"   r   c                  |    e Zd Z ed           ed          ddddZdd ed           ed          dddZdS )PaperExecutorz0.000452N)fee_rateslippage_bps
cost_modelr'   r   r(   r)   CostModel | NonereturnNonec               r    || _         || _        |p t          ||t          d          z            | _        d S )N100)taker_fee_ratemin_slippage_pct)r'   r(   r   r   r)   )selfr'   r(   r)   s       r#   __init__zPaperExecutor.__init__   s>     ($z	\hkrsxkyky\y(z(z(zr"   r   )half_spread_pctexpected_move_pctdepth_penalty_pct
hold_hoursr   r   
mark_pricer3   Decimal | Noner4   r5   r6   r   c               F   |j         dk    r|j         n	||j        z  }| j                            t	          |||nt          d          ||nt          d          ||                    }t          | j        j        |pt          d          |          }	||	z  t          d          z  }
|j        dk    r||
z   n||
z
  }||j        z  }|| j	        z  }t          ||||
|j        z  ||z
  |j        |j        |j        |j        |j        |j        |j         |j                  S )Nr   999r   )notional_usdr4   r3   r5   r6   r.   buy)r   r   r   r   r   r   r   r   r   r   r   r   r   )estimated_notional_usdsizer)   estimater   r   maxr0   sider'   r   r   r   r   r   r   roundtrip_cost_pctallowedreason)r1   r   r7   r3   r4   r5   r6   notional_hintcostslip_pctslipr   notional	entry_fees                 r#   executezPaperExecutor.execute!   s]   9?9VYZ9Z9Z55`jmsmx`x''*7H7T"3"3ZabgZhZh3B3NT[\_T`T`"3%  
 
 t79XGTWLLZkllH$wu~~5*0+*>*>Z$&&JQUDU
+t},	!+%	1,* 0"4!2)-)@ $,;
 
 
 	
r"   )r'   r   r(   r   r)   r*   r+   r,   )r   r   r7   r   r3   r8   r4   r8   r5   r   r6   r   r+   r   )r   r   r   r   r2   rK   r!   r"   r#   r%   r%      s        .5gi.@.@ZaZabeZfZf  HL { { { { { {
 fj  PT  sz  sz  {~  s  s  W^  W^  _b  Wc  Wc 
 
 
 
 
 
 
 
r"   r%   N)
__future__r   dataclassesr   decimalr   src.execution.cost_modelr   r   src.execution.order_intentr   r   r%   r!   r"   r#   <module>rQ      s    " " " " " " ! ! ! ! ! !       > > > > > > > > 2 2 2 2 2 2 $        $
 $
 $
 $
 $
 $
 $
 $
 $
 $
r"   