This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Sat May 16 00:14:55 2020 | |
| Updated script to handle certain bugs: | |
| - "<0.01" issue. Value will be set to 0.00 instead. | |
| - ValueError: could not convert string to float: '1,081.62' (due to the comma) | |
| @author: KPO | |
| """ |
This file contains hidden or 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
| //////////////////////////////////////////////////// | |
| // Using StocksCafe API | |
| // | |
| // API onlt for Friends of StocksCafe and you can only make 100 API calls every day (reset at 12am SGT daily) | |
| // | |
| // Profile: https://stocks.cafe/user/profile | |
| // Documentation: https://documenter.getpostman.com/view/6100314/RzfmG81Y#8b9ca17e-239c-4e56-ace8-d008da4250e1 | |
| //////////////////////////////////////////////////// | |
| stockscafe_api_user = 'your_username' |
This file contains hidden or 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
| api_key = 'PASTE_YOUR_API_KEY_HERE' | |
| url = 'https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=' | |
| function getAlphaVantage(symbol) { | |
| var response = UrlFetchApp.fetch(url + symbol + "&apikey=" + api_key).getContentText(); | |
| var data = JSON.parse(response); | |
| var timeSeries = data["Time Series (Daily)"]; | |
| var value = 0.0; | |
| for (var dates in timeSeries) { | |
| value = timeSeries[dates]["4. close"]; |