def __init__(self, symbols, direction='up', change='percent', output_format='pandas', api=None): self.direction = direction self.change = change err_msg = "Please input a valid market ticker (ex. $DJI)." self.symbols = _handle_lists(symbols, mult=False, err_msg=err_msg) super(Movers, self).__init__(output_format, api)
def __init__(self, markets="EQUITY", date=None, output_format='pandas', api=None): self.date = date or datetime.datetime.now() err_msg = "Please enter one more most markets (EQUITY, OPTION, etc.)"\ "for retrieval." self.markets = _handle_lists(markets, err_msg=err_msg) self.markets = [market.lower() for market in self.markets] if not set(self.markets).issubset(set(self._MARKETS)): raise ValueError("Please input valid markets for hours retrieval.") super(MarketHours, self).__init__(output_format, api)
def __init__(self, symbols, **kwargs): self.period_type = kwargs.pop("period_type", "month") self.period = kwargs.pop("period", "") self.frequency_type = kwargs.pop("frequency_type", "daily") self.frequency = kwargs.pop("frequency", "") start = kwargs.pop("start_date", datetime.datetime(2018, 1, 1)) end = kwargs.pop("end_date", datetime.datetime.today()) self.need_extended = kwargs.pop("extended", "") self.output_format = kwargs.pop("output_format", 'pandas') self.opt = kwargs api = kwargs.get("api") self.start, self.end = _sanitize_dates(start, end, set_defaults=False) if self.start and self.end: self.start = to_timestamp(self.start) * 1000 self.end = to_timestamp(self.end) * 1000 self.symbols = _handle_lists(symbols) super(PriceHistory, self).__init__(self.output_format, api)
def __init__(self, symbol, **kwargs): self.contract_type = kwargs.pop("contract_type", "ALL") self.strike_count = kwargs.pop("strike_count", "") self.include_quotes = kwargs.pop("include_quotes", "") self.strategy = kwargs.pop("strategy", "") self.interval = kwargs.pop("interval", "") self.strike = kwargs.pop("strike", "") self.range = kwargs.pop("range", "") self.from_date = kwargs.pop("from_date", "") self.to_date = kwargs.pop("to_date", "") self.volatility = kwargs.pop("volatility", "") self.underlying_price = kwargs.pop("underlying_price", "") self.interest_rate = kwargs.pop("interest_rate", "") self.days_to_expiration = kwargs.pop("days_to_expiration", "") self.exp_month = kwargs.pop("exp_month", "") self.option_type = kwargs.pop("option_type", "") self.output_format = kwargs.pop("output_format", 'pandas') self.api = kwargs.pop("api", None) self.opts = kwargs self.symbols = _handle_lists(symbol) super(Options, self).__init__(self.output_format, self.api)
def test_handle_lists_err(self, mult): with pytest.raises(ValueError): _handle_lists(mult, mult=False)
def test_handle_lists_mult(self, mult): assert _handle_lists(mult) == [1, 2, 3]
def test_handle_lists_sing(self, single): assert _handle_lists(single, mult=False) == single assert _handle_lists(single) == [single]
def __init__(self, symbols, output_format='pandas', api=None): self.symbols = _handle_lists(symbols) if len(self.symbols) > 100: raise ValueError("Please input a valid symbol or list of up to " "100 symbols") super(Quotes, self).__init__(output_format, api)