Update to enable tracking id from order to trade - #199
Closed
qacollective wants to merge 3 commits into
Closed
Conversation
This is a simple change to backtesting.py to enable a user to track which trade came from which order (and a lot of other potential benefits) as outlined in issue #197. It simply allows the assignment of an id when creating an order at with `Strategy.buy()` and `Strategy.sell()`. The id is type agnostic, so the user can make it a string, int, float or whatever may be necessary. I could not think of a better way to solve this problem and I will be able to test that this works in the next day or so. I hope people think this is a good idea 馃槦 馃槄
kernc
requested changes
Dec 16, 2020
kernc
left a comment
Owner
There was a problem hiding this comment.
Will additionally need a unit test and a good example use for the docs.
Comment on lines
+479
to
+480
| An ID attribute which, if set, persists to enable tracking of this order | ||
| if it becomes a trade in `Strategy.trades` and when closed in `Strategy.closed_trades`. |
Owner
There was a problem hiding this comment.
Maybe:
An arbitrary tag object which, if set, propagates to the
Tradethis order started.
Which begs the question, what about orders that close existing trades?
Contributor
Author
|
Sorry, I have completely butchered the PR process here. git is driving me a bit nuts. |
Owner
|
Fyi, you can |
Contributor
Author
馃槄 sorry, yes I'm in the difficult position of trying to do a lot with a little time at the moment, so your advice is great and something I would normally have googled to self-educate but December is 馃ぎ haha |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a simple change to backtesting.py to enable a user to track which trade came from which order (and a lot of other potential benefits) as outlined in issue #197.
It simply allows the assignment of an id when creating an order at with
Strategy.buy()andStrategy.sell(). The id is type agnostic, so the user can make it a string, int, float or whatever may be necessary.I could not think of a better way to solve this problem and I will be able to test that this works in the next day or so. I hope people think this is a good idea 馃槦 馃槄