Content-Length: 262118 | pFad | http://github.com/kernc/backtesting.py/commit/#start-of-content

6880C3D6 BUG: Ensure order.size is an int · kernc/backtesting.py@f8f4969 · GitHub
Skip to content

Commit f8f4969

Browse files
committed
BUG: Ensure order.size is an int
Fixes #954
1 parent f94b20f commit f8f4969

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

backtesting/backtesting.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,8 @@ def _copy(self, **kwargs):
590590
def close(self, portion: float = 1.):
591591
"""Place new `Order` to close `portion` of the trade at next market price."""
592592
assert 0 < portion <= 1, "portion must be a fraction between 0 and 1"
593-
size = copysign(max(1, round(abs(self.__size) * portion)), -self.__size)
593+
# Ensure size is an int to avoid rounding errors on 32-bit OS
594+
size = copysign(max(1, int(round(abs(self.__size) * portion))), -self.__size)
594595
order = Order(self.__broker, size, parent_trade=self, tag=self.__tag)
595596
self.__broker.orders.insert(0, order)
596597

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/kernc/backtesting.py/commit/#start-of-content

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy