Pages:
Author

Topic: Gekko - a javascript trading bot and backtesting platform - page 29. (Read 147876 times)

legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
When real trading is enabled, is there some kind of limit I can impose on it so it uses a small amount of my money for trading instead of my whole balance?
Again, for Bitstamp.
sr. member
Activity: 352
Merit: 250
Is it me, or basically you must call Gekko every single time you want "advice"? I thought that it looped constantly and checking every few seconds what's up and reporting back, but I left it for a few minutes and saw nothing printed besides the initial information even with debug logging enabled.

This on Bitstamp.

In the settings their is a time interval. Gekko will check every time, once the time interval is over, and give you advice. So if you want almost instant trading you set the time interval to something like 15 min.
I wouldn't recommend this because you will have much more crossovers and the fees will kill most of you profits.
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
Is it me, or basically you must call Gekko every single time you want "advice"? I thought that it looped constantly and checking every few seconds what's up and reporting back, but I left it for a few minutes and saw nothing printed besides the initial information even with debug logging enabled.

This on Bitstamp.
sr. member
Activity: 287
Merit: 250
Thanks for your feedback!

Profit should be compared vs a simple hold strategy

That's a valid point, currently Gekko logs the start price and the end price, but doesn't calculate the % increase between the two (which you would have when doing a buy and hold). I will add this!

also it should take fees into account.

It does. You can configure the trading fee in the profit calculator part of the configuration. The default is 0.6% because the candles I prepared are from Mt. Gox.

And maybe begin with a balanced amount of btc and usd.

On default Gekko starts out with 100 currency (USD) and 1 asset (BTC), but again this is based on the configuration. You can edit this in the simulation balance.

I will update the docs so this is clear without reading the configuration files.
newbie
Activity: 31
Merit: 0
Profit should be compared vs a simple hold strategy, also it should take fees into account.
And maybe begin with a balanced amount of btc and usd.
sr. member
Activity: 287
Merit: 250
Big update: Gekko now supports backtesting!

Please be warned that this code is in early development stage, I would not advice to act on the computed results just yet.

This does mean that I want all the feedback I can get so that the feature becomes stable. In short you need precalculated candles in csv (which you can get in my other topic) and the latest version of Gekko. You can find more detailed information in the docs.

And the result looks something like this (ran on the hourly USD candles):

Quote
(...)
2013-06-30 02:35:24 (INFO):   ADVICE is to SELL @ 115.750 (-0.252)   at    2013-05-11 11:00:00
2013-06-30 02:35:24 (INFO):   ADVICE is to BUY @ 117.300 (0.287)   at    2013-05-13 12:00:00
2013-06-30 02:35:24 (INFO):   ADVICE is to SELL @ 114.480 (-0.461)   at    2013-05-14 23:00:00
2013-06-30 02:35:24 (INFO):   ADVICE is to BUY @ 115.500 (0.315)   at    2013-05-16 02:00:00
2013-06-30 02:35:24 (INFO):   ADVICE is to SELL @ 120.100 (-0.253)   at    2013-05-19 18:00:00
2013-06-30 02:35:24 (INFO):   ADVICE is to BUY @ 124.440 (0.257)   at    2013-05-23 03:00:00


2013-06-30 02:35:24 (INFO):         WARNING: BACKTESTING FEATURE NEEDS PROPER TESTING
2013-06-30 02:35:24 (INFO):         WARNING: ACT ON THESE NUMBERS AT YOUR OWN RISK!


2013-06-30 02:35:24 (INFO):   (PROFIT REPORT) start price:          17.51001
2013-06-30 02:35:24 (INFO):   (PROFIT REPORT) end price:          125.44
2013-06-30 02:35:24 (INFO):   (PROFIT REPORT) original simulated balance:    116.339 USD
2013-06-30 02:35:24 (INFO):   (PROFIT REPORT) current simulated balance:    1695.713 USD
2013-06-30 02:35:24 (INFO):   (PROFIT REPORT) simulated profit:       1579.374 USD (1357.562%)
sr. member
Activity: 287
Merit: 250
The latest version quites for me immediately after sending a notification email:

Oops, fixed now Smiley
newbie
Activity: 44
Merit: 0
The latest version quites for me immediately after sending a notification email:

Quote
2013-06-17 17:24:58 (DEBUG):    fetching new trades for new bucket at Mt. Gox
2013-06-17 17:25:01 (DEBUG):    calculated candle: 0
2013-06-17 17:25:01 (DEBUG):    calced EMA properties for new candle:
2013-06-17 17:25:01 (DEBUG):             short ema 101.493
2013-06-17 17:25:01 (DEBUG):             long ema 101.179
2013-06-17 17:25:01 (DEBUG):             diff ema 0.310
2013-06-17 17:25:01 (DEBUG):    we are currently in uptrend (0.310)
2013-06-17 17:25:01 (INFO):     ADVICE is to BUY @ 101.837 (0.310)
~/gekko $

sr. member
Activity: 287
Merit: 250
I just did a big internal update to Gekko: Gekko now calculates candles under the hood and uses the close as a price indicator. AFAIK this is a way more standard way to calculate indicators based on price. This may stabilise the calculated prices.

This is a big step towards implementing a system that supports over a 100 different indicators (ta-lib) because it needs to get candles fed. It also makes it much easier to get backtesting rolling.

It would be awesome if anyone could let it spin for a testrun (I would advice downloading this in addition to the old version, as it's pretty new and the code really needs to get solid. I would advice against real trading for now). If anyone could glance at the (much more readable) code that would be awesome.

I use http://bitcoinwisdom.com/ for the ticker information and looks like they group their results in some way.
This might explain the difference because if you group all results you get a weighted average compared to a normal average of the latest trades.

I am desperately searching for the common way to calculate price based on trades (in the new version I calculate candles and use the close as a price indicator). You could check the new version out to see wether it better matches other services Smiley
sr. member
Activity: 352
Merit: 250
Does indeed seem something weird with the way of calculation. My trade was calculated like this (have to add +2 hours because of gekko runs in GMT and website with data is GMT+2)
Code:
2013-06-15 12:17:04 (INFO):     ADVICE is to HOLD @ 101.940 (-0.302)
2013-06-15 12:17:04 (INFO):     (PROFIT REPORT) original simulated balance:      203.171 USD
2013-06-15 12:17:04 (INFO):     (PROFIT REPORT) current simulated balance:       203.171 USD
2013-06-15 12:17:04 (INFO):     (PROFIT REPORT) simulated profit:                0.000 USD (0.000%)

If you look at the data around this time all trades in the last 5 minutes are above 102. The way the EMA is calculated I think mtgox gives indeed back older information if you ask for the most recent trade like you pointed out.

I'll add the next tick to do give some more data.

Code:
14:19:32 103.10297 1.48000
14:19:32 103.10296 0.14511
14:19:04 103.10295 2.00000
14:18:39 103.34000 0.25152
14:17:37 103.10295 0.17904
14:16:20 102.60000 3.55653
14:16:19 102.60105 1.17900
14:16:19 102.64001 1.57890
14:15:29 102.64000 0.36969
14:15:04 102.64000 0.02010
14:15:00 102.70000 0.61020
14:14:52 103.36535 0.75617
14:14:52 102.97000 0.25382
14:12:56 102.71000 0.02010
14:12:54 102.75000 0.95498
14:12:54 102.78000 1.21879
14:12:53 102.90252 0.00317
14:12:49 103.38000 1.00000
14:12:49 103.36535 0.01000
14:11:39 103.44000 0.25523
14:11:29 103.44000 0.76239
14:11:29 103.43210 2.56137
14:11:19 103.43210 5.43862
14:11:19 103.43200 0.10000
14:11:19 103.40000 0.79500
14:11:19 103.38150 0.01000
14:10:55 102.90252 0.20998

Edit New Tick:
Didn't buy because difference not big enough.

I use http://bitcoinwisdom.com/ for the ticker information and looks like they group their results in some way.
This might explain the difference because if you group all results you get a weighted average compared to a normal average of the latest trades.
 
Code:
2013-06-15 13:12:04 (INFO):     ADVICE is to HOLD @ 103.103 (0.004)
2013-06-15 13:12:04 (INFO):     (PROFIT REPORT) original simulated balance:      203.171 USD
2013-06-15 13:12:04 (INFO):     (PROFIT REPORT) current simulated balance:       203.171 USD
2013-06-15 13:12:04 (INFO):     (PROFIT REPORT) simulated profit:                0.000 USD (0.000%)

Code:
15:14:36 101.66000 0.02500
15:13:43 101.75101 0.84800
15:12:37 102.00000 5.39634
15:06:24 102.15000 24.8300
15:06:24 102.15100 4.98170
15:06:24 102.19991 0.10000
15:06:24 102.30000 0.96505
15:06:24 102.38000 4.00000
15:06:23 102.50000 0.00049
15:06:23 102.50000 46.5663
15:06:21 102.50000 42.2023
15:06:21 102.50190 0.14340
15:06:21 102.52000 0.01950
15:06:21 102.56000 11.1833
15:06:21 102.79990 0.01000
15:05:52 102.56000 0.01000
15:05:51 102.56000 0.01000
newbie
Activity: 44
Merit: 0
Thank you. That is a good thing to be aware of.
sr. member
Activity: 287
Merit: 250
Gekko will ask for the most recent trades and the price is the average of all trades that happened after (date of most recent trade - sampleSize in seconds).

It appears that Mt. Gox sometimes doesn't deliver the most recent trades but a bit more outdated ones. But I will have to do some more research to make sure.
newbie
Activity: 44
Merit: 0
Previous tick:

Quote
013-06-13 15:00:04 (DEBUG):    calculated new tick: 0  price: 108.969  diff: -0.006
2013-06-13 15:00:04 (DEBUG):    we are currently not in an up or down trend  (-0.006)
2013-06-13 15:00:04 (INFO):     ADVICE is to HOLD @ 108.969 (-0.006)

A sell was triggered at a later tick:

Quote
2013-06-13 17:00:05 (DEBUG):    calculated new tick: 0  price: 102.060  diff: -0.623
2013-06-13 17:00:05 (DEBUG):    we are currently in a downtrend  (-0.623)
2013-06-13 17:00:05 (INFO):     ADVICE is to SELL @ 102.060 (-0.623)

How far back does Gekko look when when choosing trades to use for the EMA?  I don't remember for sure, but I think the price had started to drop quickly by about 10 minutes before the hour.
sr. member
Activity: 287
Merit: 250
hmm that's strange.

Gekko currently calculates EMA based on prices calculated a little different than it should (not based on candle Close but on a couple of trades around that time). I am currently rewriting Gekko to a candle based price calculation approach.

Could you post the the previously calculated tick? And did Gekko trigger a sell at the next tick?
newbie
Activity: 44
Merit: 0
For some reason Gekko just missed a sell signal.

Quote
2013-06-13 16:00:04 (DEBUG):    refreshing
2013-06-13 16:00:04 (DEBUG):    fetching exchange...
2013-06-13 16:00:05 (DEBUG):    fetched exchange
2013-06-13 16:00:05 (DEBUG):    calculated new tick: 0  price: 108.300  diff: -0.058
2013-06-13 16:00:05 (DEBUG):    we are currently not in an up or down trend  (-0.058)
2013-06-13 16:00:05 (INFO):     ADVICE is to HOLD @ 108.300 (-0.058)

These times are Mountain time so that would be 22:00 UTC.

bitcoincharts.com shows that ema(21) was about 107.9 and ema(10) was about 106.9 at that time.

http://bitcoincharts.com/charts/mtgoxUSD#rg2zigHourlyzczsg2013-06-13zeg2013-06-14ztgSza1gEMAzm1g10za2gEMAzm2g21zi1gMACDzi2gATRzv

This should have triggered a sell with the settings that I am using.  Is there a bug?

Quote
// Exponential Moving Averages settings:
config.EMA = {
  // timeframe per candle
  interval: 60, // in minutes
  // EMA weight (α)
  // the higher the weight, the more smooth (and delayed) the line
  shortEMA: 10,
  longEMA: 21,
  // amount of samples to remember and base initial EMAs on
  ticks: 100,
  // max difference between first and last trade to base price calculation on
  sampleSize: 10, // in seconds
  // the difference between the EMAs (to act as triggers)
  sellTreshold: -0.125,
  buyTreshold: 0.125
};

config.watch = {
  exchange: 'MtGox',
  currency: 'USD',
  asset: 'BTC'
}

Edit:  modified formatting for easier reading.
sr. member
Activity: 287
Merit: 250
Yes you need some tools if you want to keep Gekko running independently of the current session (recommended, you probably want to run Gekko for long periods of time).

In the advanced features doc you can read about some other tools to run Gekko headless (nohup or nodejs tools like forever).
sr. member
Activity: 352
Merit: 250
Also using
> node gekko |& tee GekkoTimboLog.txt
to be able to see the output in the terminal but also write it to a log file so you'll have it  when for some reason the pc shuts down.
sr. member
Activity: 352
Merit: 250
Let me know how it goes. I am planning on also buying a raspberry when I have some free time.

Got it working with the tutorial you posted. You do need a 4GB card minimum because node will fill up the 2GB card.  Grin
(http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/)

I'll report back if I encounter any problems. Have it set up with a smaal mtGox account. Tweaked the settings and with some manual backtesting so hope it works Smiley

Edit:
Dont forget to do make a screen so it wont stop when you logout from ssh.
> sudo apt-get install screen
> screen -S gekko
sr. member
Activity: 287
Merit: 250
Let me know how it goes. I am planning on also buying a raspberry when I have some free time.
sr. member
Activity: 352
Merit: 250
Good to know it works. I'll try agian with an other sd card and try again. This one was only 2GB so that might be the problem.
(or try arch linux because it seems lighter)
Pages:
Jump to: