[discussion] Supporting market orders in live trading
#11
Quote:From kraken api description https://www.kraken.com/help/api I had the ordertype=market in mind to go the market taker way.

Most people do, the problem is that this is an order type that will always buy (or sell), regardless of liquidity. In liquid markets this is fine but I don't want to design Gekko so it works fine in liquid markets and people can lose all their money in iliquid markets.

Quote:maybe add a new param to the advice, e.g. setTakerLimit=2 to calculate a price limit of -2% against to topmost orderbook price?

Exactly!

Quote:In this case you could decide in the strategy advice how much market taking you want...

I still think that in 90% of the scenarios you will pay more with orders that execute at market, since there are 3 extra costs involved:

- paying taker fees (depends on exchange)
- crossing the spread
- market slippage

As such this needs to be configurable and won't be default. But yes, it should be configurable from within the strategy. I'm thinking of something similar to the passing the trigger object when calling "this.advice". RIght now you pass:

Code:
this.advice({
  direction: 'long' // or short
  trigger: { // ignored when direction is not "long"
    type: 'trailingStop',
    trailPercentage: 5
    // or:
    // trailValue: 100
  }
});

I propose we change this direction string to an object where the strategy can indicate market taking a certain %.

Quote:do you think it will work with this price limit adjustment out of the box?

It won't, this requires some changes to Gekko and to Gekko Broker. Right now Gekko Broker never crosses the spread here: https://github.com/askmike/gekko/blob/99...s#L90-L135

EDIT: I actually see now this behaviour was added to Gekko Broker (I was using that in other private projects), but needs to be reworked to work better with Gekko.
  Reply
#12
Ok, I implemented this feature today, works really nice. See this commit: https://github.com/mark-sch/gekko/commit...8909a0f6ec

The advice has three new possible params, example:

this.emit('advice', { recommendation: 'short', setTakerLimit: '1%', setSellAmount: '10%', date: moment() });
this.emit('advice', { recommendation: 'long', setTakerLimit: '3.5', setBuyAmount: '18', date: moment() });

All three params are able to handle absolute values or percentages. So setting a setTakerLimit of 1% within the advice will buy for example at the highest available bid from the orderbook plus 1%, so the new limit price is bid+1%. This will force a market taker most of the time. If the available offers are worse than this price, it will only fill a partial taker order and keep the rest until you are able to buy with current bid+1% (moving) limit again.

I tested with a new Telegram bot UI and also added the dynamic Amount feature - instead of fixed 95% right now. So you can buy with a certain percentage or a certain fixed amount of your currency. This should also enable trading mutiple assets on one currency by setting these values in strategy. If you are willing to merge now or later, let my know, I will then create a pull request.
  Reply
#13
Very interesting code!

Quote:This should also enable trading mutiple assets on one currency by setting these values in strategy.

I don't think so: with Gekko is constantly fetching your balances and triggering events when they change. If you run multiple bots over the same pairs there are a number of other problems we need to solve first.

Quote:All three params are able to handle absolute values or percentages. So setting a setTakerLimit of 1% within the advice will buy for example at the highest available bid from the orderbook plus 1%, so the new limit price is bid+1%

Very interesting, in a few places Gekko supports passing values as notional or %, but I'm using a different interface for this:

Code:
this.advice({
  direction: 'long' // or short
  trigger: { // ignored when direction is not "long"
    type: 'trailingStop',
    trailPercentage: 5
    // or:
    // trailValue: 100
  }
});

Quote:Ok, I implemented this feature today, works really nice

I am afraid your current changes don't work across all supporter exchanges, which ones did you test?
  Reply


Forum Jump:


Users browsing this thread: