Created
September 13, 2021 00:43
-
-
Save marcosan93/b3498f3770a7eacc9036573c0e46ef1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getPositions(val, thres=.01, short=True): | |
| """ | |
| Provided a specific sentiment value, will return 1, 0, or -1 representing | |
| buy, hold, or sell respectively. The threshold will determined how high or low the score | |
| needs to be to trigger a buy or sell, otherwise it will be a hold. | |
| """ | |
| # Sentiment score threshold | |
| thres = .01 | |
| # Getting positions | |
| if val > thres: | |
| return 1 | |
| elif val < -thres and short: | |
| return -1 | |
| else: | |
| return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment