diff --git a/robin_stocks/robinhood/__init__.py b/robin_stocks/robinhood/__init__.py index e852841..81f614e 100644 --- a/robin_stocks/robinhood/__init__.py +++ b/robin_stocks/robinhood/__init__.py @@ -33,6 +33,7 @@ find_options_by_expiration_and_strike, find_options_by_specific_profitability, find_options_by_strike, find_tradable_options, + get_aggregate_open_positions, get_aggregate_positions, get_all_option_positions, get_chains, get_market_options, get_open_option_positions, get_option_historicals, diff --git a/robin_stocks/robinhood/options.py b/robin_stocks/robinhood/options.py index 9e8b5f2..518bf11 100644 --- a/robin_stocks/robinhood/options.py +++ b/robin_stocks/robinhood/options.py @@ -34,6 +34,21 @@ def get_aggregate_positions(info=None): data = request_get(url, 'pagination') return(filter_data(data, info)) +@login_required +def get_aggregate_open_positions(info=None): + """Collapses all open option positions for a stock into a single dictionary. + + :param info: Will filter the results to get a specific value. + :type info: Optional[str] + :returns: Returns a list of dictionaries of key/value pairs for each order. If info parameter is provided, \ + a list of strings is returned where the strings are the value of the key that matches info. + + """ + url = aggregate_url() + payload = {'nonzero': 'True'} + data = request_get(url, 'pagination', payload) + return(filter_data(data, info)) + @login_required def get_market_options(info=None):