2
$\begingroup$

I am currently developing a software that needs to store stock prices and the amount of stocks (sold/purchased) of a given company. Now I am wondering which data types I need to use to store this data. The issue I have with that is that I don't know which numbers (how many decimals) can occur:

  1. Is there any standard on the precision of stock prices, e.g. how many decimals can there be?
  2. I know that there can be fractional shares due to stock splits, dividend reinvestments or just because your broker allows it. Same here: How many decimals can there be at maximum?

Is there any "broker / banking industry" standard on this?

$\endgroup$
4
  • $\begingroup$ Is this for accounting? That’s the only use where this matters. Otherwise use float and be done with this $\endgroup$ – Aksakal almost surely binary Jan 16 at 17:22
  • $\begingroup$ @Aksakalalmostsurelybinary A nitpick, but float is not a good choice for non-integer values that must have an exact decimal representation. You can't, for examlpe, represent 1.3 exactly with a floating-point variable. A "decimal" type is better suited for monetary values and exact decimal fractions. $\endgroup$ – D Stanley Jan 16 at 22:59
  • 1
    $\begingroup$ @DStanley, true, but I'm saying the exactness is only needed for accounting. $\endgroup$ – Aksakal almost surely binary Jan 16 at 23:01
  • 2
    $\begingroup$ I’m voting to close this question because as Aksakal said, this seems a question in brokerage firm accounting practices, rather than Quant Finance. It should be addressed to an accountant, and the answer will probably depend on details of your business and operations. $\endgroup$ – noob2 Jan 17 at 17:23
3
$\begingroup$

Giving my 2 cents on your questions: I believe the amount of decimal places is dependent on (the exchange and) the type of financial product. However, an Investopedia article writes:

In 2005, the Securities and Exchange Commission introduced Rule 612, also known as the Sub-Penny Rule. Rule 612 requires the minimum price increments for stocks over \$1.00 to be \$0.01 while stocks under \$1.00 can be quoted in increments of \$0.0001.

This rule can also be found here. Trying to answer your second question, I don't believe there is any industry standard, since Fidelity writes that

Fractional share quantities can be entered out to 3 decimal places (.001 as long as the value of the order is at least $0.01).

But Robinhood and Interactive brokers allow the purchase of fractional shares as small as 0.000001 and 0.0001, respectively, as long as you satisfy the minimum purchase amount. I don't know if this helps.

$\endgroup$
6
  • $\begingroup$ thank you, while your 2 cents might not be a final reply (maybe there isn't one at all), the Robinhood sample is quite interesting for me: this won't fit the SQL Server MONEY datatype (4 decimals precisions, not rounding errors etc.) as Interactive Brokers still would have done ): So your answer is already helpful (besides that I am lost now, what's the best way to store such small fractions) $\endgroup$ – stefan.at.wpf Jan 16 at 15:13
  • 1
    $\begingroup$ Asking out of curiosity. I have no experience with SQL, but why not change the datatype to allow for more decimals? Why not change the datatype to DECIMAL(19,6), thus allowing for 6 decimals after the decimal place? $\endgroup$ – Pleb Jan 16 at 15:26
  • $\begingroup$ Same for me, still new to this and already forgot about it. Guess using DECIMAL would be perfect for me. Thanks for reminding me of DECIMAL :-) I also think you are right that price precision in general depends on the exchange, so likely your answer is the final one, though one still has to figure out which exchange uses the highest precision for prices. $\endgroup$ – stefan.at.wpf Jan 16 at 17:19
  • 1
    $\begingroup$ Pro tip: If this is going to be anywhere near production code, please do read up on the pros and cons of DECIMAL or get in touch with DB pros... If this is for a little project, then don’t worry and just fire away. $\endgroup$ – Kermittfrog Jan 16 at 19:37
  • $\begingroup$ @Kermittfrog for now it's a private project. But I am curious. Can you provide more details / recommend specific resources? What could be an alternative? $\endgroup$ – stefan.at.wpf Jan 16 at 23:15
0
$\begingroup$

For listed US equities you will need to use a float for quantity and price. Fractional shares will often result from corporate actions (aquisitions, splits, etc).

The sub-penny rule mentioned above is for display purposes. You can't put an order onto a regulated US exchange at anything other than a penny increment. But, you can trade at virtually any price. You will sometimes find that your orders execute at points between two pennies (eg: $17.0025) as you get a price improvement from an executing broker.

NASDAQ will only give you fills with 4 decimal points of precision but it's quite legitimate to have more than that. I don't recall seing more than 6 - but you should always allow room for the unexpected.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.