diff --git a/massive/rest/aggs.py b/massive/rest/aggs.py index cb874fac..e72bea19 100644 --- a/massive/rest/aggs.py +++ b/massive/rest/aggs.py @@ -168,7 +168,7 @@ def get_previous_close_agg( params: Optional[Dict[str, Any]] = None, raw: bool = False, options: Optional[RequestOptionBuilder] = None, - ) -> Union[PreviousCloseAgg, HTTPResponse]: + ) -> Union[List[PreviousCloseAgg], HTTPResponse]: """ Get the previous day's open, high, low, and close (OHLC) for the specified stock ticker. @@ -176,7 +176,7 @@ def get_previous_close_agg( :param adjusted: Whether or not the results are adjusted for splits. By default, results are adjusted. Set this to false to get results that are NOT adjusted for splits. :param params: Any additional query params :param raw: Return raw object instead of results object - :return: Previous close aggregate + :return: List of previous close aggregates (the API returns a one-element list) """ url = f"/v2/aggs/ticker/{ticker}/prev" diff --git a/massive/rest/economy.py b/massive/rest/economy.py index 4c4b251f..7ba52d88 100644 --- a/massive/rest/economy.py +++ b/massive/rest/economy.py @@ -35,7 +35,7 @@ def list_treasury_yields( params: Optional[Dict[str, Any]] = None, raw: bool = False, options: Optional[RequestOptionBuilder] = None, - ) -> Union[List[TreasuryYield], HTTPResponse]: + ) -> Union[Iterator[TreasuryYield], HTTPResponse]: """ Retrieve treasury yield data. @@ -51,7 +51,7 @@ def list_treasury_yields( :param params: Additional query parameters. :param raw: Return raw HTTPResponse object if True, else return List[TreasuryYield]. :param options: RequestOptionBuilder for additional headers or params. - :return: A list of TreasuryYield objects or HTTPResponse if raw=True. + :return: An iterator of TreasuryYield objects or HTTPResponse if raw=True. """ url = "/fed/v1/treasury-yields" diff --git a/massive/rest/reference.py b/massive/rest/reference.py index b6886c55..12525548 100644 --- a/massive/rest/reference.py +++ b/massive/rest/reference.py @@ -92,7 +92,7 @@ def list_tickers( type: Optional[str] = None, market: Optional[str] = None, exchange: Optional[str] = None, - cusip: Optional[int] = None, + cusip: Optional[Union[int, str]] = None, cik: Optional[int] = None, date: Optional[str] = None, active: Optional[bool] = None, @@ -115,7 +115,7 @@ def list_tickers( :param type: Specify the type of the tickers. Find the types that we support via our Ticker Types API. Defaults to empty string which queries all types. :param market: Filter by market type. By default all markets are included. :param exchange: Specify the assets primary exchange Market Identifier Code (MIC) according to ISO 10383. Defaults to empty string which queries all exchanges. - :param cusip: Specify the CUSIP code of the asset you want to search for. Find more information about CUSIP codes at their website. Defaults to empty string which queries all CUSIPs. + :param cusip: Specify the CUSIP code of the asset you want to search for. The API treats a CUSIP as a string, so pass a string such as "037833100": an int drops leading zeros and cannot hold the letters some CUSIPs contain. An int is still accepted for backward compatibility. Find more information about CUSIP codes at their website. Defaults to empty string which queries all CUSIPs. :param cik: Specify the CIK of the asset you want to search for. Find more information about CIK codes at their website. Defaults to empty string which queries all CIKs. :param date: Specify a point in time to retrieve tickers available on that date. Defaults to the most recent available date. :param search: Search for terms within the ticker and/or company name. @@ -606,7 +606,7 @@ def list_short_interest( params: Optional[Dict[str, Any]] = None, raw: bool = False, options: Optional[RequestOptionBuilder] = None, - ) -> Union[List[ShortInterest], HTTPResponse]: + ) -> Union[Iterator[ShortInterest], HTTPResponse]: """ Retrieve short interest data for stocks. @@ -632,7 +632,7 @@ def list_short_interest( :param params: Additional query parameters. :param raw: Return raw HTTPResponse object if True, else return List[ShortInterest]. :param options: RequestOptionBuilder for additional headers or params. - :return: A list of ShortInterest objects or HTTPResponse if raw=True. + :return: An iterator of ShortInterest objects or HTTPResponse if raw=True. """ url = "/stocks/v1/short-interest" @@ -669,7 +669,7 @@ def list_short_volume( params: Optional[Dict[str, Any]] = None, raw: bool = False, options: Optional[RequestOptionBuilder] = None, - ) -> Union[List[ShortVolume], HTTPResponse]: + ) -> Union[Iterator[ShortVolume], HTTPResponse]: """ Retrieve short volume data for stocks. @@ -695,7 +695,7 @@ def list_short_volume( :param params: Additional query parameters. :param raw: Return raw HTTPResponse object if True, else return List[ShortVolume]. :param options: RequestOptionBuilder for additional headers or params. - :return: A list of ShortVolume objects or HTTPResponse if raw=True. + :return: An iterator of ShortVolume objects or HTTPResponse if raw=True. """ url = "/stocks/v1/short-volume" diff --git a/massive/rest/vX.py b/massive/rest/vX.py index ebd95a1a..91b1e782 100644 --- a/massive/rest/vX.py +++ b/massive/rest/vX.py @@ -93,7 +93,7 @@ def list_ipos( params: Optional[Dict[str, Any]] = None, raw: bool = False, options: Optional[RequestOptionBuilder] = None, - ) -> Union[List[IPOListing], HTTPResponse]: + ) -> Union[Iterator[IPOListing], HTTPResponse]: """ Retrieve upcoming or historical IPOs. @@ -108,7 +108,7 @@ def list_ipos( :param params: Additional query params. :param raw: Return raw HTTPResponse object if True, else return List[IPOListing]. :param options: RequestOptionBuilder for additional headers or params. - :return: A list of IPOListing objects or HTTPResponse if raw=True. + :return: An iterator of IPOListing objects or HTTPResponse if raw=True. """ url = "/vX/reference/ipos" diff --git a/massive/websocket/models/models.py b/massive/websocket/models/models.py index 6b3acd90..d3711e57 100644 --- a/massive/websocket/models/models.py +++ b/massive/websocket/models/models.py @@ -217,10 +217,10 @@ class CryptoQuote: event_type: Optional[Union[str, EventType]] = None pair: Optional[str] = None - bid_price: Optional[int] = None + bid_price: Optional[float] = None bid_size: Optional[float] = None - ask_price: Optional[int] = None - ask_size: Optional[int] = None + ask_price: Optional[float] = None + ask_size: Optional[float] = None timestamp: Optional[float] = None exchange_id: Optional[int] = None received_timestamp: Optional[int] = None @@ -328,7 +328,7 @@ class IndexValue: event_type: Optional[Union[str, EventType]] = None value: Optional[float] = None ticker: Optional[str] = None - timestamp: Optional[str] = None + timestamp: Optional[int] = None @staticmethod def from_dict(d): diff --git a/test_rest/test_aggs.py b/test_rest/test_aggs.py index 850a00da..5ec5826a 100644 --- a/test_rest/test_aggs.py +++ b/test_rest/test_aggs.py @@ -98,6 +98,7 @@ def test_get_daily_open_close_agg(self): def test_get_previous_close_agg(self): aggs = self.c.get_previous_close_agg("AAPL") + self.assertIsInstance(aggs, list) expected = [ PreviousCloseAgg( ticker="AAPL", diff --git a/test_rest/test_pagination.py b/test_rest/test_pagination.py new file mode 100644 index 00000000..f0f86aa2 --- /dev/null +++ b/test_rest/test_pagination.py @@ -0,0 +1,15 @@ +import types + +from base import BaseTest + + +class PaginationTest(BaseTest): + def test_list_methods_return_iterators(self): + # The iterators are lazy, so no request is sent. + for result in ( + self.c.list_treasury_yields(), + self.c.list_short_interest(), + self.c.list_short_volume(), + self.c.vx.list_ipos(), + ): + self.assertIsInstance(result, types.GeneratorType)