Skip to content

Commit

Permalink
Add version badge, swap to simple credentialing to notebook, and update
Browse files Browse the repository at this point in the history
README.
  • Loading branch information
adithyabsk committed Jun 22, 2020
1 parent 522d683 commit 028ba22
Show file tree
Hide file tree
Showing 6 changed files with 648 additions and 236 deletions.
2 changes: 2 additions & 0 deletions .env.sample
@@ -0,0 +1,2 @@
RH_USERNAME=CHANGE_ME
RH_PASSWORD=CHANGE_ME
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -70,3 +70,4 @@ target/
.python-version
.DS_Store
*.mypy_cache/*
*.env
80 changes: 20 additions & 60 deletions README.rst
Expand Up @@ -11,6 +11,10 @@ pyrh - Unofficial Robinhood API
:target: https://github.com/robinhood-unofficial/pyrh/actions?query=workflow%3Abuild+branch%3Amaster
:alt: build

.. image:: https://img.shields.io/pypi/v/pyrh?style=plastic
:target: https://pypi.org/project/pyrh/
:alt: pypi version

.. image:: https://img.shields.io/pypi/dm/pyrh?color=blue&style=plastic
:target: https://pypi.org/project/pyrh/
:alt: PyPI - Downloads
Expand All @@ -32,7 +36,7 @@ Python Framework to make trades with Unofficial Robinhood API. Supports Python 3
*Please note that parts of this project maybe non-functional / under rapid development*
#######################################################################################

* A stable release is iminent
* A stable release is imminent

Quickstart
**********
Expand All @@ -52,70 +56,26 @@ How To Install:
pip install pyrh
Current Features
****************

* Placing buy orders (\ ``Robinhood.place_buy_order``\ )
* Placing sell order (\ ``Robinhood.place_sell_order``\ )
* Fetch and cancel orders (\ ``Robinhood.order_history`` and ``Robinhood.cancel_order``\ )
* Quote information (\ ``Robinhood.quote_data``\ )
* User portfolio data (\ ``Robinhood.portfolio``\ )
* User positions data (\ ``Robinhood.positions``\ )
* More coming soon

Running example.ipynb_
**********************

.. _example.ipynb: https://github.com/robinhood-unofficial/pyrh/blob/master/notebooks/example.ipynb

* Install jupyter
.. code-block::
$ python --version # python 3.3+ for venv functionality
Python 3.7.6
$ python -m venv pyrh_env
$ source pyrh_env/bin/activate
(pyrh_env) $ pip install pyrh
(pyrh_env) $ pip install jupyter
(pyrh_env) $ jupyter notebook
Then navigate to the example file linked above and run it.

Data returned
*************
* Quote data

* Ask Price
* Ask Size
* Bid Price
* Bid Size
* Last trade price
* Previous close
* Previous close date
* Adjusted previous close
* Trading halted
* Updated at
* Historical Price

* User portfolio data

* Adjusted equity previous close
* Equity
* Equity previous close
* Excess margin
* Extended hours equity
* Extended hours market value
* Last core equity
* Last core market value
* Market value
* Order history
* Dividend history

* User positions data

* Securities owned

* News
Clone the repository and install jupyter capabilities.

.. code-block::
$ git clone https://github.com/robinhood-unofficial/pyrh.git
$ cd pyrh
$ python --version # python 3.3+ for venv functionality
Python 3.7.6
$ python -m venv pyrh_env
$ source pyrh_env/bin/activate
(pyrh_env) $ pip install .[notebook]
(pyrh_env) $ cp .env.sample .env # update the values in here
(pyrh_env) $ jupyter notebook notebooks/example.ipynb
Now just run the files in the example.

Related
*******
Expand Down
54 changes: 12 additions & 42 deletions notebooks/example.ipynb
Expand Up @@ -8,7 +8,7 @@
}
},
"source": [
"# Robinhood API Useage Examples"
"# Robinhood API Usage Examples"
]
},
{
Expand All @@ -24,8 +24,14 @@
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"from pyrh import Robinhood, dump_session, load_session\n",
"from pyrh.exceptions import InvalidCacheFile"
"from pyrh import Robinhood\n",
"from dotenv import load_dotenv\n",
"load_dotenv()\n",
"import os\n",
"# Simple credential specifications - a better method is mentioned\n",
"# in the docs.\n",
"USERNAME = os.getenv(\"RH_USERNAME\")\n",
"PASSWORD = os.getenv(\"RH_PASSWORD\")"
]
},
{
Expand All @@ -39,12 +45,8 @@
"outputs": [],
"source": [
"# Log in to app (will prompt for two-factor)\n",
"try:\n",
" rh = load_session()\n",
"except InvalidCacheFile:\n",
" rh = Robinhood(username=\"USERNAME\", password=\"PASSWORD\")\n",
" rh.login()\n",
" dump_session(rh) # so you don't have to do mfa again\n"
"rh = Robinhood(username=USERNAME, password=PASSWORD)\n",
"rh.login()"
]
},
{
Expand All @@ -56,22 +58,6 @@
}
},
"outputs": [],
"source": [
"# Get information about a stock\n",
"instrument = rh.instruments(\"GEVO\")[0]\n",
"instrument"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"is_executing": false,
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# Print stock prices\n",
"rh.print_quote(\"AAPL\")\n",
Expand Down Expand Up @@ -106,23 +92,7 @@
"source": [
"# Get quote information\n",
"quote_info = rh.quote_data(\"GEVO\")\n",
"quote_info"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"is_executing": false,
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# Buy and sell (don't worry it's a cheap stock)\n",
"buy_order = rh.place_buy_order(instrument, 1)\n",
"sell_order = rh.place_sell_order(instrument, 1)\n"
"quote_info\n"
]
}
],
Expand Down

0 comments on commit 028ba22

Please sign in to comment.