Interface AntherTradingStrategy<P extends BasicAntherTradingStrategyParameters>

Type Parameters:
P - child of BasicAntherTradingStrategyParameters
All Known Implementing Classes:
BloomTradingStrategy
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface AntherTradingStrategy<P extends BasicAntherTradingStrategyParameters>
Defines a trading strategy, an algorithmic method of placing and exiting financial market positions.
Version:
2.0.3
Author:
Stephen Prizio
  • Method Details

    • executeStrategy

      AntherTradingStrategyResult<P> executeStrategy(P parameters)
      Executes a AntherTradingStrategy with the given parameters.
      Parameters:
      parameters - P
      Returns:
      AntherTradingStrategyResult
    • openPosition

      default AntherPosition openPosition(PositionType positionType, double lotSize, LocalDateTime positionOpened, double openPrice, double stopLoss, double takeProfit)
      Creates a new AntherPosition that is considered active. In this case active means that an AntherPosition does not yet have a close price.
      Parameters:
      positionType - PositionType
      lotSize - position size
      positionOpened - time of open
      openPrice - price at open
      stopLoss - limit loss
      takeProfit - limit profit
      Returns:
      AntherPosition
    • closePosition

      default void closePosition(AntherPosition position, LocalDateTime positionClosed, double closePrice)
      Updates the given AntherPosition with a close time and price.
      Parameters:
      position - AntherPosition
      positionClosed - close time
      closePrice - close price
    • calculateLimit

      default double calculateLimit(double price, double increment, boolean shouldAdd)
      Calculates the limit used as either a take profit or stop loss.
      Parameters:
      price - trade price
      increment - increment to add or subtract
      shouldAdd - if true, add
      Returns:
      limit level
    • checkPositions

      default void checkPositions(Map<String, AntherPosition> openPositions, Map<String, AntherPosition> closedPositions, MarketPrice marketPrice)
      Checks whether the given MarketPrice closes an open AntherPosition.
      Parameters:
      openPositions - currently opened positions
      closedPositions - previously closed positions
      marketPrice - MarketPrice
    • closeDay

      default void closeDay(MarketPrice currentPrice, Map<String, AntherPosition> openPositions, Map<String, AntherPosition> closedPositions)
      Closes the day, meaning close all positions on the exit signal.
      Parameters:
      currentPrice - MarketPrice current bar
      openPositions - open positions
      closedPositions - closed positions