Hi team, Im completely new in Flink and would real...
# random
l
Hi team, Im completely new in Flink and would really apreciate some help in how to solve the following use case. In stock trading, Market makers are institutions that are hired by the stock exchange providing liquidity for some stocks and for so they must act on a daily basis keeping some stock tickers in the orders book respecting the activity parameters like (minimum amount, maximum spread between the buy and sell price and percentage of activity in trading session that usualy is from 09.00 to 18.00). I need to create a query to monitor in near real time or in a small time window those institutions that are not following the one of this three parameters. For the parameter that state percentage of activity in trading session that usualy is from 09.00 to 18.00) I also need to report how many time/hour it institutions broke the rule. Any help with mockup of queries are really welcome and would help me a lot. Thanks and Regards Slack Conversation
k
For complex rules like this, you can either use Flink’s CEP support, or (what I usually do) handle it via a custom KeyedProcessFunction. You would want to ensure you have a stream of data with correct event time/watermarks set, then
.keyBy(<market maker>)
, followed by
.process(new MarketMakerAlertingFunction())
. Inside of
MarketMakerAlertingFunction
, you would use state (probably keyed by each stock symbol, in
MapState
) to track activity, and timers to regularly inspect state/trigger alerts/clear state.