[discussion] Supporting market orders in live trading
#1
When live trading Gekko handles signals from your strategy. Your strategy can signal to buy or sell. When it does Gekko will kick of a trade execution using a sticky order: This is an advanced order type (internal to Gekko) which will try to buy (or sell) using limit orders at the ticker/top of the book/bbo.

Gekko ignores the candle price at the time your strategy fired the buy (or sell) signal. This because that price is simply the last trade price of the last traded candle. (Which by definition is never the price of the last trade, but the second last or even older).

In other words: when your strategy decides to buy, Gekko will pull the ticker (current top of the orderbook) and place an order at this top. When Gekko places a bid (to buy) and the price moves UP gekko will keep moving this bid higher until it's completely filled.

------

This is a very conservative strategy, an other (and simpler) approach is to create market orders: this way you can buy (or sell) straight away, trading with people currently offering to trade in the orderbook. This works great when you trade on a big market (for example USD/BTC on bitfinex), but terrible when you trade on a small alt market. Mainly because of two costs involved: crossing the spread and eating slippage. These costs can be as high as 3% (but only on a small market).


I uploaded a video where I explain these costs:

https://www.youtube.com/watch?v=r0yc1sonYvo

------

To guard against this risk, specifically for new users who are not aware of the details behind executing trades Gekko currently does NOT support market orders at all. Though a lot of people have been requesting it, so here is a discussion: How can Gekko support market orders, while minimizing the risk to new traders losing all their money in a few days?
  Reply
#2
The market taker order will be a very nice feature in my eyes, especially when you know there is a high potential of very big price movements within a short time frame.

E.g. I was working on a multi market strategy today, watching both ethereum and bitcoin on 1 minute candles. When a calculated price percent oszillator detects a significant rise/pump on bitcoin, the strategy will buy ethereum with a trailing stop loss (with only 0.1% bandwidth). The strategy only wants to catch the short and strong expected increase on the altcoin.

The backtest gave very nice results, 400 trades within 9 month and a total exposure of 26 hours, sharpe ratio of 96 and a total profit of 107%, but in practice I would prefer to buy as a market taker due to the fast price movement. Selling with a sticky order will be probably fine in this case.

I think it can by very useful if the order type can by specified with the advice (and not only globally in the config file) e.g. like this:

this.advice({
direction: 'long',
trigger: {
type: 'trailingStop',
trailPercentage: 0.1,
order: 'market'
}
});
  Reply
#3
Both are interesting. How do you see this ? A simple "Use market orders" toggle parameter for a live tradebot ?
  Reply
#4
Is this feature already work in progress or not yet started? Did a first implementation step and will wait or continue depending on the status...
  Reply
#5
The risks are huge (on illiquid markets). Gekko is a tool used by all kinds of people and I am very reluctant to add features that can result in loss of funds by in experienced users.

As of now I see no advantage in doing a market order over a limit order with a limit x% above the price (when buying). That executes as a market order up until some sane level. That way we prevent you losing 5% of your money when you trade on some tiny binance market.
  Reply
#6
(10-23-2018, 08:17 AM)askmike Wrote: The risks are huge (on illiquid markets). Gekko is a tool used by all kinds of people and I am very reluctant to add features that can result in loss of funds by in experienced users.

As of now I see no advantage in doing a market order over a limit order with a limit x% above the price (when buying). That executes as a market order up until some sane level. That way we prevent you losing 5% of your money when you trade on some tiny binance market.

Oh yes, I am also a fan and can confirm that limit orders, and sticky orders in particular, work nice with gekko during live trading in many situations, but not all.

Some guys, and I would say those developing strategies for a longer time, also figure out disadvantages of sticky compared to market taking orders, e.g. in this video: https://www.youtube.com/watch?v=PxVW7jM6WsI
Like @crypto49er is explaining, there are situations where limit order is performing worse a market order:


- A limit order assumes you have a market taker, picking your offer. In a pump and dump situation you may not have a taker and you are adjusting against a quickly changing order book without the ability to finish your trade. You are loosing money. A market taker could just jump in and complete.
- Some exchanges like binance do not have a fee advantage for limit orders...when the spread is small, why take the risk for waiting for a limit order to complete? In general we buy/sell because there is a price movement already and waiting make it worse.
- The process of sticky order is a lot more complex and has the risk of technical bugs - new order, cancelling, ..., new order, partial filling, id matching and so on. It is always a fight against exchange rate limits and gekko broker bugs like insufficient fund, partial filled orders or new unknown response codes. I experienced this many times and the order was not finished at all. Even sticky orders adjust quick, they do not use websockets but delayed api requests so it is not guaranteed to be topmost the orderbook all the time. A market taker order is a simple oneshot request.
- Like @crypto49er, I am watching and comparing prices between advice, trade initiated and trade completed events for a longer time now during live trading...and there are situation where you see a bigger time and price gap and you wish to have to ability to avoid this by using market taking. This happened on pretty liquid markets like kraken eth/eur.

In my eyes the sticky order is the preferred option, but with a very small candle size and in case your strategy knows from TA that you are within a pump and dump situation, I would prefer market taker orders. So strategy must explicitly advice to use the market taker option, default is sticky order, what do you think?
  Reply
#7
Quote:Oh yes, I am also a fan and can confirm that limit orders, and sticky orders in particular, work nice with gekko during live trading in many situations, but not all.

That's not what I mean! I mean that a limit order can be executed as a market order, but you can specifiy a limit:

Quote:a limit order with a limit x% above the price (when buying). That executes as a market order up until some sane level. That way we prevent you losing 5% of your money when you trade on some tiny binance market.

The point being that it will execute as a market order, but only slipping up max x%.
  Reply
#8
Ahaa, you have a market taker order in mind with slippage precheck by looking into the order book? This will be the deluxe market taker option ;-) Are you working on this? On bigger markets and smaller investments many people will be probably already happy to have a "standard" market taker option...
  Reply
#9
Quote:Ahaa, you have a market taker order in mind with slippage precheck by looking into the order book? This will be the deluxe market taker option ;-) Are you working on this? On bigger markets and smaller investments many people will be probably already happy to have a "standard" market taker option...

This isn't a very magical thing! It already exists on every exchange and it's called a "limit order", but be sure to not check the post only / partcipateDoNotIniate option. If you look at this example:

[Image: 47408473-258d1480-d792-11e8-9396-26c214614aa8.png]

Right now the "post only" button is checked, if you check the "allow taker" button instead you can create an order that will execute as market. For example:

If you want to buy right now you can create a limit order with a limit price of 5625 euro and a size of 100 bitcoin. What would happen is that you would immediately buy ~6 bitcoin (the top 3 asks) and after that place a limit order for ~94 bitcoin that rests in the orderbook (at the top of the bids). It would be very simple for Gekko to calculate this limit price based on a % above the current price, for example 1%. This wouldn't impact anyone trading in very liquid markets since all the orders would execute at market, but it would save people from eating deep into the orderbook and paying ~5%. Note that Gekko would only have to calculate the correct limit here and send one order to the exchange. All exchanges will manage executing the correct orders and placing a limit order for the remainder (if there isn't enough liquidity below the specified limit).

Note that Gekko currently does NOT do this, when Gekko would buy in the situation above it would create limit orders with a limit of 5620.29 euro (meaning it would never execute at market).

Quote:On bigger markets and smaller investments many people will be probably already happy to have a "standard" market taker option...

I am reluctant to add straight up market orders for people who don't understand order execution and trade on tiny markets on binance, not because of people who know what they are doing and trading on bitfinex..
  Reply
#10
From kraken api description https://www.kraken.com/help/api I had the ordertype=market in mind to go the market taker way. But of course, keeping the limit order and moving the price limit deeply into the orderbook to achieve immediate/partial market taking is a great idea, I did not have this present at this moment, but very nice. This will only need small gekko code changes ...maybe add a new param to the advice, e.g. setTakerLimit=2 to calculate a price limit of -2% against to topmost orderbook price? In this case you could decide in the strategy advice how much market taking you want...do you think it will work with this price limit adjustment out of the box?
  Reply


Forum Jump:


Users browsing this thread: