INNER CODE UNIT · Python

serialize_orders_to_json

DogsTailFarmer/martin-binance · martin_binance/backup.py:73

def serialize_orders_to_json(orders_manager: Orders) -> Dict[str, Any]:
    """
    Converts the Orders object into a JSON-compatible dictionary.
    Preserves the list of orders and the tp_order_id attribute.
    """
    return {
        "items": [PydanticOrderSchema.model_validate(o).model_dump(mode='json') for o in orders_manager],
        "tp_order_id": orders_manager.tp_order_id
    }


def deserialize_json_to_orders(v: Any) -> Orders:
    """
    Restores a live Orders object from a saved state
    """
    manager = Orders()

    # If a ready-made object was received (in memory during data validation)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…