microsoft / microsoft/qlib

Erroneous float calculations.

Open
#61 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
48.7k
Forks
7.7k
PR merge metrics
No merged PRs in 30d

Description

🐛 Bug Description

When an expression is being evaluated, I think the series is changed into np.float32 and when returning back its being changed back to np.float64. Calculation results are in fact erroneous.

To Reproduce

d = get_quote_data([ticker], fields=['$close', '$volume', 'Mul($close, $volume)'], start_time='2020-10-23', end_time='2020-10-30')
image

image

Expected Behavior

The actual value should be 3989893260.0

Screenshot

Environment

Note: One could run python scripts/collect_info.py under the qlib directory to get the following information.

  • Qlib version:
  • Python version:
  • OS (Windows, Linux, MacOS):
  • Commit number (optional, please provide it if you are using the dev version):

Additional Notes

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the get_quote_data reproduction using Mul($close, $volume), and run scripts/collect_info.py to record the environment. Trace where expression evaluation changes numeric precision, then verify that the reproduced value is 3989893260.0 without introducing the reported calculation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data, fintech-quant
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.