Merge pull request #365 from DidierRLopes/some-fixes

improvements and bugfixes
This commit is contained in:
DidierRLopes
2021-04-19 09:16:11 +01:00
committed by GitHub
9 changed files with 139 additions and 45 deletions

View File

@@ -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)

View File

@@ -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)
 

View File

@@ -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.
![ftd](https://user-images.githubusercontent.com/25267873/115201750-93a9bc80-a0ed-11eb-8f13-68508749259e.png)
<img width="927" alt="ftd" src="TODO">

View File

@@ -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")

View File

@@ -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.
![voinio](https://user-images.githubusercontent.com/25267873/115161878-f7a19600-a097-11eb-889b-e9cc945f174d.png)
## 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.
![vcalls](https://user-images.githubusercontent.com/25267873/115161874-f5d7d280-a097-11eb-93e2-3a2b20292f09.png)
## 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.
![vputs](https://user-images.githubusercontent.com/25267873/115161873-f40e0f00-a097-11eb-8334-3d4f14b56766.png)
* -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:
![im](https://user-images.githubusercontent.com/18151143/115068041-b191da00-9ebf-11eb-941e-4e255787ab94.png)
<img width="948" alt="chains" src="https://user-images.githubusercontent.com/25267873/115161876-f708ff80-a097-11eb-8073-195979862a45.png">

View File

@@ -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)

View File

@@ -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",

View File

@@ -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"])

View File

@@ -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()