Bitcoin Forum
April 27, 2024, 12:14:50 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 »
  Print  
Author Topic: Gekko - a javascript trading bot and backtesting platform  (Read 147801 times)
whydifficult (OP)
Sr. Member
****
Offline Offline

Activity: 287
Merit: 250



View Profile WWW
May 18, 2013, 12:14:13 PM
Last edit: April 17, 2017, 03:40:03 PM by whydifficult
 #1

[EDIT 2017]

Gekko is still undergoing active development, but almost all information here is outdated. Please check the code on github and everything else on the brand new shiny website:

https://gekko.wizb.it/



Here is the first version of my (open source) trading bot for node called Gekko.

Quote


The most valuable commodity I know of is information.

-Gordon Gekko

You can find the whole project on Gekko's Github repo.

Gekko is a Bitcoin trading bot and backtesting platform that connects to popular Bitcoin exchanges. It is written in javascript and runs on nodejs.

This is the open source do-it-yourself version, we are planning on running hosted Gekkos in the cloud which does not require you to download and install anything, configure any textfiles or deal with the commandline. If you are looking for such a solution, sign up at Wizbit and we'll let you know once it's out.

Use Gekko at you own risk.

Main features

Trading platform:

  • Paper trading
  • Live trading (trade bot)

Market interface:

  • Emit market events
  • Basic IRC Bot, basic Campfire Bot

Supported exchanges

  • Mt. Gox
  • Bitstamp
  • CEX.io
  • Kraken
  • BTC-e
  • Cryptsy (alomst; in the pipeline)

Trading platform

Even though there are multiple EMA trading bots in javascript (as Chrome plugins) all of Gekko's code is written from scratch. The goal of the project is for me to learn more about such systems, therefor I'm trying to keep the code as readable as possible to also attract non programmers.

Gekko can watch the realtime markets. You can apply automated trading methods to realtime data coming in to do live or simulated trading (automated trading or paper trading). Gekko also stores the market data it sees so you can run the trading methods with simulate trades on a set of historical data to see whether they would have been profitable during that time (backtesting).

Gekko, as well as the current bitcoin exchanges, are not built for HFT or anything related to being the fastest. The trading methods Gekko can do are based on indicators used by human day traders. The result is that Gekko does not look at data below the one minute timescale and (depending on configuration) and will normally not trade more than a couple of times per week (also depending on configuration).

So Gekko is not

  • A fully automated trading bot that you turn on and will generate profit withouth you having to do anything.
  • A trading platform for human day traders with a GUI and charts.
  • A High frequency trading bot designed to operate on < minute resolution.
  • An exchange.

Market interface

Gekko also has a plugin system that can do certain things whenever something happens or let Gekko communicate through more platforms. Gekko currently knows these plugins:

  • Campfire: Enables Gekko to talk on Campfire and report latest market data and advice.]
  • IRC bot: Enables Gekko to talk on IRC and report latest market data and advice.
  • Mailer: Automatically sends email when your trading method has new advice.
  • Profit Simulator (paper trader): Hold a fake portfolio and simulate trades based on advice.
  • Redis Beacon: Broadcast events propagating through Gekko on Redis pub/sub.

Installing Gekko

Windows user? Here is a step-by-step guide on how to get Gekko running!

Because Gekko runs on node you need node installed. You can find more detailed instructions on how to install Gekko in the install section of the README.

Configuring Gekko

Configuring Gekko consists of three parts:

  • Watching a realtime market
  • Automate trading advice
  • Enabling plugins

Read the configuring Gekko documentation for a detailed explanation.

Running Gekko

To run the bot you just have to start Gekko:

Code:
node gekko

You can also run Gekko silently or use more complex features, for examples check out the advanced features.

How does Gekko work?



If you want to contribute or are interested in how Gekko works:


Gekko a nodejs bitcoin trading bot!
Realtime Bitcoin Globe - visualizing all transactions and blocks
Tip jar (BTC): 1KyQdQ9ctjCrGjGRCWSBhPKcj5omy4gv5S
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714220090
Hero Member
*
Offline Offline

Posts: 1714220090

View Profile Personal Message (Offline)

Ignore
1714220090
Reply with quote  #2

1714220090
Report to moderator
empoweoqwj
Hero Member
*****
Offline Offline

Activity: 518
Merit: 500


View Profile
May 18, 2013, 12:34:55 PM
 #2

1) being able to trade on bitstamp as well
2) Working with slightly unreliable Internet connections  Grin
ewibit
Legendary
*
Offline Offline

Activity: 2955
Merit: 1049


View Profile
May 18, 2013, 12:38:30 PM
 #3

1) being able to trade on bitstamp as well
and btc-e, Vircurex etc. with different currencies  Wink
whydifficult (OP)
Sr. Member
****
Offline Offline

Activity: 287
Merit: 250



View Profile WWW
May 18, 2013, 01:41:29 PM
 #4

1) being able to trade on bitstamp as well
and btc-e, Vircurex etc. with different currencies  Wink

Thanks for the feedback. I will start working on getting Gekko on different exchanges.

I am thinking on calculating the EMAs based on trades done at Mt. Gox (with a fallback when Mt. Gox is down or something), but buying and selling on a configurable exchange (bitstamp, btc-e, Vircurex, campbx, etc). Because I think that at the the moment Mt. Gox sets the trading trend and all other exchanges follow it with a delay.

Gekko a nodejs bitcoin trading bot!
Realtime Bitcoin Globe - visualizing all transactions and blocks
Tip jar (BTC): 1KyQdQ9ctjCrGjGRCWSBhPKcj5omy4gv5S
Gimmoroy
Legendary
*
Offline Offline

Activity: 1372
Merit: 1000



View Profile
May 18, 2013, 03:36:32 PM
 #5

Look to the:
redis ( bot have remember historical data)
reliable graphic interface ( say kind of http://bitcoincharts.com)
socket.io ( for reliable connection)
strong sell/buy algorithm, as it's different in gox/btc-e/etc. APIs.

have fun !  Wink

whydifficult (OP)
Sr. Member
****
Offline Offline

Activity: 287
Merit: 250



View Profile WWW
May 18, 2013, 05:16:45 PM
 #6

Look to the:
redis ( bot have remember historical data)
reliable graphic interface ( say kind of http://bitcoincharts.com)
socket.io ( for reliable connection)
strong sell/buy algorithm, as it's different in gox/btc-e/etc. APIs.

have fun !  Wink

Thanks for your feedback Smiley

Great idea about storing historical data. Redis is great but it would mean a pretty big extra dependency for everyone who is not a developer and just wants to try/run gekko. Maybe if the difference in performance is not that big I could just go for flat file?

At the moment Gekko is just a simple command line tool (no frontend / GUI). Because it uses slow EMA, websockets to Mt. Gox would be overkill I think right? Eg. If it only needs a couple of trades every 60 minutes, not depending on anywhere near realtime.

I indeed want to abstract out all logic around buying and selling at the different exchanges so I can just plug in a new exchange. Right now the trading methods (there is only one yet Wink) are abstracted out so that the trading method can only advice and Gekko (who listens to the advice) holds the keys to the Mt. Gox API.

Gekko a nodejs bitcoin trading bot!
Realtime Bitcoin Globe - visualizing all transactions and blocks
Tip jar (BTC): 1KyQdQ9ctjCrGjGRCWSBhPKcj5omy4gv5S
jp
Member
**
Offline Offline

Activity: 69
Merit: 10



View Profile WWW
May 18, 2013, 06:28:18 PM
 #7

I agree on your thoughts about the unnecessary dependency upon Redis. If a high performance key/value store, you can use LevelDB. It's an inprocess database (no 3rd party dep)... Here is the best Node.js module that uses LevelDB: https://github.com/rvagg/node-levelup Also, there are a lot of 3rd party modules that integrate with levelup that do a lot of cool things.

Keep up the good work!

Helping the world exit the traditional financial system.
daybyter
Legendary
*
Offline Offline

Activity: 965
Merit: 1000


View Profile
May 18, 2013, 07:54:27 PM
 #8

How hard would it be to convert just the trading strategy to Java? You could use

https://github.com/ReAzem/cryptocoin-tradelib

then, and I could give you some code for a tradebot core, like I use it:

https://i.imgur.com/OoP0aNo.jpg

Maybe we could collaborate somehow?

whydifficult (OP)
Sr. Member
****
Offline Offline

Activity: 287
Merit: 250



View Profile WWW
May 18, 2013, 10:07:04 PM
 #9

Gekko Update:

Gekko now also supports automatic trading via BTC-e in addition to Mt. Gox! I've also updated the readme, to clarify how to run Gekko.

edit: I've just added BTC-e and I am my Gekko is using it, but it's alpha stage to say the least.

I will add more exchanges when I have some spare time.

I agree on your thoughts about the unnecessary dependency upon Redis. If a high performance key/value store, you can use LevelDB. It's an inprocess database (no 3rd party dep)... Here is the best Node.js module that uses LevelDB: https://github.com/rvagg/node-levelup Also, there are a lot of 3rd party modules that integrate with levelup that do a lot of cool things.

Keep up the good work!

Thanks for the link. I haven't heard that much about leveldb before but will look into it, sounds pretty cool. But isn't leveldb the same kind of dependency? Right now Gekko is running fine on my laptop (OSX), my pc (Windows 7) and my server (Ubuntu). It appears) that installing leveldb for windows, for example, requires building from source using Microsoft Visual Studio (not something everyone wanting to spin Gekko for a testrun is waiting for I think).

How hard would it be to convert just the trading strategy to Java? You could use

https://github.com/ReAzem/cryptocoin-tradelib

then, and I could give you some code for a tradebot core, like I use it:

https://i.imgur.com/OoP0aNo.jpg

Maybe we could collaborate somehow?

Awesome library! If I'm understanding it correctly the libary provides easy access to a lot of exchanges right? That's definitly something Gekko needs right now.

The biggest problem for me is that I have no experience in Java, so it's pretty hard for me to read the library. Gekko is just a small project at the moment, it's just a few hundred lines of code right now. Is it possible to connect to your framework using a communication layer?

I guess the easiest to get this method (which is described in more detail by Goomboo) into your library is to just port it to Java. If you don't have a lot of experience in javascript (or nodejs), you have the advantage to look at two additional projects who implement the same trading method:


I've also just looked at how to get Gekko to talk to all exchanges using nodejs, and a lot of people have written modules for exchanges already:


It should be pretty much just plugging them into Gekko, because all connect logic is already written.

Gekko a nodejs bitcoin trading bot!
Realtime Bitcoin Globe - visualizing all transactions and blocks
Tip jar (BTC): 1KyQdQ9ctjCrGjGRCWSBhPKcj5omy4gv5S
Gimmoroy
Legendary
*
Offline Offline

Activity: 1372
Merit: 1000



View Profile
May 19, 2013, 12:59:59 AM
 #10


At the moment Gekko is just a simple command line tool (no frontend / GUI). Because it uses slow EMA, websockets to Mt. Gox would be overkill I think right? Eg. If it only needs a couple of trades every 60 minutes, not depending on anywhere near realtime.

I indeed want to abstract out all logic around buying and selling at the different exchanges so I can just plug in a new exchange. Right now the trading methods (there is only one yet Wink) are abstracted out so that the trading method can only advice and Gekko (who listens to the advice) holds the keys to the Mt. Gox API.

Command line tool is not a good idea where you deal with empiric analysis (DEMA) with empiric coefficients. I, personally, love to understand what my money going to do  Wink

Sockets not for real time ( json 2 times faster) - this for persistent connection. Not for bot - just for Gox, which have connection problems. 

As for trading methods, I meant this:
1. buy/sell on a current float price ( btc-e didn't support this method, but it's simple and promised)
2. set order with hard price + not executed order should be canceled when(?)... you know. Chrome extension by TobbeLino didn't support this.

Thanks for your work! Hope your bot will be the best.



 
whydifficult (OP)
Sr. Member
****
Offline Offline

Activity: 287
Merit: 250



View Profile WWW
May 19, 2013, 11:34:56 AM
Last edit: May 19, 2013, 12:50:19 PM by whydifficult
 #11

Command line tool is not a good idea where you deal with empiric analysis (DEMA) with empiric coefficients. I, personally, love to understand what my money going to do  Wink

Sockets not for real time ( json 2 times faster) - this for persistent connection. Not for bot - just for Gox, which have connection problems.  

As for trading methods, I meant this:
1. buy/sell on a current float price ( btc-e didn't support this method, but it's simple and promised)
2. set order with hard price + not executed order should be canceled when(?)... you know. Chrome extension by TobbeLino didn't support this.

Thanks for your work! Hope your bot will be the best.

Good point, Gekko is going to need some sort of interface. Right now I'm thinking of creating a bookmarklet which you can run on clarkmoody that will connect to a local running Gekko and plot the advice (or the buys/sells) on the hourly graph. This would take the least amount of work and you can just use the clarkmoody graphs which are pretty good IMO.

So this would mean: user goes to clarkmoody, click a bookmark and see Gekko's advice / actions as shapes drawn on the graph.

I'm sorry but I still don't completely understand your suggestion for trade methods (not a lot of trade experience here):

1. Do you mean buy/sell on current market price on BTC-e? Because btc-e doesn't let you do an order at market price. This is how Gekko implements it right now when you configure buying/selling on btc-e:

  • Watch trends on Mt. Gox, when new trend (up/down):
  • Fetch the latest trades from btc-e (since prices are different from Mt. Gox), calculate btc-e price based on all trades in the last 20 seconds.
  • Buy/sell using this calculated price.

2. Yep this needs to added to Gekko.

Thanks for the tips Smiley


Edit For everyone who wants to help out testing Gekko but having some installation problems: I've made a tutorial on how to install and run Gekko on windows.

Installing Gekko on Windows

Gekko a nodejs bitcoin trading bot!
Realtime Bitcoin Globe - visualizing all transactions and blocks
Tip jar (BTC): 1KyQdQ9ctjCrGjGRCWSBhPKcj5omy4gv5S
Gimmoroy
Legendary
*
Offline Offline

Activity: 1372
Merit: 1000



View Profile
May 19, 2013, 07:15:26 PM
 #12

Sorry my bad english.
I mean this:
mtGOX API allow two trading strategies (market price / strong order )
BTCe - only strong order

This two strategies have different trading algorithms.
as first one method is realized and second have to be - maybe for GOX it should be switchable, as giving different trading results?

More - I was unable to find a document which describes stock strategy on strong orders. If I make order to sell at $1 and stock have order to bye on $1.1, which order will be executed if any will?  It's most interesting point.

Also I offer all settings should be stored as the options of stock and trading method. Other, we (users) will spend all the experiments time for change settings and try .   



 
 
whydifficult (OP)
Sr. Member
****
Offline Offline

Activity: 287
Merit: 250



View Profile WWW
May 19, 2013, 10:16:23 PM
Last edit: May 19, 2013, 10:38:17 PM by whydifficult
 #13

Gekko is being actively developed at the moment Smiley

Gekko now reports the profit it generates or would have generated (wether you have real trading enabled or not)! Gekko always simulates trading based on the EMA advice and reports about it every interval.

Quote from: Gekko
(ADVICE) 2013-05-19 22:05:53 HOLD @ 121.680 (-0.207)
(PROFIT REPORT) 2013-05-19 22:05:53 0.000 % profit (in 0 trades)

Read more in the profit reporting section in the readme. All configuration has also moved to a handy single config file.

Note that it is possible to make profit / lose money without doing any trades, due BTC changing in price

Sorry my bad english.
I mean this:
mtGOX API allow two trading strategies (market price / strong order )
BTCe - only strong order

This two strategies have different trading algorithms.
as first one method is realized and second have to be - maybe for GOX it should be switchable, as giving different trading results?

More - I was unable to find a document which describes stock strategy on strong orders. If I make order to sell at $1 and stock have order to bye on $1.1, which order will be executed if any will?  It's most interesting point.

Also I offer all settings should be stored as the options of stock and trading method. Other, we (users) will spend all the experiments time for change settings and try .

I don't quite understand it yet, because I can't find what you mean by strong order / market price strategy (I know very little about trading, I learned last week what a order book is for example). If you can point me to some links I will research it and try to put it into Gekko Smiley

Upcoming features

  • Backtesting different EMA settings
  • More exchanges

Gekko a nodejs bitcoin trading bot!
Realtime Bitcoin Globe - visualizing all transactions and blocks
Tip jar (BTC): 1KyQdQ9ctjCrGjGRCWSBhPKcj5omy4gv5S
Gimmoroy
Legendary
*
Offline Offline

Activity: 1372
Merit: 1000



View Profile
May 19, 2013, 11:36:12 PM
 #14

Strong order - you make order to sell/buy which point price of deal
market price - you make order to sell/buy and stock execute it on current market price ( as made in TobbeLino's bot)

The names can be wrong, but the description correct imho. 
whydifficult (OP)
Sr. Member
****
Offline Offline

Activity: 287
Merit: 250



View Profile WWW
May 20, 2013, 12:07:58 AM
 #15

Strong order - you make order to sell/buy which point price of deal
market price - you make order to sell/buy and stock execute it on current market price ( as made in TobbeLino's bot)

The names can be wrong, but the description correct imho.  

Ow that I understand Smiley

BTC-e doesn't let me do a 'market price', I have to state at which price I want to place an order. When you have enabled auto trading and Gekko identifies a trend a couple of things will happen:

  • If you configured Mt. Gox -> buy/sell at 'market price'
  • If you configured BTC-e -> look at all the BTC-e trades in the last 20 seconds and calculate average price, now buy sell with this price.

This is just a workaround to first grab the latest price and use that. Do you suggest a special strategy for 'strong orders'? Because right now Gekko will never do a strong order on Mt. Gox because it can do a market price. I can make it configurable so that Mt. Gox will also have a 'strong order' option, but what price should Gekko use or how should it calculate a price?

Gekko a nodejs bitcoin trading bot!
Realtime Bitcoin Globe - visualizing all transactions and blocks
Tip jar (BTC): 1KyQdQ9ctjCrGjGRCWSBhPKcj5omy4gv5S
jp
Member
**
Offline Offline

Activity: 69
Merit: 10



View Profile WWW
May 20, 2013, 03:36:35 AM
 #16

Quote
But isn't leveldb the same kind of dependency?

No. Think of it like sqlite, there is no 3rd party dependency other than the Node.js library. LevelDB is database created by Google by the way. Levelup is the Node.js implementation.

-JP

Helping the world exit the traditional financial system.
davider
Member
**
Offline Offline

Activity: 72
Merit: 10


View Profile WWW
May 20, 2013, 12:49:15 PM
 #17

Thank you for your bot. Do you think to add other altcoin trading?
I think it would be great to have LTC/USD with BTC-E.
induce
Newbie
*
Offline Offline

Activity: 18
Merit: 0


View Profile
May 20, 2013, 07:21:21 PM
 #18

askmike is the man! Keep up the good work dude!
whydifficult (OP)
Sr. Member
****
Offline Offline

Activity: 287
Merit: 250



View Profile WWW
May 20, 2013, 10:38:55 PM
 #19

No. Think of it like sqlite, there is no 3rd party dependency other than the Node.js library. LevelDB is database created by Google by the way. Levelup is the Node.js implementation.

-JP

Sorry misread your first message, levelDB looks way better then trying to implement flatfile really bad myself. Storing trade history is on my todo list and I think I will use levelDB for it. Thanks for the tip!

Thank you for your bot. Do you think to add other altcoin trading?
I think it would be great to have LTC/USD with BTC-E.

Thanks!

Currently Gekko is basing all his advice on what is happening at Mt. Gox (even when you have automatic trading set at BTC-e, because for BTC every exchange will follow the trends happening at Mt. Gox). I'm planning a new feature where you can configure on what exchange (and what currency) to watch for trends Smiley

Note that other features (mostly backtesting) are higher on my todo list at the moment.

askmike is the man! Keep up the good work dude!

Haha thanks man!

Gekko a nodejs bitcoin trading bot!
Realtime Bitcoin Globe - visualizing all transactions and blocks
Tip jar (BTC): 1KyQdQ9ctjCrGjGRCWSBhPKcj5omy4gv5S
dwolfman
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile WWW
May 20, 2013, 10:39:31 PM
 #20

I'd be more interested in this if it could track the price on the same exchange as the one being traded on.  Personal choice is to not have anything to do with MtGox, so anything that can work strictly with CampBX, or BTC-e, would be best.

Wanna send coins my way? 1BY2rZduB9j8Exa4158QXPFJoJ2NWU1NGf or just scan the QR code in my avatar.  :-)
Pages: [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 »
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!