investfly-sdk 1.3__py3-none-any.whl → 1.4__py3-none-any.whl
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.
- investfly/models/TradingStrategy.py +1 -1
- investfly/samples/strategies/SmaCrossOverStrategy.py +1 -1
- investfly/samples/strategies/SmaCrossOverTemplate.py +1 -1
- investfly/utils/PercentBasedPortfolioAllocator.py +5 -6
- {investfly_sdk-1.3.dist-info → investfly_sdk-1.4.dist-info}/METADATA +1 -1
- {investfly_sdk-1.3.dist-info → investfly_sdk-1.4.dist-info}/RECORD +10 -10
- {investfly_sdk-1.3.dist-info → investfly_sdk-1.4.dist-info}/WHEEL +1 -1
- {investfly_sdk-1.3.dist-info → investfly_sdk-1.4.dist-info}/LICENSE.txt +0 -0
- {investfly_sdk-1.3.dist-info → investfly_sdk-1.4.dist-info}/entry_points.txt +0 -0
- {investfly_sdk-1.3.dist-info → investfly_sdk-1.4.dist-info}/top_level.txt +0 -0
@@ -78,7 +78,7 @@ class TradingStrategy(ABC):
|
|
78
78
|
:param tradeSignals: Trade Signals correspoding to stocks matching open trade condition
|
79
79
|
:return: List of TradeOrders to execute
|
80
80
|
"""
|
81
|
-
portfolioAllocator = PercentBasedPortfolioAllocator(10
|
81
|
+
portfolioAllocator = PercentBasedPortfolioAllocator(10)
|
82
82
|
return portfolioAllocator.allocatePortfolio(portfolio, tradeSignals)
|
83
83
|
|
84
84
|
def getStandardCloseCondition(self) -> StandardCloseCriteria | None:
|
@@ -30,6 +30,6 @@ class SmaCrossOverStrategy(TradingStrategy):
|
|
30
30
|
|
31
31
|
|
32
32
|
def processOpenTradeSignals(self, portfolio: Portfolio, tradeSignals: List[TradeSignal]) -> List[TradeOrder]:
|
33
|
-
portfolioAllocator = PercentBasedPortfolioAllocator(5
|
33
|
+
portfolioAllocator = PercentBasedPortfolioAllocator(5)
|
34
34
|
return portfolioAllocator.allocatePortfolio(portfolio, tradeSignals)
|
35
35
|
|
@@ -95,7 +95,7 @@ class SmaCrossOverTemplate(TradingStrategy):
|
|
95
95
|
"""
|
96
96
|
|
97
97
|
# We provide a convenience utility that allocates given percent (10% set below) of portfolio in the given stock
|
98
|
-
portfolioAllocator = PercentBasedPortfolioAllocator(10
|
98
|
+
portfolioAllocator = PercentBasedPortfolioAllocator(10)
|
99
99
|
return portfolioAllocator.allocatePortfolio(portfolio, tradeSignals)
|
100
100
|
|
101
101
|
def getStandardCloseCondition(self) -> StandardCloseCriteria | None:
|
@@ -6,17 +6,15 @@ from investfly.models.StrategyModels import PortfolioSecurityAllocator, TradeSig
|
|
6
6
|
|
7
7
|
class PercentBasedPortfolioAllocator(PortfolioSecurityAllocator):
|
8
8
|
|
9
|
-
BROKER_FEE =
|
9
|
+
BROKER_FEE = 1.0
|
10
10
|
|
11
|
-
def __init__(self, percent: float
|
11
|
+
def __init__(self, percent: float) -> None:
|
12
12
|
self.percent = percent
|
13
|
-
self.positionType = positionType
|
14
13
|
|
15
14
|
def allocatePortfolio(self, portfolio: Portfolio, tradeSignals: List[TradeSignal]) -> List[TradeOrder]:
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
pendingOrdersSecurities = {o.security for o in portfolio.pendingOrders if o.tradeType == tradeType}
|
16
|
+
openPositionSecurities = {p.security for p in portfolio.openPositions}
|
17
|
+
pendingOrdersSecurities = {o.security for o in portfolio.pendingOrders}
|
20
18
|
openAndPendingSecurities = openPositionSecurities.union(pendingOrdersSecurities)
|
21
19
|
|
22
20
|
tradeOrders: List[TradeOrder] = []
|
@@ -28,6 +26,7 @@ class PercentBasedPortfolioAllocator(PortfolioSecurityAllocator):
|
|
28
26
|
while buyingPower > allocatedAmountPerSecurity and len(tradeSignals) > 0:
|
29
27
|
tradeSignal = tradeSignals.pop(0)
|
30
28
|
if tradeSignal.security not in openAndPendingSecurities:
|
29
|
+
tradeType = TradeType.BUY if tradeSignal.position == PositionType.LONG else TradeType.SHORT
|
31
30
|
tradeOrder = TradeOrder(tradeSignal.security, tradeType, maxAmount=allocatedAmountPerSecurity)
|
32
31
|
tradeOrders.append(tradeOrder)
|
33
32
|
buyingPower = buyingPower - allocatedAmountPerSecurity - PercentBasedPortfolioAllocator.BROKER_FEE
|
@@ -17,7 +17,7 @@ investfly/models/PortfolioModels.py,sha256=wEHzaxEMEmliNR1OXS0WNzzao7ZA5qhKIPzAj
|
|
17
17
|
investfly/models/SecurityFilterModels.py,sha256=4baTBBI-XOKh8uTpvqVvk3unD-xHoyooO3dd5lKWbXA,5806
|
18
18
|
investfly/models/SecurityUniverseSelector.py,sha256=N2cYhgRz3PTh6T98liiiTbJNg27SBpaUaIQGgDHFbF4,8645
|
19
19
|
investfly/models/StrategyModels.py,sha256=n9MVOJFPtc_Wkiq5TyhdQnaiTUeXGMYqLmBE9IEiW10,5553
|
20
|
-
investfly/models/TradingStrategy.py,sha256=
|
20
|
+
investfly/models/TradingStrategy.py,sha256=N1V0dZX6T2buVyg5NZL8inAKlLZSHZnrv-x2g9kxQBk,6362
|
21
21
|
investfly/models/__init__.py,sha256=6uMfJwcYaH1r-T-bbh6gMud0VpnoSQTkPNDVMDE3JXo,1383
|
22
22
|
investfly/samples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
23
|
investfly/samples/indicators/IndicatorTemplate.py,sha256=X0AlStLnL1SBSnTwrtW_sthm00tmuN5V7N-GrtiarmM,4454
|
@@ -25,15 +25,15 @@ investfly/samples/indicators/NewsSentiment.py,sha256=fcpAqOcNWmqYsP-xwJquCX_6G7N
|
|
25
25
|
investfly/samples/indicators/RsiOfSma.py,sha256=kiLvMhrsbc_lV0EEpERGW2im19u5XmyJk88aTDGSBis,1719
|
26
26
|
investfly/samples/indicators/SmaEmaAverage.py,sha256=9pp3TtEKJADD_bfufwrWlwMswlTLoN7Nj6BC_jJ1sRs,1749
|
27
27
|
investfly/samples/indicators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
28
|
-
investfly/samples/strategies/SmaCrossOverStrategy.py,sha256=
|
29
|
-
investfly/samples/strategies/SmaCrossOverTemplate.py,sha256=
|
28
|
+
investfly/samples/strategies/SmaCrossOverStrategy.py,sha256=e_gR8gwHJ5m6lU_Ib8jeQrER3cD6q569IIhwglKePew,1680
|
29
|
+
investfly/samples/strategies/SmaCrossOverTemplate.py,sha256=rLYVT8dYDx7TKx5PFI8nN4JzTHtx4pPlnZ9JvxWnBfo,8181
|
30
30
|
investfly/samples/strategies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
31
|
investfly/utils/CommonUtils.py,sha256=lCXAdI8-6PgbutcXJqUmSfuuLXp82FcnlxNVjCJpqLU,2631
|
32
|
-
investfly/utils/PercentBasedPortfolioAllocator.py,sha256=
|
32
|
+
investfly/utils/PercentBasedPortfolioAllocator.py,sha256=EHrOyHbaYHLwE-4vUSQCVXwbEgLs-nDjLVRH3cdgslI,1563
|
33
33
|
investfly/utils/__init__.py,sha256=2BqXoOQElv-GIU6wvmf2aaAABAcNny2TETcj7kf9rzM,129
|
34
|
-
investfly_sdk-1.
|
35
|
-
investfly_sdk-1.
|
36
|
-
investfly_sdk-1.
|
37
|
-
investfly_sdk-1.
|
38
|
-
investfly_sdk-1.
|
39
|
-
investfly_sdk-1.
|
34
|
+
investfly_sdk-1.4.dist-info/LICENSE.txt,sha256=Jmd2U7G7Z1oNdnRERRzFXN6C--bEo_K56j4v9EpJSTg,1090
|
35
|
+
investfly_sdk-1.4.dist-info/METADATA,sha256=V4g8ckW2EKMQw6XXoyT-MONak8Mrn-KJF113rYrl74E,7507
|
36
|
+
investfly_sdk-1.4.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
37
|
+
investfly_sdk-1.4.dist-info/entry_points.txt,sha256=GDRF4baJQXTh90DvdJJx1DeRezWfPt26E567lTs3g6U,66
|
38
|
+
investfly_sdk-1.4.dist-info/top_level.txt,sha256=dlEJ2OGWA3prqMvXELeydS5RTdpSzh7hz1LwR3NMc7A,10
|
39
|
+
investfly_sdk-1.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|