Skip to content

Update to enable tracking id from order to trade - #199

Closed
qacollective wants to merge 3 commits into
kernc:masterfrom
qacollective:master
Closed

Update to enable tracking id from order to trade#199
qacollective wants to merge 3 commits into
kernc:masterfrom
qacollective:master

Conversation

@qacollective

Copy link
Copy Markdown
Contributor

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 馃槦 馃槄

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 kernc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will additionally need a unit test and a good example use for the docs.

Comment thread backtesting/backtesting.py Outdated
Comment thread backtesting/backtesting.py Outdated
Comment thread backtesting/backtesting.py Outdated
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`.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe:

An arbitrary tag object which, if set, propagates to the Trade this order started.

Which begs the question, what about orders that close existing trades?

Comment thread backtesting/backtesting.py Outdated
@qacollective

Copy link
Copy Markdown
Contributor Author

Sorry, I have completely butchered the PR process here. git is driving me a bit nuts.

@kernc

kernc commented Dec 17, 2020

Copy link
Copy Markdown
Owner

Fyi, you can git push --force to overwrite existing branch contents.

@qacollective

Copy link
Copy Markdown
Contributor Author

Fyi, you can git push --force to overwrite existing branch contents.

馃槄 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

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