askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.05k stars 3.95k forks source link

Overlapping buy/sell orders #193

Closed djmuk closed 8 years ago

djmuk commented 10 years ago

I will look into it, but when I get a quick reversal (eg from up to down and back to up so gekko places a sell followed by a buy on the next candle) and the original order is not completed gekko seems to 'forget' about the original order and only track the new one - I then have to go in and manually cancel the orphaned order. Using 1 minute candles probably doesn't help!

I think it should cancel the original rather keep tracking it and attempting to re-price it and fill it.

djmuk commented 10 years ago

Think I have a fix - testing it (reset this.order =0 on completion or cancel/replace, check in noteorder if this.order<>0 then cancel it)

askmike commented 10 years ago

yes that solution would work, the current setup is not really architected for such fast actions. Are you seeing good results on the 1min timescale?

djmuk commented 10 years ago

as I am on cexio I can say it is saving me from some of the wilder swings but as the market is mainly trading within about a 1% window it is difficult to be sure. I think it is generally going in the right direction. I have made several 'improvements' which I want to separate out into specific commits, but need to do the 'proper' job first!

askmike commented 10 years ago

Looking forward to the pull.

  • Buy at bid / sell at ask (offset by small amount) rather than current sell at bid, buy at ask.
  • A couple of different pricing values for candles (EMA on VWAP and EMA on trade price)

Please make those configurable!

I like the logging idea a lot :) If you send a pull I'll gladly put it in.

djmuk commented 10 years ago

OK - I need to work out how to isolate those bits from the other tweaks I have made! I might end up creating a new repo and making the changes there.

At present all the candle values are single letters (OHLCVP) - are you keen to keep to that pattern for any new stored values or can we use more letters? I am thinking of creating extra price indicators as I mentioned above. EMA of VWAP (SO EMA on pricexV

askmike commented 10 years ago

I am thinking of creating extra price indicators as I mentioned above. EMA of VWAP (SO EMA on pricexV

So the P in OHLCVP is the VWAP already, I calculate it myself for all 1min candles and upscale to bigger candles accordingly.

Do you mean you also want the store some indicator result like EMA result in the database? Or do you mean you need the VWAP? If the latter you can do that already (access it by candle.p). If the first I don't fully understand what you are trying to do and why you want it as part of the candle?

djmuk commented 10 years ago

MIke I am proposing 2 extra price indicators, for the following reasons:

I am suggesting the following (which need to be calculated directly from trade data so need to be stored in the candle store) - P here is the price of each individual trade not the VWAP.

For consolidating candles into n x 1m candles these would be combined as

It is simple to make an EMA across N Values of X (X1 .. XN below where XN is the last value) even if you don't know N at the start: EMA = (1 x X1 = 2 x X2 + 3x X3...+ N x XN ) / (N * (N-1)/2)

askmike commented 8 years ago

This should be fixed in the new portfoliomanager!