mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-08 10:22:09 +00:00
Merge pull request #365 from DidierRLopes/some-fixes
improvements and bugfixes
This commit is contained in:
@@ -363,6 +363,9 @@ Distributed under the MIT License. See [LICENSE](https://github.com/DidierRLopes
|
||||
[Artem Veremy](https://www.linkedin.com/in/veremey/) - artem@veremey.net
|
||||
|
||||
[James Maslek](https://www.linkedin.com/in/james-maslek-b6810186/) - jmaslek11@gmail.com
|
||||
|
||||
Feel free to share loss porn, memes or any questions at https://discord.gg/FmKjHKMn
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
* [VICE article](https://www.vice.com/en/article/qjp9vp/gamestonk-terminal-is-a-diy-meme-stock-version-of-bloomberg-terminal)
|
||||
|
||||
@@ -214,6 +214,7 @@ Command|Description|Source
|
||||
`short` |short interest |[Quandl](https://www.quandl.com/)
|
||||
`warnings` |company warnings according to Sean Seah book |[MarketWatch](https://www.marketwatch.com/)
|
||||
`dp` |dark pools (ATS) vs OTC data [FINRA](https://www.finra.org/#/)
|
||||
`ftd` |display fails-to-deliver data [SEC](https://www.sec.gov)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -175,11 +175,12 @@ Display barchart of dark pool (ATS) and OTC (Non ATS) data
|
||||
## ftd <a name="ftd"></a>
|
||||
|
||||
```text
|
||||
usage: ftd [-n]
|
||||
usage: ftd [-n N_NUM]
|
||||
```
|
||||
|
||||
The fails-to-deliver data collected by SEC. Fails to deliver on a given day are a cumulative number of all fails outstanding until that day, plus new fails that occur that day, less fails that settle that day. See <https://www.sec.gov/data/foiadocsfailsdatahtm>. [Source: SEC]
|
||||
|
||||
* -n : number of latest fails-to-deliver being printed. Default 10.
|
||||
* -n : number of latest fails-to-deliver being printed. Default 20.
|
||||
|
||||

|
||||
|
||||
<img width="927" alt="ftd" src="TODO">
|
||||
|
||||
@@ -39,7 +39,7 @@ def fails_to_deliver(other_args: List[str], ticker: str):
|
||||
action="store",
|
||||
dest="n_num",
|
||||
type=check_positive,
|
||||
default=10,
|
||||
default=20,
|
||||
help="number of latest fails-to-deliver being printed",
|
||||
)
|
||||
|
||||
@@ -102,5 +102,7 @@ def fails_to_deliver(other_args: List[str], ticker: str):
|
||||
|
||||
plt.show()
|
||||
|
||||
print("")
|
||||
|
||||
except Exception as e:
|
||||
print(e, "\n")
|
||||
|
||||
@@ -1,50 +1,89 @@
|
||||
# OPTIONS DATA
|
||||
# OPTIONS
|
||||
|
||||
This menu aims to give insight on options. options can cause significant share price movement, and option pricing gives
|
||||
info about market sentiment for a ticker.
|
||||
This menu aims to give insight on options.
|
||||
|
||||
* [volume](#volume)
|
||||
* Show traded options for a given expiry [Yahoo Finance]
|
||||
This menu aims to give insight on options. Options can cause significant share price movement, and option pricing gives info about market sentiment for a ticker. The usage of the following commands along with an example will be exploited below:
|
||||
|
||||
* [exp](#exp)
|
||||
* See/set expiry date [Yahoo Finance]
|
||||
* [voi](#voi)
|
||||
* Volume + open interest options trading plot [Yahoo Finance]
|
||||
* [vcalls](#vcalls)
|
||||
* Calls volume + open interest plot [Yahoo Finance]
|
||||
* [vputs](#vputs)
|
||||
* Puts volume + open interest plot [Yahoo Finance]
|
||||
* [chains](#chains)
|
||||
* Display option chains for
|
||||
* Display option chains [Source: Tradier]
|
||||
|
||||
## volume <a name="get"></a>
|
||||
|
||||
## exp <a name="exp"></a>
|
||||
|
||||
```text
|
||||
usage: volume -e yyyy-mm-dd
|
||||
usage: exp [-d {0,1,2,3,4,5,6,7,8,9,10,11}]
|
||||
```
|
||||
|
||||
or
|
||||
See/set expiry dates. [Source: Yahoo Finance]
|
||||
|
||||
* -d : Expiry date index to set.
|
||||
|
||||
<img width="955" alt="exp" src="https://user-images.githubusercontent.com/25267873/115161875-f6706900-a097-11eb-8566-bb7b408856a5.png">
|
||||
|
||||
|
||||
## voi <a name="voi"></a>
|
||||
|
||||
```text
|
||||
usage: volume --expiry yyyy-mm-dd
|
||||
usage: voi [-v MIN_VOL] [-m MIN_SP] [-M MAX_SP]
|
||||
```
|
||||
|
||||
Plots Volume + Open Interest of calls vs puts. [Source: Yahoo Finance]
|
||||
|
||||
Display volume graph for a date. [Source: Yahoo Finance]
|
||||
* -v : Minimum volume (considering open interest) threshold of the plot.
|
||||
* -m : Minimum strike price to consider in the plot.
|
||||
* -M : Maximum strike price to consider in the plot.
|
||||
|
||||

|
||||
|
||||
|
||||
## vcalls <a name="vcalls"></a>
|
||||
|
||||
```text
|
||||
usage: vcalls [-m MIN_SP] [-M MAX_SP]
|
||||
```
|
||||
|
||||
Plots Calls Volume + Open Interest. [Source: Yahoo Finance]
|
||||
|
||||
* -m : Minimum strike price to consider in the plot.
|
||||
* -M : Maximum strike price to consider in the plot.
|
||||
|
||||

|
||||
|
||||
|
||||
## vputs <a name="vputs"></a>
|
||||
|
||||
```text
|
||||
usage: vputs [-m MIN_SP] [-M MAX_SP]
|
||||
```
|
||||
|
||||
Plots Puts Volume + Open Interest. [Source: Yahoo Finance]
|
||||
|
||||
* -m : Minimum strike price to consider in the plot.
|
||||
* -M : Maximum strike price to consider in the plot.
|
||||
|
||||

|
||||
|
||||
* -e, --expiry : expiration date.
|
||||
|
||||
## chains <a name="chains"></a>
|
||||
Display a table of options chains.
|
||||
|
||||
This data requires a Tradier sandbox developer account, which can be made [here](#https://tradier.com/products/market-data-api)
|
||||
|
||||
````
|
||||
usage: chains [--calls] [--puts] [-m MIN] [-M MAX]
|
||||
usage: chains [--calls] [--puts] [-m MIN_SP] [-M MAX_SP]
|
||||
````
|
||||
* --calls : Flag to only display call options
|
||||
* --puts : Flag to display only put options
|
||||
* -m : Minimum strike price to show
|
||||
* -M : Maximum strike price to show
|
||||
|
||||
For combines tables, call options are on the left and put options are on the right of the strike
|
||||
Display options chains. [Source: Tradier]
|
||||
|
||||
As an example, if I load my ticker and select an expiry, to view the options chain for strikes between $129 and $135, one would use:
|
||||
* --calls : Flag to show calls only
|
||||
* --puts : Flag to show puts only
|
||||
* -m : Minimum strike price to consider.
|
||||
* -M : Maximum strike price to consider.
|
||||
|
||||
````
|
||||
chains -m 129 -M 135
|
||||
````
|
||||
Which outputs:
|
||||

|
||||
|
||||
<img width="948" alt="chains" src="https://user-images.githubusercontent.com/25267873/115161876-f708ff80-a097-11eb-8073-195979862a45.png">
|
||||
|
||||
@@ -88,7 +88,9 @@ def get_option_chains(symbol: str, expiry: str) -> pd.DataFrame:
|
||||
def display_chains(symbol: str, expiry: str, other_args: List[str]):
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="chains", add_help=False, description="Display options chains"
|
||||
prog="chains",
|
||||
add_help=False,
|
||||
description="Display option chains [Source: Tradier]",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
@@ -201,6 +203,7 @@ def display_chains(symbol: str, expiry: str, other_args: List[str]):
|
||||
floatfmt=".2f",
|
||||
)
|
||||
)
|
||||
print("")
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
@@ -38,7 +38,7 @@ class OptionsController:
|
||||
parser = argparse.ArgumentParser(
|
||||
add_help=False,
|
||||
prog="exp",
|
||||
description="""See expiry dates.""",
|
||||
description="""See/set expiry dates. [Source: Yahoo Finance]""",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-d",
|
||||
|
||||
@@ -351,8 +351,9 @@ def plot_calls_volume_open_interest(
|
||||
df_calls["strike"],
|
||||
df_calls["volume"] + df_calls["openInterest"],
|
||||
color="lightgreen",
|
||||
width=0.45,
|
||||
)
|
||||
plt.bar(df_calls["strike"], df_calls["volume"], color="green")
|
||||
plt.bar(df_calls["strike"], df_calls["volume"], color="green", width=0.45)
|
||||
|
||||
plt.title(f"{ticker} calls volumes for {exp_date} ")
|
||||
plt.legend(["Stock Price", "Open Interest", "Volume"])
|
||||
@@ -443,8 +444,9 @@ def plot_puts_volume_open_interest(
|
||||
df_puts["strike"],
|
||||
-df_puts["volume"] - df_puts["openInterest"],
|
||||
color="pink",
|
||||
width=0.45,
|
||||
)
|
||||
plt.bar(df_puts["strike"], -df_puts["volume"], color="red")
|
||||
plt.bar(df_puts["strike"], -df_puts["volume"], color="red", width=0.45)
|
||||
|
||||
plt.title(f"{ticker} puts volumes for {exp_date} ")
|
||||
plt.legend(["Stock Price", "Open Interest", "Volume"])
|
||||
|
||||
63
terminal.py
63
terminal.py
@@ -196,26 +196,51 @@ def main():
|
||||
b_quit = mill.papermill_menu()
|
||||
|
||||
elif ns_known_args.opt == "ba":
|
||||
b_quit = ba_controller.menu(s_ticker, s_start)
|
||||
b_quit = ba_controller.menu(
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker, s_start
|
||||
)
|
||||
|
||||
elif ns_known_args.opt == "res":
|
||||
b_quit = rm.res_menu(s_ticker, s_start, s_interval)
|
||||
b_quit = rm.res_menu(
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker,
|
||||
s_start,
|
||||
s_interval,
|
||||
)
|
||||
|
||||
elif ns_known_args.opt == "ca":
|
||||
b_quit = ca_controller.menu(df_stock, s_ticker, s_start, s_interval)
|
||||
|
||||
elif ns_known_args.opt == "fa":
|
||||
b_quit = fam.fa_menu(s_ticker, s_start, s_interval)
|
||||
b_quit = fam.fa_menu(
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker,
|
||||
s_start,
|
||||
s_interval,
|
||||
)
|
||||
|
||||
elif ns_known_args.opt == "ta":
|
||||
b_quit = ta_controller.menu(df_stock, s_ticker, s_start, s_interval)
|
||||
b_quit = ta_controller.menu(
|
||||
df_stock,
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker,
|
||||
s_start,
|
||||
s_interval,
|
||||
)
|
||||
|
||||
elif ns_known_args.opt == "dd":
|
||||
b_quit = dd_controller.menu(df_stock, s_ticker, s_start, s_interval)
|
||||
b_quit = dd_controller.menu(
|
||||
df_stock,
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker,
|
||||
s_start,
|
||||
s_interval,
|
||||
)
|
||||
|
||||
elif ns_known_args.opt == "eda":
|
||||
if s_interval == "1440min":
|
||||
b_quit = eda_controller.menu(df_stock, s_ticker, s_start, s_interval)
|
||||
b_quit = eda_controller.menu(
|
||||
df_stock,
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker,
|
||||
s_start,
|
||||
s_interval,
|
||||
)
|
||||
else:
|
||||
df_stock = yf.download(s_ticker, start=s_start, progress=False)
|
||||
df_stock = df_stock.rename(
|
||||
@@ -231,7 +256,12 @@ def main():
|
||||
df_stock.index.name = "date"
|
||||
s_interval = "1440min"
|
||||
|
||||
b_quit = eda_controller.menu(df_stock, s_ticker, s_start, s_interval)
|
||||
b_quit = eda_controller.menu(
|
||||
df_stock,
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker,
|
||||
s_start,
|
||||
s_interval,
|
||||
)
|
||||
|
||||
elif ns_known_args.opt == "op":
|
||||
b_quit = op_controller.menu(
|
||||
@@ -273,7 +303,12 @@ def main():
|
||||
continue
|
||||
|
||||
if s_interval == "1440min":
|
||||
b_quit = pred_controller.menu(df_stock, s_ticker, s_start, s_interval)
|
||||
b_quit = pred_controller.menu(
|
||||
df_stock,
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker,
|
||||
s_start,
|
||||
s_interval,
|
||||
)
|
||||
# If stock data is intradaily, we need to get data again as prediction
|
||||
# techniques work on daily adjusted data. By default we load data from
|
||||
# Alpha Vantage because the historical data loaded gives a larger
|
||||
@@ -291,7 +326,10 @@ def main():
|
||||
df_stock_pred = df_stock_pred.sort_index(ascending=True)
|
||||
df_stock_pred = df_stock_pred[s_start:]
|
||||
b_quit = pred_controller.menu(
|
||||
df_stock_pred, s_ticker, s_start, s_interval="1440min"
|
||||
df_stock_pred,
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker,
|
||||
s_start,
|
||||
s_interval="1440min",
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@@ -299,7 +337,12 @@ def main():
|
||||
return
|
||||
|
||||
elif ns_known_args.opt == "ra":
|
||||
b_quit = ra_controller.menu(df_stock, s_ticker, s_start, s_interval)
|
||||
b_quit = ra_controller.menu(
|
||||
df_stock,
|
||||
s_ticker.split(".")[0] if "." in s_ticker else s_ticker,
|
||||
s_start,
|
||||
s_interval,
|
||||
)
|
||||
|
||||
elif ns_known_args.opt == "scr":
|
||||
b_quit = screener_controller.menu()
|
||||
|
||||
Reference in New Issue
Block a user