Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Retrieves exchange rate from Poloniex ETH.
- */
- function updateETH()
- {
- var response = UrlFetchApp.fetch("https://poloniex.com/public?command=returnTicker");
- // TODO: set your sheet name here
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current prices");
- var json = JSON.parse(response.getContentText());
- var rate = json.BTC_ETH.last;
- // TODO: set column coordinates here in format (column, row); this is now set to A1
- sheet.getRange(2, 3).setValue(rate);
- }
- /**
- * Retrieves exchange rate from Poloniex ETH/ETC.
- */
- function updateETHETC()
- {
- var response = UrlFetchApp.fetch("https://poloniex.com/public?command=returnTicker");
- // TODO: set your sheet name here
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current prices");
- var json = JSON.parse(response.getContentText());
- var rate = json.ETH_ETC.last;
- // TODO: set column coordinates here in format (column, row); this is now set to A1
- sheet.getRange(2, 5).setValue(rate);
- }
- /**
- * Retrieves exchange rate from Poloniex for BTC.
- */
- function updateBTC()
- {
- var response = UrlFetchApp.fetch("https://poloniex.com/public?command=returnTicker");
- // TODO: set your sheet name here
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current prices");
- var json = JSON.parse(response.getContentText());
- var rate = json.USDT_BTC.last;
- // TODO: set column coordinates here in format (column, row); this is now set to A1
- sheet.getRange(1, 1).setValue(rate);
- }
- /**
- * Retrieves Steem exchange rate from Poloniex for STEEM.
- */
- function updateSteem()
- {
- var response = UrlFetchApp.fetch("https://poloniex.com/public?command=returnTicker");
- // TODO: set your sheet name here
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current prices");
- var json = JSON.parse(response.getContentText());
- var rate = json.BTC_STEEM.last;
- // TODO: set column coordinates here in format (column, row); this is now set to A1
- sheet.getRange(3, 3).setValue(rate);
- }
- /**
- * Retrieves exchange rate from Poloniex for ETC.
- */
- function updateETC()
- {
- var response = UrlFetchApp.fetch("https://poloniex.com/public?command=returnTicker");
- // TODO: set your sheet name here
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current prices");
- var json = JSON.parse(response.getContentText());
- var rate = json.BTC_ETC.last;
- // TODO: set column coordinates here in format (column, row); this is now set to A1
- sheet.getRange(1, 3).setValue(rate);
- }
- /**
- * Retrieves exchange rate from Bittrex for something.
- */
- function updatePIVX()
- {
- var response = UrlFetchApp.fetch("https://bittrex.com/api/v1.1/public/getticker?market=BTC-LTC");
- // TODO: set your sheet name here
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current prices");
- var json = JSON.parse(response.getContentText());
- var rate = json.BTC-LTC.last;
- // TODO: set column coordinates here in format (column, row); this is now set to A1
- sheet.getRange(3, 4).setValue(rate);
- }
- /**
- * Retrieves exchange rate from Kraken not in current use.
- */
- function updateKraken()
- {
- var response = UrlFetchApp.fetch("https://api.kraken.com/0/public/Ticker?pair=ETHXBT");
- // TODO: set your sheet name here
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current prices");
- var json = JSON.parse(response.getContentText());
- var rate = json.result.XETHXXBT.c[0];
- // TODO: set column coordinates here in format (column, row); this is now set to A2
- sheet.getRange(2, 1).setValue(rate);
- }
- /**
- * Retrieves exchange rate from Kraken for ICN.
- */
- function updateICN()
- {
- var response = UrlFetchApp.fetch("https://api.kraken.com/0/public/Ticker?pair=ICNXBT");
- // TODO: set your sheet name here
- var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Current prices");
- var json = JSON.parse(response.getContentText());
- var rate = json.result.XICNXXBT.c[0];
- // TODO: set column coordinates here in format (column, row); this is now set to A2
- sheet.getRange(1, 5).setValue(rate);
- }
- /**
- * Retrieves exchange rates from both exchanges.
- */
- function updateAll()
- {
- updateETH();
- updateSteem();
- updateBTC();
- updateETC();
- updateICN();
- updateETHETC();
- }
- /**
- * Adds a custom menu to the active spreadsheet, containing a single menu item
- * for invoking the function specified above.
- * The onOpen() function, when defined, is automatically invoked whenever the
- * spreadsheet is opened.
- * For more information on using the Spreadsheet API, see
- * https://developers.google.com/apps-script/service_spreadsheet
- */
- function onOpen() {
- var sheet = SpreadsheetApp.getActiveSpreadsheet();
- var entries = [{
- name : "Update ETH",
- functionName : "updateETH"
- }, {
- name : "Update BTC",
- functionName : "updateBTC"
- }, {
- name : "Update Steem",
- functionName : "updateSteem"
- },{
- name : "Update ETH/ETC",
- functionName : "updateETHETC"
- }, {
- name : "Update ETC",
- functionName : "updateETC"
- }, {
- name : "Update ICN",
- functionName : "updateICN"
- }, {
- name : "Update all",
- functionName : "updateAll"
- }];
- sheet.addMenu("Scripts", entries);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement