INNER CODE UNIT · Python

current_position_value

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

					current_position_value = (1 + self.open_long_positions_list[i].profit_percent * self.open_long_positions_list[i].leverage / 100) * self.open_long_positions_list[i].first_coins_in_position
					current_position_profit = (self.open_long_positions_list[i].profit_percent * self.open_long_positions_list[i].leverage / 100) * self.open_long_positions_list[i].first_coins_in_position
					if current_position_profit > 0:
						self.total_wins += 1
					self.total_first_coins += current_position_value * (1 - self.close_position_fee_percent / 100)
					self.closed_positions_list.append(self.open_long_positions_list[i])
					self.open_long_positions_list = self.open_long_positions_list[:-1]


	def _check_conditions_to_close_short_position(self):
		main_condition = self.is_price_increasing and not self.last_is_price_increasing
		open_short_positions_count = len(self.open_short_positions_list)
		for i in reversed(range(open_short_positions_count)):
			if self.current_candle.low < self.open_short_positions_list[i].take_profit_price or \
				self.current_candle.high > self.open_short_positions_list[i].stop_loss_price or \
				main_condition:
					self.last_position_status += self.CLOSE_SHORT_POSITION
					recent_candles_list = self.open_short_positions_list[i].recent_candles_list

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…