How to create a formula to convert a cryptocurrency denominated in USD to BTC?
Objective: I need to determine the price of some cryptos in BTC (as opposed to USD). I trade some cryptos that are denominated in BTC (Bitcoin) but the price import for many of those provides the market value only in USD (some are available in BTC but most are not). My solution is to import the USD price for that crypto as well as the BTC price and then divide the USD price of the crypto by the price of BTC (in USD). That simple division will give me the price of that crypto in BTC.
Method: I have a table called Price Imports where I import the prices of cryptos and I have a separate table called Trades where I input the trades I have done and I use the XLOOKUP formula to pull the current market price from the Price Imports table into the Trades table. That works fine (thanks to Barry & SG who helped me with that recently).
The formula I have in the ‘Current price’ column tells the spreadsheet to do nothing if the Trade Status is ‘4’ (investment has been sold therefore current price is irrelevant). Otherwise, look in the Price Imports table to find the coin symbol and return the corresponding value in the “Price” column.
I’m trying to write a formula that should be simple but I’m hitting roadblocks. I want to tell the spreadsheet to look up the price of ETH-USD and look up the price of BTC-USD and then divide ETH-USD by BTC-USD… like this: ETH-USD price / BTC-USD price.
I can get it to work if I use the following syntax:
(STOCK $A4,price) / (STOCK $A$2,price) or similarly without locking the row
(STOCK $A4,price) / (STOCK $A2,price)
However that will work only if BTC-USD is in row 2 and I do not sort the table or add / delete rows. If I re-sort the table or add rows then the formula points to the wrong row and therefore the wrong crypto price.
I tried substituting the cell reference A2 by inputting the BTC price symbol BTC-USD but then the spreadsheet gave me the error “There is no security named “40,346.867” … which is the correct BTC price, but for some reason that syntax is looking for a ‘name’ which is actually the price. I’ve tried inputting it several ways but keep getting errors; I can not figure out what syntax I need to tell the cell to calculate the price of ETH divided by the price of BTC, whether by A] referencing the row that has the price of BTC-USD even if that row moves around due to sorting or adding rows or B] telling the formula to fetch both prices and divide one by the other.
I’ve enclosed screenshots that illustrate what I have so far. If anyone can offer a solution as to the right syntax that would be great.