I am developing a trading system which stores data in SQLite, consisting of OHLC and volume. I would also like to store some indicators like RSI etc I read the other answer which indicated integers as the data type. In my case I am looking at 8 digit precision which would slow down the calculations if I were to multiply every value by 1e8 Any recommendations are appreciated!
Best Data Type to Store Prices with 8 Decimals in SQLite
datatypesmoneysqlite
Related Question
- In what data type should I store an email address in database
- PostgreSQL Data Types – Comparing bytea and smallint[]
- SQLite function to specify exactly how the data is stored internally
- Best SQL Data Type for x.x.x Format
- SQL Server – Best Data Type to Store Result of HASHBYTES(‘MD5’)
- SQLite Data Types – What Is the Use of Specifying Data Types?
- Software Uses SQLite and Has Frequent DB Lock Errors. Zero Access to Code. Anything we can do
Best Answer
The FAQ pretty much explains the reason why you don't want to use their
REAL
data type for storing numbers with 8 decimal places.https://www.sqlite.org/faq.html#q16
Workaround 1
The trick of using an
INTEGER
to achieve your required level of precision has been used since computers existed.With today's powerful CPUs, I wouldn't worry about the overhead of any additional calculations. You'll need to run benchmarks to (dis)prove my statement.
Workaround 2
IMHO - You shouldn't use a tool that doesn't support your requirements.