Interface DataStructureInterface


public interface DataStructureInterface
Interface used by strategies to interact with data structure

Methods that return a list of DataStructureInterface.TreeResponseInterval split the requested time range into intervals in an approximate way. For performance reasons data is stored pre-aggregated in fixed-size blocks, and each interval is built from whole blocks instead of individual events. Block positions are unrelated to the requested times, so interval boundaries are shifted from the requested ones, by up to one block (about intervalWidth / 5 with default settings); only the end of the last interval is exact. An event that happened just before a requested boundary can therefore be counted in the neighboring interval. The reported timestamps hide most of this: all elements except the last are labeled with the requested times, only the last element shows its real boundary. If exact [t0, t1) boundaries are needed, getRawEvents(long, long, java.lang.String, velox.api.layer1.messages.indicators.DataStructureInterface.StandardEvents[]) can be used to retrieve all raw events from that interval directly.

  • Method Details

    • get

      ArrayList<DataStructureInterface.TreeResponseInterval> get(long t0, long intervalWidth, int intervalNumber, String alias, DataStructureInterface.StandardEvents[] interestedEvents)
      Query for standard events Returns list, containing aggregation from start time to t0 exclusive, followed by list of aggregations for the interval [t0, t0 + intervalWidth * intervalNumbers), divided by intervalNumber parts
      Parameters:
      t0 - start time (inclusive)
      intervalWidth -
      intervalNumber -
      alias -
      interestedEvents - array of standard tree events that should be returned
      Returns:
      0th element is aggregation from start time to t0 exclusive elements 1 to intervalNumber are aggregations of following intervals
    • get

      List<DataStructureInterface.TreeResponseInterval> get(Class<?> strategyClass, String generatorName, long t0, long intervalWidth, int intervalNumber, String alias, Class<?>[] customEvents)
      Query for custom events. All events in this request must be generated by the same generator, owned by this strategy. If you need events from more then 1 generator, do multiple gets Returns list, containing aggregation from start time to t0 exclusive, followed by list of aggregations for the interval [t0, t0 + intervalWidth * intervalNumbers), divided by intervalNumber parts
      Parameters:
      strategyClass - class of strategy that owns generator
      generatorName - name of generator that generated events (same as one given to Layer1ApiUserMessageAddStrategyUpdateGenerator) constructor
      t0 - start time (inclusive)
      intervalWidth -
      intervalNumber -
      alias -
      customEvents - array of value classes (provided in GeneratedEventInfo.valueClass) for custom events you want to retrieve
      Returns:
      0th element is aggregation from start time to t0 exclusive elements 1 to intervalNumber are aggregations of following intervals
    • get

      List<Object> get(Class<?> strategyClass, String generatorName, long t0, long t1, String alias) throws IllegalArgumentException
      Query for custom events. Returns all events in range [t0, t1), generated by this generator
      Parameters:
      strategyClass - class of strategy that owns generator
      generatorName - name of generator that generated events (same as one given to Layer1ApiUserMessageAddStrategyUpdateGenerator) constructor
      t0 - start time (inclusive)
      t1 - end time (exclusive)
      alias -
      Returns:
      list of events, created by generator in time range [t0, t1). Events are sorted in order they were generated and have ascending CustomGeneratedEvent.getTime()
      Throws:
      IllegalArgumentException - if this generator uses aggregated events
    • get

      Similar to get(long, long, int, String, StandardEvents[]) but returns a single aggregation from the first event to t1. [-inf, t1]
      Parameters:
      t1 -
      alias -
      interestedEvents - array of standard tree events that should be returned
      Returns:
      aggregation [-inf, t1] for given events
    • get

      DataStructureInterface.TreeResponseInterval get(Class<?> strategyClass, String generatorName, long t1, String alias, Class<?>[] customEvents)
      Similar to get(Class, String, long, long, int, String, Class[]) but returns a single aggregation from the first event to t1. [-inf, t1]
      Parameters:
      strategyClass - class of strategy that owns generator
      generatorName - name of generator that generated events (same as one given to Layer1ApiUserMessageAddStrategyUpdateGenerator) constructor
      t1 -
      alias -
      customEvents - array of value classes (provided in GeneratedEventInfo.valueClass) for custom events you want to retrieve
      Returns:
      aggregation [-inf, t1] for given events
    • get

      List<? extends CustomGeneratedEvent> get(Class<?> strategyClass, String generatorName, long t1, String alias) throws IllegalArgumentException
      Parameters:
      strategyClass - class of strategy that owns generator
      generatorName - name of generator that generated events (same as one given to Layer1ApiUserMessageAddStrategyUpdateGenerator) constructor
      t1 -
      alias -
      Returns:
      list of events, created by generator in time range [-inf, t1]. Events are sorted in order they were generated and have ascending CustomGeneratedEvent.getTime()
      Throws:
      IllegalArgumentException - if this generator uses aggregated events
    • getRawEvents

      default List<Event> getRawEvents(long t0, long t1, String alias, DataStructureInterface.StandardEvents[] interestedEvents)
      Returns raw (non-aggregated) events for given alias in time range [t0, t1), clamped to the current time. Unlike get(long, long, int, String, StandardEvents[]) boundaries are exact: an event is included if and only if t0 <= event time < t1.

      Returned objects are concrete subclasses of Event corresponding to requested types (e.g. TradeEvent for TRADE, DepthEvent for DEPTH), sorted by Event.getTime(). For ORDER the same account visibility rules are applied as in get(long, long, int, String, StandardEvents[]), but executions are returned as stored: unlike that method, the ones predating the initial position are not filtered out.

      Cost and memory are proportional to the number of events in the range (there is no aggregation), so prefer narrow ranges; DEPTH/MBO over long ranges can return millions of events.

      Parameters:
      t0 - start time (inclusive)
      t1 - end time (exclusive)
      alias -
      interestedEvents - array of standard tree events that should be returned
      Returns:
      raw events of requested types in [t0, t1), sorted by time
    • getByProvider

      ArrayList<DataStructureInterface.TreeResponseInterval> getByProvider(long t0, long intervalWidth, int intervalNumber, String providerProgrammaticName, DataStructureInterface.StandardEvents[] interestedEvents)
      Query for standard events from provider tree Returns list, containing aggregation from start time to t0 exclusive, followed by list of aggregations for the interval [t0, t0 + intervalWidth * intervalNumbers), divided by intervalNumber parts
      Parameters:
      t0 - start time (inclusive)
      intervalWidth -
      intervalNumber -
      providerProgrammaticName - programmatic name of provider
      interestedEvents - array of standard tree events that should be returned
      Returns:
      0th element is aggregation from start time to t0 exclusive elements 1 to intervalNumber are aggregations of following intervals
    • getByProvider

      DataStructureInterface.TreeResponseInterval getByProvider(long t1, String providerProgrammaticName, DataStructureInterface.StandardEvents[] interestedEvents)
      Similar to getByProvider(long, long, int, String, StandardEvents[]) but returns a single aggregation from the first event to t1. [-inf, t1]
      Parameters:
      t1 -
      providerProgrammaticName - programmatic name of provider
      interestedEvents - array of standard tree events that should be returned
      Returns:
      aggregation [-inf, t1] for given events