Convert an IBPy Contract object to a dict containing any non-default values.

def contract_to_dict(contract):
    """Convert an IBPy Contract object to a dict containing any non-default values."""
    default = Contract()
    return {field: val for field, val in vars(contract).items() if val != getattr(default, field, None)}