Robinhood node
Trade stocks for free with simple to use library.
Install
yarn add robinhood-node
Use
const RH = require('robinhood-node');
const rh = new RH({ user: 'RH user', password: 'RH password' });
const account = new rh.Account();
console.log(await account.user);;
const stock = new rh.Stock('AMZN');
console.log(await stock.quote);
const orderResponse = await stock.marketOrder('buy', 1);
const order = new rh.Order(orderResponse.id);
console.log(order.status());
order.cancel();
Interface
Each class can be initiated from a robinhood-node instance.
RobinhoodNode
This is the main class to use. You can use it in anonymous mode. Some actions like selling/buying will require to login as a Robinhood user. There are 2 ways to login into the library:
user & password (&mfa key):
new RH({ user: 'your RH email', password: 'your RH password', mfa: 12345 });
mfa
is optional and required only if your settings on Robinhood require it. In order to get the mfa try to leave it empty and then you should get the code on your first attempt.
token:
new RH({ token: 'your RH token' });
Once you login with username&password youu should get a token in reponse. this token can be used to access RH API from now on.
Stock
constructor(symbols)
- symbols of stocks seperated by comma.
quote
- get latest quote for symbol(s).
marketOrder(orderType, quantity, extraParams = {})
- orderType - buy
or sell
.
limitOrder(orderType, quantity, price, extraParams = {})
orderType - buy
or sell
.
Order
constructor(id)
- optional order id.
status(id)
- get order status. order id is optional (can be set up when initiated).
cancel(id)
- cancel an order. order id is optional (can be set up when initiated).
recent
- get recent orders.
static place(params)
- manually place an order. a better use will be to interact with Stock class in order to place an order.
Account
constructor()
positions
accounts
user
basicInfo
investment