How to get alerts when a function value changes using mongo db and python?

Viewed 67

I have been working with mongo db and python in prevailing times. I tried searching for ideas for my code workflow on google but couldn't find any, any kind of help is appreciated.

  1. I am updating my MongoDB every second with stock market data.

  2. On the basis of OHLC data I can calculate moving averages of different days let's say 20daysMA and 50daysMA

  3. Now I want to auto calculate moving average features and send me an alert when a certain condition is met(for example 20dayMA crossed 50dayMA)

I have used pandas dataframe to calculate 20dayMA and 50dayMA and setting crossover conditions that tell the index when the crossover happned. (cross_over is a derived column of bool type values)

But I have no idea of how do I calculate something when my database gets updated every second and check the condition in every insert and then send an alert when the condition becomes true.

Any kind of examples, references to solve this problem would be a great help.

0 Answers
Related