Giter Site home page Giter Site logo

bcwik9 / robinhood-on-rails Goto Github PK

View Code? Open in Web Editor NEW
146.0 21.0 53.0 341 KB

A web dashboard for the free trading platform Robinhood using Ruby on Rails and a private API

License: MIT License

Ruby 57.76% JavaScript 7.75% CSS 5.59% HTML 28.47% CoffeeScript 0.25% Dockerfile 0.19%
robinhood robinhood-api etf trading stocks trade-stocks dashboard investing stock-market web-dashboard

robinhood-on-rails's Introduction

Robinhood on Rails

Robinhood on Rails is a simple web-based dashboard for the free stock trading phone app Robinhood. Users can buy, sell, and research stocks, all for no charge. You're presented with your autorefreshing portfolio after logging in: (more screenshots here.)

image

DISCLAIMER

I am not affiliated with Robinhood or its associates. I am in no way responsible for any losses incurred through using this code or application. This app relies on the private API as found here (special thanks to sanko for providing documentation). It isn't recommended to use this since the API is private and can change unexpectedly at any time, and is not officially supported. Using any kind of unpublished API for investing is risky, and you should thoroughly review any code involving any kind of money or investment published on the web to ensure the creator isn't doing something malicious. It's your money, after all. Your safest bet is to use the sanctioned phone app. Having said that, creating this app has been a lot of fun and I use it a lot more than I use the phone app.

Updates and features

Latest updates

6/30/2020

  • Made it easier to log in with 2FA enabled
  • Fixed login bug with challenge authentication

4/27/2020

  • Fixed another login bug

5/31/2019

  • Added support for new challenge login authentication

4/3/2019

  • Fixed login bug

2/2/2019

  • Started cryptocurrency watchlist support
  • Added rough API explorer portal
  • Updated token to Oauth2

10/23/2017

  • Bug fix for correcting the buying power for instant accounts

7/20/2017

  • Bug fix for displaying correct numbers in the "Return" column when the return is > $1000

5/23/2017

  • Added support for splits

5/18/2017

  • Added additional order support
    • Market order
    • Limit order
    • Stop loss order
    • Stop limit order
  • Added details to order history page
  • Various refactor improvements and bugfixes

5/5/2017

5/3/2017

  • Added historical (week, year, all) porfolio price charts

Current features

  • Realtime, auto-refreshing portfolio dashboard
    • Custom "folder" labels (stock organizing dividers)
  • Watchlist
    • Add and remove stocks
    • Custom "folders" labels (stock organizing dividers)
  • Reorganizing/ordering stocks via drag 'n drop automatically syncs with Robinhood phone app
  • Price charts for stocks and portfolio history
  • Fundamentals tooltips
  • Stocktwits integration
  • Orders
    • Supports market, limit, stop loss, and stop limit orders for buying and selling
    • Cancel pending orders
  • Transfers
    • Basic deposit and withdraw from existing ACH accounts
    • View history
  • Dividends
  • Notifications
    • View and dismiss
  • Cryptocurrency
    • Search and view prices for cryptocurrencies
    • Watchlist management
  • Security
    • 2FA support
    • Challenge authentication support

Future features

  • Estimates
  • Settings
  • Custom stock alerts
  • Future dividends
  • Volume charts
  • Improving performance of Orders page
  • Automated, complex trading rules

Usage

You have the choice of a basic installation or Docker (see instructions below).

Basic installation

This is a basic Rails project. You can install Ruby on Rails (and RVM) by visiting the RVM install page. If you already have ruby on rails set up, simply clone this project. Then run the basic steps to run the project like you would any other rails project:

  • rvm install 2.3.5
  • rvm use 2.3.5
  • bundle update
  • bundle install
  • bundle exec rake db:create db:migrate
  • bundle exec rails server
  • navigate to http://localhost:3000/ in whatever webrowser you use (I use chrome, for instance), and you should see a login screen: image
  • Enter your log in info, and you'll be presented with your Robinhood dashboard.

Install with Docker

This repository comes with a Dockerfile to easily set up a server with minimal configuration. To build the image, run:

$ git clone https://github.com/bcwik9/robinhood-on-rails.git
$ cd robinhood-on-rails
$ docker build --tag robinhood-on-rails .

Then you can run the server:

$ docker run -dt -p 3000:3000 robinhood-on-rails

This will run the server on your host-machine's port 3000.

Who am I

I am not affiliated with Robinhood or any of its associates. This is just a project I find fun. More info at bencwik.com

Influences and references

Thanks to Jeffrey Smith for his designs which I based a lot of the front end work off of. Thanks to sanko for their work documenting Robinhood's API. Last but not least thanks to Robinhood for their app!

robinhood-on-rails's People

Contributors

bcwik9 avatar bdowling avatar cdtweb avatar j6k4m8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robinhood-on-rails's Issues

Run in a Docker container

I'll claim implementing this one unless someone else feels strongly about it :)

Wanted to post first in case there's a reason you see why not to do this.

Portfolio Empty

Tried recreating the container multiple time but my portfolio remains empty. It seems the whole section is failing to load. Is there a timeout happening or something?

Screen Shot 2020-10-07 at 4 57 00 PM

login doesn't work

Tried to use the docker approach on MAC OS but the login form is not working.

Two-factor authentication

Just ran into this. If I have two-factor authentication enabled, it will not log you in unless you disable that option in robinhood.(not sure if I put this in the right spot, I don't generally use github, app looks awesome btw!)

Robinhood changed Login API endpoint

The Login URL has been changed and the auth token process have been changed as it now uses Oauth2 and Bearer. Any chance the code will reflect these changes soon?. I am trying from my end, but it seems I need to change more than few places. Thanks

Implementing the historical Options orders endpoint.

Any chance we can get this implemented.
def get_option_orders
@option_orders = get_all_results robinhood_get("#{ROBINHOOD_API_URL}/options/orders/")
end

I have never coded in ruby so it's causing some headache but logically it seems very straight forward if you know the language constructs.

Thanks for all the hard work.

What is Rails doing?

Does this application rely on Rails-specific server-side functionality or API calls? I wonder if there's a way to strip all server-side functionality from this and run it as a simple HTML page.

Bundle

I had to run bundle update before bundle install. It may be worth adding that in the instructions.

I also had to update ruby but I think people may have an up-to-date version.

Missing device token

Hi @bcwik9. Thank you for making this! I can't wait to use it.

I just installed this manually on my Mac OSX 10.13.6 (High Sierra) after getting all the ruby issues resolved (rvm, ruby, gem, bundler versions)

After running the local server on port 3000, I attempt to login with my credentials and I get this "Missing device token" error. I get this error both with and without Two Factor Authentication on my account.

image

System details:

$rvm list
=* ruby-2.7.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

$ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin17]

$gem --version
3.1.2

$bundle -v
Bundler version 2.1.4

Traceback:

$bundle exec rails server
=> Booting Puma
=> Rails 5.0.7.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
Please register a mime type using `register_mime_type` then
use `register_compressor` or `register_transformer`.
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
 (called from block in <class:Railtie> at /Users/frak/.rvm/gems/ruby-2.7.1/gems/less-rails-2.8.0/lib/less/rails/railtie.rb:16)
DEPRECATION WARNING: You are using a deprecated processor interface Less::Rails::ImportProcessor.
Please update your processor interface:
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
 (called from block in <class:Railtie> at /Users/frak/.rvm/gems/ruby-2.7.1/gems/less-rails-2.8.0/lib/less/rails/railtie.rb:21)
/Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/stack.rb:35: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/static.rb:113: warning: The called method `initialize' is defined here
Puma starting in single mode...
* Version 3.12.4 (ruby 2.7.1-p83), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/" for ::1 at 2020-04-25 11:47:17 -0400
/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: warning: rb_check_safe_obj will be removed in Ruby 3.0
/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:81: warning: deprecated Object#=~ is called on Integer; it always returns nil
  ActiveRecord::SchemaMigration Load (0.1ms)  SELECT "schema_migrations".* FROM "schema_migrations"
DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <class:ApplicationController> at /Users/frak/git/robinhood/robinhood-on-rails/app/controllers/application_controller.rb:5)
Processing by DashboardController#home as HTML
/Users/frak/.rvm/gems/ruby-2.7.1/gems/actionview-5.0.7.2/lib/action_view/view_paths.rb:11: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/frak/.rvm/gems/ruby-2.7.1/gems/actionview-5.0.7.2/lib/action_view/lookup_context.rb:134: warning: The called method `template_exists?' is defined here
  Rendering dashboard/home.html.haml within layouts/application
/Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/abstract_controller/helpers.rb:68: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_controller/metal/request_forgery_protection.rb:284: warning: The called method `form_authenticity_token' is defined here
  Rendered layouts/_robinhood_login_form.html.haml (3.2ms)
  Rendered dashboard/home.html.haml within layouts/application (54.7ms)
  Rendered application/_favicon.html.erb (1296.5ms)
  Rendered layouts/_flash_message.html.haml (2.5ms)
  Rendered layouts/_side_menu.html.haml (3.7ms)
Completed 200 OK in 1506ms (Views: 1498.8ms | ActiveRecord: 0.0ms)


/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: warning: rb_check_safe_obj will be removed in Ruby 3.0
/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:81: warning: deprecated Object#=~ is called on Integer; it always returns nil
/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: warning: rb_check_safe_obj will be removed in Ruby 3.0
/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:81: warning: deprecated Object#=~ is called on Integer; it always returns nil
/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: warning: rb_check_safe_obj will be removed in Ruby 3.0
/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:81: warning: deprecated Object#=~ is called on Integer; it always returns nil
/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: warning: rb_check_safe_obj will be removed in Ruby 3.0
/Users/frak/.rvm/gems/ruby-2.7.1/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:81: warning: deprecated Object#=~ is called on Integer; it always returns nil
Started POST "/robinhood_login" for ::1 at 2020-04-25 11:47:29 -0400
Processing by RobinhoodController#login as HTML
  Parameters: {"utf8"=>"โœ“", "authenticity_token"=>"xxxx", "username"=>"xxxx", "password"=>"[FILTERED]", "commit"=>"Log in"}
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6503  100  6503    0     0   2360      0  0:00:02  0:00:02 --:--:--  2359
Completed 500 Internal Server Error in 5381ms (ActiveRecord: 0.0ms)



RuntimeError (Missing device token):

app/models/concerns/robinhood.rb:48:in `set_account_token'
app/controllers/robinhood_controller.rb:12:in `login'
  Rendering /Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
  Rendering /Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
  Rendered /Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (2.3ms)
  Rendering /Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
  Rendered /Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.1ms)
  Rendering /Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
  Rendered /Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.1ms)
  Rendered /Users/frak/.rvm/gems/ruby-2.7.1/gems/actionpack-5.0.7.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (23.9ms)
/Users/frak/git/robinhood/robinhood-on-rails/app/models/concerns/robinhood.rb:48: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
/Users/frak/.rvm/gems/ruby-2.7.1/gems/web-console-3.7.0/lib/web_console/exception_mapper.rb:31: warning: in `eval'
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2020-04-25 11:52:41 -0400 ===
- Goodbye!
Exiting

I'd love to finally get this working. Please let me know if you need any more information.
Thank you!

How does this work?

Hi! I just found this project and it looks awesome!

Are there any instructions for running it?

UI becomes unresponsive after a period of time

Description

After having the dashboard sit a while, things start to become unresponsive (tabbing between portfolio/watchlist, or opening up an order modal and changing the order type, etc).
I believe this has to do with a faulty JS setup between the dashboard and watchlist, where things are being called and loaded multiple times when they're actually already loaded.
Reloading the page fixes the issue (until it sits there long enough again)

auto-update Docker instance after source edits

Hello, great work! I too prefer to deploy via Docker.

One minor pet peeve was having to stop, rebuild and run the Docker image after any change in code (or git pull).

Here is my new way to launching, after the initial docker build:


$ cd ~/www/robinhood-on-rails 
$  docker run --name=RobinhoodOnRails  -v $HOME/www/robinhood-on-rails:$HOME/robinhood-on-rails  -dt -p 3222:3000 robinhood-on-rails 

Wherein:

  • --name since I don't expect to run multiple instances on the same server. This prevents Docker from assigning random aliases, and simplifies instance management.

  • -p 3222 externalizes to a port other than 3000, which on my server was already taken.

  • -v The main point of this issue. Binds a dir from host to guest, and since Rails is already launched in dev mode, reloads new code on the fly.

I am unsure how to best adapt into the Dockerfile, etc.

Buying power remains $0.00

Buying power seems to constantly read $0.00 regardless of cash available or deposits. This happens with an account with no Robinhood gold.

image

Is it just me?

I get this weird error, used to work fine. I don't get portfolio list at all, tried resetting the DB, pulled latest branch, etc. using mac os x with homebrew to run. Love the software!

Completed 500 Internal Server Error in 588ms (ActiveRecord: 16.7ms)

NoMethodError (undefined method `[]' for nil:NilClass):

app/controllers/robinhood_controller.rb:314:in block in watchlist' app/controllers/robinhood_controller.rb:313:in each'
app/controllers/robinhood_controller.rb:313:in `watchlist'

Question: Auto-refresh rate?

I'm also making a Robinhood client (for Windows 10), and ran into an api call limit while testing. What refresh rate do you use when auto refreshing? I want to avoid the call limit so the user doesn't run into any issues with normal use.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.