-4

Is there a way to get the number of trades in a time window? For example, within 1 hour of time window, I want to find the number of trades for Apple, e.g. number of buys and number of sells.

I wasn't able to find that with yfinance. Maybe there are other APIs with different strategies. Any idea is appreciated.

EDIT:

I am looking for information on a specific date (or rage) which shows how many transactions were made via the market and how many percents are sells and how many percents are buys. Consider a stock with share price of 10 (start of the business day) and a market cap of 10000. So, 1000 shares exists. Tomorrow before market opens, I know that the closed price is 5 and the market cap is 8000. That means 1600 shares. A change from 1000 to 1600 shares means, during the market open time, 600 trades (transactions) were done. If I know that for example, 500 out of 600 transactions are "sell", then I assume more of the people traded the stock yesterday (I am now waiting for market to open in today).

I know that stock websites, e.g. Yahoo finance, show realtime share price and market cap. But I wasn't able to achieve what I want with yfinance package in Python. In fact, the number of sells and buys are not known in the websites. Is that something secret? Don't know...

As a real example see Nvidia 30 day average volume here.

enter image description here

This means that starting from July 20, the daily volume starts to decrease. Does that mean fewer buys? or more sells? This is what I want to know.

5
  • 1
    I think the keyword you are looking for is "volume".
    – keshlam
    Commented Aug 13, 2023 at 9:12
  • @keshlam Really? The question does not describe volume as far as I can tell. Commented Aug 13, 2023 at 12:08
  • My broker (in Australia) has "course of sales" which tracks each trade but the answer to your Q will depend on your country & data provider. Also, number of buys and sells will always be the same - a trade is a buy and a sell of equal number of shares. Orders can be filled with multiple trades. Settlement is done net. Commented Aug 13, 2023 at 12:44
  • Number of transactions, if that's what is wanted, may be hard to get; most folks don't care about that granularity . Ditto hourly. Hm.
    – keshlam
    Commented Aug 13, 2023 at 13:16
  • I have updated the post. Please see it.
    – mahmood
    Commented Aug 14, 2023 at 11:52

2 Answers 2

2

Some brokers offer Time & Sales Data. If you can figure out how to scrape it, you can collect what you need.

As for your EDIT, it doesn't make much sense. For every transaction, there is a buyer and a seller. A transacton at the ask means that a buyer bought shares on the order book (NBBO). And conversely, a transaction at the bid means that a seller took out liquidity.

More buyers doesn't mean that price will rise (or vice versa). What moves price is an aggregate volume of buyers (or sellers) that takes out the volume available at NBBO.

As for your $10 stock example, it's nonsensical on multiple accounts. Market cap does not reflect how many trades occurred, merely the float times the value per share. A $10 stock could gap down to $5 with zero trades. Or 5,000 shares could have been traded for the same result.

-1

If you divide the volume aapl.info["volume"] with the latest price, you'll get a good sense for the number of daily transactions.

5
  • How? Price & volume are unrelated. Commented Aug 13, 2023 at 12:09
  • 2
    Volume is number of shares traded. For a volume of 1M, please tell me how many trades there are if the price is $10, $20 or $30? It can't be determined. The market could have seen 1 trade of 1M shares, or 100,000 trades of 10 shares. Even if volume is in $ (it isn't), it's the same problem. I wonder if the poster is getting confused with something else (orders?) They ask for number of buys and sells. By definition a trade is both a buy and a sell. An order might be filled by multiple trades but at this point I am reluctant to speculate on what they are after. Commented Aug 13, 2023 at 12:39
  • Valid point, cc clarification may be needed here, along with whether hourly is really necessary (and possible)...
    – keshlam
    Commented Aug 13, 2023 at 13:18
  • And note that a single sale or purchase from the point of view of the buyer or seller may be spread across multiple trades. So I'm not sure the number of trades is actually very informative.
    – keshlam
    Commented Aug 13, 2023 at 14:40
  • Volume divided by cost has nothing to do with the number of transactions. Commented Aug 14, 2023 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .