timharding31 / stock-fox

StockFox is a clone of the popular stock-trading application, Robinhood
2 stars 1 forks source link

StockFox

StockFox is my version of the popular securities trading site, Robinhood. It was built initially in a two-week period in August, 2020, though I'll be making improvements steadily to the site's functionality & features. StockFox uses a Ruby on Rails backend with a Redux state-managed React frontend. Users can sign up to research the U.S. stock market, keep tabs on interesting stocks via their "watchlist", and execute trades with $10,000 of initial buying power. Stock information is available via searching, or by exploring top categories from the users' homepage.

Here's a link to the site if you'd like to explore for yourself: StockFox

Features

Asset Detail Page

A stock's detail page contains a large chart of its historical prices for a user-selected range, a company profile with details about the company's products/services, and a news feed to research the latest market sentiment about the stock.

Light Mode

Dark Mode

Fetching stock data

Prices for the requested stock symbol & range are stored in StockFox's redux state and are retrieved from the financialmodelingprep API. One-day historical prices are fetched immediately upon sign-in for any stocks in the user's watchlist or portfolio, and additional stock symbols and/or ranges are fetched upon user access of the stock's profile page. Historical price fetches always update the application's PostgreSQL with each requested stock's latest price, so price information displayed before future API calls remain up-to-date.

Each stock's company profile is also requested via API, which is displayed below the stock's price chart and updates the Postgres database with further details about the stock (name, sector, industry, etc.). News articles pertaining to a stock are fetched from the Bing News API (query by symbol and by company name). The latest four most popular articles are displayed to the user, though more can be requested by hitting the "Show More" button.

Updating the chart

By default, a stock show page shows a chart of its one-day prices, rendered with Recharts' ResponsiveContainer & LineChart. Users can select broader ranges by hitting the buttons below the chart. The selection passes down a range to the chart component, which keys into the prices slice of the Redux state to render the appropriate data. Mousing over the chart updates the price displayed based on the timeframe, which is visible in the tooltip above the chart selection area. Any chart rendering price data that's increased in the given range is displayed in green, while losses are displayed in red.

Sidebar Modules

The sidebar displays a permanent reference to the user's portfolio and watchlist, with miniature charts (rendered with react-sparklines) showing each stock's one-day price movement. Clicking a row from either module redirects the user to that stock's detail page, where the user can purchase more of that asset, sell off their holdings, or add/remove the stock from their watchlist.

Sidebar Light

Sidebar Dark

When a user signs in, their watchlist and portfolio are fetched from the PostgreSQL database, which also triggers an API call to grab one-day prices for each stock symbol in either list. This enables the rendering of sparkline components in the sidebar, and also ensures that price & company profile data are available immediately if the user chooses to visit a stock's page from the sidebar link.

An order form and add/remove from watchlist control are presented above the sidebar charts when visiting a stock's page, but the sidebar charts are always available from every page on StockFox to ensure immediate access to the assets users care about most.

Technologies Leveraged