Class BaseFlux<T>

java.lang.Object
tech.cassandre.trading.bot.util.base.Base
tech.cassandre.trading.bot.util.base.batch.BaseFlux<T>
Type Parameters:
T - flux
Direct Known Subclasses:
AccountFlux, OrderFlux, PositionFlux, TickerFlux, TradeFlux

public abstract class BaseFlux<T> extends Base
Base flux.

update() method is called by schedulers, and it does two things: - Calls the getNewValues() method you implemented to retrieve new values from "outside" (for example: call the service to retrieve new tickers). - For each value retrieved previously, we call the saveValues() method you implemented to save all the data in the database. - Each value saved in database is then push to the flux to be consumed by strategies. note: you are not forced to implement getNewValues() or saveValues().

  • Field Details

    • flux

      protected final reactor.core.publisher.Flux<Set<T>> flux
      Flux.
    • fluxSink

      protected reactor.core.publisher.FluxSink<Set<T>> fluxSink
      Flux sink.
  • Constructor Details

    • BaseFlux

      public BaseFlux()
      Constructor.
  • Method Details

    • getOverflowStrategy

      protected reactor.core.publisher.FluxSink.OverflowStrategy getOverflowStrategy()
      Set the default overflow strategy - override to change it.
      Returns:
      overflow strategy
    • getFlux

      public reactor.core.publisher.Flux<Set<T>> getFlux()
      Getter for flux.
      Returns:
      flux
    • update

      public final void update()
      Method executed when values have to be retrieved (usually called by schedulers).
    • emitValue

      public void emitValue(T newValue)
      Emit new value.
      Parameters:
      newValue - new value
    • emitValues

      public void emitValues(Set<T> newValues)
      Emit new values.
      Parameters:
      newValues - new values
    • getNewValues

      protected Set<T> getNewValues()
      Implements this method to return all the new values. Those values will be sent to the strategy.
      Returns:
      list of new values
    • saveValues

      protected Set<T> saveValues(Set<T> newValue)
      Implements this method to save values coming from flux.
      Parameters:
      newValue - new value
      Returns:
      the value saved