Created
May 23, 2020 10:13
-
-
Save dkp1903/90f37d8a4f3f400c60212dfb642370f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select (change)="selectChangeHandler | |
($event)"> | |
<option selected="selected" value="IBM">IBM</option> | |
<option value="WMT">Walmart</option> | |
<option value="BABA">Alibaba</option> | |
<option value="SNAP">Snap Inc</option> | |
<option value="AAPL">Apple</option> | |
<option value="NFLX">Netflix</option> | |
<option value="TWTR">Twitter</option> | |
<option value="AMZN">Amazon</option> | |
<option value="SPOT">Spotify</option> | |
<option value="FB">Facebook</option> | |
<option value="TSLA">Tesla Inc</option> | |
<option value="DAL">Delta Airlines</option> | |
<option value="MSFT">Microsoft</option> | |
<option value="MA">Mastercard</option> | |
<option value="GOOGL">Alphabet(Google)</option> | |
</select> | |
<google-chart #chart | |
[title]="title" | |
[type]="type" | |
[data]= "data" | |
[columns] = "columns" | |
[options]="options" | |
[width]="width" | |
[height]="height"> | |
</google-chart> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { LiveMarketDataService } from '../../services/live-market-data.service'; | |
@Component({ | |
selector: 'app-candlestick', | |
templateUrl: './candlestick.component.html', | |
styleUrls: ['./candlestick.component.css'] | |
}) | |
export class CandlestickComponent implements OnInit { | |
selectedStock: string = ''; | |
selectChangeHandler(event: any) { | |
this.selectedStock = event.target.value; | |
} | |
stockDetails = []; | |
title = this.selectedStock; | |
type = 'CandlestickChart'; | |
data = []; | |
columns = ['Timestamp', 'Open', 'High', 'Low', 'Close']; | |
options = { }; | |
width = 1000; | |
height = 800; | |
constructor(private livemarketdataservice: LiveMarketDataService) { | |
} | |
ngOnInit(): any | |
{ | |
let all_times = []; | |
console.log("Log: " + this.selectedStock); | |
this.livemarketdataservice.stockLiveData(this.selectedStock).subscribe(res => { | |
let timeStamp = res["Time Series (1min)"]; | |
all_times.push(timeStamp); | |
let element: any; | |
for(element in timeStamp){ | |
this.stockDetails.push([ | |
element, | |
parseFloat(res["Time Series (1min)"][element]["1. open"]), | |
parseFloat(res["Time Series (1min)"][element]["2. high"]), | |
parseFloat(res["Time Series (1min)"][element]["3. low"]), | |
parseFloat(res["Time Series (1min)"][element]["4. close"]) | |
]) | |
} | |
this.data = this.stockDetails; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment