INNER CODE UNIT · Python

_update_open_long_positions_statistics

Erfaniaa/crypto-trading-strategy-backtester · backtester.py:415

	def _update_open_long_positions_statistics(self):
		open_long_positions_count = len(self.open_long_positions_list)
		for i in range(open_long_positions_count):
			self.open_long_positions_list[i].max_profit_percent = max(self.open_long_positions_list[i].max_profit_percent, 100 * (self.current_candle.close - self.open_long_positions_list[i].entry_price) / self.open_long_positions_list[i].entry_price)
			self.open_long_positions_list[i].min_profit_percent = min(self.open_long_positions_list[i].min_profit_percent, 100 * (self.current_candle.close - self.open_long_positions_list[i].entry_price) / self.open_long_positions_list[i].entry_price)


	def _update_open_short_positions_statistics(self):
		open_short_positions_count = len(self.open_short_positions_list)
		for i in range(open_short_positions_count):
			self.open_short_positions_list[i].max_profit_percent = max(self.open_short_positions_list[i].max_profit_percent, -100 * (self.current_candle.close - self.open_short_positions_list[i].entry_price) / self.open_short_positions_list[i].entry_price)
			self.open_short_positions_list[i].min_profit_percent = min(self.open_short_positions_list[i].min_profit_percent, -100 * (self.current_candle.close - self.open_short_positions_list[i].entry_price) / self.open_short_positions_list[i].entry_price)


	def _check_conditions_to_close_long_position(self):
		main_condition = self.is_price_decreasing and not self.last_is_price_decreasing
		open_long_positions_count = len(self.open_long_positions_list)
		for i in reversed(range(open_long_positions_count)):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…