From 86ce6e54b1d1a6143779b94e7bdadd9785374403 Mon Sep 17 00:00:00 2001 From: phileaton Date: Fri, 1 Jan 2021 10:02:48 -0800 Subject: [PATCH] Fixed find_options_by_specific_profitability find_options_by_specific_profitability will fail if an empty list is returned by get_option_market_data_by_id. Added a check for empty list. --- robin_stocks/options.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/robin_stocks/options.py b/robin_stocks/options.py index 5c73603..7a07887 100644 --- a/robin_stocks/options.py +++ b/robin_stocks/options.py @@ -301,15 +301,17 @@ def find_options_by_specific_profitability(inputSymbols, expirationDate=None, st continue market_data = get_option_market_data_by_id(option['id']) - option.update(market_data[0]) - write_spinner() - - try: - floatValue = float(option[typeProfit]) - if (floatValue >= profitFloor and floatValue <= profitCeiling): - data.append(option) - except: - pass + + if len(market_data): + option.update(market_data[0]) + write_spinner() + + try: + floatValue = float(option[typeProfit]) + if (floatValue >= profitFloor and floatValue <= profitCeiling): + data.append(option) + except: + pass return(helper.filter(data, info))