Spaces:
Sleeping
Sleeping
| package com.rods.backtestingstrategies.entity; | |
| import jakarta.persistence.*; | |
| import lombok.*; | |
| import java.time.LocalDate; | |
| // JPA requirement | |
| // force factory usage | |
| public class CrossOver { | |
| private Long id; | |
| // Date when crossover occurred | |
| private LocalDate date; | |
| private CrossOverType type; // BULLISH or BEARISH | |
| // Price at crossover | |
| private double price; | |
| /* ========================== | |
| Factory Methods | |
| ========================== */ | |
| public static CrossOver bullish(Candle candle) { | |
| return new CrossOver( | |
| null, | |
| candle.getDate(), | |
| CrossOverType.BULLISH, | |
| candle.getClosePrice() | |
| ); | |
| } | |
| public static CrossOver bearish(Candle candle) { | |
| return new CrossOver( | |
| null, | |
| candle.getDate(), | |
| CrossOverType.BEARISH, | |
| candle.getClosePrice() | |
| ); | |
| } | |
| } | |