investfly-sdk 1.3__py3-none-any.whl → 1.5__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/api/py.typed ADDED
File without changes
@@ -15,7 +15,8 @@ class ModelUtils:
15
15
 
16
16
  @staticmethod
17
17
  def parseDatetime(date_str: str) -> datetime:
18
- dt = datetime.strptime(date_str, '%Y-%m-%dT%H:%M:%S.%f')
18
+ dateFormat = '%Y-%m-%dT%H:%M:%S.%f' if "." in date_str else '%Y-%m-%dT%H:%M:%S'
19
+ dt = datetime.strptime(date_str, dateFormat)
19
20
  dt = dt.astimezone(ModelUtils.est_tz)
20
21
  return dt
21
22
 
@@ -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, PositionType.LONG)
81
+ portfolioAllocator = PercentBasedPortfolioAllocator(10)
82
82
  return portfolioAllocator.allocatePortfolio(portfolio, tradeSignals)
83
83
 
84
84
  def getStandardCloseCondition(self) -> StandardCloseCriteria | None:
File without changes
@@ -11,7 +11,7 @@ from typing import Any, List, Dict
11
11
  import math
12
12
  import statistics
13
13
  import numpy as np
14
- import talib
14
+ import talib # type: ignore
15
15
  import pandas
16
16
 
17
17
  # ! WARN ! Imports other than listed above are disallowed and won't pass validation
@@ -1,7 +1,7 @@
1
1
  import datetime
2
2
  from typing import Any, List, Dict
3
3
  import numpy as np
4
- import talib
4
+ import talib # type: ignore
5
5
 
6
6
  from investfly.models import *
7
7
  from investfly.utils import *
@@ -1,7 +1,7 @@
1
1
  from typing import Any, List, Dict
2
2
 
3
3
  import numpy as np
4
- import talib
4
+ import talib # type: ignore
5
5
 
6
6
  from investfly.models import *
7
7
  from investfly.utils import *
@@ -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, PositionType.LONG)
33
+ portfolioAllocator = PercentBasedPortfolioAllocator(5)
34
34
  return portfolioAllocator.allocatePortfolio(portfolio, tradeSignals)
35
35
 
@@ -12,7 +12,9 @@ from typing import Any, List, Dict
12
12
  import math
13
13
  import statistics
14
14
  import numpy as np
15
- import talib # https://pypi.org/project/TA-Lib/
15
+
16
+ # https://pypi.org/project/TA-Lib/
17
+ import talib # type: ignore
16
18
  import pandas
17
19
  # ! WARN ! Imports other than listed above are disallowed and won't pass validation
18
20
 
@@ -95,7 +97,7 @@ class SmaCrossOverTemplate(TradingStrategy):
95
97
  """
96
98
 
97
99
  # We provide a convenience utility that allocates given percent (10% set below) of portfolio in the given stock
98
- portfolioAllocator = PercentBasedPortfolioAllocator(10, PositionType.LONG)
100
+ portfolioAllocator = PercentBasedPortfolioAllocator(10)
99
101
  return portfolioAllocator.allocatePortfolio(portfolio, tradeSignals)
100
102
 
101
103
  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 = 5.0
9
+ BROKER_FEE = 1.0
10
10
 
11
- def __init__(self, percent: float, positionType: PositionType) -> None:
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
- tradeType = TradeType.BUY if self.positionType == PositionType.LONG else TradeType.SHORT
18
- openPositionSecurities = {p.security for p in portfolio.openPositions if p.position == self.positionType}
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
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: investfly-sdk
3
- Version: 1.3
3
+ Version: 1.5
4
4
  Summary: Investfly SDK
5
5
  Author-email: "Investfly.com" <admin@investfly.com>
6
6
  License: The MIT License (MIT)
@@ -6,34 +6,37 @@ investfly/api/PortfolioApiClient.py,sha256=llNISIHWSx3wvf83usGhwPhVr-3RYGAndBNpZ
6
6
  investfly/api/RestApiClient.py,sha256=XjvJCqAqUMPa7tXkhxGwaOj1xgHkfLcA8Q0027Z6xm8,3236
7
7
  investfly/api/StrategyApiClient.py,sha256=w5_hQrxtQ7-1C1uu0UKL37ZbcjXmtdBAYXPtEiM-MC4,2087
8
8
  investfly/api/__init__.py,sha256=JeeOmrsPbVk4B26DT3hbvBoxAvkMEhJ-PeKeloNGF08,600
9
+ investfly/api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
10
  investfly/cli/InvestflyCli.py,sha256=SCRqC4GpaVPB7RDzMAgr7_GpEl0ai4GF1qlBKXsjUws,10565
10
11
  investfly/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
12
  investfly/models/CommonModels.py,sha256=kbyWsez1voii2K2wyflYCW7i9lYQh49nbrts4bTvvG4,2348
12
13
  investfly/models/Indicator.py,sha256=9v46Ozs2O8UPUjDzVC1MpoGx2iwnA__ZyrySVXxX8Qo,10660
13
14
  investfly/models/MarketData.py,sha256=NbyOh472uIXyHaTW9eYCBbiTu2szSq47iCz8i3qI1v0,6081
14
15
  investfly/models/MarketDataIds.py,sha256=CTNCb7G8NgLb84LYCqqxwlhO8e6RV-AUGwJH9GDv53A,3248
15
- investfly/models/ModelUtils.py,sha256=pnrVIDM26LqK0Wuw7gTs0c97lCLIV_fm0EUtlEfT7j4,964
16
+ investfly/models/ModelUtils.py,sha256=fdKO0hswgRALfSj8UvNSdtQyDo0QzDc10j3YXa0YIIA,1040
16
17
  investfly/models/PortfolioModels.py,sha256=wEHzaxEMEmliNR1OXS0WNzzao7ZA5qhKIPzAjWQuUOM,8658
17
18
  investfly/models/SecurityFilterModels.py,sha256=4baTBBI-XOKh8uTpvqVvk3unD-xHoyooO3dd5lKWbXA,5806
18
19
  investfly/models/SecurityUniverseSelector.py,sha256=N2cYhgRz3PTh6T98liiiTbJNg27SBpaUaIQGgDHFbF4,8645
19
20
  investfly/models/StrategyModels.py,sha256=n9MVOJFPtc_Wkiq5TyhdQnaiTUeXGMYqLmBE9IEiW10,5553
20
- investfly/models/TradingStrategy.py,sha256=uUgQpZRgioVADIKerdC5VD0LEy9LvDqEEGvtRTgWASM,6381
21
+ investfly/models/TradingStrategy.py,sha256=N1V0dZX6T2buVyg5NZL8inAKlLZSHZnrv-x2g9kxQBk,6362
21
22
  investfly/models/__init__.py,sha256=6uMfJwcYaH1r-T-bbh6gMud0VpnoSQTkPNDVMDE3JXo,1383
23
+ investfly/models/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
24
  investfly/samples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- investfly/samples/indicators/IndicatorTemplate.py,sha256=X0AlStLnL1SBSnTwrtW_sthm00tmuN5V7N-GrtiarmM,4454
25
+ investfly/samples/indicators/IndicatorTemplate.py,sha256=Pn3jGVjMVwhqN1-F5FTAUPm4caFa3ORORNtvL353iEc,4470
24
26
  investfly/samples/indicators/NewsSentiment.py,sha256=fcpAqOcNWmqYsP-xwJquCX_6G7Ntr3A1-m31eJHAUOE,65095
25
- investfly/samples/indicators/RsiOfSma.py,sha256=kiLvMhrsbc_lV0EEpERGW2im19u5XmyJk88aTDGSBis,1719
26
- investfly/samples/indicators/SmaEmaAverage.py,sha256=9pp3TtEKJADD_bfufwrWlwMswlTLoN7Nj6BC_jJ1sRs,1749
27
+ investfly/samples/indicators/RsiOfSma.py,sha256=fSPKYPF8vJqhRs2LvMZJp_e7pb5rBPpsXF7Fu3ZdS04,1735
28
+ investfly/samples/indicators/SmaEmaAverage.py,sha256=DrKPrcV4QaxKAp8lwQmFue-_LVteKnB-zgIgwx_25Bk,1765
27
29
  investfly/samples/indicators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- investfly/samples/strategies/SmaCrossOverStrategy.py,sha256=szjmnqQN8O7CRIS1vc-fRONKg4Dy1d59dZhiSEpEJAI,1699
29
- investfly/samples/strategies/SmaCrossOverTemplate.py,sha256=HSyVh89_d-k1aAzqs_WFt8EDxs809OjWq6V3VJVUNQw,8200
30
+ investfly/samples/strategies/SmaCrossOverStrategy.py,sha256=e_gR8gwHJ5m6lU_Ib8jeQrER3cD6q569IIhwglKePew,1680
31
+ investfly/samples/strategies/SmaCrossOverTemplate.py,sha256=5wDg1ecAC75ijnKs8hP6hG5EG9P58jLK_RRKTIrQnCI,8197
30
32
  investfly/samples/strategies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
33
  investfly/utils/CommonUtils.py,sha256=lCXAdI8-6PgbutcXJqUmSfuuLXp82FcnlxNVjCJpqLU,2631
32
- investfly/utils/PercentBasedPortfolioAllocator.py,sha256=oKaSjq5L_3NfRo2iayepCZtZnCevsx4XpsxFfZMTnV8,1684
34
+ investfly/utils/PercentBasedPortfolioAllocator.py,sha256=EHrOyHbaYHLwE-4vUSQCVXwbEgLs-nDjLVRH3cdgslI,1563
33
35
  investfly/utils/__init__.py,sha256=2BqXoOQElv-GIU6wvmf2aaAABAcNny2TETcj7kf9rzM,129
34
- investfly_sdk-1.3.dist-info/LICENSE.txt,sha256=Jmd2U7G7Z1oNdnRERRzFXN6C--bEo_K56j4v9EpJSTg,1090
35
- investfly_sdk-1.3.dist-info/METADATA,sha256=Nxdk0L1ZE5eKcJzRVbofnXgfkQs6NGEUAMRFOimKZqo,7507
36
- investfly_sdk-1.3.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
37
- investfly_sdk-1.3.dist-info/entry_points.txt,sha256=GDRF4baJQXTh90DvdJJx1DeRezWfPt26E567lTs3g6U,66
38
- investfly_sdk-1.3.dist-info/top_level.txt,sha256=dlEJ2OGWA3prqMvXELeydS5RTdpSzh7hz1LwR3NMc7A,10
39
- investfly_sdk-1.3.dist-info/RECORD,,
36
+ investfly/utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ investfly_sdk-1.5.dist-info/LICENSE.txt,sha256=Jmd2U7G7Z1oNdnRERRzFXN6C--bEo_K56j4v9EpJSTg,1090
38
+ investfly_sdk-1.5.dist-info/METADATA,sha256=mf8Zji3FmIY8S0Lk2hJocJftq1oNr604BdKhp_SFx3s,7507
39
+ investfly_sdk-1.5.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
40
+ investfly_sdk-1.5.dist-info/entry_points.txt,sha256=GDRF4baJQXTh90DvdJJx1DeRezWfPt26E567lTs3g6U,66
41
+ investfly_sdk-1.5.dist-info/top_level.txt,sha256=dlEJ2OGWA3prqMvXELeydS5RTdpSzh7hz1LwR3NMc7A,10
42
+ investfly_sdk-1.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.3.0)
2
+ Generator: setuptools (75.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5