Coverage for source/agent/agents/simple_trading_algorithm.py: 29%
14 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-08-01 20:51 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-08-01 20:51 +0000
1# agent/agents/simple_trading_algorithm.py
3# global imports
4import numpy as np
6# local imports
7from source.agent import TradingAlgorithmBase
9class SimpleTradingAlgorithm(TradingAlgorithmBase):
10 """"""
12 def perform_action(self, trend_predictions: int, market_data: np.ndarray) -> int:
13 """
14 Performs the trading action based on the trend predictions and market data.
16 Parameters:
17 trend_predictions (np.ndarray): The predicted trends.
18 market_data (np.ndarray): The current market data.
20 Returns:
21 (int): The result of the trading action.
22 """
24 current_trades_occupancy_coeff = market_data[1]
25 import logging
27 action = None
28 # UP_TREND
29 if trend_predictions == 0:
30 action = 0 if current_trades_occupancy_coeff < 1 else 1
31 # DOWN_TREND
32 elif trend_predictions == 1:
33 action = 2 if current_trades_occupancy_coeff < 1 else 1
34 # NO_TREND
35 else:
36 action = 1
38 logging.info(f"Performing action with trend_predictions: {current_trades_occupancy_coeff}, {action}")
39 return action