Ejemplo n.º 1
0
    def map_quote(quote: dict) -> dict:
        instrument_id = parse_instrument_url(quote["instrument"])

        plucked = {
            "instrument_id": instrument_id,
            **pluck(DESIRED_QUOTE_KEYS, quote)
        }
        plucked["updated_at"] = parse_updated_at(plucked["updated_at"])
        return plucked
Ejemplo n.º 2
0
    def update_index_symbol(datum: dict) -> pymongo.operations.UpdateOne:
        data = {
            "timestamp": timestamp,
            "has_traded": datum.get("has_traded"),
            "updated_at": parse_updated_at(datum.get("updated_at")),
            "trading_halted": datum.get("trading_halted"),
        }
        instrument_id = parse_instrument_url(datum["instrument"])

        return pymongo.operations.UpdateOne({"instrument_id": instrument_id},
                                            {"$set": data})