
    Djy                    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mZmZmZ dd
Zd Zd Zd Zd Zd ZdS )    )annotationsN)Decimal)DeskMandatebuild_trade_planbuild_trader_desk_reportformat_trader_desk_report100bullish82.000.031.20c                Z    |pg }d| id|iddid|dd|ddd	d
d|iddddddddddd	S )Nmidstateconstructive	tradeable)r   atr_pctok)r   
spread_pctz0.000001neutral)fundingcrowding_stateblockers&tradingview_community_research_contextT      z60.00)	evaluatedhitrate_pct)sourceresearch_onlyrecent_ideas_counttrack_recordcoingecko_marketsloaded)r   status)	pricetrendmomentum
volatility	liquidityderivativesrisk	sentimentfundamentals )r   r'   r   scorespreadatrs         L/home/agent/projects/CryptoTradingBot/Crypto_Agent/tests/test_trader_desk.py_coinr4      s    ~2H5!n- +<<#6::#-KKX&>!"#*,WEE	
 
 $7(KK      c            	     v    dddt                      t          ddgd          dddd	g d
ddddgdddddS )NFrisk_onz55.00spread_too_widez0.20)r0   r   r1   )BTCETH)market_regimecoinsr   paper_candidate)final_trade_scorer   recommendationconfluence_below_thresholdblock_new_entry)r;   scores)live_order_allowedmainnet_signed_actionmarket_snapshot
confluence)r4   r/   r5   r3   _payloadrG      s    #!&&ww76G5HQWXXX 
 
 '-4"Xijj-4CTVrBs  HY  Z  Z 
 
  r5   c                 @   t          t                      dt                                } | 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}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}}| 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}||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}||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 }||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         }
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}
| j        }|
|v }|st	          j        d |fd!|
|f          t	          j	        |
          dt          j                    v st	          j        |           rt	          j	        |           ndt	          j	        |          d"z  }dd|iz  }t          t	          j        |                    d x}
x}}d S )#Nr9   tiny_live_candidate==z.%(py2)s
{%(py2)s = %(py0)s.action
} == %(py5)splanpy0py2py5assert %(py7)spy7longz1%(py2)s
{%(py2)s = %(py0)s.direction
} == %(py5)sz87.00)zK%(py2)s
{%(py2)s = %(py0)s.score
} == %(py8)s
{%(py8)s = %(py4)s(%(py6)s)
}r   )rO   rP   py4py6py8zassert %(py10)spy10Fisz:%(py2)s
{%(py2)s = %(py0)s.live_order_allowed
} is %(py5)sz=%(py2)s
{%(py2)s = %(py0)s.mainnet_signed_action
} is %(py5)sT)z:%(py2)s
{%(py2)s = %(py0)s.requires_preflight
} is %(py5)s)is not)z5%(py2)s
{%(py2)s = %(py0)s.stop_loss
} is not %(py5)sstyleretest_limit_zonez%(py1)s == %(py4)spy1rV   assert %(py6)srW   /community_track_record_supportive_research_onlyinz/%(py1)s in %(py5)s
{%(py5)s = %(py3)s.reasons
}rc   py3rQ   )r   rG   r   action
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanation	directionr0   r   rC   rD   requires_preflight	stop_loss
entry_zonereasons)rM   @py_assert1@py_assert4@py_assert3@py_format6@py_format8@py_assert5@py_assert7@py_format9@py_format11@py_assert0@py_assert2@py_format5@py_format7s                 r3   Wtest_trader_desk_promotes_high_quality_long_to_tiny_candidate_without_live_side_effectsr   1   s)   HJJ{}}==D;///;///////////;/////////////4/////4//////;////////////////////////////////>#V#>V##########>V############4#####4######>####V###########################:))))):))))))))))):)))))))))))))4)))))4)))))):))))))))))))))))))))))))))))))))))))))))))))))))))))))))"+e+"e++++++++++"e++++++++++++4+++++4++++++"++++e+++++++++++++++++++++++++++%..%..........%............4.....4......%..............................."*d*"d**********"d************4*****4******"****d***************************>%%>%%%%%%%%%%>%%%%%%%%%%%%4%%%%%4%%%%%%>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%?7#:'::#':::::::::::#'::::::#::::'::::::::::::::::::::::::::::<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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Lr5   c                 X   t          t                      dt                                } | 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}}d	}| j        }||v }|st	          j        d
|fd||f          t	          j	        |          dt          j                    v st	          j        |           rt	          j	        |           ndt	          j	        |          dz  }dd|iz  }t          t	          j        |                    d x}x}}d}| j        }||v }|st	          j        d
|fd||f          t	          j	        |          dt          j                    v st	          j        |           rt	          j	        |           nd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}}d S )Nr:   no_traderJ   rL   rM   rN   rR   rS   r8   rf   )z0%(py1)s in %(py5)s
{%(py5)s = %(py3)s.blockers
}ri   r@   0)z9%(py2)s
{%(py2)s = %(py0)s.notional_cap_usdc
} == %(py5)s)r   rG   r   rk   rl   rm   rn   ro   rp   rq   rr   rs   r   notional_cap_usdc)rM   ry   rz   r{   r|   r}   r   r   s           r3   4test_trader_desk_blocks_hard_market_quality_blockersr   ?   s   HJJ{}}==D;$*$;*$$$$$$$$$$;*$$$$$$$$$$$$4$$$$$4$$$$$$;$$$$*$$$$$$$$$$$$$$$$$$$$$$$$$$$------------------------------------------------------------------'84=8'=8888888888'=88888'888888888884888884888888=888888888888888888888888888!(S(!S((((((((((!S((((((((((((4(((((4((((((!((((S(((((((((((((((((((((((((((((r5   c                 v   t                      } d| d         d<   d| d         d<   d| d         d         d         d         d	<   d
| d         d         d         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}}d}|j        }||v }|st	          j        d|fd||f          t	          j	        |          dt          j                    v st	          j        |          rt	          j	        |          ndt	          j	        |          dz  }dd|iz  }t          t	          j        |                    d x}x}}d S )Nrisk_offrF   r;   rE   bearishr<   r9   r'   r   z85.00rB   r>   T)long_only_tiny_liveshortrJ   rU   rM   rN   rR   rS   watch_shadowrL   ,short_is_shadow_only_under_tiny_live_mandaterf   rh   ri   )rG   r   r   rt   rl   rm   rn   ro   rp   rq   rr   rs   rk   rx   )	payloadrM   ry   rz   r{   r|   r}   r   r   s	            r3   =test_trader_desk_short_is_shadow_only_under_tiny_live_mandater   H   s   jjG-7GL/*2<G/CLGw'.w7@BIGL(#E*+>?GUKD,Q,Q,QRRD>$W$>W$$$$$$$$$$>W$$$$$$$$$$$$4$$$$$4$$$$$$>$$$$W$$$$$$$$$$$$$$$$$$$$$$$$$$$;(.(;.((((((((((;.((((((((((((4(((((4((((((;((((.(((((((((((((((((((((((((((9IT\I9\IIIIIIIIII9\IIIII9IIIIIIIIIIITIIIIITIIIIII\IIIIIIIIIIIIIIIIIIIIIIIIIIIIIr5   c                 	   t          t                                } | 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}}| 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         }d}||k    }|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }	t          t          j
        |	                    d x}x}}| j        d         }|j        }d}
||
k    }|st          j        d|fd||
f          t          j        |          t          j        |          t          j        |
          dz  }	dd|	iz  }t          t          j
        |                    d x}x}x}}
t!          |           }d}||v }|st          j        d|fd||f          t          j        |          dt          j                    v st          j        |          rt          j        |          nddz  }dd|iz  }t          t          j
        |                    d x}}d}||v }|st          j        d|fd||f          t          j        |          dt          j                    v st          j        |          rt          j        |          nddz  }dd|iz  }t          t          j
        |                    d x}}d S ) Nztrader_desk.v1rJ   )z6%(py2)s
{%(py2)s = %(py0)s.schema_version
} == %(py5)sreportrN   rR   rS   FrZ   r\   r]   tiny_live_candidates   ra   rb   rd   rW   r   r9   )z,%(py3)s
{%(py3)s = %(py1)s.coin
} == %(py6)s)rc   rj   rW   zassert %(py8)srX   zJARVIS Trader Desk v1rf   )z%(py1)s in %(py3)stext)rc   rj   zassert %(py5)srQ   z	live=nein)r   rG   schema_versionrl   rm   rn   ro   rp   rq   rr   rs   rC   rD   summaryplanscoinr   )r   ry   rz   r{   r|   r}   r   r   r   r   r~   r   r   @py_format4s                 r3   /test_trader_desk_report_is_sorted_and_read_onlyr   V   s   %hjj11F 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46444446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$--$----------$------------6-----6------$-------------------------------'050'50000000000'500000000000060000060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16Q61Q66666666661Q6666616666Q666666666666666666666666666<?(?(5(5((((((((((5(((((?((((((((5((((((((((((((((((((((((((((($V,,D"*"d**********"d*****"***********d*****d***************************;$;$;$$r5   )r	   r
   Nr   r   r   )
__future__r   builtinsrn   _pytest.assertion.rewrite	assertionrewriterl   decimalr   src.trader_desk.decisionr   r   r   r   r4   rG   r   r   r   r   r/   r5   r3   <module>r      s    " " " " " "                     w w w w w w w w w w w w   (  *M M M) ) )J J J
 
 
 
 
r5   