Skip to content

Instantly share code, notes, and snippets.

View boshng95's full-sized avatar
🏠
Working from home

Bosh Ng boshng95

🏠
Working from home
View GitHub Profile
@Override
public void onBindViewHolder(@NonNull stockIndexViewHolder stockIndexViewHolder, int i) {
String[] arrayIndexName = {"S&P/ASX 200 Index","S&P/ASX 50 Index"};
Company index = stockIndexesArrayList.get(i);
stockIndexViewHolder.candleStickChart.setHighlightPerDragEnabled(true);
stockIndexViewHolder.candleStickChart.setDrawBorders(true);
stockIndexViewHolder.candleStickChart.setBorderColor(Color.LTGRAY);
YAxis yAxis = stockIndexViewHolder.candleStickChart.getAxisLeft();
public class LoadChartClass {
public LoadChartClass(){}
public Stock loadAnyChart(Company equity, String equityName){
ArrayList<DailyPrice> indexDailyPrices = equity.getCompanyStockPrices();
Table table = Table.instantiate("x");
List<DataEntry> data = new ArrayList<>();
public class DailyPrice {
private String dailyDate;
private double dailyOpen;
private double dailyHigh;
private double dailyLow;
private double dailyClose;
private int dailyVolume;
public DailyPrice(String dailyDate, double dailyOpen, double dailyHigh, double dailyLow, double dailyClose, int dailyVolume) {
private void getStockPricesOnline(final String companyCode){
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
String inputLine;
String result;
boolean successful = false;
while(!successful){
{
"Meta Data": {
"1. Information": "Daily Prices (open, high, low, close) and Volumes",
"2. Symbol": "ASX:CBA",
"3. Last Refreshed": "2019-10-16",
"4. Output Size": "Compact",
"5. Time Zone": "US/Eastern"
},
"Time Series (Daily)": {
"2019-10-16": {
let companies = ["A2M","CBA","AHG","ABC","CCL"]
for company in companies{
let jsonUrlStringPrice = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=ASX:"+company+"&outputsize=100&apikey=demo"
//API key need to be claim in AlphaVantage
URLSession.shared.dataTask(with: url){ (data, response, err) in
guard let data = data else {return}
do{
let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as AnyObject