-
Notifications
You must be signed in to change notification settings - Fork 181
Encapsulate Trailing and Stop #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| TRAILING = 2 | ||
| STOP = 1 | ||
|
|
||
| class OrderType: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still could be improved but it's a step in the right direction. by improvements we could use real enums and get read of the whole from_str but that would require a lot more mapping ;)
Like mapping the UI element to string -> enum value :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
| } | ||
| } | ||
|
|
||
| self.lossTypes = ("Trailing", "Stop") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably leverage the actual enum values? let's not use integers but actual strings? what do you think? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could work - trying to think of how would be best to handle semantics vs presentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, as long as the enums stay the same, we can just replace the value.
So TRAILING can change from 1 to "Trailing", then we don't even need a mapper ;p
algobot/interface/configuration.py
Outdated
| if dictionary[tab, 'groupBox'].isChecked(): | ||
| if dictionary[tab, 'takeProfitType'].currentText() == "Trailing": | ||
| takeProfitType = TRAILING | ||
| if dictionary[tab, 'takeOrderType'].currentText() == "Trailing": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably use the to_str method()
| :return: Stop loss strategy in string format. | ||
| """ | ||
| if self.lossStrategy == STOP: | ||
| if self.lossStrategy == OrderType.STOP: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably deprecate this function and add a kwarg for suffix in the to_str method
tests/test_backtester.py
Outdated
| """ | ||
| backtester = self.backtester | ||
| backtester.takeProfitType = STOP | ||
| backtester.takeOrderType = OrderType.STOP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
| from algobot.enums import OrderType | ||
|
|
||
|
|
||
| class OrderTypeTest(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use pytest? We should soon start rewriting all unit test tests to leverage pytest :p
ZENALC
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments
Encapsulate
TRAILINGandSTOPinto distinct objects.Not 100% sure of this one so please correct me where I mis-interpreted things.