Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f8f4969

Browse filesBrowse files
committed
BUG: Ensure order.size is an int
Fixes kernc#954
1 parent f94b20f commit f8f4969
Copy full SHA for f8f4969

1 file changed

+2-1Lines changed: 2 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎backtesting/backtesting.py‎

Copy file name to clipboardExpand all lines: backtesting/backtesting.py
+2-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.