Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add targt weights to portfolio
  • Loading branch information
kic committed Apr 25, 2021
commit 6ca7764a213bd0aaf03c1535aec734045b03db90
6 changes: 6 additions & 0 deletions pandas-ml-quant/pandas_ml_quant/portfolio/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class TargetWeight(Quantity):
def __init__(self, v: float):
assert -1 <= v <= 1, 'Weighs need to be between -1 and 1'
super().__init__(v)
self.warned_fee = False

def value(self,
lazy_current_portfolio: Callable[[str, str], pd.DataFrame],
Expand All @@ -72,6 +73,11 @@ def value(self,
price: float = None,
fee: float = 0,
):
if fee != 0:
if not self.warned_fee:
_log.warning("we can't handle fees properly using TargetWeight. Your PriceTimeseries should use bid/ask or spread!")
self.warned_fee = True

def evaluate(pos: pd.Series):
if pos.empty:
return 0
Expand Down