zetamarkets / sdk

SDK for accessing the Zeta program
Other
85 stars 29 forks source link

Trigger orders (StopLoss/TakeProfit) #251

Closed filipzeta closed 1 year ago

filipzeta commented 1 year ago

This PR implements trigger orders, which will be utilised for stop-loss/take-profit functionality.

Functionality defaults to FillOrKill with trigger direction acting as a stop-loss/take-profit order (INCREASING if Ask, DECREASING if Bid), but you can use any order type and direction you wish to create more complicated things such as stop-limit orders.

Trigger price and order price are separate - as we don't have market order functionality in the program it's probably best to do orderPrice = triggerPrice + slippage, unless manually specified otherwise.

Trigger orders expire after State.triggerOrderTimeoutSeconds, and they can be deleted by an admin or the owner. They can also be edited by the owner (just the asset cannot be changed).

filipzeta commented 1 year ago