Esempio n. 1
0
 def from_dict(cls, d: Dict) -> Stock:
     temp = dict(d)
     temp["asof"] = parse_date(d["asof"]) if d.get("asof") else None
     temp["indicators"] = {k: StockIndicator.from_dict(v) for k, v in d.get("indicators", dict()).items()}
     temp["realTimeDetails"] = StockRealTimeDetails.from_dict(d.get("realTimeDetails", dict()))
     temp.pop("historicPrices", [])
     return Stock(**temp)
Esempio n. 2
0
 def from_dict(cls, d: Dict) -> Fund:
     temp = dict(d)
     temp["type"] = FundType.from_str(d.get("type"))  # type: ignore
     temp["shareClass"] = FundShareClass.from_str(d.get("shareClass"))  # type: ignore
     temp["holdings"] = [FundHolding.from_dict(e) for e in d.get("holdings", [])]
     temp["asof"] = parse_date(d["asof"]) if d.get("asof") else None
     temp["indicators"] = {k: FundIndicator.from_dict(v) for k, v in d.get("indicators", dict()).items()}
     temp["realTimeDetails"] = FundRealTimeDetails.from_dict(d.get("realTimeDetails", dict()))
     temp.pop("historicPrices", [])
     return Fund(**temp)
Esempio n. 3
0
 def from_dict(cls, d: Dict) -> StockRealTimeDetails:
     temp = dict(d)
     temp["lastUpdated"] = parse_date(d["lastUpdated"]) if d.get("lastUpdated") else None
     return StockRealTimeDetails(**temp)
Esempio n. 4
0
def test_parse_date():
    s = "2019-01-01T00:00:00Z"
    assert parse_date(s) == datetime(2019, 1, 1, tzinfo=timezone.utc)
Esempio n. 5
0
 def _parse_date(cls, date_str: Optional[str]) -> Optional[date]:  # type: ignore
     return parse_date(date_str).date() if date_str else None
Esempio n. 6
0
 def from_dict(cls, d: Dict) -> FundRealTimeDetails:
     temp = dict(d)
     temp["ci"] = tuple(d.get("ci", [None, None]))
     temp["holdings"] = [FundRealTimeHolding.from_dict(h) for h in d.get("holdings", [])]
     temp["lastUpdated"] = parse_date(d["lastUpdated"]) if d.get("lastUpdated") else None
     return FundRealTimeDetails(**temp)