-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Refactor roundtrip #293
Refactor roundtrip #293
Conversation
5f44b8b
to
124cc0d
Compare
CC @a-campbell |
…n and does not require closing of positions.
…d one that has portfolio values to compute portfolio round-trip return.
124cc0d
to
c88fb72
Compare
('Avg # round_trips per day', lambda x: float(len(x)) / | ||
(x.max() - x.min()).days), | ||
('Avg # round_trips per month', lambda x: float(len(x)) / | ||
(((x.max() - x.min()).days) / 21)), |
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 use utils.APPROX_BDAYS_PER_MONTH
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.
+1
6a17150
to
9ce08a0
Compare
abs_amount = int(abs(t.amount)) | ||
indiv_prices = [signed_price] * abs_amount | ||
if (len(price_stack) == 0) or \ | ||
(copysign(1, price_stack[-1]) == copysign(1, t.amount)): |
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.
would np.sign(price_stack[-1]) == np.sign(t.amount)
work here?
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.
That's what I had initially but there was a huge overhead with calling numpy
on a scalar.
Complete rewrite of the round-trip analysis. Now does complete portfolio reconstruction based on transactions and matches orders even without crossing the zero-mark which should make it much more generally applicable. Also much better output.