quantex 0.6.1__tar.gz → 0.6.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {quantex-0.6.1 → quantex-0.6.2}/PKG-INFO +1 -1
- {quantex-0.6.1 → quantex-0.6.2}/pyproject.toml +1 -1
- {quantex-0.6.1 → quantex-0.6.2}/src/quantex/broker.py +33 -40
- {quantex-0.6.1 → quantex-0.6.2}/LICENSE.md +0 -0
- {quantex-0.6.1 → quantex-0.6.2}/README.md +0 -0
- {quantex-0.6.1 → quantex-0.6.2}/src/quantex/__init__.py +0 -0
- {quantex-0.6.1 → quantex-0.6.2}/src/quantex/backtester.py +0 -0
- {quantex-0.6.1 → quantex-0.6.2}/src/quantex/commission.py +0 -0
- {quantex-0.6.1 → quantex-0.6.2}/src/quantex/datasource.py +0 -0
- {quantex-0.6.1 → quantex-0.6.2}/src/quantex/strategy.py +0 -0
|
@@ -75,7 +75,7 @@ class Broker:
|
|
|
75
75
|
openPositionsDirection = self.openPositions[name][0].direction
|
|
76
76
|
curr_timestamp = self.__context__.datas[name].Timestamp[-1]
|
|
77
77
|
if openPositionsDirection and openPositionsDirection != order.direction:
|
|
78
|
-
price: float = self.__context__.datas[name].
|
|
78
|
+
price: float = self.__context__.datas[name].Open[-1]
|
|
79
79
|
if self.execute_condition(order, price):
|
|
80
80
|
amount = order.amount
|
|
81
81
|
for i in range(len(self.openPositions[name])):
|
|
@@ -93,18 +93,14 @@ class Broker:
|
|
|
93
93
|
amount -= closed_amount
|
|
94
94
|
if amount == 0:
|
|
95
95
|
if order.parentId is not None:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
elif (
|
|
101
|
-
self.orderQueue[name][i].parentId == order.parentId
|
|
96
|
+
for queued_order in self.orderQueue[name]:
|
|
97
|
+
if (
|
|
98
|
+
queued_order.id != order.id
|
|
99
|
+
and queued_order.parentId == order.parentId
|
|
102
100
|
):
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
idx
|
|
107
|
-
) ## OCO - One Cancels the Other
|
|
101
|
+
self.cancelQueue[name].append(
|
|
102
|
+
queued_order
|
|
103
|
+
) ## OCO - One Cancels the Other
|
|
108
104
|
break
|
|
109
105
|
positions = []
|
|
110
106
|
for openOrder in self.openPositions[name]:
|
|
@@ -154,7 +150,7 @@ class Broker:
|
|
|
154
150
|
self.cash += total
|
|
155
151
|
return True
|
|
156
152
|
else:
|
|
157
|
-
price: float = self.__context__.datas[name].
|
|
153
|
+
price: float = self.__context__.datas[name].Open[-1]
|
|
158
154
|
if self.execute_condition(order, price):
|
|
159
155
|
total = order.amount * price
|
|
160
156
|
self.openPositions[name].append(
|
|
@@ -388,38 +384,35 @@ class Broker:
|
|
|
388
384
|
"""
|
|
389
385
|
if name is None:
|
|
390
386
|
name = list(self.__context__.datas.keys())[0]
|
|
391
|
-
totalPositionAmount = 0
|
|
392
387
|
if len(self.openPositions[name]) == 0:
|
|
393
388
|
return
|
|
394
|
-
direction = self.openPositions[name][0].direction
|
|
395
389
|
for order in self.openPositions[name]:
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
390
|
+
if order.direction == OrderDirection.BUY:
|
|
391
|
+
self.orderQueue[name].append(
|
|
392
|
+
NewOrder(
|
|
393
|
+
self.__orderId__,
|
|
394
|
+
self.__context__.datas[name].Timestamp[-1],
|
|
395
|
+
OrderType.MARKET,
|
|
396
|
+
OrderDirection.SELL,
|
|
397
|
+
order.amount_filled,
|
|
398
|
+
None,
|
|
399
|
+
order.parentId or order.id,
|
|
400
|
+
)
|
|
407
401
|
)
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
402
|
+
self.__orderId__ += 1
|
|
403
|
+
elif order.direction == OrderDirection.SELL:
|
|
404
|
+
self.orderQueue[name].append(
|
|
405
|
+
NewOrder(
|
|
406
|
+
self.__orderId__,
|
|
407
|
+
self.__context__.datas[name].Timestamp[-1],
|
|
408
|
+
OrderType.MARKET,
|
|
409
|
+
OrderDirection.BUY,
|
|
410
|
+
order.amount_filled,
|
|
411
|
+
None,
|
|
412
|
+
order.parentId or order.id,
|
|
413
|
+
)
|
|
420
414
|
)
|
|
421
|
-
|
|
422
|
-
self.__orderId__ += 1
|
|
415
|
+
self.__orderId__ += 1
|
|
423
416
|
|
|
424
417
|
def is_long(self, name: str | None = None) -> bool:
|
|
425
418
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|