Pages:
Author

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

newbie
Activity: 28
Merit: 0
Thanks, let me know how the testing goes. Right now Gekko is just doing the really basic stuff (only look at price data of one single exchange, use a simple method like EMA and switch the full balance towards the detected trend). I am in the process of making Gekko more and more advanced.
Works stable, but log format changes too frequently ;-) BTW I've made some visualisations from log data for easier analysis. Currently after 1 day 6 hours time and 4 transactions I have -0.28% profit (-1.34 to 3.68 during that time) with market being ~ +1%. Not so bad ;-)

I didn't know about TA-lib. It would indeed speed up Gekko's development by a lot of things if I can just plug it into Gekko! I've done a quick test and the installation fails on my laptop (OS X) and my vps (Linux), and I don't want to try windows. (I need to do some more research: not running latest node etc). So if I can get this working I think this is going to be optional in the settings.
Installed flawlessly on my debian wheezy box with latest node. Let me know if I could help somehow.

I don't have a background in trading so I'm open in ideas about contradictory suggestions by different methods (for as soon as we have different methods). The user defined weights would be the most straightforward option. I would have to do more reading about neural networks before I can implement such a system into Gekko (if you know about it and can point me to some reading that would be great).
Simple voting should do the job for now. With neural networks (what amazes me there's again a ready to use node library https://npmjs.org/package/brain) you'll have to teach it with history as input (price and all methods) and deserved output (buy/sell) - this part may be the hardest job to do.

Your last point is something Gekko could definitely implement in the future, however this is much harder than applying basic math to current price numbers. So I first want to have a solid bot before I enter this kind of field. But we can of course already start thinking about what good indicators could be, I personally doubt a correlation between Bitcoin news coverage and the price (for example) at the moment, but this would all have to be backtested.
OK, keep it simple and working now, there'll be time for other improvements.

I'm getting better suggestions for new trade methods for Gekko to implement, so backtesting is a really big point on my list. I am currently figuring out if I can use the Mt. Gox data downloader provided by nitrous. This will download every trade from Mt. Gox and stuff it into a SQLite database, something Gekko could very easily use to extract data from.

My current todo list:

  • Risk percentage (how much % can Gekko play with)
  • Better profit logging
  • Backtesting
  • Solid way to implement trading methods (it is not possible to trade 10% of allowed balance for example)
  • MACD trading method

+1 for backtesting and MACD, but use mysql or postgres as database engine if possible.

So it's time to pull latest version and see what happens Smiley

sr. member
Activity: 462
Merit: 250
Thanks, note that is still doesn't look at real balance & profit but still simulates trades on every advice. This will get updated soon though.

---

Good news for all Bitstamp traders out there: Right now you need to hand over your login credentials because their API doesn't use API keys with restricted rights (like only acces to ask balance and create orders). I filled a ticket for this and just got a new response:

Quote
Dear Mike,

We are working on changing our API access at the moment.

This means that in the future you won't have to give a Bitstamp trade bot (Gekko or other) your full credentials.

Good Job! Also don't forget my remark on candlesticks, it would be good practice to save the open, high, low, close per interval instead of only the close you have now.
sr. member
Activity: 287
Merit: 250
Thanks, note that is still doesn't look at real balance & profit but still simulates trades on every advice. This will get updated soon though.

---

Good news for all Bitstamp traders out there: Right now you need to hand over your login credentials because their API doesn't use API keys with restricted rights (like only acces to ask balance and create orders). I filled a ticket for this and just got a new response:

Quote
Dear Mike,

We are working on changing our API access at the moment.

This means that in the future you won't have to give a Bitstamp trade bot (Gekko or other) your full credentials.
newbie
Activity: 40
Merit: 0

EDIT: I have updated the profit reporting of Gekko, it now looks like this:

Code:
2013-06-04 00:02:30 (INFO): ADVICE is to HOLD @ 120.750 (0.861)
2013-06-04 00:02:30 (INFO): (PROFIT REPORT) original simulated balance: 222.430 USD
2013-06-04 00:02:30 (INFO): (PROFIT REPORT) current simulated balance: 219.378 USD
2013-06-04 00:02:30 (INFO): (PROFIT REPORT) simulated profit: -3.052 USD (-1.372%)

Liking the new look! 
sr. member
Activity: 287
Merit: 250
Code:
npm http 200 https://registry.npmjs.org/read
npm ERR! error installing [email protected]

npm ERR! Error: No compatible version found: read@'>=1.0.0- <1.1.0-'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.1.0","0.1.1"]
npm ERR!     at installTargetsError (/usr/share/npm/lib/cache.js:488:10)
npm ERR!     at next_ (/usr/share/npm/lib/cache.js:438:17)
npm ERR!     at next (/usr/share/npm/lib/cache.js:415:44)
npm ERR!     at /usr/share/npm/lib/cache.js:408:5
npm ERR!     at saved (/usr/share/npm/lib/utils/npm-registry-client/get.js:147:7)
npm ERR!     at Object.oncomplete (/usr/lib/nodejs/graceful-fs.js:230:7)
npm ERR! You may report this log at:
npm ERR!    
npm ERR! or use
npm ERR!     reportbug --attach /home/xxx/gekko/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.8.0-22-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "update"
npm ERR! cwd /home/xxx/gekko
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.4
npm ERR! message No compatible version found: read@'>=1.0.0- <1.1.0-'
npm ERR! message Valid install targets:
npm ERR! message ["0.0.1","0.0.2","0.0.3","0.1.0","0.1.1"]
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/xxx/gekko/npm-debug.log
npm not ok

It is still complaining about the dependencies requiring a newer version of node. Your version is almost a year old (from june 2012). Did you catch my response last time?

Your node version is out of date, the Bitstamp module doesn't really require node 0.10 but other dependencies do. Could you try to update to 0.10.x?

You can check what node version is installed by running 'node -v' in a terminal. Here is a guide that will show you how to install node 0.10.x on a Raspberry PI.

EDIT: I have updated the profit reporting of Gekko, it now looks like this:

Code:
2013-06-04 00:02:30 (INFO): ADVICE is to HOLD @ 120.750 (0.861)
2013-06-04 00:02:30 (INFO): (PROFIT REPORT) original simulated balance: 222.430 USD
2013-06-04 00:02:30 (INFO): (PROFIT REPORT) current simulated balance: 219.378 USD
2013-06-04 00:02:30 (INFO): (PROFIT REPORT) simulated profit: -3.052 USD (-1.372%)
legendary
Activity: 2955
Merit: 1049
Code:
npm http 200 https://registry.npmjs.org/read
npm ERR! error installing [email protected]

npm ERR! Error: No compatible version found: read@'>=1.0.0- <1.1.0-'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.1.0","0.1.1"]
npm ERR!     at installTargetsError (/usr/share/npm/lib/cache.js:488:10)
npm ERR!     at next_ (/usr/share/npm/lib/cache.js:438:17)
npm ERR!     at next (/usr/share/npm/lib/cache.js:415:44)
npm ERR!     at /usr/share/npm/lib/cache.js:408:5
npm ERR!     at saved (/usr/share/npm/lib/utils/npm-registry-client/get.js:147:7)
npm ERR!     at Object.oncomplete (/usr/lib/nodejs/graceful-fs.js:230:7)
npm ERR! You may report this log at:
npm ERR!     
npm ERR! or use
npm ERR!     reportbug --attach /home/xxx/gekko/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.8.0-22-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "update"
npm ERR! cwd /home/xxx/gekko
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.4
npm ERR! message No compatible version found: read@'>=1.0.0- <1.1.0-'
npm ERR! message Valid install targets:
npm ERR! message ["0.0.1","0.0.2","0.0.3","0.1.0","0.1.1"]
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/xxx/gekko/npm-debug.log
npm not ok
sr. member
Activity: 287
Merit: 250
Out of curiosity, did anyone loose a bit on the recent drop in price. I had gekko running on default settings in 'simulation' mode for 12 hours before the drop. Got no advice except one emailed to me - Sell at bottom price. LoL.  The drop was so fast that by the time the bot got 3 confirmations it was all over. Well, not completely, it did drop another 5 dollars usd on the 120 price shortly after that, then climbed back up to 125.
Right this moment hovering around 118. I still believe it is only going to get stronger. It is picking up real momentum and the only way it is going to fail is something better comes along ( ie government publishes their own official crypto-world-currency ), or it is somehow taxed to oblivion at the exchanges.

Gekko right now does not use the three thresholds to verify the trend. I think I should better clarify this in the readme.

Here is the data from my Gekko trading at Mt. Gox (price is in euros, time is in UTC: right now it's 19:10):

Code:
mike:~/nodeprojects/gekko-stuff$ cat gekko.log | grep SELL
2013-05-31 00:59:49 (INFO): ADVICE is to SELL @ 99.605 (-0.288)
2013-05-31 01:00:20 (INFO): SELL was succesfull

Code:
mike:~/nodeprojects/gekko-stuff$ tail gekko.log
2013-06-03 18:59:55 (INFO): ADVICE is to HOLD @ 93.763 (-0.275)
2013-06-03 18:59:55 (INFO): (PROFIT REPORT) -0.267% profit (in 1 trades)

EMA is not well suited for detecting this kind of sudden movements, because it takes time to verify that the trend is really happening. More trading methods will be added in the future!
sr. member
Activity: 462
Merit: 250
Out of curiosity, did anyone loose a bit on the recent drop in price. I had gekko running on default settings in 'simulation' mode for 12 hours before the drop. Got no advice except one emailed to me - Sell at bottom price. LoL.  The drop was so fast that by the time the bot got 3 confirmations it was all over. Well, not completely, it did drop another 5 dollars usd on the 120 price shortly after that, then climbed back up to 125.
Right this moment hovering around 118. I still believe it is only going to get stronger. It is picking up real momentum and the only way it is going to fail is something better comes along ( ie government publishes their own official crypto-world-currency ), or it is somehow taxed to oblivion at the exchanges.

That is pretty obvious as EMA crossovers are always lagging behind price. They are good for confirming trends, but they will never pick up a spike up or down.
full member
Activity: 196
Merit: 100
Out of curiosity, did anyone loose a bit on the recent drop in price. I had gekko running on default settings in 'simulation' mode for 12 hours before the drop. Got no advice except one emailed to me - Sell at bottom price. LoL.  The drop was so fast that by the time the bot got 3 confirmations it was all over. Well, not completely, it did drop another 5 dollars usd on the 120 price shortly after that, then climbed back up to 125.
Right this moment hovering around 118. I still believe it is only going to get stronger. It is picking up real momentum and the only way it is going to fail is something better comes along ( ie government publishes their own official crypto-world-currency ), or it is somehow taxed to oblivion at the exchanges.
sr. member
Activity: 287
Merit: 250
Very interesting project, I'm testing it now, my thoughts about future development:

- please take a look at TA-lib for node: https://npmjs.org/package/talib - using those libraries may speed up development of other useful methods
- before that, it would be good to decide how Gekko will deal with multiple methods and possibly contradictory suggestions. Some kind of voting mechanism with user-defined weights? Neural network? Other? Maybe suggestion should look like: 10% SELL, 70% KEEP, 20% BUY - SO KEEP.
- how about other input data? There's a lot of possible input data sources, other than exchange rate, eg. stock market indexes, google trends data for some keywords (related with bitcoin, world economy etc.) which can be correlated with btc future price trends. Will you propose some unified structure for such data to be shared possibly between different methods, or specific method will have to do it for it's own use?

I'd be very happy to contribute to the project, however I'm not a js programmer (but I'm trying to get a little bit more familliar with it). Currently I could share my debian scripts for running gekko daemon using node's "forever" module. Let me know if you're interested.

Thanks, let me know how the testing goes. Right now Gekko is just doing the really basic stuff (only look at price data of one single exchange, use a simple method like EMA and switch the full balance towards the detected trend). I am in the process of making Gekko more and more advanced.

I didn't know about TA-lib. It would indeed speed up Gekko's development by a lot of things if I can just plug it into Gekko! I've done a quick test and the installation fails on my laptop (OS X) and my vps (Linux), and I don't want to try windows. (I need to do some more research: not running latest node etc). So if I can get this working I think this is going to be optional in the settings.

I don't have a background in trading so I'm open in ideas about contradictory suggestions by different methods (for as soon as we have different methods). The user defined weights would be the most straightforward option. I would have to do more reading about neural networks before I can implement such a system into Gekko (if you know about it and can point me to some reading that would be great).

Your last point is something Gekko could definitely implement in the future, however this is much harder than applying basic math to current price numbers. So I first want to have a solid bot before I enter this kind of field. But we can of course already start thinking about what good indicators could be, I personally doubt a correlation between Bitcoin news coverage and the price (for example) at the moment, but this would all have to be backtested.

I'm getting better suggestions for new trade methods for Gekko to implement, so backtesting is a really big point on my list. I am currently figuring out if I can use the Mt. Gox data downloader provided by nitrous. This will download every trade from Mt. Gox and stuff it into a SQLite database, something Gekko could very easily use to extract data from.

I think rikigst theory looks great. Be fascinating to get this working. I like the idea of a gradual buy or sell. The chrome bot also allows a 'reserve' to be kept safe. I think that could be useful to. I think a lot of us see bitcoin having greater value over time. So I aim to 'build' my reserve, and only trade a percentage.

Besides, you need bitcoins to buy things only for sale in bitcoins...like some of the shares available that give a great return compared to poor mans GPU mining on their gaming rig.

The reserve part was pointed out to me yesterday as well and is on my current list of todos. Even though I don't want to force everyone into keeping / managing his bitcoin in a certain way, I do think it is best practise to not keep all of your BTC at an exchange.

My current todo list:

  • Risk percentage (how much % can Gekko play with)
  • Better profit logging
  • Backtesting
  • Solid way to implement trading methods (it is not possible to trade 10% of allowed balance for example)
  • MACD trading method
full member
Activity: 196
Merit: 100
I think rikigst theory looks great. Be fascinating to get this working. I like the idea of a gradual buy or sell. The chrome bot also allows a 'reserve' to be kept safe. I think that could be useful to. I think a lot of us see bitcoin having greater value over time. So I aim to 'build' my reserve, and only trade a percentage.

Besides, you need bitcoins to buy things only for sale in bitcoins...like some of the shares available that give a great return compared to poor mans GPU mining on their gaming rig.
hero member
Activity: 826
Merit: 1000
Here's an example. Parameters are kP = -70, kI = -10, kD= -470. Sample time is 120 minutes.



It basically sells when price raises, and buys when price falls. GRADUALLY.
Wallet starts with 1000$ (0 btcs) on May, 3rd, 00.00; ends with 1518$ worth of bitcoins today (0 usd).
Fee included in simulation?
newbie
Activity: 28
Merit: 0
Very interesting project, I'm testing it now, my thoughts about future development:

- please take a look at TA-lib for node: https://npmjs.org/package/talib - using those libraries may speed up development of other useful methods
- before that, it would be good to decide how Gekko will deal with multiple methods and possibly contradictory suggestions. Some kind of voting mechanism with user-defined weights? Neural network? Other? Maybe suggestion should look like: 10% SELL, 70% KEEP, 20% BUY - SO KEEP.
- how about other input data? There's a lot of possible input data sources, other than exchange rate, eg. stock market indexes, google trends data for some keywords (related with bitcoin, world economy etc.) which can be correlated with btc future price trends. Will you propose some unified structure for such data to be shared possibly between different methods, or specific method will have to do it for it's own use?

I'd be very happy to contribute to the project, however I'm not a js programmer (but I'm trying to get a little bit more familliar with it). Currently I could share my debian scripts for running gekko daemon using node's "forever" module. Let me know if you're interested.
sr. member
Activity: 287
Merit: 250
I think I get the picture, thanks for the explanation. So if the bot detects a trend the advantage of this method vs EMA is that if the trend is not real the bot does not have gambled the full balance on it. Is that the advantage? Because when you know there is going to be an uptrend you want to buy asap, right?

When I'm done with the backtesting feature of Gekko it will also be a lot easier to test these methods on historical data.

There is a tiny practical problem if you want to implement this method into Gekko right now. Because it only knows EMA at the moment and thus only has to sell or buy everything at once I would need to adjust the way Gekko handles the advice from the method to the real orders. If I understand it correctly your method would advice at a given moment something like 'sell 10% of balance' (and fire these advices of multiple times during the trend). Is that true? In that case I will update Gekko so that your trading method can be implemented.
newbie
Activity: 46
Merit: 0
Here's an example. Parameters are kP = -70, kI = -10, kD= -470. Sample time is 120 minutes.



It basically sells when price raises, and buys when price falls. GRADUALLY.
Wallet starts with 1000$ (0 btcs) on May, 3rd, 00.00; ends with 1518$ worth of bitcoins today (0 usd).
newbie
Activity: 46
Merit: 0
That's awsome! I don't quite understand the reasoning behind the math yet though.
Could you maybe point me to some reading explaining the logic of the method?
Hem... Actually, I came up with this by myself. You see, it's only a step futher Goomboo's method: his and mine share the input signal (ema-diff), but the behaviour is different. Goomboo's one is acting like a Schmitt Trigger (http://en.wikipedia.org/wiki/Schmitt_trigger), as it has only three output states (BUY EVERYTHING, SELL EVERYTHING, HOLD).
After operating the chrome bot for a while, i noticed that useful information was given not only by the ema-diff current value (is it positive? negative? above/under some threshold?), but also its trend, too. For instance, when the price has a peak, the ema-diff derivative changes sign.
Since I'm an engineer in the field of Control Theory, I wondered if smoothening Goomboo's strategy worked. So, instead of brutally buying/selling everything, the strategy I came up with should gradually buy or sell small quantities of btc, depending on the current ema value, its variation, and its past history.

So I fetched Gox's historic data, and wrote a small piece of software which simulates this aforementioned PID (http://en.wikipedia.org/wiki/PID_controller) strategy. Since I didn't know which parameters would fit best, I ran multiple instancies with different values.
Behaviours similar to Goomboo's strategy can be achieved with positive kP,kD and kI parameters (with kD >> kP in order to sell at the top and buy at the bottom).
Finally, I discovered that the best outcomes (20-30% profit from 1st to 17th may) came with NEGATIVE kI and kD parameters.
In a few words, this strategy is good for ranging markets. It buys gradually when the price falls, and it sells when it rises. But it will not profit if the price rises (or falls) for too long. I will attach some simulation charts in a minute.

I've been searching for something similar on Google, but couldn't find anything. Perhaps it has been given some other name (other than PID, which is a term from a totally different field), and it uses some other different signal (or set of signals, multiple inputs give more information than one, see MACD).
But this one is very similar to the original one, and can be understood by almost everyone, as it's quite simple.
Any thoughts?
sr. member
Activity: 287
Merit: 250
I am slowly getting to a point where I think Gekko runs pretty stable. Here are a couple of features I've added in the last few days:

Gekko now uses a portfolio manager to calculate the orders more precise (auto trading at BTC-e and Bitstamp is much better)

In my testing it is pretty stable at selling and buying at all three exchanges (It did cost me some fee haha). It wil create an order if the balance is bigger than the minimal order size (different per exchange), check if the order gets filled, if not do it again, etc.

You can now pass a command line parameter to tell Gekko which config file to use

I use this so that I can easily watch and trade at all three exchanges at the same time using the same Gekko code (I copied the config multiple times). I also have multiple non-trading Gekkos running at different currencies at Mt. Gox (and Gekkos with different EMA settings at BTC/USD) to calculate the most profitable settings / currency exchange over time (backtesting is on the todo).

Code:
$ ps ax | grep gekko
10475 ?        Sl     0:02 node gekko.js
10486 ?        Sl     0:05 node gekko.js config=config-half
10489 ?        Sl     0:03 node gekko.js config=config-mini
14701 pts/0    Sl     0:01 node gekko.js config=bitstamp
15295 pts/0    Sl     0:02 node gekko.js config=config-btce
15354 pts/0    Sl     0:00 node gekko.js config=config-mtgox-GBP
15358 pts/0    Sl     0:01 node gekko.js config=config-mtgox-AUD
15381 pts/0    Sl     0:00 node gekko.js config=config-mtgox-CHF
15386 pts/0    Sl     0:00 node gekko.js config=config-mtgox-CNY
15392 pts/0    Sl     0:00 node gekko.js config=config-mtgox-RUB
15399 pts/0    D+     0:00 grep gekko

I used nohup to route Gekkos output to different log files. For more information about how to specify other config files or how to use nohup (or an alternative) check out the 'advanced features' documentation.
sr. member
Activity: 287
Merit: 250
That's awsome! I don't quite understand the reasoning behind the math yet though.

I've written gekko so that it should be pretty modular: In theory you only have to create a new file and place it into method and enable it in the config. The easiest is to hack the current EMA method, but basically gekko currently expects this from a trading method:

  • Needs to be a file inside the method folder
  • It needs to expose an evenEmitter (see current method) so that Gekko can talk to it.
  • It needs to listen to `init` and the watcher object that follows.
  • It can use the `getTrades` method on the watcher to get data to analyze
  • It should not advice before the `start` event (from Gekko).
  • Gekko expects the method to emit the event advice whenever it advices a BUY, SELL or HOLD (with meta data)

I will write better documentation describing how to add new trading methods, similar to the documentation on how to add exchanges. If you need help just let me know, and in the meantime I am curious about the trading method. Could you maybe point me to some reading explaining the logic of the method?

EDIT:

if your method is similar to EMA in that it will fetch trades each candle / interval, calculate a bunch of numbers based on the latest price and advice based on those numbers it is the easiest to use the whole EMA method (but you can ofcourse rewrite it if you want).
newbie
Activity: 46
Merit: 0
Hello,
I'm trying to write a new strategy method by modifying exponential-moving-averages.js;
it should work this way:
  • user defines three extra parameters: kP, kI, kD
  • each sample interval, calculate ema-difference (same way like before), let's call it diff[now]
  • Proportional section:
    • (if kP*diff[now] > 0) buy kP*diff[now] BTC
    • (if kP*diff[now] < 0) sell -kP*diff[now] BTC
  • Derivative section:
    • (if kD*(diff[now]-diff[now-1]) > 0) buy kD*(diff[now]-diff[now-1]) BTC
    • (if kD*(diff[now]-diff[now-1]) < 0) sell -kD*(diff[now]-diff[now-1]) BTC
  • Integrative section:
    • define integral=sum of the last 10 (or more) diffs (diff[now]+diff[now-1]+...+diff[now-9])
    • (if kI*integral > 0) buy kI*integral BTC
    • (if kI*integral < 0) sell -kI*integral BTC

(For those who know Control Theory, this should act as a PID controller, with diff(t) as input.)
I've done some simulations, and it should be profitable with a ranging market (like the last 30 days)
The question is:
do I have to mess with the advice function only? Or does the strategy file have to be completely rewritten?
Thank you
sr. member
Activity: 287
Merit: 250
If your (older) version of Gekko is running smooth you can ignore this.

There are currently two bugs in dependencies of Gekko. I've submitted a fix for both but until these get merged you have to quickfix them yourself.

These bugs only effect your Gekko when you are watching either Mt. Gox or BTC-e.

You can read more in the readme.
Pages:
Jump to: