microsoft / microsoft/qlib

The error in float calculations

Open
#1,665 0 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

In Position.py, the function sell_stock() will check np.isclose(self.position[stock_id]["amount"], trade_amount), but I found a bug that this check is False, and self.position[stock_id]["amount"] < -1e-5 is True. The reason of this problem may be the error in float calculations.

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 in Position.py at sell_stock() and inspect the np.isclose check alongside the reported self.position[stock_id]["amount"] < -1e-5 condition. Reproduce the float-calculation case and determine the expected handling for the remaining amount; done when the reported inconsistency is resolved and the behavior is covered by a regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
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.