Closed Quenos closed 1 month ago
Looks like it's a MarginReportEntry field not MarginReport. Maybe that's the issue? Thanks for opening this! Could you submit a PR to both the advanced-streamer and master branches?
Looks like it's a MarginReportEntry field not MarginReport. Maybe that's the issue?
Yes, that's a typo in the original post. I've changed the following (not the complete class yet.
class MarginReportEntry(TastytradeJsonDataclass):
"""
Dataclass containing an individual entry (relating to a specific position)
as part of the overall margin report.
"""
description: str
code: str
underlying_symbol: Optional[str]
underlying_type: Optional[str]
margin_calculation_type: str
margin_requirement: Decimal
margin_requirement_effect: PriceEffect
maintenance_requirement: Decimal
maintenance_requirement_effect: PriceEffect
buying_power: Decimal
buying_power_effect: PriceEffect
groups: List[Dict[str, Any]]
price_increase_percent: Decimal
price_decrease_percent: Decimal
expected_price_range_up_percent: Optional[Decimal] = None
expected_price_range_down_percent: Optional[Decimal] = None
point_of_no_return_percent: Optional[Decimal] = None
initial_requirement: Optional[Decimal] = None
initial_requirement_effect: Optional[PriceEffect] = None
Thanks for opening this! Could you submit a PR to both the advanced-streamer and master branches?
Yes I will.
Describe the bug Calling Account.get_margin_requirements(session) will throw Pydantic exceptions for missing and extra fields. For options on Equity it seems to work just fine.
How to reproduce With options on futures in your portfolio call Account.get_margin_requirements(session)
Working on a solution but running in some strange issues. Pydantic is e.g. complaining about the fact that underlying-symbol is missing
But changing the underlying_symbol field in Account.MarginReport to Optional[str] does not solve the issue.
What am I missing here?
EDIT: It helps if you also add '= None' to the Optional field :)