Manually place limit orders that stay ontop
#1
Information 
Hello,

I am trying to figure out how I can use gekko to manually place buy limit orders that stay ontop of the orderbook when it starts moving. Stopping at a defined limit if the order is not filled.

I haven't been able to find a strategy that I want to use so i'm still trying to do manual trades.

Thanks!

PS: If this is in the wrong section, I am sorry please move it  Huh
  Reply
#2
Quote:PS: If this is in the wrong section

I need to restructure the sections, it's a bit messy at the moment.

Quote:I am trying to figure out how I can use gekko to manually place buy limit orders that stay ontop of the orderbook

I'm not fully understanding your question, but as of right now you have 2 tools available:

Use Gekko

You can use Gekko to create use/create a strategy that won't just trade, but also figure out when to trade (using TA indicators or any other math you put in your strategies). Read more about Gekko Strategies here: https://gekko.wizb.it/docs/strategies/introduction.html

If you want to trade yourself (you want to decide when to buy or sell) this is not the way to go.

Use Gekko Broker

If you don't want to use a Gekko strategy to determine when to buy or sell, but if you want to buy or sell yourself: you can use the sticky order from Gekko Broker. But note: this is a technical tool with a low level interface (to be used within your own nodejs trading system). I might wrap this into a tiny dashboard at some point, but I hope other people will do that.

An example of you how you can use Gekko Broker in your own trading app:

Code:
// from NPM
const Broker = require('gekko-broker');
// from the gekko repo
// const Broker = require('../gekko/exchange/GekkoBroker');

const binance = new Broker({
  currency: 'USDT',
  asset: 'BTC',
  private: true,

  exchange: 'binance',
  key: 'x',
  secret: 'y'
});


const type = 'sticky';
const side = 'buy';
const amount = 1;

const order = binance.createOrder(type, side, amount);

order.on('statusChange', s => console.log(now(), 'new status', s));
order.on('fill', s => console.log(now(), 'filled', s));
order.on('error', s => console.log(now(), 'error!', e));
order.on('completed', a => {
  console.log(new Date, 'completed!');
  order.createSummary((err, s) => {
    if(err)
      throw err;
    console.log(new Date, 'summary:');
    console.log(JSON.stringify(s, null, 2));
  });
});

If you put that into a file and run the file it will:

- create an order to buy 1 BTC by placing orders at the top of the book (bid side, does not cross).
- update the order (cancel/create new one) if the best bid moves up.
- log whenever a) it moved an order and b) there was a (partial) fill.
- when it's completed (when the 1 btc was bought) it will print a summary.

I just ran it (buying 1 BNB) and this was my output:

Code:
root@foxtail:~/gb/nusadua# node b
2018-07-29 03:46:02 new status SUBMITTED
2018-07-29 03:46:02 new status OPEN
2018-07-29 03:46:04 filled 1
2018-07-29 03:46:04 new status FILLED
2018-07-29T03:46:04.127Z 'completed!'
2018-07-29T03:46:04.358Z 'summary:'
{
  "price": 0.0017479,
  "amount": 1,
  "date": "2018-07-29T03:46:02.576Z",
  "side": "buy",
  "orders": 1,
  "fees": {
    "BNB": 0.00075
  },
  "feePercent": 0.075
}

Quote:Stopping at a defined limit if the order is not filled.

I'm not 100% sure what you mean, but you can pas a limit flag to createOrder. In the above example replace:

Quote:const order = binance.createOrder(type, side, amount);

with:

Quote:const order = binance.createOrder(type, side, amount, { limit: 100 });

Where limit the maximum price you are willing to pay (when buying) or the minimum price you are willing to get (when selling). However this still never crosses, this simply allows you to stay below the BBO.

After the order is created you are able to change this limit by calling:

Code:
order.moveLimit(120)

There is also an outbid flag you can pass in that object, but it's NOT stable yet.
  Reply
#3
I saw you had another question in your other thread, I'll answer it here:

Quote:Is there a way to run this from the command line and specify the buy price?

So above I talked about the sticky order, see here: https://gekko.wizb.it/docs/gekko-broker/...order.html

Which is kind of like an "advanced" order that tries to get the fastest order execution without crossing (meaning: you pay less fees on some exchanges - maker fees, and you get a better price since you don't cross the spread). It's meant for situations where you know you want to buy or sell for a good price, but you don't care about other details (like at what price exactly you want to buy at).

Where as if you want to specify price, you basically want to do a limit order. There is no stable limit order (as Gekko itself only uses sticky orders) as of right now.
  Reply


Forum Jump:


Users browsing this thread: