The Staggered Orders strategy
Places a large amount of buy and sell orders at certain intervals, covering the orderbook from very low prices to very high prices. The range is supposed to cover all conceivable prices for as long as the user intends to run the strategy. That could be from -100x to +100x (-99% to +10000%). Profits will be made from price movements, and the strategy introduces friction to such movements. It gives markets depth, and makes them look better. It never "sells at a loss", but always at a profit.
This strategy works well on laptops and computers that aren't on(line) all the time. It works perfectly well if you run it a few times a day, once a week or once a month. More profits will likely be made if it's online all the time, but even that is not sure. It depends on market conditions.
Parameters and Configuration
- Mode: mountain, neutral, valley, buy slope, or sell slope. Explained lower.
- Spread: Spread between your highest bid and lowest ask (%)
- Increment: At which increments will orders be placed (%)
- Lower bound: How low do you expect the price to ever go? Buy orders will be placed from center price down to this price. Price of Quote asset as measured in Base asset.
- Upper bound: How high do you expect price to ever reach? Sell orders will be placed from center price up to this price. Price of Quote asset as measured in Base asset.
- Allow instant fill: When several orders fill and the price immediately returns, the bot will have to place orders that will likely fill instantly. If this option is enabled, the target spread will be recovered easily, and some immediate profit will be made. If this is disabled, the bot will have to remove some orders to get the necessary funds to keep going. Default is on, and we recommend keeping it so.
- Operational depth: Actual number of orders to maintain on the books. Instead of placing all orders to cover full range, maintain only N orders deep.
Initial orders placement
On each start the strategy checks whether there are buy and sell orders on the specified market. If there are no orders, the strategy will start to place buy and sell orders one-by-one starting from the far end (lower bound and upper bound). This should result in getting the best possible prices even if the center price isn't where expected or moves after starting.
The orders are placed on
price * (1 + increment) distance from each order. Order amounts are calculated automatically. Bigger range decreases order sizes. Smaller increment decreases order sizes.
How profits are made
The bot makes orders to buy back more of what it sold, for the same total price, and to sell back all of what it bought, for a bigger price. This way every time the price moves in an opposite direction, profits are realized. As the price moves back and forth, a little or much, small profits are made and immediately reinvested to increase future profits. This can continue as long as the price ever moves anywhere, and the price stays within assigned range.
Spread, increment and profits
Increment is a distance between orders and spread is a distance between highest buy and lowest sell orders. The actual profit will not be equal to defined
spread as you may think. The profit will be somewhere between
spread - increment. Why? Because the resulting profits is a combination of spread trades and volatility trades. Lets take a look at the simple example to understand this.
- spread: 10%
- increment: 4%
- orders prices: 83 87 91 95 <center> 105 109 113 117
While price is not moving anywhere, you may take profits from
105-95 = 10), this will give the max profit %. Then imagine that buy order at
95 was filled. The next sell order will be placed at price
101. If it is also filled, the realized profit will be
101-95 = 6
Note: on significant price movements non-slope modes can actually bring bigger profit than just usual
spread - increment. This may happen because newly obtained liquidity from trades is distributed across ALL range, increasing far orders.
Fully filled order on the one side will result in placing a next closer-to-center order on the opposite side. It will be closer by
price * (1 + increment).
Partially filled orders
When there is a partially filled order on the one side, the strategy will not immediately allocate the newly obtained funds. Instead, it will reserve the amount needed to place a next closer-to-center order.
Also, if there are both buy and sell trades resulting in partially filled orders on the both sides, the strategy will replace these orders with a new full-sized orders if there is enough funds.
Allocation of excess funds
New available funds may come from trading profits and/or from the transfer from another account. In both cases these funds will be allocated by expanding the range if needed, or/and by increasing existing orders in size.
Staggered Orders strategy is intended to work on a wide range like -100x to +100x. To cover such a wide range, it may require hundreds or even thousands of orders. Maintaining such orders count puts a significant overhead on the strategy execution time, on the blockchain (by order placements and cancellation transactions), and also lots of time is needed for initial orders placement. Furthermore, playing with spread and increment also requires replacing of all orders.
As actual trading is happening around market center price, it's enough to keep only N orders around the center to handle price movements in near-center range.
The basic factors to consider while setting operational depth:
- Worker online %. The less worker is online, the more depth it needs to handle price movements.
- Increment size. The less increment is being used, the more depth it needs. Otherwise, worker may not benefit from catching a large buy or sell candle.
The logic of operational depth is following:
- When initial orders placement is happening, only N-depth orders are placed to orderbook, and remaining orders are kept in memory as "virtual" orders.
- On each restart the strategy will restore all virtual orders basing on amount of a current furthest real order
- On price movements, virtual orders are replaced with real orders on as-needed basis to keep no less than N real orders on market
- When price movement is directed to one side, the opposite side may accumulate excessive orders (
N + x). These excessive orders will be automatically replaced with virtual orders one-by-one if the actual number of orders on this side will exceed
N + threshold(
thresholdis defined in code and can be changed later, so current value is omitted here). Note that furthest real order will be replaced only if it's amount is the same as next order closer to the center. This condition is a must to not break normal asset balance distribution inside a trading side.
At any time the user can adjust range bounds. The strategy will place additional orders to cover the new range using trade profits or funds transferred from outside. If boundaries are narrowed, newly available funds will be used to increase order sizes.
Fallback logic when target spread is not reached
In some rare cases there may be a situation when all funds are allocated, but target spread is not reached. In this case the strategy will cancel furthest buy or sell order and use these funds to place next closer-to-center order to reach the target spread.
- Buy orders same QUOTE
- Sell orders same BASE
Mountain mode concentrates funds more to the center, so it makes more profit "right now" and compounds profits faster, but it's less good if the price decides to drift significantly.
Orders size increase: maximize order size as close to center as possible. When all orders are max, the new increase round is started from the furthest order.
- Buy orders same BASE
- Sell orders same QUOTE
Valley mode is for bootstrapping a market or highly-volatile one. It makes very little profit if price stays where it started, but can withstand a massive change and loves volatility.
Orders size increase: maximize order sizes as far as possible from center first. When all orders are max, the new increase round is started from the closest-to-center order.
- All orders same BASE (profit comes in QUOTE)
Buy and sell slope is good for accumulating the other asset. You could for instance invest $50k with this strategy and reap profits with $100 sized orders over a massive range. It's like milking the market or "financial independence mode"
Orders size increase: maximize order size as low as possible. Buy orders maximized as far as possible (same as valley), and sell orders as close as possible to the center price (same as mountain).
- All orders same QUOTE (profit made in BASE)
Orders size increase: maximize order size as high as possible. Buy orders as close to the center price (same as mountain), and sell orders as far as possible from the center price (same as valley).
- Buy orders, from far end towards center:
lower_order_base * sqrt(1 + increment)
- Sell orders, from far end towards center:
higher_order_quote * sqrt(1 + increment)
Neutral mode is for any market, and it is a nice balance between Valley mode and the Mountain mode, because order amounts slightly bigger towards the center. It will work well in stable times and also with extreme movements, giving you peace of mind at all times.
Orders size increase: try to flatten everything by increasing order sizes to neutral. When everything is correct, maximize closest orders and then increase other orders to match that.
The strategy doesn't require any "state" to be remembered, and rely solely on the actual data from the blockchain. This might allow you to start the strategy with one computer, interrupt it at any point, and continue with another. You only need to have the same settings. Though you can also change the settings and continue and the strategy will place new orders according to the new settings.
After every single action the bot will re-evaluate the whole situation and act accordingly. It won't assume that an order has been successfully made, but look at the situation with new eyes every time. This eliminates several tricky situations and weird behavior.
Operating mode and range can be changed at any time
If these are changed, the bot removes orders outside of defined range, and allocates all funds according to current configuration. If range is increased, it caused the bot to spend any profits to create new orders to fill the new range. Changing operating mode leaves all orders as they are, and will only change future behavior.
If the user starts with only base or quote, the bot will place orders closer to the market price and wait until one fills, and the game begins. Profits will be used to add orders to the other side until the strategy is completely balanced (according to the configuration).
The most important thing is to make the range (upper and lower bounds) wide enough. If you don't do this, you will end up with only the worse of the assets. Do you want that to happen? If not, use a massive range. We suggest +-100x. Yes, 10,000x range. With mountain and neutral mode it will cost very little to increase your range from 10x to 100x, so do it. With valley mode it costs much, but if you are using it to begin with you expect huge volatility, so do it. With buy slope it's cheap to extend upper bound, and with sell slope the opposite.
Increment and spread
The smaller the increments the more often orders will be filled, but the smaller the profit per order. (With same amount of funds).
The smaller the spread the more orders will fill, but the smaller the profit also. There is likely a sweet spot somewhere. You can also use a massive spread like 10,000% if you like, but it is questionable whether you need a bot for that, as an order might fill once per year or so.
If you intend to run the strategy on an always-on computer, then smaller spreads and increments might make sense. If you expect to run the bot once a day, try the default spread (6%) and increment (4%). If you intend to run the bot once a week, sane values might be 20% spread and 10% increment.
Note: avoid changing increment and spread without cancelling all orders. This may result in losses. See the "Spread, increment and profits" section.
It is best to start the strategy with an 'equal' amount of both assets (if you have a symmetric range). 'quote-amount / price' should be 'base-amount'.