
    7TjP                    V    d dl mZ d dlZd dlmc mZ d dlm	Z	 d dl
mZ d Zd Zd ZdS )    )annotationsN)Decimal)analyze_size_curvec                 .    dddddddgddddddggiS )	Nlevelsz99.99z0.20)pxszz99.95z1.00z100.01z100.05 r
       R/home/agent/projects/CryptoTradingBot/Crypto_Agent/tests/test_size_impact_curve.py_bookr      sD    v	&	&wf(E(EF	'	')G)GH  r   c            
     |   t          t                      t          d          t          d          t          d          t          d          t          d          ft          d          t          d          t          d          	          } | d
         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}d | d         D             }g d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}| d         d         d         d         }t          |          }d}t          |          }||k    }	|	s"t          j        d|	fd||f          dt          j	                    v st          j
        t                    rt          j        t                    ndt          j        |          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}	x}}| d         d         d         d         }t          |          }| d         d         d         d         }t          |          }||k    }	|	s"t          j        d|	fd||f          dt          j	                    v st          j
        t                    rt          j        t                    ndt          j        |          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}	x}}| d         d         d          }d!}||u }|slt          j        d"|fd#||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}| d         d         d          }d$}||u }|slt          j        d"|fd#||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}| d%         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}| d&         }d!}||u }|slt          j        d"|fd#||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}| d'         }d$}||u }|slt          j        d"|fd#||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}d S )(N10152550100z0.80z0.12z0.75	notionalsexpected_move_pctrisk_budget_usdstop_distance_pct	mid_pricez100.00)==)z%(py1)s == %(py4)spy1py4assert %(py6)spy6c                    g | ]
}|d          S )notional_usdr
   ).0rows     r   
<listcomp>zCtest_size_curve_uses_actual_levels_and_risk_cap.<locals>.<listcomp>   s    :::CC:::r   rows)r   r   r   r   r   r   buy
impact_pctz0.0100)zP%(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} == %(py10)s
{%(py10)s = %(py6)s(%(py8)s)
}r   )py0py2r   r   py8py10zassert %(py12)spy12   )>)zO%(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} > %(py10)s
{%(py10)s = %(py6)s(%(py8)s)
}risk_allowedTisz%(py1)s is %(py4)sFmax_recommended_notional_usd	read_onlylive_order_allowed)r   r   r   
@pytest_ar_call_reprcompare	_safereprAssertionError_format_explanation@py_builtinslocals_should_repr_global_name)report@py_assert0@py_assert3@py_assert2@py_format5@py_format7@py_assert1@py_assert7@py_assert9@py_assert5@py_format11@py_format13s               r   /test_size_curve_uses_actual_levels_and_risk_caprJ      s3   4=='$--wW\~~^!&//!&//  F +*(*(**********(*********(***************************::6&>:::]>]>]>]]:>]]]]]]]]]]]:>]]]]]]:]]]]>]]]]]]]]]]]]]]]]]]]]]]]]]]]]&>!$U+L9O79::OhOgh>O>OO:>OOOOOOOOOOO:>OOOOOOOOOOOOO7OOOOO7OOOOOO9OOOO:OOOOOOOOOOOgOOOOOgOOOOOOhOOOO>OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO&>!$U+L9l79::lVF^TUEVW\E]^jEklWEk=l=ll:=lllllllllll:=lllllllllllll7lllll7llllll9llll:lllllllllllWlllllWllllllEkllll=llllllllllllllllllllllllllllllll&>!^,44,4444444444,44444,4444444444444444444444444444444&>!^,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019T91T99999999991T9999919999T999999999999999999999999999+&$&$&&&&&&&&&&$&&&&&&&&&$&&&&&&&&&&&&&&&&&&&&&&&&&&&&'050'50000000000'500000'00005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00r   c            	        t          t                      t          d          t          d          ft          d          t          d          t          d                    } | d         d         d         d         }d	}||u }|slt          j        d
|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}| d         d         d         }d	}||u }|slt          j        d
|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}d S )Nr   10001r   r%      r&   depth_sufficientFr0   r2   r   r   r   cost_allowed)r   r   r   r6   r7   r8   r9   r:   )r>   r?   r@   rA   rB   rC   s         r   1test_size_curve_blocks_when_depth_is_insufficientrQ   "   s   GDMM76??;wWZ||  F &>!U#$67@5@75@@@@@@@@@@75@@@@@7@@@@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   )
__future__r   builtinsr;   _pytest.assertion.rewrite	assertionrewriter6   decimalr   src.execution.size_impact_curver   r   rJ   rQ   r
   r   r   <module>rY      s    " " " " " "                     > > > > > >  1 1 1&6 6 6 6 6r   