rename positions => all_positions
This commit is contained in:
@@ -1204,7 +1204,7 @@ class Strategy(ABC):
|
||||
raise ValueError(f'log_type should be either "info" or "error". You passed {log_type}')
|
||||
|
||||
@property
|
||||
def positions(self) -> Dict[str, Position]:
|
||||
def all_positions(self) -> Dict[str, Position]:
|
||||
positions_dict = {}
|
||||
for r in self.routes:
|
||||
positions_dict[r.symbol] = r.strategy.position
|
||||
@@ -1213,6 +1213,6 @@ class Strategy(ABC):
|
||||
@property
|
||||
def portfolio_value(self) -> float:
|
||||
total_position_values = 0
|
||||
for key, p in self.positions.items():
|
||||
for key, p in self.all_positions.items():
|
||||
total_position_values += p.pnl
|
||||
return (total_position_values + self.capital) * self.leverage
|
||||
|
||||
@@ -17,7 +17,7 @@ class TestPortfolioValue(Strategy):
|
||||
# print('self.available_margin', self.available_margin)
|
||||
# print('self.capital', self.capital)
|
||||
# print('=========')
|
||||
assert round(self.portfolio_value) == round((self.capital + self.positions['ETH-USDT'].pnl + self.positions['BTC-USDT'].pnl) * self.leverage)
|
||||
assert round(self.portfolio_value) == round((self.capital + self.all_positions['ETH-USDT'].pnl + self.all_positions['BTC-USDT'].pnl) * self.leverage)
|
||||
|
||||
def should_long(self) -> bool:
|
||||
return self.index == 0 and self.symbol == 'ETH-USDT'
|
||||
|
||||
@@ -4,7 +4,7 @@ from jesse.strategies import Strategy
|
||||
class TestPositions(Strategy):
|
||||
def before(self):
|
||||
if self.index == 0:
|
||||
assert self.positions[self.symbol] == self.position
|
||||
assert self.all_positions[self.symbol] == self.position
|
||||
|
||||
def should_long(self) -> bool:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user