Package edu.yu.marketmaker.state
Class TradingStateService
java.lang.Object
edu.yu.marketmaker.state.TradingStateService
Trading state service controls system-wide positions.
-
Constructor Summary
ConstructorsConstructorDescriptionTradingStateService(Repository<String, Position> positionRepository, Repository<UUID, Fill> fillRepository) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Flux<Position> TCP/RSocket: get all current positions via request-stream on route"positions".reactor.core.publisher.Mono<Position> getPositionRSocket(String symbol) TCP/RSocket: get a specific position via request-response on route"positions.{symbol}".reactor.core.publisher.Flux<StateSnapshot> RSocket request-stream endpoint.reactor.core.publisher.Mono<Void> submitFillRSocket(Fill fill) TCP/RSocket: submit a fill via request-response on route"state.fills".
-
Constructor Details
-
TradingStateService
public TradingStateService(Repository<String, Position> positionRepository, Repository<UUID, Fill> fillRepository) Constructor.- Parameters:
positionRepository-fillRepository-
-
-
Method Details
-
submitFillRSocket
@MessageMapping("state.fills") public reactor.core.publisher.Mono<Void> submitFillRSocket(@Payload Fill fill) TCP/RSocket: submit a fill via request-response on route"state.fills".- Parameters:
fill- the fill to record- Returns:
Monothat completes empty on success, or errors on invalid input
-
getAllPositionsRSocket
TCP/RSocket: get all current positions via request-stream on route"positions". Each position is emitted as a separate item, then the stream completes.- Returns:
- a
Fluxthat emits every currentPositionand then completes
-
getPositionRSocket
@MessageMapping("positions.{symbol}") public reactor.core.publisher.Mono<Position> getPositionRSocket(@DestinationVariable String symbol) TCP/RSocket: get a specific position via request-response on route"positions.{symbol}". Example route:"positions.AAPL"- Parameters:
symbol- ticker symbol extracted from the route- Returns:
- a
Monoemitting thePosition, or empty if not found
-
streamPositions
RSocket request-stream endpoint. Connect via TCP to port 7000 (spring.rsocket.server.port) and send route"state.stream".The subscriber first receives a
StateSnapshotfor every position that already exists at subscription time (the current snapshot), and then continues to receive a newStateSnapshotevery time a fill is submitted that updates a position – i.e. the stream never completes while the connection is open.- Returns:
- a hot
FluxofStateSnapshotitems
-