Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
a98ceb2
initial set up for react firebase and reactfire
bleetdh Aug 29, 2017
617ec6b
re set up react, firebase and reactfire
bleetdh Aug 29, 2017
1256289
using template for react router firebase
bleetdh Aug 30, 2017
1176031
removed node module
bleetdh Aug 30, 2017
6e4f3e4
tried adding rsi data but failed
bleetdh Aug 31, 2017
052d074
working livestock page
shaunl89 Aug 31, 2017
034c139
Merge pull request #1 from shaunloh89/master
bleetdh Sep 1, 2017
c5aec83
managed to generate sample graph with recharts
shaunl89 Sep 2, 2017
d29d7a7
before merging shaun renamed files
bleetdh Sep 3, 2017
451d549
minor updates to Graph and Livestock
shaunl89 Sep 3, 2017
aab3b09
merge conflict resolved
bleetdh Sep 3, 2017
bf55fbf
Merge pull request #2 from shaunloh89/master
bleetdh Sep 3, 2017
e815b15
api for stock price can be called
bleetdh Sep 3, 2017
06bdde4
managed to configure price output for 9 options
bleetdh Sep 3, 2017
65f98ac
added one more option
bleetdh Sep 3, 2017
a6bcb6e
graph working but need change x axis
bleetdh Sep 4, 2017
afe0b65
minor changes before merging upstream
shaunl89 Sep 4, 2017
52845e9
Merge Upstream Merge remote-tracking branch 'upstream/master'
shaunl89 Sep 4, 2017
44363a2
refined search results
bleetdh Sep 4, 2017
f7e4fd6
adjust code for handleChange
bleetdh Sep 4, 2017
48949c7
trying to render the RSI graph, gotta fix the render picking up an ob…
shaunl89 Sep 4, 2017
fbbbac0
working RSI graph but with x-axis index 0-9
shaunl89 Sep 5, 2017
b6fca05
removed priceArr
bleetdh Sep 5, 2017
55b485f
Merge branch 'master' into master
bleetdh Sep 5, 2017
3241888
Merge pull request #4 from shaunloh89/master
bleetdh Sep 5, 2017
5a88e16
able to show dates on RSI x-axis
shaunl89 Sep 5, 2017
65a0d4c
Merge remote-tracking branch 'upstream/master'
shaunl89 Sep 5, 2017
2093de5
separated PriceGraph js
bleetdh Sep 5, 2017
d44ab96
merged with jerad
bleetdh Sep 5, 2017
e074b9a
cleand up some stuff
bleetdh Sep 5, 2017
9e95632
cleaned up
bleetdh Sep 5, 2017
f82facb
RSI dates in order, attempting to do the time period dropdown
shaunl89 Sep 5, 2017
1041818
merged with upstream
shaunl89 Sep 5, 2017
1783389
Merge pull request #5 from shaunloh89/master
bleetdh Sep 5, 2017
57e04cf
RSI graph works with the dropdown list
shaunl89 Sep 5, 2017
27ed877
minor update for RSI graph
shaunl89 Sep 5, 2017
c6f3753
changed RSI to Relative Strength Index
shaunl89 Sep 5, 2017
b2d50f0
trying deployment
bleetdh Sep 6, 2017
e59a0c0
Merge remote-tracking branch 'upstream/master'
shaunl89 Sep 6, 2017
317fc34
regression failed
bleetdh Sep 6, 2017
cbeea42
Merge pull request #7 from shaunloh89/master
bleetdh Sep 6, 2017
713a423
tidied up some stuff
bleetdh Sep 6, 2017
521d596
Merge remote-tracking branch 'upstream/master'
shaunl89 Sep 6, 2017
73ec2e7
cleaned up code, removed rsiArr and timeArr states
shaunl89 Sep 6, 2017
1edb194
added regression
bleetdh Sep 6, 2017
c8a91ca
Merge with 'upstream/master' that is able to deploy on Firebase with …
shaunl89 Sep 6, 2017
8cc1799
added ADX prediction
bleetdh Sep 6, 2017
fc126c4
Merge remote-tracking branch 'upstream/master'
shaunl89 Sep 6, 2017
c949d78
still cannot change data for symbol change
bleetdh Sep 7, 2017
8926a6c
updated readme and added readme_images/
shaunl89 Sep 7, 2017
b13999d
minor changes to readme
shaunl89 Sep 7, 2017
97b9a46
added more prediction
bleetdh Sep 7, 2017
30115ce
homepage about done
bleetdh Sep 7, 2017
cdd0f1a
did some housekeeping
bleetdh Sep 7, 2017
59464d3
edited gif
bleetdh Sep 7, 2017
55ecc58
readme updated
shaunl89 Sep 7, 2017
a8f4f56
fix conflicts after upstream merge
shaunl89 Sep 7, 2017
62f2e2e
Merge pull request #8 from shaunloh89/master
bleetdh Sep 7, 2017
bd7314c
merged conflict resolved
bleetdh Sep 7, 2017
c04848c
edited size of graph
bleetdh Sep 7, 2017
7e663a0
update readme
shaunl89 Sep 7, 2017
7be0c45
Merge branch 'master' into master
bleetdh Sep 7, 2017
7df13ae
Merge pull request #9 from shaunloh89/master
bleetdh Sep 7, 2017
f6d8fbf
edited some css
bleetdh Sep 7, 2017
d47836b
Merge branch 'master' of https://github.com/bleetdh/project-4
bleetdh Sep 7, 2017
a435157
updated readme included regression analysis
shaunl89 Sep 7, 2017
01e55c6
Merge remote-tracking branch 'upstream/master'
shaunl89 Sep 7, 2017
87a7c8f
minor updates
shaunl89 Sep 7, 2017
8658582
minor change to readme
shaunl89 Sep 7, 2017
c96951d
Merge pull request #10 from shaunloh89/master
bleetdh Sep 7, 2017
4f153d8
changes to regression analysis readme part
shaunl89 Sep 7, 2017
a79ef00
Merge pull request #11 from shaunloh89/master
bleetdh Sep 7, 2017
eb5ec6e
removed reverse for data
bleetdh Sep 8, 2017
c457558
Merge branch 'master' of https://github.com/bleetdh/project-4
bleetdh Sep 8, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "graviton-eabd7"
}
}
9 changes: 0 additions & 9 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# dependencies
node_modules

