o
    Í¿SiY  ã                   @  s@   d dl mZ d dlmZmZmZ h d£Zddd„Zdd
d„ZdS )é    )Úannotations)ÚAnyÚDictÚList>   ÚquoteÚmd_rawÚcandlesÚ	raw_quoteÚmarket_dataÚraw_candlesÚraw_market_dataÚanalysisr   Úreturnc                 C  s   t | ƒS )a:  Return a persistence-safe copy of an analysis payload.

    Goal: allow storing GPT outputs + computed features while preventing
    any raw candles/quote/market_data payloads from being written to Mongo.

    This intentionally strips keys like `market_data`, `candles`, and `quote`
    at any nesting level.
    ©Ú_strip_forbidden_keys)r   © r   ú</var/www/html/Trade-python/app/v1/utils/snapshot_sanitize.pyÚ compact_analysis_for_persistence   s   	r   Úvaluec                 C  sV   t | tƒri }|  ¡ D ]\}}|tv rqt|ƒ||< q|S t | tƒr)dd„ | D ƒS | S )Nc                 S  s   g | ]}t |ƒ‘qS r   r   )Ú.0Úvr   r   r   Ú
<listcomp>)   s    z)_strip_forbidden_keys.<locals>.<listcomp>)Ú
isinstanceÚdictÚitemsÚ_FORBIDDEN_KEYSr   Úlist)r   ÚoutÚkr   r   r   r   r      s   

r   N)r   r   r   r   )r   r   r   r   )	Ú
__future__r   Útypingr   r   r   r   r   r   r   r   r   r   Ú<module>   s
    
