Using Vanna.AI to find cheap tech stocks as investments (natural language to SQL)

Ashish Singal
Vanna AI
Published in
4 min readMay 16, 2023

I’m going to use Vanna to find a new tech investment for my portfolio. Let’s get started. Overall, I’d like to find something with growth but still relatively inexpensive. And I’d like it to be a larger name that has some brand value.

Let’s get started.

Understanding the data

Before asking questions, it’s important to get an understanding of what data is available so we can ask questions that are answerable by the data.

Here are some of the more interesting and useful tables —

  1. Tickers — This contains a list of all of the companies that are listed on exchanges along with all current data about time — including company info (such as name, ticker, sector, industry), fundamental data (such as earnings, PE ratio), and price data (such as change over 1 day, 1 week, 1 month, historical volatility).
  2. Daily — The daily table contains price history (keyed on ticker and date). Columns include price change, market cap, high, low, close, etc.
  3. Fundamentals — Information gleaned from earnings announcements, including earnings, revenue, balance sheet info, etc.
  4. Portfolios — These are the portfolio holdings of large asset managers (13Fs) reported each quarter.
  5. Insider trades — These are trades by significant shareholders or executives of a company declared to the SEC.
  6. Correlation — These are calculated correlation pairs for each ticker. We use 3 months of data to calculate them.

Asking exploratory questions

Next, let’s dive in and ask some questions.

Let’s get a list of the sectors by market cap, along with the number of companies and the median market cap. Link to the question & answer.

Question: list the sectors by total market cap and include number of companies and median market cap

The AI wrote the following SQL, grabbing the tickers table, grouping by market cap, and even calculating median correctly (which would have taken quite a bit of Googling otherwise).

SELECT sector, COUNT(*) AS company_count, 
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY marketcap) AS median_market_cap,
SUM(marketcap) AS total_market_cap
FROM dush.quandl.tickers
WHERE marketcap IS NOT NULL
GROUP BY sector
ORDER BY total_market_cap DESC

The results show that tech is the biggest sector by market cap, by far, even though healthcare has more companies in it (they are just less valuable on average).

We want to dive into tech, so let’s ask for the industries within tech. Here’s the question & answer.

Question: list the industries by total market cap within the technology sector and include number of companies and median market cap

SELECT industry, COUNT(*) AS company_count, 
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY marketcap) AS median_market_cap,
SUM(marketcap) AS total_market_cap
FROM dush.quandl.tickers
WHERE marketcap IS NOT NULL AND sector = 'Technology'
GROUP BY industry
ORDER BY total_market_cap DESC

Seems infra software, consumer electronics (thanks Apple), and semiconductors (thanks NVIDIA) are top.

Diving into our specific questions

Ok, now let’s get into specific companies.

First, let’s see the top companies in technology by market cap (Q&A here). Apple, Microsoft, Alphabet and Amazon, as expected, are the biggest.

Next, let’s calculate the PE and PS ratios by industry within tech. Q&A here.

Question: list industries by price to sales (sum of market cap divided by sum of revenueusd) for companies in the Technology sector. include market cap, revenue, and company count.

Note I had to tell Vanna explicitly to use the revenueusd column as opposed to the revenue column. Otherwise, the answers were off because of companies like Sony that report in foreign currencies.

Electronics & Computer Distribution has really low price to sales — let’s see what companies are in there. Q&A here.

I haven’t heard of any of these companies — the biggest, by far, Arrow Electronics, sells computer parts. Doesn’t seem like a particularly lucrative corner of the tech world.

Now, let’s get all large cap stocks with the lowest price to sales. Q&A here.

Three of the top five cheapest tech stocks are the old school PC makers like HP, Dell and HP Enterprise.

Ok, for our final query, let’s add in the revenue growth requirement of at least 30% and bump up the minimum market cap to $20bn. Q&A here.

So there you have it. Uber and Doordash are the top tech two companies to invest in that are growing quickly, have a low price to sales, and are big, recognizable companies.

--

--