Skip to content

Instantly share code, notes, and snippets.

@gperrin01
Last active September 15, 2015 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gperrin01/cf481f9ac266abf91197 to your computer and use it in GitHub Desktop.
Save gperrin01/cf481f9ac266abf91197 to your computer and use it in GitHub Desktop.

#Brokerage App - Requirements

Create your own brokerage and map your associations to respect the following hierarchy:
  • Your brokerage can have many clients
  • A client can have many stocks
  • Many clients can have the same stocks so you need to know everyone's holdings (e.g. Bob owns 15 Google Stocks but Joe owns 23 of them)
Create the usual Rails app for your brokerage - You will be acting as the brokerage manager, not as a client logging on the site
  • The homepage lists all the clients

  • Click on a client to show all their stock, their market value and the client's cash balance

  • A client can buy stocks at market rate; these stocks will be added to the client's holdings and the purchase amount subtracted from the cash balance.

  • Add checks and/or validations so that you cannot go to a negative cash balance

  • Consider creating methods in your models so that the controller can access them

  • A client can sell a stock. The proceeds go into his account and the stock is removed from the client's holdings

  • If you feel like it, add the possibility to create a new stock which is not in your seed data

Use forms helpers so that dropdowns menus show the list of availabled stocks when necessary

##You need to create the following classes:

BROKERAGE
  • name
  • clients (through associations)
CLIENT
  • name
  • cash balance
  • stocks (through associations)
STOCK

Example Seed Data

  • Available stocks: AAPL, GOOG, AMZN, US Bank, TD Bank, BofA, GE, SolarWinds, GreenEnergie

Extra steps

####Add portfolios to your brokerage. You can decide on how to organise the app, here is a suggestion

  • Portfolios are generated at the brokerage level

  • A client can have many portfolios (e.g. US portfolio, Tech portfolio, Financial sector portfolio, Green portfolio, etc)

  • A portfolio is made of one or more stocks

  • A stock can be present in many portfolios (e.g. Google can be present in the Tech portfolio as well as the US portfolio)

  • Many clients can have the same portfolio (e.g. you and I want to have exposure to Tech)

  • The homepage also has a link to list all your portfolios. From the portfolio page you can create a new portfolio for your brokerage, or add stocks to an existing portfolio

  • Depending on how you build it you might have to change your app so that clients do not buy/sell stocks anymore but they buy/sell units of a portfolio.

Use Yahoo Finance Gem API to get live quotes for the stocks

RTFM :) https://github.com/herval/yahoo-finance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment