From 3f16a382b0a23acf0e4a11d00bf0290cfb9e8a06 Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Sat, 25 Feb 2023 16:21:30 -0800 Subject: [PATCH] fix for options screener --- .../stocks/options}/README.md | 0 .../stocks/options/high_iv.ini} | 35 ++-- .../stocks/options/iv_below_20day.ini} | 32 +-- .../stocks/options/spy_30_delta.ini} | 20 +- .../stocks/options}/template.ini | 0 .../stocks/options/presets/Highest_OI.ini | 180 ----------------- .../stocks/options/presets/Long_FAANGM.ini | 179 ----------------- .../stocks/options/presets/SPY_ATM_Calls.ini | 180 ----------------- .../stocks/options/presets/SPY_ATM_Poots.ini | 180 ----------------- .../options/presets/TSLA_Calls_90Days.ini | 180 ----------------- .../stocks/options/presets/TSLA_Poots.ini | 180 ----------------- .../stocks/options/presets/high_IV.ini | 182 ------------------ .../options/screen/screener_controller.py | 19 +- .../stocks/options/screen/syncretism_model.py | 115 ++++++----- .../stocks/options/screen/syncretism_view.py | 13 +- 15 files changed, 119 insertions(+), 1376 deletions(-) rename openbb_terminal/{stocks/options/presets => miscellaneous/stocks/options}/README.md (100%) rename openbb_terminal/{stocks/options/presets/Highest_IV.ini => miscellaneous/stocks/options/high_iv.ini} (91%) rename openbb_terminal/{stocks/options/presets/3DTE_Degenerate.ini => miscellaneous/stocks/options/iv_below_20day.ini} (93%) rename openbb_terminal/{stocks/options/presets/Highest_Volume.ini => miscellaneous/stocks/options/spy_30_delta.ini} (94%) rename openbb_terminal/{stocks/options/presets => miscellaneous/stocks/options}/template.ini (100%) delete mode 100644 openbb_terminal/stocks/options/presets/Highest_OI.ini delete mode 100644 openbb_terminal/stocks/options/presets/Long_FAANGM.ini delete mode 100644 openbb_terminal/stocks/options/presets/SPY_ATM_Calls.ini delete mode 100644 openbb_terminal/stocks/options/presets/SPY_ATM_Poots.ini delete mode 100644 openbb_terminal/stocks/options/presets/TSLA_Calls_90Days.ini delete mode 100644 openbb_terminal/stocks/options/presets/TSLA_Poots.ini delete mode 100644 openbb_terminal/stocks/options/presets/high_IV.ini diff --git a/openbb_terminal/stocks/options/presets/README.md b/openbb_terminal/miscellaneous/stocks/options/README.md similarity index 100% rename from openbb_terminal/stocks/options/presets/README.md rename to openbb_terminal/miscellaneous/stocks/options/README.md diff --git a/openbb_terminal/stocks/options/presets/Highest_IV.ini b/openbb_terminal/miscellaneous/stocks/options/high_iv.ini similarity index 91% rename from openbb_terminal/stocks/options/presets/Highest_IV.ini rename to openbb_terminal/miscellaneous/stocks/options/high_iv.ini index 946d19a1436..0fb16644274 100644 --- a/openbb_terminal/stocks/options/presets/Highest_IV.ini +++ b/openbb_terminal/miscellaneous/stocks/options/high_iv.ini @@ -1,10 +1,10 @@ # Author of preset: Danglewood -# Description: The highest implied volatility of all the options in the market. +# Description: Delta bound filter. [FILTER] # tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. # E.g. "GME" or for multiples "AMC,BB,GME". -tickers = +tickers = # exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. exclude = @@ -16,7 +16,7 @@ min-diff = max-diff = # itm [bool]: select in the money options. -itm = true +itm = false # otm [bool]: select out of the money options. otm = true @@ -34,16 +34,16 @@ min-exp = max-exp = # min-price [float]: minimum option premium. -min-price = +min-price = # max-price [float]: maximum option premium. max-price = #min-strike [float]: minimum option strike. -min-strike = +min-strike = #max-strike [float]: maximum option strike. -max-strike = +max-strike = # calls [true|false]: select call options. calls = true @@ -55,7 +55,7 @@ puts = true stock = true # etf [true|false]: select etf options. -etf = true +etf = false # min-sto [float]: minimum option price / stock price ratio. min-sto = @@ -76,10 +76,10 @@ min-myield = max-myield = # min-delta [float]: minimum delta greek. -min-delta = +min-delta = # max-delta [float]: maximum delta greek. -max-delta = +max-delta = # min-gamma [float]: minimum gamma greek. min-gamma = @@ -100,25 +100,25 @@ min-vega = max-vega = #min-iv [float]: minimum implied volatility. -min-iv = +min-iv = 1.00 #max-iv [float]: maximum implied volatility. max-iv = #min-oi [float]: minimum open interest. -min-oi = 1 +min-oi = 10 #max-oi[float]: maximum open interest max-oi = #min-volume [float]: minimum volume. -min-volume = +min-volume = 10 #max-volume [float]: maximum volume. max-volume = #min-voi [float]: minimum volume / oi ratio. -min-voi = +min-voi = #max-voi [float]: maximum volume / oi ratio. max-voi = @@ -135,21 +135,24 @@ max-cap = # "lp_desc", "lp_asc": lastprice, descending / ascending. # "md_desc", "md_asc": current stock price, descending / ascending. # "oi_desc", "oi_asc": open interest, descending / ascending. +# "v_desc", "v_asc": volume, descending / ascending. +# "ρ_desc", "ρ_asc": rho, descending / ascending. + order-by = "iv_desc" # limit [int]: number of results (max 50). limit = # active [true|false]: if set to true, restricts to options for which volume, open interest, ask, and bid are all > 0. -active = +active = true # [float|int] deviation from the 20 day average min-price-20d = max-price-20d = min-volume-20d = max-volume-20d = -min-iv-20d = -max-iv-20d = +min-iv-20d = +max-iv-20d = min-delta-20d = max-delta-20d = min-gamma-20d = diff --git a/openbb_terminal/stocks/options/presets/3DTE_Degenerate.ini b/openbb_terminal/miscellaneous/stocks/options/iv_below_20day.ini similarity index 93% rename from openbb_terminal/stocks/options/presets/3DTE_Degenerate.ini rename to openbb_terminal/miscellaneous/stocks/options/iv_below_20day.ini index e95b2cdc681..ca2153a983f 100644 --- a/openbb_terminal/stocks/options/presets/3DTE_Degenerate.ini +++ b/openbb_terminal/miscellaneous/stocks/options/iv_below_20day.ini @@ -1,10 +1,10 @@ # Author of preset: Danglewood -# Description: 3-DTE max options with the highest IV. +# Description: Delta bound filter. [FILTER] # tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. # E.g. "GME" or for multiples "AMC,BB,GME". -tickers = +tickers = # exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. exclude = @@ -16,7 +16,7 @@ min-diff = max-diff = # itm [bool]: select in the money options. -itm = true +itm = false # otm [bool]: select out of the money options. otm = true @@ -31,19 +31,19 @@ max-ask-bid = min-exp = # max-exp [int]: maximum days until expiration. -max-exp = 3 +max-exp = # min-price [float]: minimum option premium. -min-price = +min-price = # max-price [float]: maximum option premium. max-price = #min-strike [float]: minimum option strike. -min-strike = +min-strike = #max-strike [float]: maximum option strike. -max-strike = +max-strike = # calls [true|false]: select call options. calls = true @@ -55,7 +55,7 @@ puts = true stock = true # etf [true|false]: select etf options. -etf = true +etf = false # min-sto [float]: minimum option price / stock price ratio. min-sto = @@ -76,13 +76,13 @@ min-myield = max-myield = # min-delta [float]: minimum delta greek. -min-delta = +min-delta = # max-delta [float]: maximum delta greek. -max-delta = +max-delta = # min-gamma [float]: minimum gamma greek. -min-gamma = 1 +min-gamma = # max-gamma [float]: maximum gamma greek. max-gamma = @@ -136,21 +136,23 @@ max-cap = # "md_desc", "md_asc": current stock price, descending / ascending. # "oi_desc", "oi_asc": open interest, descending / ascending. # "v_desc", "v_asc": volume, descending / ascending. -order-by = "iv_desc" +# "ρ_desc", "ρ_asc": rho, descending / ascending. + +order-by = "iv_asc" # limit [int]: number of results (max 50). limit = # active [true|false]: if set to true, restricts to options for which volume, open interest, ask, and bid are all > 0. -active = +active = true # [float|int] deviation from the 20 day average min-price-20d = max-price-20d = min-volume-20d = max-volume-20d = -min-iv-20d = -max-iv-20d = +min-iv-20d = 0.80 +max-iv-20d = min-delta-20d = max-delta-20d = min-gamma-20d = diff --git a/openbb_terminal/stocks/options/presets/Highest_Volume.ini b/openbb_terminal/miscellaneous/stocks/options/spy_30_delta.ini similarity index 94% rename from openbb_terminal/stocks/options/presets/Highest_Volume.ini rename to openbb_terminal/miscellaneous/stocks/options/spy_30_delta.ini index fcf1000413c..9808f91a146 100644 --- a/openbb_terminal/stocks/options/presets/Highest_Volume.ini +++ b/openbb_terminal/miscellaneous/stocks/options/spy_30_delta.ini @@ -1,10 +1,10 @@ # Author of preset: Danglewood -# Description: The most heavily traded options. +# Description: Delta bound filter. [FILTER] # tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. # E.g. "GME" or for multiples "AMC,BB,GME". -tickers = +tickers = "SPY" # exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. exclude = @@ -40,10 +40,10 @@ min-price = max-price = #min-strike [float]: minimum option strike. -min-strike = +min-strike = 280 #max-strike [float]: maximum option strike. -max-strike = +max-strike = # calls [true|false]: select call options. calls = true @@ -76,10 +76,10 @@ min-myield = max-myield = # min-delta [float]: minimum delta greek. -min-delta = +min-delta = 0.10 # max-delta [float]: maximum delta greek. -max-delta = +max-delta = 0.35 # min-gamma [float]: minimum gamma greek. min-gamma = @@ -106,13 +106,13 @@ min-iv = max-iv = #min-oi [float]: minimum open interest. -min-oi = 1 +min-oi = 10 #max-oi[float]: maximum open interest max-oi = #min-volume [float]: minimum volume. -min-volume = +min-volume = 100 #max-volume [float]: maximum volume. max-volume = @@ -136,7 +136,9 @@ max-cap = # "md_desc", "md_asc": current stock price, descending / ascending. # "oi_desc", "oi_asc": open interest, descending / ascending. # "v_desc", "v_asc": volume, descending / ascending. -order-by = "v_desc" +# "ρ_desc", "ρ_asc": rho, descending / ascending. + +order-by = # limit [int]: number of results (max 50). limit = diff --git a/openbb_terminal/stocks/options/presets/template.ini b/openbb_terminal/miscellaneous/stocks/options/template.ini similarity index 100% rename from openbb_terminal/stocks/options/presets/template.ini rename to openbb_terminal/miscellaneous/stocks/options/template.ini diff --git a/openbb_terminal/stocks/options/presets/Highest_OI.ini b/openbb_terminal/stocks/options/presets/Highest_OI.ini deleted file mode 100644 index c7ce672d74b..00000000000 --- a/openbb_terminal/stocks/options/presets/Highest_OI.ini +++ /dev/null @@ -1,180 +0,0 @@ -# Author of preset: Danglewood -# Description: The most open interest of them all. -[FILTER] - -# tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. -# E.g. "GME" or for multiples "AMC,BB,GME". -tickers = - -# exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. -exclude = - -# min-diff [int]: minimum difference in percentage between strike and stock price. -min-diff = - -# max-diff [int]: maximum difference in percentage between strike and stock price. -max-diff = - -# itm [bool]: select in the money options. -itm = true - -# otm [bool]: select out of the money options. -otm = true - -# min-ask-bid [float]: minimum spread between bid and ask. -min-ask-bid = - -# max-ask-bid [float]: maximum spread between bid and ask. -max-ask-bid = - -# min-exp [int]: minimum days until expiration. -min-exp = - -# max-exp [int]: maximum days until expiration. -max-exp = - -# min-price [float]: minimum option premium. -min-price = - -# max-price [float]: maximum option premium. -max-price = - -#min-strike [float]: minimum option strike. -min-strike = - -#max-strike [float]: maximum option strike. -max-strike = - -# calls [true|false]: select call options. -calls = true - -# puts [true|false]: select put options. -puts = true - -# stock [true|false]: select normal stocks. -stock = true - -# etf [true|false]: select etf options. -etf = true - -# min-sto [float]: minimum option price / stock price ratio. -min-sto = - -# max-sto [float]: maximum option price / stock price ratio. -max-sto = - -# min-yield [float]: minimum premium / strike price ratio. -min-yield = - -# max-yield [float]: maximum premium / strike price ratio. -max-yield = - -# min-myield [float]: minimum yield per month until expiration date. -min-myield = - -# max-myield [float]: maximum yield per month until expiration date. -max-myield = - -# min-delta [float]: minimum delta greek. -min-delta = - -# max-delta [float]: maximum delta greek. -max-delta = - -# min-gamma [float]: minimum gamma greek. -min-gamma = - -# max-gamma [float]: maximum gamma greek. -max-gamma = - -# min-theta [float]: minimum theta greek. -min-theta = - -# max-theta [float]: maximum theta greek. -max-theta = - -# min-vega [float]: minimum vega greek. -min-vega = - -# max-vega [float]: maximum vega greek. -max-vega = - -#min-iv [float]: minimum implied volatility. -min-iv = - -#max-iv [float]: maximum implied volatility. -max-iv = - -#min-oi [float]: minimum open interest. -min-oi = 1 - -#max-oi[float]: maximum open interest -max-oi = - -#min-volume [float]: minimum volume. -min-volume = - -#max-volume [float]: maximum volume. -max-volume = - -#min-voi [float]: minimum volume / oi ratio. -min-voi = - -#max-voi [float]: maximum volume / oi ratio. -max-voi = - -# min-cap [float]: minimum market capitalization (in billions USD). -min-cap = - -# max-cap [float]: maximum market capitalization (in billions USD). -max-cap = - -# order-by [default: e_desc]: how to order results, possible values: -# "e_desc", "e_asc": expiration, descending / ascending. -# "iv_desc", "iv_asc": implied volatility, descending / ascending. -# "lp_desc", "lp_asc": lastprice, descending / ascending. -# "md_desc", "md_asc": current stock price, descending / ascending. -# "oi_desc", "oi_asc": open interest, descending / ascending. -order-by = "oi_desc" - -# limit [int]: number of results (max 50). -limit = - -# active [true|false]: if set to true, restricts to options for which volume, open interest, ask, and bid are all > 0. -active = - -# [float|int] deviation from the 20 day average -min-price-20d = -max-price-20d = -min-volume-20d = -max-volume-20d = -min-iv-20d = -max-iv-20d = -min-delta-20d = -max-delta-20d = -min-gamma-20d = -max-gamma-20d = -min-theta-20d = -max-theta-20d = -min-vega-20d = -max-vega-20d = -min-rho-20d = -max-rho-20d = - -# [float|int] deviation from the 100 day average -min-price-100d = -max-price-100d = -min-volume-100d = -max-volume-100d = -min-iv-100d = -max-iv-100d = -min-delta-100d = -max-delta-100d = -min-gamma-100d = -max-gamma-100d = -min-theta-100d = -max-theta-100d = -min-vega-100d = -max-vega-100d = -min-rho-100d = -max-rho-100d = diff --git a/openbb_terminal/stocks/options/presets/Long_FAANGM.ini b/openbb_terminal/stocks/options/presets/Long_FAANGM.ini deleted file mode 100644 index 9ef359e9ef4..00000000000 --- a/openbb_terminal/stocks/options/presets/Long_FAANGM.ini +++ /dev/null @@ -1,179 +0,0 @@ -# Author of preset: Danglewood -# Description: 180 day options in the FAANGM club at, near, outside the money; sorted by open interest. -[FILTER] - -# tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. -# E.g. "GME" or for multiples "AMC","BB","GME". -tickers = "FB","AAPL","AMZN","NFLX","GOOG","MSFT" - -# exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. -exclude = - -# min-diff [int]: minimum difference in percentage between strike and stock price. -min-diff = - -# max-diff [int]: maximum difference in percentage between strike and stock price. -max-diff = - -# itm [bool]: select in the money options. -itm = true - -# otm [bool]: select out of the money options. -otm = true - -# min-ask-bid [float]: minimum spread between bid and ask. -min-ask-bid = - -# max-ask-bid [float]: maximum spread between bid and ask. -max-ask-bid = - -# min-exp [int]: minimum days until expiration. -min-exp = 180 - -# max-exp [int]: maximum days until expiration. -max-exp = - -# min-price [float]: minimum option premium. -min-price = - -# max-price [float]: maximum option premium. -max-price = - -#min-strike [float]: minimum option strike. -min-strike = - -#max-strike [float]: maximum option strike. -max-strike = - -# calls [true|false]: select call options. -calls = true - -# puts [true|false]: select put options. -puts = true - -# stock [true|false]: select normal stocks. -stock = - -# etf [true|false]: select etf options. -etf = - -# min-sto [float]: minimum option price / stock price ratio. -min-sto = - -# max-sto [float]: maximum option price / stock price ratio. -max-sto = - -# min-yield [float]: minimum premium / strike price ratio. -min-yield = - -# max-yield [float]: maximum premium / strike price ratio. -max-yield = - -# min-myield [float]: minimum yield per month until expiration date. -min-myield = - -# max-myield [float]: maximum yield per month until expiration date. -max-myield = - -# min-delta [float]: minimum delta greek. -min-delta = 0.15 - -# max-delta [float]: maximum delta greek. -max-delta = 0.55 - -# min-gamma [float]: minimum gamma greek. -min-gamma = - -# max-gamma [float]: maximum gamma greek. -max-gamma = - -# min-theta [float]: minimum theta greek. -min-theta = - -# max-theta [float]: maximum theta greek. -max-theta = - -# min-vega [float]: minimum vega greek. -min-vega = - -# max-vega [float]: maximum vega greek. -max-vega = - -#min-iv [float]: minimum implied volatility. -min-iv = - -#max-iv [float]: maximum implied volatility. -max-iv = - -#min-oi [float]: minimum open interest. -min-oi = - -#max-oi[float]: maximum open interest -max-oi = - -#min-volume [float]: minimum volume. -min-volume = - -#max-volume [float]: maximum volume. -max-volume = - -#min-voi [float]: minimum volume / oi ratio. -min-voi = - -#max-voi [float]: maximum volume / oi ratio. -max-voi = - -# min-cap [float]: minimum market capitalization (in billions USD). -min-cap = - -# max-cap [float]: maximum market capitalization (in billions USD). -max-cap = - -# order-by [default: e_desc]: how to order results, possible values: -# e_desc, e_asc: expiration, descending / ascending. -# iv_desc, iv_asc: implied volatility, descending / ascending. -# lp_desc, lp_asc: lastprice, descending / ascending. -# md_desc, md_asc: current stock price, descending / ascending. -order-by = "oi_desc" - -# limit [int]: number of results (max 50). -limit = - -# active [true|false]: if set to true, restricts to options for which volume, open interest, ask, and bid are all > 0. -active = true - -# [float|int] deviation from the 20 day average -min-price-20d = -max-price-20d = -min-volume-20d = -max-volume-20d = -min-iv-20d = -max-iv-20d = -min-delta-20d = -max-delta-20d = -min-gamma-20d = -max-gamma-20d = -min-theta-20d = -max-theta-20d = -min-vega-20d = -max-vega-20d = -min-rho-20d = -max-rho-20d = - -# [float|int] deviation from the 100 day average -min-price-100d = -max-price-100d = -min-volume-100d = -max-volume-100d = -min-iv-100d = -max-iv-100d = -min-delta-100d = -max-delta-100d = -min-gamma-100d = -max-gamma-100d = -min-theta-100d = -max-theta-100d = -min-vega-100d = -max-vega-100d = -min-rho-100d = -max-rho-100d = diff --git a/openbb_terminal/stocks/options/presets/SPY_ATM_Calls.ini b/openbb_terminal/stocks/options/presets/SPY_ATM_Calls.ini deleted file mode 100644 index b96cb16cf3a..00000000000 --- a/openbb_terminal/stocks/options/presets/SPY_ATM_Calls.ini +++ /dev/null @@ -1,180 +0,0 @@ -# Author of preset: Danglewood -# Description: SPY calls at or near the money, sorted by open interest. -[FILTER] - -# tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. -# E.g. "GME" or for multiples "AMC","BB","GME". -tickers = "SPY" - -# exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. -exclude = false - -# min-diff [int]: minimum difference in percentage between strike and stock price. -min-diff = - -# max-diff [int]: maximum difference in percentage between strike and stock price. -max-diff = - -# itm [bool]: select in the money options. -itm = true - -# otm [bool]: select out of the money options. -otm = true - -# min-ask-bid [float]: minimum spread between bid and ask. -min-ask-bid = - -# max-ask-bid [float]: maximum spread between bid and ask. -max-ask-bid = - -# min-exp [int]: minimum days until expiration. -min-exp = - -# max-exp [int]: maximum days until expiration. -max-exp = - -# min-price [float]: minimum option premium. -min-price = - -# max-price [float]: maximum option premium. -max-price = - -#min-strike [float]: minimum option strike. -min-strike = - -#max-strike [float]: maximum option strike. -max-strike = - -# calls [true|false]: select call options. -calls = true - -# puts [true|false]: select put options. -puts = true - -# stock [true|false]: select normal stocks. -stock = true - -# etf [true|false]: select etf options. -etf = true - -# min-sto [float]: minimum option price / stock price ratio. -min-sto = - -# max-sto [float]: maximum option price / stock price ratio. -max-sto = - -# min-yield [float]: minimum premium / strike price ratio. -min-yield = - -# max-yield [float]: maximum premium / strike price ratio. -max-yield = - -# min-myield [float]: minimum yield per month until expiration date. -min-myield = - -# max-myield [float]: maximum yield per month until expiration date. -max-myield = - -# min-delta [float]: minimum delta greek. -min-delta = 0.45 - -# max-delta [float]: maximum delta greek. -max-delta = - -# min-gamma [float]: minimum gamma greek. -min-gamma = 0.027 - -# max-gamma [float]: maximum gamma greek. -max-gamma = - -# min-theta [float]: minimum theta greek. -min-theta = - -# max-theta [float]: maximum theta greek. -max-theta = - -# min-vega [float]: minimum vega greek. -min-vega = - -# max-vega [float]: maximum vega greek. -max-vega = - -#min-iv [float]: minimum implied volatility. -min-iv = - -#max-iv [float]: maximum implied volatility. -max-iv = - -#min-oi [float]: minimum open interest. -min-oi = - -#max-oi[float]: maximum open interest -max-oi = - -#min-volume [float]: minimum volume. -min-volume = - -#max-volume [float]: maximum volume. -max-volume = - -#min-voi [float]: minimum volume / oi ratio. -min-voi = - -#max-voi [float]: maximum volume / oi ratio. -max-voi = - -# min-cap [float]: minimum market capitalization (in billions USD). -min-cap = - -# max-cap [float]: maximum market capitalization (in billions USD). -max-cap = - -# order-by [default: e_desc]: how to order results, possible values: -# "e_desc", "e_asc": expiration, descending / ascending. -# "iv_desc", "iv_asc": implied volatility, descending / ascending. -# "lp_desc", "lp_asc": lastprice, descending / ascending. -# "md_desc", "md_asc": current stock price, descending / ascending. -# "oi_desc", "oi_asc": open interest, descending / ascending. -order-by = "oi_desc" - -# limit [int]: number of results (max 50). -limit = - -# active [true|false]: if set to true, restricts to options for which volume, open interest, ask, and bid are all > 0. -active = true - -# [float|int] deviation from the 20 day average -min-price-20d = -max-price-20d = -min-volume-20d = -max-volume-20d = -min-iv-20d = -max-iv-20d = -min-delta-20d = -max-delta-20d = -min-gamma-20d = -max-gamma-20d = -min-theta-20d = -max-theta-20d = -min-vega-20d = -max-vega-20d = -min-rho-20d = -max-rho-20d = - -# [float|int] deviation from the 100 day average -min-price-100d = -max-price-100d = -min-volume-100d = -max-volume-100d = -min-iv-100d = -max-iv-100d = -min-delta-100d = -max-delta-100d = -min-gamma-100d = -max-gamma-100d = -min-theta-100d = -max-theta-100d = -min-vega-100d = -max-vega-100d = -min-rho-100d = -max-rho-100d = diff --git a/openbb_terminal/stocks/options/presets/SPY_ATM_Poots.ini b/openbb_terminal/stocks/options/presets/SPY_ATM_Poots.ini deleted file mode 100644 index b27abad9df5..00000000000 --- a/openbb_terminal/stocks/options/presets/SPY_ATM_Poots.ini +++ /dev/null @@ -1,180 +0,0 @@ -# Author of preset: Danglewood -# Description: SPY puts at or near the money, sorted by open interest. -[FILTER] - -# tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. -# E.g. "GME" or for multiples "AMC","BB","GME". -tickers = "SPY" - -# exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. -exclude = false - -# min-diff [int]: minimum difference in percentage between strike and stock price. -min-diff = - -# max-diff [int]: maximum difference in percentage between strike and stock price. -max-diff = - -# itm [bool]: select in the money options. -itm = true - -# otm [bool]: select out of the money options. -otm = true - -# min-ask-bid [float]: minimum spread between bid and ask. -min-ask-bid = - -# max-ask-bid [float]: maximum spread between bid and ask. -max-ask-bid = - -# min-exp [int]: minimum days until expiration. -min-exp = - -# max-exp [int]: maximum days until expiration. -max-exp = - -# min-price [float]: minimum option premium. -min-price = - -# max-price [float]: maximum option premium. -max-price = - -#min-strike [float]: minimum option strike. -min-strike = - -#max-strike [float]: maximum option strike. -max-strike = - -# calls [true|false]: select call options. -calls = false - -# puts [true|false]: select put options. -puts = true - -# stock [true|false]: select normal stocks. -stock = true - -# etf [true|false]: select etf options. -etf = true - -# min-sto [float]: minimum option price / stock price ratio. -min-sto = - -# max-sto [float]: maximum option price / stock price ratio. -max-sto = - -# min-yield [float]: minimum premium / strike price ratio. -min-yield = - -# max-yield [float]: maximum premium / strike price ratio. -max-yield = - -# min-myield [float]: minimum yield per month until expiration date. -min-myield = - -# max-myield [float]: maximum yield per month until expiration date. -max-myield = - -# min-delta [float]: minimum delta greek. -min-delta = - -# max-delta [float]: maximum delta greek. -max-delta = 0.6 - -# min-gamma [float]: minimum gamma greek. -min-gamma = 0.03 - -# max-gamma [float]: maximum gamma greek. -max-gamma = - -# min-theta [float]: minimum theta greek. -min-theta = - -# max-theta [float]: maximum theta greek. -max-theta = - -# min-vega [float]: minimum vega greek. -min-vega = - -# max-vega [float]: maximum vega greek. -max-vega = - -#min-iv [float]: minimum implied volatility. -min-iv = - -#max-iv [float]: maximum implied volatility. -max-iv = - -#min-oi [float]: minimum open interest. -min-oi = - -#max-oi[float]: maximum open interest -max-oi = - -#min-volume [float]: minimum volume. -min-volume = - -#max-volume [float]: maximum volume. -max-volume = - -#min-voi [float]: minimum volume / oi ratio. -min-voi = - -#max-voi [float]: maximum volume / oi ratio. -max-voi = - -# min-cap [float]: minimum market capitalization (in billions USD). -min-cap = - -# max-cap [float]: maximum market capitalization (in billions USD). -max-cap = - -# order-by [default: e_desc]: how to order results, possible values: -# "e_desc", "e_asc": expiration, descending / ascending. -# "iv_desc", "iv_asc": implied volatility, descending / ascending. -# "lp_desc", "lp_asc": lastprice, descending / ascending. -# "md_desc", "md_asc": current stock price, descending / ascending. -# "oi_desc", "oi_asc": open interest, descending / ascending. -order-by = "oi_desc" - -# limit [int]: number of results (max 50). -limit = - -# active [true|false]: if set to true, restricts to options for which volume, open interest, ask, and bid are all > 0. -active = true - -# [float|int] deviation from the 20 day average -min-price-20d = -max-price-20d = -min-volume-20d = -max-volume-20d = -min-iv-20d = -max-iv-20d = -min-delta-20d = -max-delta-20d = -min-gamma-20d = -max-gamma-20d = -min-theta-20d = -max-theta-20d = -min-vega-20d = -max-vega-20d = -min-rho-20d = -max-rho-20d = - -# [float|int] deviation from the 100 day average -min-price-100d = -max-price-100d = -min-volume-100d = -max-volume-100d = -min-iv-100d = -max-iv-100d = -min-delta-100d = -max-delta-100d = -min-gamma-100d = -max-gamma-100d = -min-theta-100d = -max-theta-100d = -min-vega-100d = -max-vega-100d = -min-rho-100d = -max-rho-100d = diff --git a/openbb_terminal/stocks/options/presets/TSLA_Calls_90Days.ini b/openbb_terminal/stocks/options/presets/TSLA_Calls_90Days.ini deleted file mode 100644 index 6ff295ed910..00000000000 --- a/openbb_terminal/stocks/options/presets/TSLA_Calls_90Days.ini +++ /dev/null @@ -1,180 +0,0 @@ -# Author of preset: OpenBB Terminal -# Description: TSLA calls near the money with up to 90-DTE, sorted by open interest. -[FILTER] - -# tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. -# E.g. "GME" or for multiples "AMC","BB","GME". -tickers = "TSLA" - -# exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. -exclude = false - -# min-diff [int]: minimum difference in percentage between strike and stock price. -min-diff = - -# max-diff [int]: maximum difference in percentage between strike and stock price. -max-diff = - -# itm [bool]: select in the money options. -itm = true - -# otm [bool]: select out of the money options. -otm = true - -# min-ask-bid [float]: minimum spread between bid and ask. -min-ask-bid = - -# max-ask-bid [float]: maximum spread between bid and ask. -max-ask-bid = - -# min-exp [int]: minimum days until expiration. -min-exp = 3 - -# max-exp [int]: maximum days until expiration. -max-exp = 90 - -# min-price [float]: minimum option premium. -min-price = - -# max-price [float]: maximum option premium. -max-price = - -#min-strike [float]: minimum option strike. -min-strike = - -#max-strike [float]: maximum option strike. -max-strike = - -# calls [true|false]: select call options. -calls = true - -# puts [true|false]: select put options. -puts = true - -# stock [true|false]: select normal stocks. -stock = true - -# etf [true|false]: select etf options. -etf = true - -# min-sto [float]: minimum option price / stock price ratio. -min-sto = - -# max-sto [float]: maximum option price / stock price ratio. -max-sto = - -# min-yield [float]: minimum premium / strike price ratio. -min-yield = - -# max-yield [float]: maximum premium / strike price ratio. -max-yield = - -# min-myield [float]: minimum yield per month until expiration date. -min-myield = - -# max-myield [float]: maximum yield per month until expiration date. -max-myield = - -# min-delta [float]: minimum delta greek. -min-delta = 0.30 - -# max-delta [float]: maximum delta greek. -max-delta = 0.65 - -# min-gamma [float]: minimum gamma greek. -min-gamma = - -# max-gamma [float]: maximum gamma greek. -max-gamma = - -# min-theta [float]: minimum theta greek. -min-theta = - -# max-theta [float]: maximum theta greek. -max-theta = - -# min-vega [float]: minimum vega greek. -min-vega = - -# max-vega [float]: maximum vega greek. -max-vega = - -#min-iv [float]: minimum implied volatility. -min-iv = - -#max-iv [float]: maximum implied volatility. -max-iv = - -#min-oi [float]: minimum open interest. -min-oi = - -#max-oi[float]: maximum open interest -max-oi = - -#min-volume [float]: minimum volume. -min-volume = - -#max-volume [float]: maximum volume. -max-volume = - -#min-voi [float]: minimum volume / oi ratio. -min-voi = - -#max-voi [float]: maximum volume / oi ratio. -max-voi = - -# min-cap [float]: minimum market capitalization (in billions USD). -min-cap = - -# max-cap [float]: maximum market capitalization (in billions USD). -max-cap = - -# order-by [default: e_desc]: how to order results, possible values: -# "e_desc", "e_asc": expiration, descending / ascending. -# "iv_desc", "iv_asc": implied volatility, descending / ascending. -# "lp_desc", "lp_asc": lastprice, descending / ascending. -# "md_desc", "md_asc": current stock price, descending / ascending. -# "oi_desc", "oi_asc": open interest, descending / ascending. -order-by = "oi_desc" - -# limit [int]: number of results (max 50). -limit = - -# active [true|false]: if set to true, restricts to options for which volume, open interest, ask, and bid are all > 0. -active = true - -# [float|int] deviation from the 20 day average -min-price-20d = -max-price-20d = -min-volume-20d = -max-volume-20d = -min-iv-20d = -max-iv-20d = -min-delta-20d = -max-delta-20d = -min-gamma-20d = -max-gamma-20d = -min-theta-20d = -max-theta-20d = -min-vega-20d = -max-vega-20d = -min-rho-20d = -max-rho-20d = - -# [float|int] deviation from the 100 day average -min-price-100d = -max-price-100d = -min-volume-100d = -max-volume-100d = -min-iv-100d = -max-iv-100d = -min-delta-100d = -max-delta-100d = -min-gamma-100d = -max-gamma-100d = -min-theta-100d = -max-theta-100d = -min-vega-100d = -max-vega-100d = -min-rho-100d = -max-rho-100d = diff --git a/openbb_terminal/stocks/options/presets/TSLA_Poots.ini b/openbb_terminal/stocks/options/presets/TSLA_Poots.ini deleted file mode 100644 index 087b07e423e..00000000000 --- a/openbb_terminal/stocks/options/presets/TSLA_Poots.ini +++ /dev/null @@ -1,180 +0,0 @@ -# Author of preset: OpenBB Terminal -# Description: TSLA puts near the money with up to 90-DTE, sorted by open interest. -[FILTER] - -# tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. -# E.g. "GME" or for multiples "AMC","BB","GME". -tickers = "TSLA" - -# exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. -exclude = false - -# min-diff [int]: minimum difference in percentage between strike and stock price. -min-diff = - -# max-diff [int]: maximum difference in percentage between strike and stock price. -max-diff = - -# itm [bool]: select in the money options. -itm = true - -# otm [bool]: select out of the money options. -otm = true - -# min-ask-bid [float]: minimum spread between bid and ask. -min-ask-bid = - -# max-ask-bid [float]: maximum spread between bid and ask. -max-ask-bid = - -# min-exp [int]: minimum days until expiration. -min-exp = 3 - -# max-exp [int]: maximum days until expiration. -max-exp = 90 - -# min-price [float]: minimum option premium. -min-price = - -# max-price [float]: maximum option premium. -max-price = - -#min-strike [float]: minimum option strike. -min-strike = - -#max-strike [float]: maximum option strike. -max-strike = - -# calls [true|false]: select call options. -calls = false - -# puts [true|false]: select put options. -puts = true - -# stock [true|false]: select normal stocks. -stock = true - -# etf [true|false]: select etf options. -etf = false - -# min-sto [float]: minimum option price / stock price ratio. -min-sto = - -# max-sto [float]: maximum option price / stock price ratio. -max-sto = - -# min-yield [float]: minimum premium / strike price ratio. -min-yield = - -# max-yield [float]: maximum premium / strike price ratio. -max-yield = - -# min-myield [float]: minimum yield per month until expiration date. -min-myield = - -# max-myield [float]: maximum yield per month until expiration date. -max-myield = - -# min-delta [float]: minimum delta greek. -min-delta = - -# max-delta [float]: maximum delta greek. -max-delta = -0.3 - -# min-gamma [float]: minimum gamma greek. -min-gamma = - -# max-gamma [float]: maximum gamma greek. -max-gamma = 0.5 - -# min-theta [float]: minimum theta greek. -min-theta = - -# max-theta [float]: maximum theta greek. -max-theta = - -# min-vega [float]: minimum vega greek. -min-vega = - -# max-vega [float]: maximum vega greek. -max-vega = - -#min-iv [float]: minimum implied volatility. -min-iv = - -#max-iv [float]: maximum implied volatility. -max-iv = - -#min-oi [float]: minimum open interest. -min-oi = - -#max-oi[float]: maximum open interest -max-oi = - -#min-volume [float]: minimum volume. -min-volume = - -#max-volume [float]: maximum volume. -max-volume = - -#min-voi [float]: minimum volume / oi ratio. -min-voi = - -#max-voi [float]: maximum volume / oi ratio. -max-voi = - -# min-cap [float]: minimum market capitalization (in billions USD). -min-cap = - -# max-cap [float]: maximum market capitalization (in billions USD). -max-cap = - -# order-by [default: e_desc]: how to order results, possible values: -# "e_desc", "e_asc": expiration, descending / ascending. -# "iv_desc", "iv_asc": implied volatility, descending / ascending. -# "lp_desc", "lp_asc": lastprice, descending / ascending. -# "md_desc", "md_asc": current stock price, descending / ascending. -# "oi_desc", "oi_asc": open interest, descending / ascending. -order-by = "oi_desc" - -# limit [int]: number of results (max 50). -limit = - -# active [true|false]: if set to true, restricts to options for which volume, open interest, ask, and bid are all > 0. -active = true - -# [float|int] deviation from the 20 day average -min-price-20d = -max-price-20d = -min-volume-20d = -max-volume-20d = -min-iv-20d = -max-iv-20d = -min-delta-20d = -max-delta-20d = -min-gamma-20d = -max-gamma-20d = -min-theta-20d = -max-theta-20d = -min-vega-20d = -max-vega-20d = -min-rho-20d = -max-rho-20d = - -# [float|int] deviation from the 100 day average -min-price-100d = -max-price-100d = -min-volume-100d = -max-volume-100d = -min-iv-100d = -max-iv-100d = -min-delta-100d = -max-delta-100d = -min-gamma-100d = -max-gamma-100d = -min-theta-100d = -max-theta-100d = -min-vega-100d = -max-vega-100d = -min-rho-100d = -max-rho-100d = diff --git a/openbb_terminal/stocks/options/presets/high_IV.ini b/openbb_terminal/stocks/options/presets/high_IV.ini deleted file mode 100644 index ccf9ca3f66e..00000000000 --- a/openbb_terminal/stocks/options/presets/high_IV.ini +++ /dev/null @@ -1,182 +0,0 @@ -# Author of preset: terp340 -# Description: This is just a sample screener for high IV. This looks for OTM options with IV between 80 and 100 %, -# less than 14 Days til expiry, a volume of at least 100 and a bid ask spread of at least 0.05 -[FILTER] - -# tickers [string]: a list of space or comma separated tickers to restrict or exclude them from the query. -# E.g. "GME" or for multiples "AMC,BB,GME". -tickers = - -# exclude [true|false]: if true, then tickers are excluded. If false, the search is restricted to these tickers. -exclude = - -# min-diff [int]: minimum difference in percentage between strike and stock price. -min-diff = - -# max-diff [int]: maximum difference in percentage between strike and stock price. -max-diff = - -# itm [bool]: select in the money options. -itm = false - -# otm [bool]: select out of the money options. -otm = true - -# min-ask-bid [float]: minimum spread between bid and ask. -min-ask-bid = - -# max-ask-bid [float]: maximum spread between bid and ask. -max-ask-bid = 0.05 - -# min-exp [int]: minimum days until expiration. -min-exp = - -# max-exp [int]: maximum days until expiration. -max-exp = 14 - -# min-price [float]: minimum option premium. -min-price = - -# max-price [float]: maximum option premium. -max-price = - -#min-strike [float]: minimum option strike. -min-strike = - -#max-strike [float]: maximum option strike. -max-strike = - -# calls [true|false]: select call options. -calls = true - -# puts [true|false]: select put options. -puts = true - -# stock [true|false]: select normal stocks. -stock = - -# etf [true|false]: select etf options. -etf = - -# min-sto [float]: minimum option price / stock price ratio. -min-sto = - -# max-sto [float]: maximum option price / stock price ratio. -max-sto = - -# min-yield [float]: minimum premium / strike price ratio. -min-yield = - -# max-yield [float]: maximum premium / strike price ratio. -max-yield = - -# min-myield [float]: minimum yield per month until expiration date. -min-myield = - -# max-myield [float]: maximum yield per month until expiration date. -max-myield = - -# min-delta [float]: minimum delta greek. -min-delta = - -# max-delta [float]: maximum delta greek. -max-delta = - -# min-gamma [float]: minimum gamma greek. -min-gamma = - -# max-gamma [float]: maximum gamma greek. -max-gamma = - -# min-theta [float]: minimum theta greek. -min-theta = - -# max-theta [float]: maximum theta greek. -max-theta = - -# min-vega [float]: minimum vega greek. -min-vega = - -# max-vega [float]: maximum vega greek. -max-vega = - -#min-iv [float]: minimum implied volatility. -min-iv = 0.80 - -#max-iv [float]: maximum implied volatility. -max-iv = 1.0 - -#min-oi [float]: minimum open interest. -min-oi = - -#max-oi[float]: maximum open interest -max-oi = - -#min-volume [float]: minimum volume. -min-volume = 100 - -#max-volume [float]: maximum volume. -max-volume = - -#min-voi [float]: minimum volume / oi ratio. -min-voi = - -#max-voi [float]: maximum volume / oi ratio. -max-voi = - -# min-cap [float]: minimum market capitalization (in billions USD). -min-cap = - -# max-cap [float]: maximum market capitalization (in billions USD). -max-cap = - -# order-by [default: e_desc]: how to order results, possible values: -# "e_desc", "e_asc": expiration, descending / ascending. -# "iv_desc", "iv_asc": implied volatility, descending / ascending. -# "lp_desc", "lp_asc": lastprice, descending / ascending. -# "md_desc", "md_asc": current stock price, descending / ascending. -# "oi_desc", "oi_asc": open interest, descending / ascending. -# "v_desc", "v_asc": volume, descending / ascending. -order-by = iv_desc - -# limit [int]: number of results (max 50). -limit = - -# active [true|false]: if set to true, restricts to options for which volume, open interest, ask, and bid are all > 0. -active = - -# [float|int] deviation from the 20 day average -min-price-20d = -max-price-20d = -min-volume-20d = -max-volume-20d = -min-iv-20d = -max-iv-20d = -min-delta-20d = -max-delta-20d = -min-gamma-20d = -max-gamma-20d = -min-theta-20d = -max-theta-20d = -min-vega-20d = -max-vega-20d = -min-rho-20d = -max-rho-20d = - -# [float|int] deviation from the 100 day average -min-price-100d = -max-price-100d = -min-volume-100d = -max-volume-100d = -min-iv-100d = -max-iv-100d = -min-delta-100d = -max-delta-100d = -min-gamma-100d = -max-gamma-100d = -min-theta-100d = -max-theta-100d = -min-vega-100d = -max-vega-100d = -min-rho-100d = -max-rho-100d = diff --git a/openbb_terminal/stocks/options/screen/screener_controller.py b/openbb_terminal/stocks/options/screen/screener_controller.py index 26c638572e1..9801010d60c 100644 --- a/openbb_terminal/stocks/options/screen/screener_controller.py +++ b/openbb_terminal/stocks/options/screen/screener_controller.py @@ -38,7 +38,7 @@ class ScreenerController(BaseController): """Constructor""" super().__init__(queue) - self.preset = "high_IV" + self.preset = "high_iv.ini" self.screen_tickers: List = list() if session and obbff.USE_PROMPT_TOOLKIT: @@ -76,7 +76,7 @@ class ScreenerController(BaseController): dest="preset", type=str, help="View specific custom preset", - default="", + default="high_iv", choices=self.preset_choices, ) if other_args and "-" not in other_args[0][0]: @@ -104,7 +104,7 @@ class ScreenerController(BaseController): action="store", dest="preset", type=str, - default="template", + default="high_iv", help="Filter presets", choices=self.preset_choices, ) @@ -121,12 +121,9 @@ class ScreenerController(BaseController): add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="scr", - description="""Screener filter output from https://ops.syncretism.io/index.html. - Where: CS: Contract Symbol; S: Symbol, T: Option Type; Str: Strike; Exp v: Expiration; - IV: Implied Volatility; LP: Last Price; B: Bid; A: Ask; V: Volume; OI: Open Interest; - Y: Yield; MY: Monthly Yield; SMP: Regular Market Price; SMDL: Regular Market Day Low; - SMDH: Regular Market Day High; LU: Last Trade Date; LC: Last Crawl; ITM: In The Money; - PC: Price Change; PB: Price-to-book. """, + description=""" + Screener filter output from https://ops.syncretism.io/index.html. + """, ) parser.add_argument( "-p", @@ -142,8 +139,8 @@ class ScreenerController(BaseController): "-l", "--limit", type=check_positive, - default=10, - help="Limit of random entries to display. Default shows all", + default=25, + help="Limit of entries to display, default of 25.", dest="limit", ) diff --git a/openbb_terminal/stocks/options/screen/syncretism_model.py b/openbb_terminal/stocks/options/screen/syncretism_model.py index 676ab00d5ee..d4c203a079f 100644 --- a/openbb_terminal/stocks/options/screen/syncretism_model.py +++ b/openbb_terminal/stocks/options/screen/syncretism_model.py @@ -3,18 +3,21 @@ __docformat__ = "numpy" import configparser import logging -from pathlib import Path -from typing import Dict, Optional, Tuple, Union +from typing import Dict, Tuple import pandas as pd import yfinance as yf -from openbb_terminal.core.config.paths import USER_PRESETS_DIRECTORY from openbb_terminal.decorators import log_start_end from openbb_terminal.helper_funcs import request +from openbb_terminal.core.config.paths import ( + USER_PRESETS_DIRECTORY, + MISCELLANEOUS_DIRECTORY, +) from openbb_terminal.rich_config import console from openbb_terminal.stocks.options import yfinance_model +pd.set_option("display.precision", 4) logger = logging.getLogger(__name__) accepted_orders = [ @@ -35,13 +38,9 @@ accepted_orders = [ @log_start_end(log=logger) def get_historical_greeks( - symbol: str = "", - expiry: Optional[str] = None, - strike: Optional[Union[str, float]] = None, - chain_id: Optional[str] = None, - put: bool = False, + symbol: str, expiry: str, strike: float, chain_id: str = "", put: bool = False ) -> pd.DataFrame: - """Get historical option greeks + """Get histoical option greeks Parameters ---------- @@ -49,7 +48,7 @@ def get_historical_greeks( Stock ticker symbol expiry: str Option expiration date - strike: Union[str, float] + strike: float Strike price to look for chain_id: str OCC option symbol. Overwrites other inputs @@ -61,25 +60,15 @@ def get_historical_greeks( df: pd.DataFrame Dataframe containing historical greeks """ - if isinstance(strike, str): - try: - strike = float(strike) - except ValueError: - console.print( - f"[red]Strike of {strike} cannot be converted to a number.[/red]\n" - ) - return pd.DataFrame() if not chain_id: options = yfinance_model.get_option_chain(symbol, expiry) - options = options.puts if put else options.calls + if put: + options = options.puts + else: + options = options.calls - selection = options.loc[options.strike == strike, "contractSymbol"] - try: - chain_id = selection.values[0] - except IndexError: - console.print(f"[red]Strike price of {strike} not found.[/red]\n") - return pd.DataFrame() + chain_id = options.loc[options.strike == strike, "contractSymbol"].values[0] r = request(f"https://api.syncretism.io/ops/historical/{chain_id}") @@ -135,7 +124,7 @@ def get_preset_choices() -> Dict: """ PRESETS_PATH = USER_PRESETS_DIRECTORY / "stocks" / "options" - PRESETS_PATH_DEFAULT = Path(__file__).parent.parent / "presets" + PRESETS_PATH_DEFAULT = MISCELLANEOUS_DIRECTORY / "stocks" / "options" preset_choices = { filepath.name: filepath for filepath in PRESETS_PATH.iterdir() @@ -160,34 +149,40 @@ def get_screener_output(preset: str) -> Tuple[pd.DataFrame, str]: ---------- preset: str Chosen preset - Returns ------- - Tuple[pd.DataFrame, str] - DataFrame with screener data or empty if errors, String containing error message if supplied + pd.DataFrame: + DataFrame with screener data, or empty if errors + str: + String containing error message if supplied """ d_cols = { - "contractSymbol": "CS", - "symbol": "S", - "optType": "T", - "strike": "Str", - "expiration": "Exp ∨", - "impliedVolatility": "IV", - "lastPrice": "LP", - "bid": "B", - "ask": "A", - "volume": "V", + "contractSymbol": "Contract Symbol", + "expiration": "Expiration", + "symbol": "Ticker", + "optType": "Type", + "strike": "Strike", + "volume": "Vol", "openInterest": "OI", - "yield": "Y", - "monthlyyield": "MY", - "regularMarketPrice": "SMP", - "regularMarketDayLow": "SMDL", - "regularMarketDayHigh": "SMDH", - "lastTradeDate": "LU", - "lastCrawl": "LC", - "inTheMoney": "ITM", - "pChange": "PC", - "priceToBook": "PB", + "impliedVolatility": "IV", + "delta": "Delta", + "gamma": "Gamma", + "rho": "Rho", + "theta": "Theta", + "vega": "Vega", + # "yield": "Y", + # "monthlyyield": "MY",, + # "regularMarketDayLow": "SMDL", + # "regularMarketDayHigh": "SMDH", + "lastTradeDate": "Last Traded", + "bid": "Bid", + "ask": "Ask", + "lastPrice": "Last", + # "lastCrawl": "LC", + # "inTheMoney": "ITM", + "pChange": "% Change", + "regularMarketPrice": "Underlying", + "priceToBook": "P/B", } preset_filter = configparser.RawConfigParser() @@ -224,15 +219,15 @@ def get_screener_output(preset: str) -> Tuple[pd.DataFrame, str]: if df_res.empty: return df_res, f"No options data found for preset: {preset}" - df_res = df_res.rename(columns=d_cols)[list(d_cols.values())[:17]] - df_res["Exp ∨"] = df_res["Exp ∨"].apply( - lambda x: pd.to_datetime(x, unit="s").strftime("%m-%d-%y") + df_res = df_res.rename(columns=d_cols)[list(d_cols.values())[:20]] + df_res["Expiration"] = df_res["Expiration"].apply( + lambda x: pd.to_datetime(x, unit="s").strftime("%y-%m-%d") ) - df_res["LU"] = df_res["LU"].apply( - lambda x: pd.to_datetime(x, unit="s").strftime("%m-%d-%y") + df_res["Last Traded"] = df_res["Last Traded"].apply( + lambda x: pd.to_datetime(x, unit="s").strftime("%y-%m-%d") ) - df_res["Y"] = df_res["Y"].round(3) - df_res["MY"] = df_res["MY"].round(3) + # df_res["Y"] = df_res["Y"].round(3) + # df_res["MY"] = df_res["MY"].round(3) return df_res, "" else: @@ -250,7 +245,6 @@ def check_presets(preset_dict: dict) -> str: ---------- preset_dict: dict Defined presets from configparser - Returns ------- error: str @@ -342,7 +336,7 @@ def check_presets(preset_dict: dict) -> str: elif key == "tickers": for symbol in value.split(","): try: - if yf.Ticker(eval(symbol)).info["regularMarketPrice"] is None: + if yf.Ticker(eval(symbol)).fast_info["lastPrice"] is None: error += f"{key} : {symbol} not found on yfinance" except NameError: @@ -354,8 +348,9 @@ def check_presets(preset_dict: dict) -> str: except Exception: error += f"{key} : {value} , should be integer\n" - elif key == "order-by" and value.replace('"', "") not in accepted_orders: - error += f"{key} : {value} not accepted ordering\n" + elif key == "order-by": + if value.replace('"', "") not in accepted_orders: + error += f"{key} : {value} not accepted ordering\n" if error: logging.exception(error) return error diff --git a/openbb_terminal/stocks/options/screen/syncretism_view.py b/openbb_terminal/stocks/options/screen/syncretism_view.py index dd785e8c715..94d23de10c3 100644 --- a/openbb_terminal/stocks/options/screen/syncretism_view.py +++ b/openbb_terminal/stocks/options/screen/syncretism_view.py @@ -59,7 +59,7 @@ def view_available_presets(preset: str): @log_start_end(log=logger) def view_screener_output( preset: str, - limit: int = 20, + limit: int = 25, export: str = "", sheet_name: Optional[str] = None, ) -> List: @@ -98,10 +98,14 @@ def view_screener_output( df_res = df_res.head(limit) print_rich_table( - df_res, headers=list(df_res.columns), show_index=False, title="Screener Output" + df_res, + headers=df_res.columns.tolist(), + show_index=False, + title="Screener Output", + floatfmt=".4f", ) - return list(set(df_res["S"].values.tolist())) + return list(set(df_res["Ticker"].values)) # pylint:disable=too-many-arguments @@ -165,9 +169,10 @@ def view_historical_greeks( if raw: print_rich_table( df.tail(limit), - headers=list(df.columns), + headers=df.columns.tolist(), title="Historical Greeks", show_index=True, + floatfmt=".4f", ) if not external_axes: