perpdex
Published in

perpdex

Order dependency of trade execution

Summary

  • Results of multiple trade executions (positions, avg entry price, margin) depend on the order of execution.
  • This makes it more difficult to handle programmatically
  • We have tried to come up with an alternative method that does not depend on the order of execution.
Photo by Lili Popper on Unsplash

Problem settings

Question

Is there a reasonable alternative trade rule that the final states do not depend on the order of execution?

Settings

  • Assume an account where all positions are combined and calculated (major CEX is in this rule)
  • States are position, entry price, and margin balance.
  • These states change depending on the execution of the trade
  • Traders can use this rule to execute multiple pending trades at once at any given point in time. If executed frequently, the rules will be the same as the normal rules. In other words, traders can choose between alternative rules and normal rules.

Freedom of the final states

  • No matter which order they are executed in, the position will have the same result.
  • No matter which order they are executed, the margin balance minus entry price * position will be the same
  • So, there is only one degree of freedom, for example, if the entry price is determined, the other states are determined.
  • The entry price falls between the minimum and maximum entry price for each execution

What is reasonable trade rule?

There are several perspectives

  • For exchanges, the smaller the unrealized loss, the lower the risk.
  • Traders can reduce unrealized PnL by trading, but not vice versa. Therefore, the smaller the absolute value of unrealized PnL, the narrower the trader’s options and the fewer the options for attack
  • It is natural if the result is continuous for all input variables. It is not good if the result changes abruptly depending on the sign.
  • The less execution and profit-taking processes, the smaller the computational cost.
  • Simple rules are good.

Method 1

Method

  • Consider all executions as one execution averaged together and execute against the initial state.

Analysis

  • Mixing the buy and sell and taking an average is not in the best nature because the entry price may be out of range. (It is easy to understand when considering the two-dimensional plane of position and notional value)
  • This means that this could result in impossible states in exact executions.

Method 2

Method

  • Separate the buy and sell and take an average of each.
  • First, execute a trade in the same direction as the current position, then execute the opposite trade

Analysis

  • One profit-taking process
  • The final entry price is either the average of the initial state and the entry price of the first execution, or the entry price of the second execution
  • The only branch that can cause a discontinuity is the sign of the initial position
  • When the initial position is negligibly small, changing the order of execution between the first and second executions does not change the result. So, it is continuous.
  • This execution result can be reproduced by adjusting the order with accurate execution

Conclusion

Method 2 looks good.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store