Showing posts with label Google. Show all posts
Showing posts with label Google. Show all posts

08/11/2024

[Google Sheets] Import data from Investing.com

DISCLAIMER: This is not a stock picking recommendation, the tickers shown are used as example and not provided as financial or investment advice.

DISCLAIMER2: Web scraping can go against usage policies so read them, understand them and abide by them. Also web scraping is notoriously flaky as small changes in the retrieved page can affect the location of the desired element(s).

We have already seen how to import data from Yahoo Finance and Coingecko, now we try to add Investing.com as source which unfortunately does not provide API, so we have to do some HTML scraping instead.

We would like to retrieve the current price of an ETF called JPNA. By looking at that page we can luckily identify a specific locator, which then allows us to do a couple string manipulation operations before getting the desired value:

function getInvestingData(path) {
  var result = UrlFetchApp.fetch("https://www.investing.com/etfs/" + path.toLowerCase());
  var response = result.getContentText();
  var start = response.indexOf(' data-test="instrument-price-last">') + 35;
  var end = response.indexOf('</div>', start)
  var out = response.substring(start, end);
  var strip = out.replace(",", "");
  return Number(strip);
}

19/10/2024

[Google Sheets] Import crypto data from Coingecko

DISCLAIMER: I do not recommend investing in crypto, all tokens you will see are used as sample and not provided as financial or investment advice.

We've already seen how to add custom functions to our Google Sheets projects, importing Yahoo Finance data. Now we expand this to import cryptocurrency data from Coingecko.

I could have picked any of the million sources, but this one has a simple free plan which for light usage works well.

After registering and getting your API key, RTFM to find that they provide a lot of stuff, what we care about is the pricing data in this example, you will need to find the ID of the currency you want (NOT the token) by querying the list and then you can get the data you want by calling (add your API key at the end):

"https://api.coingecko.com/api/v3/simple/price?ids=" + token + "&vs_currencies=usd&x_cg_demo_api_key="

You can put this in a Google Sheet function as well (you can extend input parameters to get quote in different currencies as well):

function getCoingeckoData(path) {
  var result = UrlFetchApp.fetch("https://api.coingecko.com/api/v3/simple/price?ids=" + path + "&vs_currencies=usd&x_cg_demo_api_key=YOUR_API_KEY");
  var response = result.getContentText();
  var json = JSON.parse(response);
  return json[path]['usd'];
}

22/12/2023

[Google Sheets] Import data from Yahoo Finance

DISCLAIMER: This is not a stock picking recommendation, the tickers shown are used as example and not provided as financial or investment advice.

Google Sheets offers the GOOGLEFINANCE function which can be used to import market data.

Usage is simple, for example to get the price of a stock, first search for it on Google Finance, then look at the quote URL it generates and copy the exchange:ticker value into the function.

In this example we try to get the quote for A200 ETF traded on the Australian ASX exchange. The URL shows ASX:A200 after the quote part, therefore we should use:

=GOOGLEFINANCE("ASX:A200")

So far, so good. Sometimes however Google does not show data for a particular ticker, or it shows data only in another currency or from another exchange. 
For example, another ETF XESC shows quotes from many exchanges but is also traded on the German XETRA (XESC.DE), which is not sourced by Google. Or the CHSPI ETF traded on the Swiss Six exchange (CHSPI.SW) is simply not found at all.

15/02/2015

[CentOS 7] Chrome use system theme fix

After installing Google Chrome on CentOS 7 with the default theme enabled, you may notice that it will display the mouse pointer in the default Xorg theme instead of blending in with the system.

A workaround is to edit the /usr/share/icons/default/index.theme file by changing

Inherits=dmz-aa

to

Inherits=Adwaita

17/01/2015

[Yum] Add and manage custom repositories

In the latest Fedora versions, it is possible to add custom repositories to yum by creating a .repo file under the /etc/yum.repos.d/ folder following this structure:

[REPOSITORY_NAME]
baseurl=REPOSITORY_URL
enabled=1
gpgcheck=1
gpgkey=URL_TO_KEY

This will add and enable the repo available at REPOSITORY_URL signed by the GPG key found at URL_TO_KEY to your list.

Here's a couple of offical Fedora repos for Google Chrome and VirtualBox:

26/04/2014

[Linux] Xfce set Chrome as default browser

So, you installed Google Chrome (not Chromium) on your machine and set it as default browser from its menu but even if it's the only installed browser, you see Xfce not using it as the default one:

exo-open --launch WebBrowser

asks you to specify the default browser instead of launching it, and if you set it, Chrome complains he's not the default every time you open it.

You may work around the issue by changing the preferred application for the browser:

gksu xfce4-settings-manager

and setting the default browser as:

/usr/bin/google-chrome "%s"

then ignoring Chrome's complaint.