MCPcopy Index your code
hub / github.com/kernc/backtesting.py / close

Method close

backtesting/backtesting.py:388–393  ·  view source on GitHub ↗

Close portion of position by closing `portion` of each active trade. See `Trade.close`.

(self, portion: float = 1.)

Source from the content-addressed store, hash-verified

386 return self.size < 0
387
388 def close(self, portion: float = 1.):
389 """
390 Close portion of position by closing `portion` of each active trade. See `Trade.close`.
391 """
392 for trade in self.__broker.trades:
393 trade.close(portion)
394
395 def __repr__(self):
396 return f'<Position: {self.size} ({len(self.__broker.trades)} trades)>'

Callers

nothing calls this directly

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected