Get notified when a crypto pair goes above your desired price.
docker compose up --buildConnect to the web socket server on ws://127.0.0.1:9090/ws
send payload
{
"cmd": "watch",
"symbol": "btcusdc",
"price": 1.0
}You will get a response on the web socket connection on the next trade to Take profit on btcusdc.
cmd No need to change, watch is currently the only command.
symbol must be a lowercase coin pair available on Binance.
price can be any floating point number but INF is sure to cause issues.
ingestsubscribes to default symbols and starts streaming prices.ingestadds prices to an internal queue with thesymbol,current_priceandprice_target.watchchecks each added price to see if a there is a price watch.- if
watchfinds the price of a symbol has gone over any requested threshold, it will publish aprice_above_targetevent. watchlistens to it's ownprice_above_targetevents to purge the price watch list of that price point. This has a race condition edge case in multi-user environments.apilistens toprice_above_targetevents. If there is an event, any users watching this symbol at this price will be notified to take profit.apiwaits for a user to connect to the websocket endpoint.- when user sends a valid command to the
apiawatchcommand is published internally with thesymbol, andprice_target. ingestprocess the command queue forwatchcommands.ingestwill subscribe to the symbol in the command.ingestpublishes awatchedevent with the thesymbol, andprice_target.watchlistens forwatchedmessages and will add thesymbol, andprice_targetto the watched list.
- Error checking is very light, and things are sure to blow up if the happy path is not adheared to.
- There is no way for a user to stop watching, or unsubscribe from a symbol.
- Once a symbol is subscribed to the system will always be subscribed to that symbol untill redis restart.
- The control flow is confusing.
- Better documentation.