# testing
coverage

# production
build

# misc
.DS_Store
.env
npm-debug.log
156 changes: 127 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,163 @@
# Your Project Name
# Graviton

This is the starter code for WDI projects. Please update this README file with information specific to your project. Replace this paragraph for instance, with a short description of your project. Then update the sections below. Refer to your project specificaion for instructions on how to submit your projects.
_**Revolutionizing Stock Analysis**_

## Getting Started
> **_Graviton_** _is an app that provides realtime stock information and charting of historical data, with a technical predictive algorithm._

Provide instructions here about how to get your project running on our local machine. Do we just need to clone and open a certain file or do we need to install anything first.
## Live Version

### Prerequisites
Click for an app demo:
[https://graviton-eabd7.firebaseapp.com](https://graviton-eabd7.firebaseapp.com)

What is needed to install and run the project, how do we install them
## Objectives
- To provide users with a simple interface displaying real time, historical stock trends based on desired time intervals

```
Code example
```
- Enable users to know the confidence level of the current market based on a regression analysis performed on the stock's Relative Strength Index (RSI) and Average Directional Index (ADX)


## Getting Started

This project is built with [**ReactJS**](https://facebook.github.io/react/) for its front end user interfacing and [**Firebase**](https://firebase.google.com/).

### How to Use

A step by step guide on how to install and use the project, for example if this is a game, how do we play it.
Fork and clone this repository into your own directory. Install the dependencies used in this project by entering the following code in your terminal (with a prerequisite of [**Homebrew**](https://brew.sh/)):

``brew install yarn``

``yarn install``

### Deployment

#### Hosting
This project was deployed with [Firebase](https://firebase.google.com/) follow the documentation for your deployment.

## Built With

* JavaScript
* ReactJS
* Firebase
* [**react-router-firebase-auth**](https://github.com/tylermcginnis/react-router-firebase-auth)

## APIs Used
* Alpha Vantage (https://www.alphavantage.co/#page-top)
* Recharts (http://recharts.org/)

## Application Overview
![](/readme_images/graviton_frontpage.png)
![](/readme_images/livestocks_page.png)

##### Process Flow
![](/readme_images/process_flow.png)

##### Initial Wireframes

![](/readme_images/initial_visualization.png)

![](/readme_images/stocks_wireframe.png)

## React Components
Primarily built on ReactJS, the Live Stocks page of this app is based off the following React components:

![](/readme_images/react_components.png)

The main components were RSI (in blue, also the landing page), stock price (green) and ADX (in red), with RSI being the parent of both stock price and ADX.

## Regression Analysis
Linear regression aims to fit a linear equation of the form **Y = a + bX** to the observed data (think a line of best fit). In which for this project, X will be the historical RSI, also known as the explanatory variable while Y is the predicted RSI, the dependent variable.

**_a_**, the intersect and **_b_**, the slope can then be determined as shown in the formula below, based on historical records of the RSI and stock price.

![](/readme_images/regression_line.png)

Running regression analysis on the historical Relative Stock Index and Average Directional Index of the stock, we were able to estimate an expected price of the stock, thereby predicting the trajectory of the price (will the price increase or decrease in the forseeable future)

We decided to increase the analytical tools by providing a price adjusted RSI that adjusts the overbought and oversold levels. The is a technical momentum indicator used to indicated overbought or oversold conditions in the market, that compares the magnitude of recent gains and losses over a specified time period. (_http://www.investopedia.com/terms/r/rsi.asp_).

However we find this lacking in accuracy during periods of uptrend and downtrend.

![](/readme_images/RSI.png)

We calculated the new overbought and oversold levels by using geometric average to determine the deviation, which provided us with a more price sensitive benchmark.

## Recharts

To utilize the Recharts API, we had to import it into each component that has to render a graph as follows.

```
Code example
import { LineChart, Line, XAxis, YAxis, Tooltip, CartesianGrid, Legend, ReferenceLine } from 'recharts'
```

More steps...
Followed by the JSX below that is called in the rendered return of the component, that can be easily customized.

```
until finished
<LineChart width={700} height={200} data={rsiData}
margin={{ top: 5, right: 0, left: 20, bottom: 5 }}>
<XAxis hide='true' dataKey='date' padding={{ right: 20 }} />
<YAxis type='number' domain={[25, 75]} padding={{ top: 0, bottom: 0 }} />
<CartesianGrid strokeDasharray='3 3' />
<Tooltip />
<ReferenceLine y={70} label='Max' stroke='red' />
<ReferenceLine y={30} label='Min' stroke='red' />

<Legend />
<Line type='monotone' dataKey='RSI' stroke='#82ca9d' strokeWidth={2} dot={false} />
</LineChart>
```

## Issues Faced

## Tests
##### Infinite Geometric Mean
In the calculation of the Geometric Average, the formula used was as such,

Did you write automated tests? If so, how do we run them.
_Geometric Average = (RSI1 x RSI2 x RSI3 .... RSI(n))^(1/n)_

However, in code, an error would occur because the multiplication of a large amount of RSI data led to the value to become infinity.

```
Code example
```
A fix was to manipulate the mathematical formula into

## Live Version
_Geometric Average = (RSI1^(1/n) x RSI2^(1/n) x RSI3^(1/n) .... RSI(n)^(1/n))_

Where is this deployed online (github pages, heroku etc), give us the link and any access details we need.
Code used:
``parseFloat(Math.pow(x, (1/xRSI.length))).toFixed(2)``

## Built With
##### Deployment
On the first deployment to Firebase, an NPM regression package used encountered an error with create-react-app, being that

What did you use to build it, list the technologies, plugins, gems, packages etc.
```npm run build``` fails to minify

* [jQuery](http://jquery.com/) - jQuery for example is something you likely used
More information regarding the error can be found in the link below. Due to constraints of time, the NPM package had to be abandoned and the regression analysis hand coded on our own.

## Workflow
_https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md_

Did you write user stories, draw wireframes, use task tracking, produce ERDs? Did you use source control, with regular commits? Include links to them here.
##### 404 Error When Refreshing a Deployed Page
![](/readme_images/404error.png)

## Authors
A 404/Not Found html file was in the root directory to handle cases when a user tries to access a page that does not exist or to prevent broken links in other cases. However, it was found on deployment, that whenever the user refreshed the current page, there will always be a redirect to this 404 html file.

A fix was to include a URL rewrite in the ``firebase.json`` file as follows:

Did you collaborate with others on this project, list them here
```
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
```

## Further Development
* Incorporate more stocks
* Have multiple regression lines inside the graph
* Include more technical indicators


## Authors

* **John McClain** - *Responsible for keeping vests white* - [GithubUserName](https://github.com/GithubUserName)
* **[Brian Lee](https://github.com/bleetdh)**
* **[Jerald Chua](https://github.com/karl-x)**
* **[Shaun Loh](https://github.com/shaunloh89)**

## Acknowledgments

* Hat tip to anyone who's code was used, for example [this was a useful starting point for creating this template](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2).
Tyler McGinnis' [react-router-firebase-auth](https://github.com/tylermcginnis/react-router-firebase-auth)

Our GA instructor Prima Aulia Gusta and teaching assistant Shimei Wong
6 changes: 6 additions & 0 deletions database.rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
19 changes: 19 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Loading