How Mudrex executes a strategy?

The objective of this piece is to give you an overview of what goes on inside Mudrex systems once you make a strategy live for real trades.

A key part of Mudrex systems are getting the latest OHLCV data from exchanges for all assets, processing that data to use for signal calculations and placing orders on exchanges if buy or sell signal is generated. This is how overall flow happens.

Mudrex strategy running flow

Data Polling

As a trader, it is very important for you to access market information as soon as possible. We pull OHLCV data from exchanges every minute for each asset pair. Then that data is resampled for each available time frame. Currently, we support 1m, 3m, 5m, 10m, 15m, 30m, 1H, 2H, 4H, 6H, 1D, 3D and 1W as timeframes to apply in strategies. For example, 15 min timeframe data would be resampled at 8:00, 8:15, 8:30… and 1H data would be resampled at 8:00, 9:00, 10:00…

Starting a strategy

Once you assign a budget to a strategy and put it live to trade, your strategy goes into ‘initiated’ state and your assigned balance get locked from available balance to ‘in-trade’ balance. The strategy then waits for its first tick data according to its timeframe. As soon as it gets its first tick data the strategy status gets changed to ‘running’ status.

For example, if you have selected 15 min time interval for your strategy and you make the strategy live at 9:16. Till 9:30 the strategy would remain in initiated status and at 9:30 the strategy gets its first tick data and the status gets changed from ‘initiated’ to ‘running’. That’s when you start seeing the results of the strategy.

Strategy in initiated state

Strategy in running state

Generating buy/sell signals

Strategy pulls the latest tick data for its time interval. Once the data is pulled all the required calculations are done to check if there is a buy/sell condition match. For an example, if a simple RSI strategy is running which buys when RSI < 30 and sells when the RSI > 70 and is running with a time interval of 30 min. The strategy pulls the latest data at 8:00, 8:30, 9:00….. and calculates RSI using the latest data at these time intervals. If the RSI satisfy the above conditions, a buy/sell signal is generated.

Placing orders

As described above, if a buy/sell signal is generated by a strategy our order placing system checks for user balance and if there is sufficient balance then a market order is placed. We intentionally put market orders instead of the limit order to ensure order fulfilment. After that we keep track of the order and as the order gets fulfilled user balance gets updated. We protect traders from large slippage by cancelling an order automatically if the slippage exceeds 2%. Traders can see each order’s detail in their respective profiles.

Fee Deductions:

Fees are deducted once a trade is completed. Right now, Mudrex doesn’t charge any fee and the only fee deducted would be exchanges fees. Fee could be different depending on the exchange you want to trade on.

Example: You put a strategy live on Binance for ETH/BTC market with 1 BTC balance.

If a buy signal is generated, an order would be put on Binance to buy ETH for 1 BTC at market price

Assuming market price at 1 ETH = 0.02 BTC and Binance fees = 0.1% you will get:

1/0.02 – Binance fee => 50 – 0.001*50 = 49.95 ETH (0.05 ETH would be deducted as fee)

Similarly in case of sell of 50 ETH you will get
50/50 – Binance fee => 1 – 0.001*1 = 0.999 BTC (0.001 BTC would be deducted as fee)

Stopping a Strategy

A strategy could be stopped anytime a trader wants. A button in the user interface is available to stop a strategy from live trading. Once a user stops a strategy we wait for the next tick to complete the strategy and close any open position if there is any. As soon as the positions are closed and the strategy is stopped your balance transferred from in-trade balance to available balance and trader can withdraw it anytime.