How to Resolve the Issue of -$1 in Your Stock Portfolio Tracker’s Last Price

If you’ve been using the FREE Google Spreadsheet Stock Portfolio Tracker to keep track of your stock securities, you may have noticed a problem with the prices displaying as “-$1.” Many readers have reached out to me about this issue, and I’m here to explain what’s causing it and provide a solution.

Firstly, for those who may be new to the Stock Portfolio Tracker, it’s a useful tool I created to help people monitor their stock holdings based on transactions. It’s a convenient and efficient way to keep track of your portfolio’s performance.

However, if you prefer to track your portfolio privately without relying on a third-party tool like Stocks.Cafe, you can check out the Stock Portfolio Tracker. It’s a free online spreadsheet that allows you to monitor your investments independently.

Now, let’s address the problem at hand. The issue with the “$-1” prices is caused by Yahoo preventing access to their API call. But don’t worry, I have a solution for you.

When I last made changes to the Yahoo Price updater, I implemented two different solutions. Luckily, one of these implementations is still functional. The short version of the solution is this: Instead of using the getYPrice3() function, switch to the getYPrice2() function.

Please note that I can’t guarantee how long this implementation will continue to work, but for now, it’s a reliable fix. Here’s the code for the getYPrice2() function:

“`javascript
function getYPrice2(symbol) {
symbol = symbol || “D05.SI”;
symbol = encodeURI(symbol);
Utilities.sleep(Math.floor(Math.random() * 5000));
var url = ‘https://query2.finance.yahoo.com/v7/finance/options/’+ symbol; // last one day history
Logger.log(url);
var response = UrlFetchApp.fetch(url, {muteHttpExceptions: true});
var responseCode = response.getResponseCode();
Logger.log(“Response code:” + responseCode);
if (responseCode === 200) {
var chain = JSON.parse(response.getContentText());
Logger.log(parseFloat(chain.optionChain.result[0].quote.regularMarketPrice));
return parseFloat(chain.optionChain.result[0].quote.regularMarketPrice);
} else {
return -1;
}
}
“`

I’m sharing this code for anyone who may still be using a very old version of the Stock Portfolio Tracker. If you’re interested, you can update your implementation with this code.

On another note, if you’re looking to trade the stocks I mentioned, I recommend opening an account with Interactive Brokers. They are a leading low-cost and efficient broker that I trust and personally use to invest and trade my holdings on various stock exchanges, including Singapore, the United States, London, and Hong Kong.

Interactive Brokers offers a wide range of trading options, including stocks, ETFs, options, futures, forex, bonds, and funds. With a single integrated account, you can trade these assets worldwide. They provide a reliable platform for executing trades and have a solid reputation in the industry.

If you’re interested in learning more about Interactive Brokers, I’ve written a comprehensive series called the Interactive Brokers Deep Dive. This series covers various aspects of using Interactive Brokers, starting with how to create and fund your account easily.

In summary, if you’ve been experiencing the issue of “-$1” in your Stock Portfolio Tracker’s last price, it’s due to Yahoo preventing access to their API call. However, there is a solution. By using the getYPrice2() function instead of getYPrice3(), you can resolve the problem. Although we can’t guarantee how long this implementation will continue to work, it’s effective for now.

If you’re using an outdated version of the Stock Portfolio Tracker, you may want to update your code with the provided getYPrice2() implementation. Additionally, if you’re interested in trading the mentioned stocks, consider opening an account with Interactive Brokers for a seamless and efficient trading experience.

That’s all for now. If you’d like to stay informed about the latest financial insights, I encourage you to subscribe to FMS Financial Insights. By subscribing, you’ll receive our weekly newsletter, packed with valuable tips and information to help you navigate the world of investments successfully. Don’t miss out on this opportunity – subscribe today!


Benjamin Low
Benjamin Low

Benjamin is known as The Passive Income Guy. He has helped hundreds of people to build passive income. He is also a member of the Million Dollar Round Table, and Certified Financial Planner™ (CFP®) and Certified Private Banker (CPB).

Leave a Reply

Your email address will not be published.