Skip to content

Update the Sign operation in ops.py#113

Merged
you-n-g merged 2 commits intomicrosoft:mainfrom
YifanDengWHU:main
Dec 14, 2020
Merged

Update the Sign operation in ops.py#113
you-n-g merged 2 commits intomicrosoft:mainfrom
YifanDengWHU:main

Conversation

@YifanDengWHU
Copy link
Contributor

Fix the bug when Sign followed by True/False value.

Description

During the alpha generation exps, I found that when the Sign operation meets True/False value, it will raise a MaybeEncodingError. Here I transform the True/False value to np.float32.

Motivation and Context

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • [x ] If you are adding a new feature, test on your own test scripts.

Screenshots of Test Results (if appropriate):

  1. Pipeline test:
  2. Your own tests:

Types of changes

  • [x ] Fix bugs
  • Add new feature
  • Update documentation

Fix the bug when Sign followed by True/False
@you-n-g
Copy link
Collaborator

you-n-g commented Dec 14, 2020

Hi,
Many thanks for sending the pull request.
But I can't understand why the data type conversion is required. Can you give us more details? Thanks

image

@YifanDengWHU
Copy link
Contributor Author

image
I mean when the sign function meets bool value, it will raise error. Here is the expression I test yesterday:
Sign(Gt($close, Sum(WMA($volume, 14),17)))
The $close value will be smaller than Sum(WMA($volume, 14),17)). So it is Sign(series([False, False, .......])) and it will raise error.
Though this expression is meaningless, but I think we should make it work?

@you-n-g
Copy link
Collaborator

you-n-g commented Dec 14, 2020

@YifanDengWHU Thanks. I see now.

Please add some comments to describe this case.
In addition, please help us to add this comments above the np.float32

# TODO:  The the precision should be configurable

Thanks for your contribution!

@you-n-g you-n-g merged commit 6b8824d into microsoft:main Dec 14, 2020
you-n-g added a commit to you-n-g/qlib that referenced this pull request Aug 16, 2025
* fix record

* fix type

* add loguru-mypy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants