Description

This assessment is related to the topic of Directional Changes. You are provided with a complete working version of a BlueJ project that detect Directional Changes events from a price interval, which you can use as the basis for your implementation.

Your task is to improve the Direction Changes (DC) detection and trading algorithm to

1) perform the trade using information from multiple DC thresholds.

2) optimize the choice of threshold using a Genetic Algorithm (GA).

You are given an initial implementation ( ) that includes:

Reading a CSV files with prices:

Detecting DC events given a threshold: detect(double delta)

Simulate a trading session: trade() For this coursework, you should use the TickData.csv as the source of prices. Part 1: Supporting multiple DC thresholds [40%] Your first task is to modify the provided java code to support multiple DC thresholds. This will involve:

(10%) Specify 10 different threshold values between 0.01 and 0.2;

(10%) Store the list of detected events for each of the 10 different thresholds;

(20%) Modify the trading simulation to use the information from multiple thresholds:

Accumulate a recommendation based on multiple thresholds (each threshold makes a recommendation and the recommended action is chosen based on the majority);

Perform the selected recommendation: BUY when Upturn recommendation; SELL when Downturn recommendation. These actions only occur if buying at a price lower than the last sell; selling at a price higher than the last buy.

Run the trading simulation after your modification and save the result (profit).

Detector.java

load()

Part 2: Optimize action selection using a Genetic Algorithm [60%]

After the improvements completed in Part 1, your trading simulation has a fixed rule to choose which action to take: the action with most recommendations is performed. You can view this as each threshold being associated with the same weight, so each threshold has the same “voting power.” This is not necessarily optimal, since there might be a single or minority of thresholds that are often more accurate than others. Your task is to optimize the selection of the action based on a weight: each threshold is associated with a weight and the action with the highest sum of weights gets performed.

To complete this task, you will need to implement a Genetic Algorithm:

(5%) Associate a weight between [0, 1] to each threshold (individual representation);

(10%) Randomly initialize a population of candidate individuals;

(5%) Evaluate the quality of individuals by simulating a trading session using the individuals’ weights to decide on the trading action. This should follow the same rules as the trading simulation from Part 1;

(10%) Perform a fitness based selection (roulette or tournament selection) to decide which individuals will be part of the next generation;

(20%) Apply genetic operators (crossover and mutation) to generate new individuals;

(10%) Repeat steps 3-5 for a number of generations.

At the end of the execution, you should report the best individual fitness (profit) and compare with the profit obtained with the strategy of Part 1.