DTCC CTM receives trade instructions for multiple asset classes. Implement an object-oriented validator that uses abstraction and polymorphism to apply the correct validation rules without placing all asset-specific logic in one conditional-heavy function.
Create an abstract TradeRule class with a validate(trade) method. Implement EquityRule, BondRule, and OptionRule subclasses. The validate_trades function must select the appropriate rule for each instruction and return validation results in the original order.
Input trades is a list of dictionaries. Every dictionary contains id, asset_type, quantity, price, and settlement_days. Option trades also contain strike.
Return a list of dictionaries with id, valid, and errors. valid is true only when no rules are violated. Error messages must use the exact strings defined below.
Unknown asset type.def validate_trades(trades):