Bitcoin Forum

Economy => Trading Discussion => Topic started by: prof7bit on April 20, 2013, 05:38:00 PM



Title: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 20, 2013, 05:38:00 PM
I'm making separate threads for individual goxtool bots to keep the goxtool thread for goxtool related stuff only. I choose this forum because the goxtool thread was moved into this forum too. (Similar software sometimes gets moved into different forums, I believe there is a forum missing for all kinds of software that is bitcoin related but *not* a bitcoin client/wallet itself)

And here is the balancer bot:
_balancer.py: https://gist.github.com/prof7bit/5395900 (https://gist.github.com/prof7bit/5395900)

This bot will maintain a constant asset allocation ratio Bitcoin/Fiat = 50/50
http://en.wikipedia.org/wiki/Rebalancing_investments#Rebalancing_bonus (http://en.wikipedia.org/wiki/Rebalancing_investments#Rebalancing_bonus)
It will do so by placing limit orders above and below current price that will restore the 50/50 ratio once price moves there and fills the order. As soon as one order is filled it will cancel the other and then calculate and place 2 new orders above and below that new price. The price distance of the orders is 7%, that can be changed in the variable DISTANCE you should not make it smaller than 2%).

This strategy will produce a small profit in the long run (a few percent per week if there are huge price swings or nothing at all when its going sideways for many days), it seems a promising strategy for BTC/USD because of its insanely high volatility but it will also make your account balance go up and down directly in tandem with BTC price, so prepared to see huge swings in your account. You should write down BTC-price, USD and BTC balance in your account once a week and plot these curves after a few months or years to see the effect. This is not a get rich quick bot, this needs patience!

Installation and usage:

  • prerequisites: you are familiar with the usage of goxtool.py
  • (most important) update goxtool to the latest version (git pull)
  • save the file from the above link as _balancer.py in the same directory as goxtool
  • ./goxtool.py --strategy=_balancer.py --protocol=websocket --use-http
  • (optional) open a separate terminal and tail -f goxtool.log | grep Strategy to follow the debug output of the strategy module
  • cancel all orders and bring your account into 50/50 balance, do so by pressing the b key
  • start the bot by pressing the p key

Disclaimer: If the above sounds chinese to you or you cannot read the code or don't understand what it does or you are not a Linux user (needed for goxtool) then algo trading is not for you. You should have the skills to implement this yourself from scratch given the description of the strategy or be able to read, understand and debug every aspect of the existing code or it will only end with a huge disappointment or maybe even a desaster.

As you can see in the code the the bot has some some hotkeys bound to certain actions to control its operations:

i show info about current status (how much out of balance)
c cancel all open rebalancing orders and suspend trading
b rebalance immediately with market order at current price
p place a pair of fresh rebalancing orders and start/resume trading
u manually force update of own order list and other stuff (should only be needed when socketio connection behaves strange or is down or other related problems, not used for normal operations)

like all other goxtool strategies it can be reloaded at runtime without restarting goxtool (for example after editing DISTANCE) by pressing the l key (lowercase L).

As you also can see from the code it is triggering its trades when it has detected the number of orders being exactly 1, this does not happen in the trade message, the user_order message is the last API message that is sent after a series of messages updating the wallet and the trade message (and this signal is also triggered after reconnect), so this is the best place to trigger new orders, knowing that the wallet is updated already (we need the new account balance for the calculations).

When the bot ever comes out of sync, I have seen this happening when price is jumping around too fast and you choose DISTANCE too small and mtgox is under ddos at the same time and the connection becomes really unreliable then you need to cancel all orders (press c to cancel and halt trading, also check with F6 that really all orders have been canceled, maybe use u to manually update if socketio is down and if its screwed up totally then restart goxtool. This should not happen very often) and then check if you need to rebalance (press i and see the log) and if needed manually rebalance (press b) and then resume automatic rebalancing (press p).


Title: Re: goxtool bot: portfolio rebalancing
Post by: jubalix on April 21, 2013, 06:02:26 AM
is there a debug mode/test mode where it can just hook into gox data, and i put in a test fiat /btc amount and see how it runs

with mocked up fees and every thing....

I guess my worry is in spikey fast trading with bad connections sometimes computer programs behave in unexpected manners.

I guess the other tool would be a face feed to simulate a jumpy/flaky gox feed....

then we would have a good test environs....

or is this already present?


I'm making separate threads for individual goxtool bots to keep the goxtool thread for goxtool related stuff only. I choose this forum because the goxtool thread was moved into this forum too. (Similar software sometimes gets moved into different forums, I believe there is a forum missing for all kinds of software that is bitcoin related but *not* a bitcoin client/wallet itself)

And here is the balancer bot:
_balancer.py: https://gist.github.com/prof7bit/5395900 (https://gist.github.com/prof7bit/5395900)

This bot will maintain a constant asset allocation ratio Bitcoin/Fiat = 50/50
http://en.wikipedia.org/wiki/Rebalancing_investments#Rebalancing_bonus (http://en.wikipedia.org/wiki/Rebalancing_investments#Rebalancing_bonus)
It will do so by placing limit orders above and below current price that will restore the 50/50 ratio once price moves there and fills the order. As soon as one order is filled it will cancel the other and then calculate and place 2 new orders above and below that new price. The price distance of the orders is 7%, that can be changed in the variable DISTANCE you should not make it smaller than 2%).

This strategy will produce a small profit in the long run (a few percent per week if there are huge price swings or nothing at all when its going sideways for many days), it seems a promising strategy for BTC/USD because of its insanely high volatility but it will also make your account balance go up and down directly in tandem with BTC price, so prepared to see huge swings in your account. You should write down BTC-price, USD and BTC balance in your account once a week and plot these curves after a few months or years to see the effect. This is not a get rich quick bot, this needs patience!

Installation and usage:

  • prerequisites: you are familiar with the usage of goxtool.py
  • (most important) update goxtool to the latest version (git pull)
  • save the file from the above link as _balancer.py in the same directory as goxtool
  • ./goxtool.py --strategy=_balancer.py --protocol=socketio --use-http
  • (optional) open a separate terminal and tail -f goxtool.log | grep Strategy to follow the debug output of the strategy module
  • cancel all orders and bring your account into 50/50 balance, do so by pressing the b key
  • start the bot by pressing the p key

Disclaimer: If the above sounds chinese to you or you cannot read the code or don't understand what it does or you are not a Linux user (needed for goxtool) then algo trading is not for you. You should have the skills to implement this yourself from scratch given the description of the strategy or be able to read, understand and debug every aspect of the existing code or it will only end with a huge disappointment or maybe even a desaster.

As you can see in the code the the bot has some some hotkeys bound to certain actions to control its operations:

i show info about current status (how much out of balance)
c cancel all open rebalancing orders and suspend trading
b rebalance immediately with market order at current price
p place a pair of fresh rebalancing orders and start/resume trading
u manually force update of own order list and other stuff (should only be needed when socketio connection behaves strange or is down or other related problems, not used for normal operations)

like all other goxtool strategies it can be reloaded at runtime without restarting goxtool (for example after editing DISTANCE) by pressing the l key (lowercase L).

As you also can see from the code it is triggering its trades when it has detected the number of orders being exactly 1, this does not happen in the trade message, the user_order message is the last API message that is sent after a series of messages updating the wallet and the trade message (and this signal is also triggered after reconnect), so this is the best place to trigger new orders, knowing that the wallet is updated already (we need the new account balance for the calculations).

When the bot ever comes out of sync, I have seen this happening when price is jumping around too fast and you choose DISTANCE too small and mtgox is under ddos at the same time and the connection becomes really unreliable then you need to cancel all orders (press c to cancel and halt trading, also check with F6 that really all orders have been canceled, maybe use u to manually update if socketio is down and if its screwed up totally then restart goxtool. This should not happen very often) and then check if you need to rebalance (press i and see the log) and if needed manually rebalance (press b) and then resume automatic rebalancing (press p).


Title: Re: goxtool bot: portfolio rebalancing
Post by: smooth on April 21, 2013, 06:41:11 AM
I guess my worrie is in spikey fast tradeing with bad conections sometimes computer programs behace in unexpected manners.

There are definitely issues with lag, dropped gox connections, etc.  Some of those are discussed on the main thread, as they aren't really specific to this strategy.

Another rebalancing strategy discussed on the same wiki page might also be interesting to play with:

http://en.wikipedia.org/wiki/Constant_proportion_portfolio_insurance



Title: Re: goxtool bot: portfolio rebalancing
Post by: 1Pakis on April 21, 2013, 07:20:09 AM
F*ck! I was doing that by hand when I was awake with emotions envolved.
I wanted an emotionless robot to do that for me all day long.
Thanks for that bot.
Donation is coming your way.
https://blockchain.info/tx/b7945ec1febb42338e96d9a05019593751dbf8f3775e56ca74789e2de661b1a0 (https://blockchain.info/tx/b7945ec1febb42338e96d9a05019593751dbf8f3775e56ca74789e2de661b1a0)
Thanks again


Title: Re: goxtool bot: portfolio rebalancing
Post by: 1Pakis on April 21, 2013, 08:37:44 AM
I set DISTANCE at 5.
I was balanced at 126.30
First trade went smoothly at 119.97
New orders opened


Title: Re: goxtool bot: portfolio rebalancing
Post by: ErebusBat on April 21, 2013, 11:23:28 PM
So... Did anyone else have the bot freak out and place 30+ orders because of GOX lag today?


Title: Re: goxtool bot: portfolio rebalancing
Post by: jubalix on April 22, 2013, 01:41:06 AM
So... Did anyone else have the bot freak out and place 30+ orders because of GOX lag today?


hmm i may have mentioned this.....need to make something like

if(watch.goxLag())
{
trade
}


goxLag()
{

if
{last.ping() > choose interval
return false}

...condition
false

....condition
true

}

etc


Title: Re: goxtool bot: portfolio rebalancing
Post by: ErebusBat on April 22, 2013, 02:33:39 AM
So... Did anyone else have the bot freak out and place 30+ orders because of GOX lag today?


hmm i may have mentioned this.....need to make something like

if(watch.goxLag())
{
trade
}


goxLag()
{

if
{last.ping() > choose interval
return false}

...condition
false

....condition
true

}

etc

It wasn't just lag tho. When I looked there was only like 60s.  However I kept getting 503 errors all over the place. 

I think a nice feature (although far from full proof) would be to cancel all orders if there are >2 bot orders, then place them again.  However it is still possible that some of those rouge orders get filled in the meantime.


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on April 22, 2013, 07:28:18 AM
I like the idea, is it also able to trade BTC/EUR ?


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 22, 2013, 09:52:33 AM
I think a nice feature (although far from full proof) would be to cancel all orders if there are >2 bot orders, then place them again.  However it is still possible that some of those rouge orders get filled in the meantime.

I'm trying to understand wat might have happened to cause these symptoms, i don't have any idea yet. It should not trade if there are != 1 open orders, it should not trade if there are != 0 submitted but not yet acked orders.

How did you start goxtool, did you use --use-http or did you send the orders via the streming API? I cannot imagine any scenario where sending an order would *not* increment gox.count_submitted *or* the number of own orders in orderbook.owns. Either the sent order doesn't get acked then count_submitted will be != 0 or there comes the ack with order id for each order then count_submitted = 0 but orderbook.owns has a new element added. In both cases it shoudl stop sending more orders. The only way I could vaguely imagine was if you did not --use-http and submitted via socketio, never received the ack and order ID, a reconnect would reset the count_submitted counter [Edit: actually only a *successful* download of own orders will reset count_submitted, not a simple reconnect] and because of ddos and 502 error you would never get the full own order list download but for some reason all the submitted orders (submitted through socketio and never acked) would later go through all at once [because they were hanging around somewhere on the server in some kind of separate (undocumented?) queue all the time]. Thats why I recommend --use-http because that way you *WILL* get an ack for every order under all circumstances because the http call will either succeed (ack) or fail.

Are you running the latest version of goxtool.py and the latet version of the bot (3rd revision) from the github gist in post #1 of this thread or are you still using one of the older versions from the other thread?

If this happens again please save the log file (*before* you restart goxtool because restarting will truncate the old log)


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 22, 2013, 09:55:19 AM
I like the idea, is it also able to trade BTC/EUR ?
Yes, just change the currency in goxtool.ini from USD to EUR.


Title: Re: goxtool bot: portfolio rebalancing
Post by: c0inbuster on April 22, 2013, 10:07:47 AM
I don't like the idea of this .ini file

because you can't have 2 goxtool instance running in 2 differents GNU screen
 (one for BTC/USD and an other one for BTC/EUR)

(if you want to do this you will have to copy goxtool)

maybe you should add flag to CLI
Code:
--cur1 BTC --cur2 EUR
or
Code:
--symbol BTCEUR


Title: Re: goxtool bot: portfolio rebalancing
Post by: c0inbuster on April 22, 2013, 02:06:44 PM
an other idea could be to allow to pass config file as parameter like this

Code:
python goxtool.py --config /path/to/goxtool.ini

so it will be possible to have a screen with BTCUSD and an other one with BTCEUR

**but** if your strategies are writing files it could be a problem because 2 differents goxtools
are writing on same file...
Let's say that you are implementing a trailing stop strategy...
you will store stop loss price in a file (because you want not to lose value if goxtool is
stopped and started)
let's call sl.txt this file (ini, json or yaml file)

maybe you should add a "name" parameter in goxtool.ini
Code:
[gox]
name = MyGox1
currency = USD
use_ssl = True
use_plain_old_websocket = False
use_http_api = False
load_fulldepth = True
load_history = True
history_timeframe = 15
secret_key =
secret_secret =

[goxtool]
set_xterm_title = True

and strategy that writes files (to store data such as last stop price) will store data as
MyGox1_sl.txt

so differents goxtool could work together

(english is not my mother tongue... so please excuse me if it's not very clear)


Adding config parameter is quite easy to do

in goxtool.py file

Code:
    argp.add_argument('--config', action="store", default="goxtool.ini",
        help="name of config file, default=goxtool.ini")

    args = argp.parse_args()

    config = goxapi.GoxConfig(args.config)

So you can now have a goxtoolBTCEUR.ini with
Code:
[gox]
currency = EUR
use_ssl = True
use_plain_old_websocket = False
use_http_api = False
load_fulldepth = True
load_history = True
history_timeframe = 15
secret_key =
secret_secret =

[goxtool]
set_xterm_title = True

and call goxtool with this config file as parameter using

Code:
python goxtool.py --config goxtoolBTCUSD.ini

or with my Raspberry Pi running my Bitcoin/Litecoin softwares in GNU Screen

Code:
screen -t goxtoolBTCUSD 50 python /home/pi/src/goxtool/goxtool.py --config /home/pi/src/goxtool/goxtoolBTCUSD.ini
screen -t goxtoolBTCEUR 51 python /home/pi/src/goxtool/goxtool.py --config /home/pi/src/goxtool/goxtoolBTCEUR.ini


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 22, 2013, 03:32:05 PM
I don't like the idea of this .ini file

because you can't have 2 goxtool instance running in 2 differents GNU screen
 (one for BTC/USD and an other one for BTC/EUR)

I'm aware of the problem. And there is also the logfile that will be written by each running gox instance. I'm already thinking about possible solutions. Currently the simplest workaround is to either copy the entire folder or start it from within different cwd. This will improve eventually but at the moment I'm still finding new bugs in the client code (handling some erroneous conditions, missed messages, previously unknown error replies from mtgox API that result from various kinds of mtgox outage and other strange mtgox behavior that could happen) these kinds of bugfixes have highest priority.


Title: Re: goxtool bot: portfolio rebalancing
Post by: c0inbuster on April 22, 2013, 03:44:02 PM
Thanks...
maybe the "name" parameter in config file is a KISS solution (Keep it Simple, Stupid)
(even for log file)

good luck hunting bugs  ;)


Title: Re: goxtool bot: portfolio rebalancing
Post by: K1773R on April 22, 2013, 03:49:14 PM
I don't like the idea of this .ini file

because you can't have 2 goxtool instance running in 2 differents GNU screen
 (one for BTC/USD and an other one for BTC/EUR)

I'm aware of the problem. And there is also the logfile that will be written by each running gox instance. I'm already thinking about possible solutions. Currently the simplest workaround is to either copy the entire folder or start it from within different cwd. This will improve eventually but at the moment I'm still finding new bugs in the client code (handling some erroneous conditions, missed messages, previously unknown error replies from mtgox API that result from various kinds of mtgox outage and other strange mtgox behavior that could happen) these kinds of bugfixes have highest priority.
then how about applying the patch i did send u? :P


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on April 22, 2013, 07:41:07 PM
got this running on my raspberry pi now for testing purposes with small amount of funds, and it's working as intended so far.
But I got a little problem: how can I run the bot in background, I can't fork the process to background using "&" because I won't be prompted for the decryption password, and if I close the SSH session the process gets killed.


Title: Re: goxtool bot: portfolio rebalancing
Post by: arsenische on April 22, 2013, 07:45:12 PM
got this running on my raspberry pi now for testing purposes with small amount of funds, and it's working as intended so far.
But I got a little problem: how can I run the bot in background, I can't fork the process to background using "&" because I won't be prompted for the decryption password, and if I close the SSH session the process gets killed.

probably you can run it from screen (https://help.ubuntu.com/community/Screen)


Title: Re: goxtool bot: portfolio rebalancing
Post by: c0inbuster on April 22, 2013, 07:48:29 PM
You can use GNU screen

Code:
$ apt-get install screen

run it using
Code:
$ screen -t goxtool 51 python /home/pi/src/goxtool/goxtool.py

CTRL + a + " to change screen
CTRL + a + c to create new screen

If you want to run it at startup, I can say you what I did
(there is probably a better solution)

put in /home/pi/.screenrc

Code:
screen -t goxtool 51 python /home/pi/src/goxtool/goxtool.py
and add

Code:
su - pi -c "/usr/bin/screen -dmS rclocal"

in your /etc/rc.local

If you consider that what I'm doing for you is valuable you can send me some crypto-coins.
https://sites.google.com/site/working4coins/donate


Title: Re: goxtool bot: portfolio rebalancing
Post by: ErebusBat on April 22, 2013, 08:06:56 PM
I think a nice feature (although far from full proof) would be to cancel all orders if there are >2 bot orders, then place them again.  However it is still possible that some of those rouge orders get filled in the meantime.

I'm trying to understand wat might have happened to cause these symptoms, i don't have any idea yet. It should not trade if there are != 1 open orders, it should not trade if there are != 0 submitted but not yet acked orders.

How did you start goxtool, did you use --use-http or did you send the orders via the streming API? I cannot imagine any scenario where sending an order would *not* increment gox.count_submitted *or* the number of own orders in orderbook.owns. Either the sent order doesn't get acked then count_submitted will be != 0 or there comes the ack with order id for each order then count_submitted = 0 but orderbook.owns has a new element added. In both cases it shoudl stop sending more orders. The only way I could vaguely imagine was if you did not --use-http and submitted via socketio, never received the ack and order ID, a reconnect would reset the count_submitted counter [Edit: actually only a *successful* download of own orders will reset count_submitted, not a simple reconnect] and because of ddos and 502 error you would never get the full own order list download but for some reason all the submitted orders (submitted through socketio and never acked) would later go through all at once [because they were hanging around somewhere on the server in some kind of separate (undocumented?) queue all the time]. Thats why I recommend --use-http because that way you *WILL* get an ack for every order under all circumstances because the http call will either succeed (ack) or fail.

Are you running the latest version of goxtool.py and the latet version of the bot (3rd revision) from the github gist in post #1 of this thread or are you still using one of the older versions from the other thread?

If this happens again please save the log file (*before* you restart goxtool because restarting will truncate the old log)

I am using the version from this post: https://bitcointalk.org/index.php?topic=148462.msg1886914#msg1886914

My startup script for the bot:
Code:
./goxtool.py --protocol=socketio --use-http --strategy=_balancer.py

OK.. perhaps it was user error then.  I did notice that the bot did not get the updated orders OR the trade so I canceled the remaining single bot order and DID manually try to "P"lace orders multiple times.  I didn't think it was that high, and I do believe the log indicated that it was also placing the orders itself.   Go and put my son down for a nap... fell asleep with him and my gox history page is full of sells.

It isn't a big deal... like you said things can and will go wrong (esp when dealing with the gox api under load), and in fact I was able to buy it back without loss so it wasn't a huge deal anyway.

So it was very possible it was just PEBKAK.


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on April 22, 2013, 08:12:51 PM
Nice, never heard of screen. thanks for the info, it's working now, even if I close the ssh client.


Title: Re: goxtool bot: portfolio rebalancing
Post by: ErebusBat on April 22, 2013, 08:17:33 PM
Nice, never heard of screen. thanks for the info, it's working now, even if I close the ssh client.

I have some scripts I wrote to help manage mine to make sure it is launched in screen (so I don't forget then close the session and think the bot is running):
Code:
$ cat botwindow.sh
#!/bin/sh
screen -D -R -A -S bot

$ cat ./startbot.sh
#!/bin/zsh
if [[ -z $STY ]] then
echo "Not in screen! Run ~/botwindow.sh"
else
cd ~/goxtool
./bot_balancer.sh
fi

So I can login and just type ./bot[tab] (botwindow.sh) and be connected to goxtool.  If it isn't running I can THEN run ./startbot.sh which will check to make sure that I am running in screen and then launch the bot.

The screen flags:

-D detach other instances if needed
-R reattach to this instance if it already exists
-A Adapt the window size to the new client... i.e. change the window size between my laptop and ipad as I switch back and forth.
-S name the session 'bot'.  This allows me to create other screen sessions without affecting my scripts.


Title: Re: goxtool bot: portfolio rebalancing
Post by: c0inbuster on April 22, 2013, 09:00:44 PM
I also forget that I also add

Code:
screen -r
to my
Code:
~/.bashrc
so when I connect through ssh
I always reattach my screen (I only use only one screen with several "windows")


Title: Re: goxtool bot: portfolio rebalancing
Post by: sturle on April 23, 2013, 04:07:18 PM
It will do so by placing limit orders above and below current price that will restore the 50/50 ratio once price moves there and fills the order. As soon as one order is filled it will cancel the other and then calculate and place 2 new orders above and below that new price.
This is a good bot!  I don't know if the strategy is good or bad (probably among the better), but it provides liquidity on both sides of the spread.  This helps stabilizing the market price, reducing the amplitude of the price movements.  A more stable price will help adoption of Bitcoin as a currency, which is good for the price in the long run.

Many bots spend too much time trying to analyze the market in every possible way, getting it wrong 50% of the time.  I have a plain stupid no nonsense bot myself, and it is very profitable.  It's intelligence is on the same level as this bot, and it is a slow market maker bot like this one.  I wrote it in two hours in perl.  The strategy is different, but just as mechanical.  Stupid strategies often work best.

My strategy for surviving DDoS attacks on MtGox is to just cancel all orders as soon as lag > 60 seconds, and sit in the corner and wait until lag is back to < 1 second.  This far from perfect, but so far the best I've found.


Title: Re: goxtool bot: portfolio rebalancing
Post by: c0inbuster on April 23, 2013, 04:26:27 PM
I have some philosophical questions:

Is it good for us if it's good for market ?
or is it good for us when it's bad for market ?

Should we help to improve usage of BTC as currency (by stabilizing price
instead of taking advantage of the price change) ?

and a question of a more greedy geek
Is it profitable ?


Title: Re: goxtool bot: portfolio rebalancing
Post by: K1773R on April 23, 2013, 04:27:08 PM
I have some philosophical questions:

Is it good for us if it's good for market ?
or is it good for us when it's bad for market ?

Should we help to improve usage of BTC as currency (by stabilizing price
instead of taking advantage of the price change) ?
the more volatile the market, the more income ;)


Title: Re: goxtool bot: portfolio rebalancing
Post by: c0inbuster on April 23, 2013, 04:29:25 PM
this is also the point of view of an amateur FX trader like me...
but it could be quite different here

moreover it will be profitable for us (only) if MtGox was paying interest on fiat currency (USD, EUR) deposit.
I don't know if they do it.


Title: Re: goxtool bot: portfolio rebalancing
Post by: K1773R on April 23, 2013, 05:29:40 PM
you didnt seem to understand it, take a further look here:
http://en.wikipedia.org/wiki/Rebalancing_investments
http://en.wikipedia.org/wiki/Constant_proportion_portfolio_insurance


Title: Re: goxtool bot: portfolio rebalancing
Post by: BTC-engineer on April 23, 2013, 05:37:49 PM
I didn't already look deep into the code, but from what I saw I can say it looks very clean to me. Good work prof7bit!

However, I've done a quick live test today and stopped it because of unexpected trading behavior.
I didn't found the time to track down the problem, nor I'm sure I will do it in the next time.

But I would like to write down the misbehavior. Maybe it helps others to improve this nice bot.  

After starting the bot-trading, the bot placed correctly two orders (+/- distance from middle).
After a few hours, mtgox could fill the higher order in one step, so there was only one open order on mtgox.
A few seconds later the bot correctly deleted the old open order.
So far so good, but now it goes strange.
The bot paced two new orders which were exactly the same like the first placement which were done hours ago.
Also from this placement the higher order was filled by mtgox (this time in two steps).
A few seconds later the bot correctly deleted the old open order.
But this time the bot placed two new (correct) orders. Which means the orders were correctly placed +/- distance from the middle.


Title: Re: goxtool bot: portfolio rebalancing
Post by: fnordfnordfnord on April 23, 2013, 07:15:49 PM
got this running on my raspberry pi now for testing purposes with small amount of funds, and it's working as intended so far.
But I got a little problem: how can I run the bot in background, I can't fork the process to background using "&" because I won't be prompted for the decryption password, and if I close the SSH session the process gets killed.

Try this: After it is up and running, hit "Ctrl-z" and then type "bg" then press Enter.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 23, 2013, 07:21:50 PM
The bot paced two new orders which were exactly the same like the first placement which were done hours ago.

This means it missed the wallet update message or it came too late. In my tests so far the wallet message always was the first message, then the trade message and finally the message to remove the order. Thats the reason I trigger the trading when the number of open orders changes (assuming that the wallet has been updated at this time already).

Maybe I need some more code to detect whether the wallet has really been updated already. Unfortunately there will arrive 3 wallet mesages, one for the USD update, one for the BTC update and a 3rd one for the fees. Might make the code a bit more complicated but still possible.

***

BTW: Today MtGox installed a new websocket server that is much more reliable than the socketio server. My recommendation for running goxtool are now:

./goxtool --protocol=websocket --use-http --strategy=_balancer.py

And no more --use-http as it was needed with socketio because sending orders over websocket is fast and reliable now.[Edit: turns out http is still needed, added it back to the above command line] The new websocket server should also reduce the risk of missing messages due to disconnects, actually I did not have even one single disconnect anymore the entire day since I switched to websocket when I heared about the new server this morning!

BTW: There is also an update for goxtool on github (fixes some problems with the handling of some error messages from the server and also fixing a problem when using use_ssl=False in combiation with websocket), please
git pull
the latest version of goxtool.


Title: Re: goxtool bot: portfolio rebalancing
Post by: BTC-engineer on April 24, 2013, 11:05:49 AM
Hello prof7bit,

thanks for your feedback and help. I think I will give your bot a second try.

I have one short, general question to this bot strategy.
It looks to me like the bot doesn't consider the trading fee when calculating the new two distance orders points and the two new order volumes.
Have I missed something? And if not, does the consideration of the trading fee when calculating the new order points and volumes has only a insignificant, or even no effect on the efficiency of the strategy?



Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 24, 2013, 11:36:06 AM
It looks to me like the bot doesn't consider the trading fee when calculating the new two distance orders points and the two new order volumes.

This is true. The fees are low enough to be not significant for the calculation of the new acount balance, so I just ignore them and if you choose the distance >> 1.2% there is also enough room for profit for every consecutive buy-sell-sequence.


Title: Re: goxtool bot: portfolio rebalancing
Post by: BTC-engineer on April 24, 2013, 02:07:38 PM
Hi everybody

I've just done some back-testing of this trading strategy and would like to let you know about my results:

For this test I've written a small test-bench in C which tries to imitate this strategy as close as possible. I've stimulated my test-bench with historical data. I've used the mtgox ticker from the beginning of this year until now (5 minute ticker). So the strategy was tested with over 32K datapoints.

I've always put a specific number of virtuall bitcoins into this test and looked at the end with how much virtual bitcoins (bitcoins+(FIAT*price)) I ended up with.
I've done this with different trading fees and different DISTANCE values.

The result for this specific test setup was:
In all scenarios I ended up with only about 1/3 of my initial virtual bitcoins.
So I lost about 2/3 of my virtual bitcoins.  

Important notes:
1. I've carefully written the test-bench, but can not guarantee that I've made a mistake.
2. I know that the gox chart of the last month was quite crazy, and the result may look different if I would test with different data.

Have fun!
 


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 24, 2013, 02:48:41 PM
I've used the mtgox ticker from the beginning of this year until now (5 minute ticker). So the strategy was tested with over 32K datapoints.

In all scenarios I ended up with only about 1/3 of my initial virtual bitcoins.
So I lost about 2/3 of my virtual bitcoins.  

This is expected. And you haven't actually lost them, you have just sold them on the way up ;-)

If it trends so strongly then the most profitable strategy would buy and hold. But if it would have gone back to the price where your test started then you should end up with slightly more coins. Generally if it is going up it will slowly sell coins on the way up and when it goes down it will buy them all back again (at a slightly cheaper price).Try to choose a test period that has the same start and end price.

How did the USD balance develop in comparison? Could you upload some plots of USD, BTC and price?


Title: Re: goxtool bot: portfolio rebalancing
Post by: ErebusBat on April 24, 2013, 03:11:04 PM
Would it also be worth calculating USD Worth (USD+(BTC*PRICE))  I have found that is a a better indicator with my personal results.


Title: Re: goxtool bot: portfolio rebalancing
Post by: ErebusBat on April 24, 2013, 04:16:15 PM
Anyone have problems with hitting a sell point and the bot not canceling/placing new orders?

This happened twice to me today (although I can only find one instance in the log ???):
Code:
2013-04-24 06:21:18,548:DEBUG:_balancer.Strategy:canceling all rebalancing orders
2013-04-24 06:21:19,663:DEBUG:goxapi.Gox:### got ack for order/cancel: 07e56a1e-abe2-4189-879f-f9daebe52473
2013-04-24 06:21:33,621:DEBUG:_balancer.Strategy:adding new initial rebalancing orders
2013-04-24 06:21:33,622:DEBUG:_balancer.Strategy:new buy order 0.043029 at 146.294770
2013-04-24 06:21:33,622:DEBUG:_balancer.Strategy:new sell order 0.015061 at 161.694270
2013-04-24 06:21:35,557:DEBUG:goxapi.Gox:### got ack for order/add: bid 14629477 4302918 530644ad-3734-42e9-946c-1c91ea79a43a
2013-04-24 06:21:37,455:DEBUG:goxapi.Gox:### got ack for order/add: ask 16169427 1506124 76ed7e56-50e2-4266-a993-39c458a5ec25

2013-04-24 08:22:34,714:DEBUG:_balancer.Strategy:*** sold 0.015061 at 161.694270
2013-04-24 10:10:49,760:DEBUG:_balancer.Strategy:canceling all rebalancing orders
2013-04-24 10:10:55,232:DEBUG:goxapi.Gox:### got ack for order/cancel: 530644ad-3734-42e9-946c-1c91ea79a43a
2013-04-24 10:10:59,359:DEBUG:_balancer.Strategy:adding new initial rebalancing orders
2013-04-24 10:10:59,360:DEBUG:_balancer.Strategy:new buy order 0.014208 at 157.676270
2013-04-24 10:10:59,361:DEBUG:_balancer.Strategy:new sell order 0.040420 at 174.273770
2013-04-24 10:11:05,381:DEBUG:goxapi.Gox:### got ack for order/add: bid 15767627 1420833 5d19afcc-bbfc-43e9-beb7-61393d16da93
2013-04-24 10:11:11,662:DEBUG:goxapi.Gox:### got ack for order/add: ask 17427377 4041987 32713cab-d754-4a23-8a74-4b24c1cb9446

Notice the ~2h gap between 08:22-10:10 where the bot sold and I manually canceled and readded the orders (c,p)  lag was not an issue, at 10:00 anyway.

I am on commit 2e615b9b6272ac99de88693b148f6aa8f2e41708 (respect use_ssl setting everywhere. don't retry on http 500 error) for the tool, and I *believe* the latest balancer bot (although it isn't in git so I can't tell for sure)  Starting with ./goxtool.py --protocol=websocket --strategy=_balancer.py.

Am I doing something wrong?


Title: Re: goxtool bot: portfolio rebalancing
Post by: BTC-engineer on April 24, 2013, 04:30:34 PM
Would it also be worth calculating USD Worth (USD+(BTC*PRICE))  I have found that is a a better indicator with my personal results.

I personally do not calculate in USD anymore.
In this case the initial USD value increased nearly 4 times.


Title: Re: goxtool bot: portfolio rebalancing
Post by: supert on April 24, 2013, 04:57:37 PM
Thank you prof7bit for providing this strategy example. I am using a variation of it. You will get a proportion of the profits (if any).


Title: Re: goxtool bot: portfolio rebalancing
Post by: ErebusBat on April 24, 2013, 05:02:20 PM
Thought I would post a tweak I made to the bot to display your current wallet and last trade price in the "i" output.   This is nice for me because I can just hit "i" then copy/paste from my log into my tracking sheet.  I do not consider myself a python expert at all so I am sure there are more succinct ways of doing this.  Replace the entire "i" section.

Code:
        if key == ord("i"):
            price = (gox.orderbook.bid + gox.orderbook.ask) / 2
            vol_buy = self.get_buy_at_price(price)
            line1 = "BTC difference: " + goxapi.int2str(vol_buy, "BTC")            
            # Log current wallet
            if len(self.gox.wallet):
                line1 += "\t"
                for currency in self.gox.wallet:
                    line1 += currency + " " \
                    + goxapi.int2str(self.gox.wallet[currency], currency).strip() \
                    + " + "
                line1 = line1.strip(" +")
            # Log last price
            price = (self.gox.orderbook.ask + self.gox.orderbook.bid) / 2
            line1 += "\tLast Price: %f" % goxapi.int2float(price, self.gox.currency)
            
            # Print the whole thing out
            self.debug(line1)

Has output like:
Code:
2013-04-24 10:50:31,489:DEBUG:_balancer.Strategy:BTC difference:       0.01234567	USD 987.65432 + BTC 1.01234567	Last Price: 158.550000

I also have a log wrapper & rotator scripts I wrote to preserve and monitor the log, you can see them in the main thread here: https://bitcointalk.org/index.php?topic=148462.msg1932608#msg1932608


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 24, 2013, 05:09:29 PM
I am on commit 2e615b9b6272ac99de88693b148f6aa8f2e41708

This is from friday, you should git pull, I'm updating goxtool almost every day, fixing little bugs and problems.

Quote
Starting with ./goxtool.py --protocol=websocket --strategy=_balancer.py.

This is ok. [Edit: I just noticed that the huge delay problem is still not solved, maybe you should continue combining the above with the --use-http option (contrary to what I have said earlier), the --use-http will not hurt anyways and trading commands become slightly more reliable then, seems we still need to keep using http for order/add/cancel for a while until all problems are fixed at mtgox]

the latest _balancer.py is the one linked in post #1 in the github gist https://gist.github.com/prof7bit/5395900 (https://gist.github.com/prof7bit/5395900).
you can also just clone the gist (its a git repository too, you can fork it or clone it):
git clone https://gist.github.com/5395900.git
and then symlink the _balancer.py from this repository into your goxtool directory (you might need to make local branches if you intend to edit the _balancer.py locally yourself)

I'm going to keep this gist updated when  I find a bug. What makes me wonder is why the two orders have so widely different volume in your log file, this makes me assume you are running an older version of the balancer that did not yet calculate the new center price from the account balances. The new version (linked in post#1) is more rubust (although still not yet 100% perfect).


Title: Re: goxtool bot: portfolio rebalancing
Post by: ErebusBat on April 24, 2013, 05:55:52 PM
Thanks for the reply... I thought I had updated, obviously not :/

All updated now... (tool+bot).  Re-balanced and orders placed

I will checkout the gist rather than my butchered solution as it is now, thanks!


Title: Re: goxtool bot: portfolio rebalancing
Post by: smooth on April 24, 2013, 07:27:37 PM
It looks to me like the bot doesn't consider the trading fee when calculating the new two distance orders points and the two new order volumes.

This is true. The fees are low enough to be not significant for the calculation of the new acount balance, so I just ignore them and if you choose the distance >> 1.2% there is also enough room for profit for every consecutive buy-sell-sequence.

I think it does adjust to your current balances, so the effect of fees  (as well as any slippage due to lag, downtime, etc.) will be factored into a future trade.

Regarding the issue of trends (some other posts on the thread), if you expect a sufficiently strong uptrend, the better strategy is to go long.  Likewise if you expect a strong downtrend, you should just go long USD (hold 0 BTC).  Both of these are ignoring the possibility of shorting or leverage.  There is a narrow range of expectations where balancing is the best approach. 


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 24, 2013, 08:23:51 PM
damn... I introduced a bug. Every goxtool revision between 12 hours ago and just now would break the balancer bot (it would place immense amounts of orders and not detect them as own orders).

Please git pull the latest goxtool, fixed it a minute ago.


Title: Re: goxtool bot: portfolio rebalancing
Post by: fnordfnordfnord on April 25, 2013, 03:39:58 AM
Just a comment for those newly experimenting with _balancer. This is not a bug or anything but be careful not to set DISTANCE too small. What will happen on a rally is that you will sell several times before the bot gets a chance to buy, then after the inevitable peak the bot will buy the cumulative of the next buy and the two or three missed buys, but at a price nearer to the peak of the rally than you'd like.


Title: Re: goxtool bot: portfolio rebalancing
Post by: limpbrains on April 26, 2013, 06:30:42 AM
Hello, prof7bit, thanks for great tool.

I'm running this bot from yesterday and currently can't see any open orders on my mtgox accout.
Here is trading history: https://dl.dropboxusercontent.com/u/1788271/history_BTC.csv
and Strategy log: https://dl.dropboxusercontent.com/u/1788271/srat.log

Looks like bot have tried to open new orders at 2013-04-25 23:11:32
but I don't have them in my gox page.

Is it correct behavior ?
What should I do to fix this issue?

Thanks


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 26, 2013, 10:54:39 AM
and Strategy log: https://dl.dropboxusercontent.com/u/1788271/srat.log

You are running it with much too small account. It needs at least a few hundred USD in the acount, otherwise it would adjust the orders to the minimum allowed order size and if this adjustment is too severe (it wouldn't matter if it adjusted them from say 0.009 to 0.01 but larger adjustments will matter) then the next calculation of the correct center price will be totally off. It will be off by more than DISTANCE and instead of placing limit orders above and below it would place *both* orders below price (or both above price) and that would result in a market order and crazy behavior and BURNING OF MONEY!

As I have already initially stated in my disclaimer: If you don't understand what this bot is doing (if you need to ask what is correct behavior) then you have not read the code! And if you did not read the code you cannot run the bot!


Title: Re: goxtool bot: portfolio rebalancing
Post by: dwolfman on April 29, 2013, 08:12:33 PM
[Edit: I just noticed that the huge delay problem is still not solved, maybe you should continue combining the above with the --use-http option (contrary to what I have said earlier), the --use-http will not hurt anyways and trading commands become slightly more reliable then, seems we still need to keep using http for order/add/cancel for a while until all problems are fixed at mtgox]

Just to clarify, does the ini entry "use_http_api = False" line do the same as --use-http would from the command line?

Kinda prefer to not have to type more command line than I need to.  ;)


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on April 30, 2013, 08:40:06 AM
Just to clarify, does the ini entry "use_http_api = False" line do the same as --use-http would from the command line?
True, not False!

use_http_api = True

is the same as --use-http. This will be the default in newer versions (unless you have an old ini file where it is still set to False). The following is what I am currently using:

use_http_api = True
use_ssl = False
use_plain_old_websocket = True

use_plain_old_websocket is the same as protocol=websocket, this is currently the most reliable streamng api server.

I'm also using use_ssl=False (this means http instead of https and ws instead of wss), I only do this because connections and http requests will be slightly faster. The disadvantage of this is my ISP, the BKA (Germany), the CIA, and the NSA and everybody else who is able to sniff my internet connection would be able to know how much money is in my MtGox account but I guess they would be able to find out anyways if they would care about my activities, they would probably just ask MtGox to send them all information and MtGox would probably comply instantly because they live under the permanent fear of losing their license and bank accounts.


Title: Re: goxtool bot: portfolio rebalancing
Post by: dwolfman on April 30, 2013, 12:26:50 PM
Thanks, and you did understand what I meant.  Guess I should have just asked about "use-http"  :D


Title: Re: goxtool bot: portfolio rebalancing
Post by: 1Pakis on May 02, 2013, 12:22:08 PM
Is the goxtool keeps getting stuck today? Or it 's just me and my system?


Title: Re: goxtool bot: portfolio rebalancing
Post by: ErebusBat on May 02, 2013, 04:16:11 PM
Is the goxtool keeps getting stuck today? Or it 's just me and my system?
Seems fine for me... although lots of trades today


Title: Re: goxtool bot: portfolio rebalancing
Post by: bitmango on May 07, 2013, 11:50:34 AM
I just installed this bot and set the distance to 3.
I rebalanced and then when I hit p it places orders correctly.

I'm seeing the sell orders go through, but the bot doesn't then place a new order at that point. I'm I right in thinking that this is incorrect behavior? There is a single bid order left in my mtgox account..

Is it due to this?

Code:
Code:
   # as long as there are ANY pending orders around we
   # just do nothing and wait for the next signal
   if count_pending:
            return

Also sometimes, I see 2 ask orders the same, and also 2 bid orders the same as well.

Currently i'm seeing an order go through and then I press c, followed by p to get new orders in. But this kind of renders the bot useless for me...


Title: Re: goxtool bot: portfolio rebalancing
Post by: ewibit on May 07, 2013, 12:30:28 PM
Is the goxtool keeps getting stuck today? Or it 's just me and my system?
I have running it now a few days and it made no trades...


Title: Re: goxtool bot: portfolio rebalancing
Post by: ghostshirt on May 07, 2013, 12:36:42 PM
Is the goxtool keeps getting stuck today? Or it 's just me and my system?

It's been working OK for me for 2 days. I'm using websocket.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 07, 2013, 12:48:56 PM
I just installed this bot and set the distance to 3.
I rebalanced and then when I hit p it places orders correctly.

I'm seeing the sell orders go through, but the bot doesn't then place a new order at that point. I'm I right in thinking that this is incorrect behavior? There is a single bid order left in my mtgox account..

Is it due to this?

Code:
Code:
   # as long as there are ANY pending orders around we
   # just do nothing and wait for the next signal
   if count_pending:
            return

The following would be correct behavior: If there is only one order left it will cancel that order and then place 2 new orders above and below the new center. (The center is calculated from the account balance, not the price of the last trade but usually it differs only a few cents, the center is the BTCUSD price at which perfect balance would be established).

If you see anything other than exactly 1 bid and 1 ask order  then there is something wrong. If there is only one existing order left and it does not attempt to trade then here is something wrong.

The code snipped you cited makes it wait until there is no more pending order left, this is important, otherwise it would not work at all and probably burn a lot of money! Orders can be pending for several seconds up to many minutes, depending how high the order lag is, the bot will not try to place more orders or do anything as long as there are stlll pending orders in the pipeline, just wait (the o_lag display at the top gives you a hint how much order lag there is currently)

DISTANCE = 3 is very low. Its extremely low, given how the order lag can spike on mtgox when there is much activity and price is moving fast. You will inevitably run into problems with such an extremely low distance. I have set mine to 11 now (because 7 was still too small) and it will trade only a few times per week (and on crazy days that happen every once in a while it might trade a few times a day). The larger the distance the fewer trades it will do, the less problems you will have and the less fees you pay to MtGox (and therefore more profit for you). With DISTANCE=11 I can leave it running unattended for days and can sleep well without worrying.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 07, 2013, 12:53:31 PM
I have running it now a few days and it made no trades...

It does not suddenly begin to "trade". It places 2 limit orders above and below immediately after you initialized it according to the instructions (no need to wait here, you can see that it worked immediately) and then it waits for market to move there and fill one of them. Please read the description and the source code and also insert self.debug() statements at all the places where you are unsure what exactly is happening to learn what the values of the variables are and why it won't work as expected.

If you followed the instrucions then it has placed 2 orders (you see them with F6 or if you zoom out the order book or by looking at the mtgox.com trading web interface). You just have to wait until price moves to fill one of these orders. Then when this happens it will automatically cancel the other remaining order and place 2 new orders above and below. You may not have any other open orders in your account (whose price ends with the MARKER digit) or it will confuse the bot and it wont operate correctly. Also if account balance suddenly changes due to other trading it will confuse the bot and its calculations.

Look at your open orders and cancel or change all orders that have a price ending with 7. If you really need a permanent order to buy a million BTC at $0.00007 in case MtGox gets hacked again then either change this order to $0.00008 or alternatively change the MARKER value to some other number between 1 and 9 that is not used by you, then manually cancel all wrong orders (F6) and reload and reinitialize according to instrutions in post #1.


Title: Re: goxtool bot: portfolio rebalancing
Post by: ghostshirt on May 07, 2013, 04:20:04 PM
Quote
DISTANCE = 3 is very low. Its extremely low, given how the order lag can spike on mtgox when there is much activity and price is moving fast. You will inevitably run into problems with such an extremely low distance. I have set mine to 11 now (because 7 was still too small) and it will trade only a few times per week (and on crazy days that happen every once in a while it might trade a few times a day). The larger the distance the fewer trades it will do, the less problems you will have and the less fees you pay to MtGox (and therefore more profit for you). With DISTANCE=11 I can leave it running unattended for days and can sleep well without worrying.

prof, I'm experimenting with DISTANCE=2. I know it's s very small distance but it seems working fine even with a lag up to 60 seconds. My thinking is as follows (in a quite generalized way), I get more profits doing 6 trades with 2$ profit each time than only 1 trade with $10 profit. Can we come up with a optimum distance level given a portfolio?


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 07, 2013, 06:02:11 PM
My thinking is as follows (in a quite generalized way), I get more profits doing 6 trades with 2$ profit each time than only 1 trade with $10 profit. Can we come up with a optimum distance level given a portfolio?

Its not a function of the portfolio size. The profit per trade is a function of distance d and fees f (f = 2*0.6 = 1.2 at MtGox). Lets first only look at the ideal situation with zero fees for smplicity, then the profit for one trade would be proportional to .

The number of trades n that happen during a fixed time period is also a function of the distance, lets call this n(d). So the profit would be

profit(d) ~ d² * n(d)

and with fees it would be:

profit(d) ~ (d-f) * d * n(d)

And now we need to know how exactly does n(d) look like? Does it have an 1/d² somewhere? I don't know it. We need to simulate it with real historical bitcoin market data (and maybe also with data from other markets). Maybe someone wants to volunteer and make a quick python (or other) script to simulate it on old data and then run it with a lot of distances (and different MtGox fees) (and over a time period where start price and end price are not too far away) and then plot a few curves:

overall profit vs. distance
number of trades vs. distance
etc.

I was hoping BTC-Engineer would come back and share his results and do more simulations but if he wont come back I will probably do it myself but I'm lazy and probably someone else will do it earlier (and hopefully post his results here)


Title: Re: goxtool bot: portfolio rebalancing
Post by: supert on May 08, 2013, 09:36:28 AM
My thinking is as follows (in a quite generalized way), I get more profits doing 6 trades with 2$ profit each time than only 1 trade with $10 profit. Can we come up with a optimum distance level given a portfolio?

Its not a function of the portfolio size. The profit per trade is a function of distance d and fees f (f = 2*0.6 = 1.2 at MtGox). Lets first only look at the ideal situation with zero fees for smplicity, then the profit for one trade would be proportional to .

The number of trades n that happen during a fixed time period is also a function of the distance, lets call this n(d). So the profit would be

p(d) ~ d² * n(d)

and with fees it would be:

p(d) ~ (d-f) * d * n(d)

And now we need to know how exactly does n(d) look like? Does it have an 1/d² somewhere? I don't know it. We need to simulate it with real historical bitcoin market data (and maybe also with data from other markets). Maybe someone wants to volunteer and make a quick python (or other) script to simulate it on old data and then run it with a lot of distances (and different MtGox fees) (and over a time period where start price and end price are not too far away) and then plot a few curves:

overall profit vs. distance
number of trades vs. distance
etc.

I was hoping BTC-Engineer would come back and share his results and do more simulations but if he wont come back I will probably do it myself but I'm lazy and probably someone else will do it earlier (and hopefully post his results here)

I looked at this before, oddly enough. The size of order follows, roughly, a Pareto distribution. That is, a 1 coin bid is roughly equally likely as a 10 coin as a 100 coin, in a given time period.

There are caveats: I looked at a lot of historical data, so it may be a function of bitcoins being cheaper in the past (so then larger trades in bitcoin terms).

Also, integer trades are much more likely; 1 btc much more than 1.01 and 10 more than 9.7 for example.

Ignoring the integer size preference, I fitted a curve to the trade size data. Where f(x) is the probability that the trade size is greater than x bitcoins,
Code:
f=1-(0.1/x)^2.

So the probability of execution at a price is
Code:
p(price)=min( 1, f(s + bid_size) )
where s is the cumulative bids (i.e. depth) at that price.

You can validate f(x) with the following matlab code:
Code:
% empiral data on probability of trade at size
trades=csvread('../data/recent_trades.csv');
[F,X]=ecdf(trades(:,3));
   
In the end, I don't really use this information in my strategy. I don't think your bots performance under a balancing strategy is that sensitive to where you place the orders, if they are in a reasonable range. I would strongly echo prof7bit's warning about placing them too close together, though. This is because of fees.


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on May 10, 2013, 07:32:50 AM
Is the bot currently broken? I only get "identification required to access private API". I didn't change anything, it just doesn't work anymore.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 10, 2013, 08:03:23 AM
Is the bot currently broken? I only get "identification required to access private API". I didn't change anything, it just doesn't work anymore.

MtGox http api is broken again. As a woraround leave away the --use-http option (or if you have set it in yor ini then temporarily use the --no-http option) until they have fixed it again.


Title: Re: goxtool bot: portfolio rebalancing
Post by: K1773R on May 10, 2013, 08:06:04 AM
Is the bot currently broken? I only get "identification required to access private API". I didn't change anything, it just doesn't work anymore.

MtGox http api is broken again. As a woraround leave away the --use-http option (or if you have set it in yor ini then temporarily use the --no-http option) until they have fixed it again.

for me its working even with --use-http


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 10, 2013, 08:34:21 AM
for me its working even with --use-http

Tnen cloudflare (or whatever anycasting web-proxy network they are using) must be messing it up. I'm located in Germany (Arcor / Vodafone).


Title: Re: goxtool bot: portfolio rebalancing
Post by: ghostshirt on May 10, 2013, 11:27:42 AM
Is the bot currently broken? I only get "identification required to access private API". I didn't change anything, it just doesn't work anymore.
I was getting the same error with use_ssl=False, I switched it to True, now it's working again.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 10, 2013, 11:42:37 AM
I was getting the same error with use_ssl=False, I switched it to True, now it's working again.

Yes, I can confirm this.

I just tried it and https API does not produce this error. So the workaround (or solution) is now to set use_ssl=True in the ini file and then --use-http will work again as before. Seems their anti-ddos web cache proxies have gone mad.


Title: Re: goxtool bot: portfolio rebalancing
Post by: dwolfman on May 13, 2013, 10:55:11 PM
Not sure why, but I keep having to set the percentage higher to keep this from cycling endlessly selling and buying, as much as two or three times a second!

I've set it for 23%, which seems ok for now.

Any idea why?  Is it due to the price being pretty volatile right now, since it seems they just came off another DDOS attack?


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 14, 2013, 07:58:39 AM
Not sure why, but I keep having to set the percentage higher to keep this from cycling endlessly selling and buying, as much as two or three times a second!

How much money do you have in your account, how big are the orders it generates?


Title: Re: goxtool bot: portfolio rebalancing
Post by: dwolfman on May 14, 2013, 03:40:37 PM
It's not much.  About 0.036 BTC and $5.44.  It's been generating 0.01 buy/sell amounts.

Since I don't have much, I'm just "playing around" with it for now.  If I can ever get my cash out of Bitfloor, I'll likely put that back into BTC and add that in so that I'll have a bit more to work with.  I'd have between 0.75 and 1 BTC once I can do that.


Title: Re: goxtool bot: portfolio rebalancing
Post by: K1773R on May 14, 2013, 04:47:21 PM
It's not much.  About 0.036 BTC and $5.44.  It's been generating 0.01 buy/sell amounts.

Since I don't have much, I'm just "playing around" with it for now.  If I can ever get my cash out of Bitfloor, I'll likely put that back into BTC and add that in so that I'll have a bit more to work with.  I'd have between 0.75 and 1 BTC once I can do that.
with so few u waste your BTC @ fees. id say atleast 100$+


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 14, 2013, 04:54:27 PM
It's not much.  About 0.036 BTC and $5.44.  It's been generating 0.01 buy/sell amounts.
This is not enough. 0.01 is the minimum order size at mtgox, the bot will adjust the order size to reach at least 0.01 and this is just too much for such a small account.


Title: Re: goxtool bot: portfolio rebalancing
Post by: dwolfman on May 14, 2013, 08:46:20 PM
Well, at least with a larger % it doesn't go buy/sell crazy.  I'm adding about .016 BTC a day from my mining rigs (just some slower GPUs I happen to have, about 280 MH/s worth).

So about $100 worth would be a good start, as someone else mentioned?  Eventually I'll be able to get to about that amount, if Bitfloor ever gives me back my $.  :(

I'm going to leave it running as is, since I'm just doing this for fun right now.

And it just started going nuts with orders again, so I upped it to 30%.


Title: Re: goxtool bot: portfolio rebalancing
Post by: K1773R on May 14, 2013, 09:13:35 PM
Well, at least with a larger % it doesn't go buy/sell crazy.  I'm adding about .016 BTC a day from my mining rigs (just some slower GPUs I happen to have, about 280 MH/s worth).

So about $100 worth would be a good start, as someone else mentioned?  Eventually I'll be able to get to about that amount, if Bitfloor ever gives me back my $.  :(

I'm going to leave it running as is, since I'm just doing this for fun right now.

And it just started going nuts with orders again, so I upped it to 30%.
you wont make money, you will give your money to mtgox in form of fees...


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 14, 2013, 09:21:56 PM
So about $100 worth would be a good start, as someone else mentioned?

$100 is still not enough, thats not worth the electricity running the computer. It starts with $5000 or $10000 and it becomes interesting with $100k or $500k (one can modify the code to add offsets to the account balance, so only the absolutely needed money must be in MtGox and the rest can be stored in safer places, maybe I could post this modification, I'm using it myself)


Title: Re: goxtool bot: portfolio rebalancing
Post by: dwolfman on May 14, 2013, 09:33:47 PM
Well, it doesn't really matter now.  After seeing the postings on the forum about the court ordered Mt Gox account seizure from Dwolla, I've decided I'm not going to get stuck again like at Bitfloor.  Moved everything off of Gox for now, and won't be running this bot any more.

I imagine things will start going badly for Gox soon, since they have that lawsuit going on and now this seizure as well.

Sure would be nice if goxtool supported other exchanges, like Camp BX for example.  That's about the only place left that doesn't have some stupid fees for withdrawing even bitcoins out (BTC-e charges .01 to withdraw, which hurts when you have a small amount like mine).

Guess it's time to dust off my programming skills and work on that bot I've been thinking about.  :)


Title: Re: goxtool bot: portfolio rebalancing
Post by: dwolfman on May 14, 2013, 09:35:03 PM
$100 is still not enough, thats not worth the electricity running the computer.

Oh, I'm not worried about the electricity.  I was running it in a virtual machine on my home network server which is on 24/7 anyway.  So whether goxtool was running or not, and whether it was making any money either, didn't really matter to me.  :)

Now if I had more to work with in BTC/$, then I'd be worried about it.  ;)


Title: Re: goxtool bot: portfolio rebalancing
Post by: bitmango on May 15, 2013, 10:08:20 AM
So about $100 worth would be a good start, as someone else mentioned?

$100 is still not enough, thats not worth the electricity running the computer. It starts with $5000 or $10000 and it becomes interesting with $100k or $500k (one can modify the code to add offsets to the account balance, so only the absolutely needed money must be in MtGox and the rest can be stored in safer places, maybe I could post this modification, I'm using it myself)

I'd like to see how this works. Would you be willing to post?


Title: Re: goxtool bot: portfolio rebalancing
Post by: smooth on May 16, 2013, 12:13:13 AM
I made the change myself as well and it is pretty (i.e. very) trivial. 

While I agree it is a good idea, and I don't really see any harm in posting it, I also kind of think that given the target audience being one where people are reading and understanding the code it shouldn't be necessary to post this.

There are a lot of ways to blow up your money with any trading bot if you don't really understand how it works.  Don't do that.

Hint: add the offline amounts to fiat_have and btc_have


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on May 16, 2013, 10:10:06 AM
So about $100 worth would be a good start, as someone else mentioned?

$100 is still not enough, thats not worth the electricity running the computer. It starts with $5000 or $10000 and it becomes interesting with $100k or $500k (one can modify the code to add offsets to the account balance, so only the absolutely needed money must be in MtGox and the rest can be stored in safer places, maybe I could post this modification, I'm using it myself)

I'm very interested in a version with this feature.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on May 16, 2013, 10:26:25 AM
I have pushed that change to the gist (please test it to make sure it still works, I had to clean up my code and remove some other experimantal stuff from my own version before committing)

there are now 2 new variables:

Code:
FIAT_COLD   = 0     # Amount of Fiat stored at home but included in calculations
COIN_COLD   = 0     # Amount of Coin stored at home but included in calculations

If all your money is at mtgox then these must be both 0. If you want to pretend you have more money than what is in the mtgox account then simply add non-zero positive numbers here.

Example: You own 42฿ and want to run the strategy with all of them but you only want to put 20฿ into MtGox and keep the other 22฿ at home. Then you just set COIN_COLD = 22 and the bot will include your cold coins in all calculations (which means the order sizes will be larger). You can do the same also with USD you don't want to store too many USD at the exchange all the time.

Note that when doing this it might easily run out of coins or USD if price moves too far in one direction. In this case you have to cancel all orders (press "c"), (also press "i" and write down the current imbalance for later comparison), stop the bot, then send enough of the cold funds to MtGox (and maybe also withdraw some from the other side if it has become too much), then adjust FIAT_COLD and COIN_COLD to reflect the new situation, wait for your funds to arrive in your account, start the bot again: First press "i" and compare the numbers to make sure the bot calculations are still correct (if not then try to figure out your mistake and fix it, if its as expected then restart the bot), if it is too far out of balance rebalance with "b", otherwise just start it again with "p".


Title: Re: goxtool bot: portfolio rebalancing
Post by: fruitrunner on May 17, 2013, 08:09:31 PM
Hello!

I need help!
Been trying to learn enough python to do my own strategy but right now I don't have time.
I'm planning to do a real simple strategy. Much simpler then the balancer.py...
If you are good with python it will probebly take less then an hour to make.

I will pay 0.1 BTC + TombRaider Steam code + far cry 3 blood dragon ubishop download

PM me

Thanks!!


Title: Re: goxtool bot: portfolio rebalancing
Post by: K1773R on May 17, 2013, 08:17:38 PM
Hello!

I need help!
Been trying to learn enough python to do my own strategy but right now I don't have time.
I'm planning to do a real simple strategy. Much simpler then the balancer.py...
If you are good with python it will probebly take less then an hour to make.

I will pay 0.1 BTC + TombRaider Steam code + far cry 3 blood dragon ubishop download

PM me

Thanks!!
go back to the newb section! open your own thread if you really believe this is an offer and not an insult...


Title: Re: goxtool bot: portfolio rebalancing
Post by: fruitrunner on May 17, 2013, 08:23:59 PM
OK, Name your price for less then 1 hour python coding!


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on May 18, 2013, 07:31:00 AM
I have pushed that change to the gist (please test it to make sure it still works, I had to clean up my code and remove some other experimantal stuff from my own version before committing)

there are now 2 new variables:

Code:
FIAT_COLD   = 0     # Amount of Fiat stored at home but included in calculations
COIN_COLD   = 0     # Amount of Coin stored at home but included in calculations

If all your money is at mtgox then these must be both 0. If you want to pretend you have more money than what is in the mtgox account then simply add non-zero positive numbers here.

Example: You own 42฿ and want to run the strategy with all of them but you only want to put 20฿ into MtGox and keep the other 22฿ at home. Then you just set COIN_COLD = 22 and the bot will include your cold coins in all calculations (which means the order sizes will be larger). You can do the same also with USD you don't want to store too many USD at the exchange all the time.

Note that when doing this it might easily run out of coins or USD if price moves too far in one direction. In this case you have to cancel all orders (press "c"), (also press "i" and write down the current imbalance for later comparison), stop the bot, then send enough of the cold funds to MtGox (and maybe also withdraw some from the other side if it has become too much), then adjust FIAT_COLD and COIN_COLD to reflect the new situation, wait for your funds to arrive in your account, start the bot again: First press "i" and compare the numbers to make sure the bot calculations are still correct (if not then try to figure out your mistake and fix it, if its as expected then restart the bot), if it is too far out of balance rebalance with "b", otherwise just start it again with "p".

Thanks, I'm testing this now.


Title: Re: goxtool bot: portfolio rebalancing
Post by: K1773R on June 02, 2013, 03:34:12 PM
i just updated goxtool and the "bars" went ugly, is this on purpose?

http://www.darkgamex.ch/upload/TMx1hw7LW2wlly43Pk5g/goxtool-buggy.png


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on June 02, 2013, 05:05:58 PM
i just updated goxtool and the "bars" went ugly, is this on purpose?
Yes and no ;-)

I changed it a while ago to use ACS_CKBOARD instead of an inverted space but did not notice the ugliness until I downgraded from Xubuntu 12.10 to 12.04 two days ago (there seem to be different fonts in Ubuntu 12.10 that make ACS_CKBOARD look much nicer).

I'm probably going to change it back again (or make it optional because some black&white terminals seem to have problems with inverted characters and inverted spaces can become invisible).


Title: Re: goxtool bot: portfolio rebalancing
Post by: K1773R on June 02, 2013, 06:05:25 PM
i just updated goxtool and the "bars" went ugly, is this on purpose?
Yes and no ;-)

I changed it a while ago to use ACS_CKBOARD instead of an inverted space but did not notice the ugliness until I downgraded from Xubuntu 12.10 to 12.04 two days ago (there seem to be different fonts in Ubuntu 12.10 that make ACS_CKBOARD look much nicer).

I'm probably going to change it back again (or make it optional because some black&white terminals seem to have problems with inverted characters and inverted spaces can become invisible).
thanks for the update


Title: Re: goxtool bot: portfolio rebalancing
Post by: idler on June 04, 2013, 05:08:10 PM
I have put about 1300 dollar to try this bot in the first of May, set the DISTANCT to 3%.

After have a trial of a month. I actually lost ~1 dollar USD (kept amount of btc equal to initial), of course after pay some fee to mtgox, so turn out no luck.

Then I've sightly modified to be adjustable ratio, I've set 80/20 btc/fiat and tested a week.
Still 1300 dollar, 3% distance and then have a better result, earned ~0.6 USD (again, kept amount of BTC equal to initial), annualized return would be 2.5%.

Earning is so little mainly because there are too few of pump and dump, but enhance the transaction volume are the key of success. I seldom check this post so I just know the cold wallet idea, I love it so much and will have a try with my 80/20.

Thanks for prof7bit again.

https://gist.github.com/idler921/5707557


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on June 04, 2013, 06:43:44 PM
i just updated goxtool and the "bars" went ugly, is this on purpose?
I've changed it back to inverted space on terminals that suppport A_REVERSE
I've also made a detection of color capabilities, so now it even works on vt100 and vt52


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on June 04, 2013, 06:52:11 PM
I have put about 1300 dollar to try this bot in the first of May, set the DISTANCT to 3%.
Last weeks have been very quiet, almost horizontal. I have now upped my own account to 10k$ on each side, I still have distance of 11% (I expect a wild roller coaster ride soon when this huge consolidation pattern comes to an end. I expect it to drop below $ 50 and then going up agan and a lot of trades to happen despite my large 11% distance.)


Title: Re: goxtool bot: portfolio rebalancing
Post by: Aido on June 05, 2013, 12:21:44 AM
How difficult would it be to implement a 24 hour (or variable time frame) High and Low price in the top of the goxtool screen?

So far I've only played around with the strategy bot code and assume the above suggestion would involve tinkering with the core goxtool code.


Title: Re: goxtool bot: portfolio rebalancing
Post by: medji on June 05, 2013, 08:36:32 PM
Looks very similar to this service
https://dnnbitcoin.aricie.com

Here's the strategy the bot uses
https://dnnbitcoin.aricie.com/Default.aspx?tabid=71

Edit: Ah, I think is dead, pity.


Title: Re: goxtool bot: portfolio rebalancing
Post by: nii236 on July 19, 2013, 10:44:31 PM
I have attempted by own implementation of the goxtool rebalancing bot located at the following link:

http://cryptotrader.org/backtests/CboFCRyQaLn2Zv76r (http://cryptotrader.org/backtests/CboFCRyQaLn2Zv76r)

Be gentle, I'm not a programmer!

Anyway the results were not very promising, no matter how I tweaked the values, it seems that I will always lose roughly 20 percent of my initial. If I increase the range of the backtest to past the April bubble then the gains are a little more respectable, but something like the popular EMA crossover method would do better in all regards.

Unless there's something wrong with my script, which is very likely. Can someone more skilled at programming than myself look at the link and let me know if there's anything wrong with it? i printed out balances at every tick though and it seems to be doing the right thing.


Title: Re: goxtool bot: portfolio rebalancing
Post by: 1Pakis on July 20, 2013, 07:35:04 PM
In order to see results with this algorithm the starting price and finishing price must be roughly the same.

So try this one
http://cryptotrader.org/backtests/oKM2ucnwtoFJTpSWD

This is my code for the same interval
http://cryptotrader.org/backtests/ASTXJE9ZzhJZA2H5u
The code is clean and small. The variables names and some comments are from the original code.

Check also this one
http://cryptotrader.org/backtests/DzbqZuFqL7xuuijFY
This not ideal because starting price is 13.40 and finishing price is 88.79.
But the gains are 225% and you have more fiat than when you started and the same amount in BTC.

Also there is a basic difference
This backtest trades only when the candle closes.
The original algorithm places trades inside the candle and before the price is reached.
I don't know if this is good or bad.

Regards,

Pakis


Title: Re: goxtool bot: portfolio rebalancing
Post by: 1Pakis on July 20, 2013, 07:53:36 PM
http://cryptotrader.org/backtests/AQjCcwKuYdoXFK5TR
An other test that includes the all times high.
About 17% gains.


Title: Re: goxtool bot: portfolio rebalancing
Post by: nii236 on July 21, 2013, 10:05:31 AM
Thanks! Its a bit concerning that beginning and finishing prices need to be the same. They won't be in the real world. I would've expected the small profits that this bot provides would be valid for any price of BTC as it automatically rebalances?

If BTC goes down to 0 USD shouldn't the bot automatically keep buying BTC and keep my total balance the same?
If BTC goes up to 1 000 000 USD shouldn't the bot automatically keep selling BTC and keep my total balance the same?

If the above is true, why does my total balance drop by 20% just because the starting and ending prices of my simulation are different?


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on July 22, 2013, 09:27:00 AM
If BTC goes down to 0 USD shouldn't the bot automatically keep buying BTC and keep my total balance the same?
If BTC goes up to 1 000 000 USD shouldn't the bot automatically keep selling BTC and keep my total balance the same?

If the above is true, why does my total balance drop by 20% just because the starting and ending prices of my simulation are different?

You are still 50% exposed to BTC price, so if BTC goes down your total worth goes down as well, it just doesn't go down as much as if you were exposed 100%. If BTC price goes up your total worth will also go up (but also not as much as if you were 100% in BTC). All the bot can do is keep your exposure to the risky asset at 50% all the time.

Its important to understand that and not use this bot with wrong expectations! This is a concave (https://sites.google.com/site/cfalevel3examprep/portfolio-planning-and-execution/ss16/reading-40/40i) strategy and as such it will underperform in strong trends but it will outperform in ranging markets, so I an use it until the next bubble begins (which will come I am 100% convinced).

Also when using it you are helping reduce volatility because you are providing a (small) resistance against every pump and dump that they have to overcome (and pay for) and so for every dollar or BTC that is allocated to such a balancing strategy it will become a little bit more expensive for the pumpers and dumpers to move the market because: (1) You are making it a little bit more expensive for them to initiate a huge move instead of helping them and (2) if it moves you are taking a little bit of their profits away (you are front-running them with your rebalancing orders), reducing their profits instead of losing money to them.


Title: Re: goxtool bot: portfolio rebalancing
Post by: nii236 on July 25, 2013, 05:38:35 AM
Thanks for the link. Does this mean you'll be switching to the opposite strategy once the next bubble starts? The CPPI that's discussed in that link? Buying more Bitcoin when it is clear that the market is going up and selling when it is going down.

Interest that two completely opposite trading strategies are perfectly valid, just depending on the current behaviour of the market!


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on July 25, 2013, 09:22:23 AM
Thanks for the link. Does this mean you'll be switching to the opposite strategy once the next bubble starts?

I'm not really sure yet how to do it exactly. If I really can convince myself that the post-bubble-bottom has been reached I will probably switch to something with much more BTC exposure (that decision will probably be a gamble but there is also a little gambler hidden inside me)


Title: Re: goxtool bot: portfolio rebalancing
Post by: pizzaman1337 on August 20, 2013, 04:04:40 PM
I like this idea - have you considered writing the tool for bitstamp's API too? Their percentage of total bitcoin trading volume has risen a fair amount recently.


Title: Re: goxtool bot: portfolio rebalancing
Post by: supert on August 21, 2013, 11:02:00 AM
I like this idea - have you considered writing the tool for bitstamp's API too? Their percentage of total bitcoin trading volume has risen a fair amount recently.

+1

I offer 0.2 btc bounty for this.

I know it's not much for the work but I hope others will add to it.


Title: Re: goxtool bot: portfolio rebalancing
Post by: sturle on August 21, 2013, 12:11:31 PM
I like this idea - have you considered writing the tool for bitstamp's API too? Their percentage of total bitcoin trading volume has risen a fair amount recently.
+1

I offer 0.2 btc bounty for this.

I know it's not much for the work but I hope others will add to it.
Bitstamp's API is pretty bad, and the security is even worse.  You  send your username and password in every request.  No API keys and no grading of permissions.  If you are somehow tricked into sending a request to the wrong server, you just gave away your account.  MtGox's API is much better in all regards.  A request sent to the wrong server contains no information of any use to anybody.

Bitcurex has an API very similar to MtGox v0, btw.  Should be trivial to port.


Title: Re: goxtool bot: portfolio rebalancing
Post by: Aido on October 24, 2013, 08:45:21 PM
I like this idea - have you considered writing the tool for bitstamp's API too? Their percentage of total bitcoin trading volume has risen a fair amount recently.

+1


Bitstamp's API is pretty bad, and the security is even worse.  You  send your username and password in every request.  No API keys and no grading of permissions.

Bitstamp have now implemented API keys

https://www.bitstamp.net/article/api-key-implementation/ (https://www.bitstamp.net/article/api-key-implementation/)



Title: Re: goxtool bot: portfolio rebalancing
Post by: supert on October 24, 2013, 08:48:52 PM
hmmm.. goxtool cross-exchange arbitrage... could be neat.


Title: Re: goxtool bot: portfolio rebalancing
Post by: ruggero on November 23, 2013, 11:23:17 AM
I'm right now testing _balancer.py (the version from Github) and I only changed the DISTANCE parameter from 7 to 11.

Before starting I balanced the amount of BTC/$ in my account and made sure the order book was empty.

I start goxtools with the commandline ./goxtool.py --strategy=_balancer.py --protocol=websocket --use-http.

I push "p" and the bot places its two orders. Since last night the bot hit the higher threshold twice, and twice it canceled the remaining order and placed two new orders.
But apparently the script didn't place the new orders at distance 11 from where the BTC sale happened, but started placing them at the same sale/buy price of where the previous buy/sale happened, so that my balances were quickly being eroded by the fees.

So I stopped it for now and decided to ask first. Any ideas? Thanks!


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on November 23, 2013, 11:54:48 AM
but started placing them at the same sale/buy price of where the previous buy/sale happened

This should not happen. After a trade is filled the balances (as displayed in the status bar at the top) should be *immediately* updated, the new orders are calculated from the balances. I have currently no idea what might be the reason for the symptoms you describe. Are you running the very latest version of goxtool?


Title: Re: goxtool bot: portfolio rebalancing
Post by: ruggero on November 23, 2013, 12:14:43 PM
Yes git cloned from the repository yesterday afternoon.

I decided to run a new test on my desktop computer (previous attempt was from a raspberry pi) from scratch, in a more controlled environment.

So I wiped everything from the RaspberryPi and git cloned goxtools and _balancer.py once again on a macmini (OSX 10.8.6).

I deleted the old API key on Gox, and made a new one. Also I made sure no pending orders were there.

I ran ./goxtools.py --add-secret and successfully registered my API key.

I edited _balancer.py so that the parameters state:
DISTANCE=11
FIAT_COLD=0
COIN_COLD=0

I launched goxtools: screen ./goxtool.py --strategy=_balancer.py --protocol=websocket --use-http

Within goxtools I balanced the BTC/$ amounts in my account using "b".
The balance was set on BTC 0.08513863 + USD 72.08415.

Then I pushed "p" and the orders were placed. "i" gives the following debug output:

2013-11-23 13:03:27,278:DEBUG:_balancer.Strategy:BTC difference at current price: -0.00055701
2013-11-23 13:03:27,281:DEBUG:_balancer.Strategy:Price where it would be balanced: 846.66796


And I'm waiting now for the trigger to hit either marker (753$~939$).

Have I missed anything?


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on November 23, 2013, 05:57:18 PM
Have I missed anything?

should work. The only thing that I could imagine causing problems are if the balance were too small (or the distance too small) so that the orders would be less than 0.01 BTC and this would not be allowed on MtGox. Then goxtool would round up to 0.01 BTC and that could cause it come out of balance too far. How large are the orders it has placed?

I'm running my balancer currently with $30k USD and 36 BTC, my order sizes are 1.79 and 1.98 currently (at 11% distance)


Title: Re: goxtool bot: portfolio rebalancing
Post by: ruggero on November 23, 2013, 08:03:43 PM
When it happened it was with an order size of 0.03.
At the moment I have an order size of 0.01. Do you think I should increase it?


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on November 23, 2013, 08:16:11 PM
When it happened it was with an order size of 0.03.
At the moment I have an order size of 0.01. Do you think I should increase it?
Yes, either more money into the account or larger distance


Title: Re: goxtool bot: portfolio rebalancing
Post by: ruggero on November 26, 2013, 10:25:58 AM
Hi again! Thanks for your reply.
After a couple of days of mining (and rescuing that little I managed to rescue from the BTC I had invested in mcxNOW fees) I added more balance to my Gox balance.

While I have distance still set to 11, I have now 1.08 BTC + 135 USD in Gox and 6 BTC + 6000 USD as cold balance.
The orders the script placed are now 0.35 for Selling BTC and 0.43 for Buying BTC.

And, yes, I unbalanced the cold wallet on purpose as I would like always to end up with a little more BTC than dollars.

I'll keep you posted if this time it works. Hopefully the price is gonna soon hit one of the triggers.

Thanks for your effort in creating goxtools, and if/when I make it work I'll be sure to send a donation your way with the first earnings!


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on November 26, 2013, 12:01:18 PM
I'll be sure to send a donation your way with the first earnings!
Please don't expect too much. If bitcoin price goes up from here and never comes back then you will increase the USD balance but at the same time decrease the BTC balance. You will still overall have more money than you had before but not in terms of BTC alone, and also less than if you had held 100% BTC all the time. You will see BTC denominated profits only if you stop the bot at around the same price where you started it, otherwise it mostly serves as an automated mechanism to keep your BTC exposure (and therefore your risk) at a constant level instead of letting it rise dangerously high with increasing price.


Title: Re: goxtool bot: portfolio rebalancing
Post by: supert on November 29, 2013, 12:09:17 PM
I'll be sure to send a donation your way with the first earnings!
Please don't expect too much. If bitcoin price goes up from here and never comes back then you will increase the USD balance but at the same time decrease the BTC balance. You will still overall have more money than you had before but not in terms of BTC alone, and also less than if you had held 100% BTC all the time. You will see BTC denominated profits only if you stop the bot at around the same price where you started it, otherwise it mostly serves as an automated mechanism to keep your BTC exposure (and therefore your risk) at a constant level instead of letting it rise dangerously high with increasing price.

I second this. With backtesting, and in principle, the main function of the balancer is to reduce volatility at the expense of some upside. I.e. you will get less profit but smoother profit.

It does do well in mean-reverting markets though (such as in the recent crashes).


Title: Re: goxtool bot: portfolio rebalancing
Post by: grbox2001 on December 10, 2013, 11:53:41 AM
I used to run this bot and I am curious how it did during all the recent market insanity.


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on December 10, 2013, 09:02:47 PM
I used to run this bot and I am curious how it did during all the recent market insanity.


This is what it should have done in the last 2 weeks: https://cryptotrader.org/backtests/fNnNrr3t7Yq5t57FD
You can see a small profit there.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on December 10, 2013, 10:06:47 PM
https://i.imgur.com/aJOU1fj.png


Title: Re: goxtool bot: portfolio rebalancing
Post by: fatal on December 11, 2013, 08:48:35 PM
Anyone having problems connecting to the api?

i'm getting:

2013-12-11 12:45:46,705:DEBUG:goxapi.WebsocketClient:trying plain old Websocket: wss://websocket.mtgox.com?Channel=depth.BTCUSD/ticker.BTCUSD ...
2013-12-11 12:45:46,964:DEBUG:goxapi.WebsocketClient:WebSocketConnectionClosedException  reconnecting in 1 seconds...
2013-12-11 12:45:47,966:DEBUG:goxapi.WebsocketClient:trying plain old Websocket: wss://websocket.mtgox.com?Channel=depth.BTCUSD/ticker.BTCUSD ...



Title: Re: goxtool bot: portfolio rebalancing
Post by: piramida on December 11, 2013, 09:45:52 PM
yes, it does not work anymore. not just for this bot, for anyone.


Title: Re: goxtool bot: portfolio rebalancing
Post by: Aido on December 11, 2013, 09:51:15 PM
Yes, MtGOX API has been down for several hours now. DDoS apparently.


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on December 11, 2013, 10:31:26 PM
it seems to work when you switch to socketio instead of websocket.

EDIT: no it doesn't update anything then.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on December 11, 2013, 11:24:00 PM
please

git pull


and then run with

--protocol=pubnub

still experimental because I coded it in a hurry but seems to work already


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on December 12, 2013, 08:26:25 AM
please

git pull


and then run with

--protocol=pubnub

still experimental because I coded it in a hurry but seems to work already


seems to work, but it doesn't show the account info @ the top.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on December 12, 2013, 09:54:47 AM
Please edit the goxtool.ini and set use_tonce=True (and while you are at it also set use_http_api=True). It seems that with my current implementation some API requests during initialization come out of chronological sequence, making some API requests fail sometimes but the "tonce" which is only requres a 10 second time window has not such strict requirements and stilll works.

I have made this the default for new installations now but existing installations will still have the old settings in the ini.

Edit: and please git pull once a day, I'm still not finished with the pubnub stuff, its still a huge mess, their python API is ugly and incomplete and therefore the goxtool side of this is a huge pile of workarounds, I am still trying to fix it and make it more elegant and more reliable.


Title: Re: goxtool bot: portfolio rebalancing
Post by: fatal on December 12, 2013, 10:39:21 AM
Thanks! Appreciate the work and quick turn around...  made the changes suggested and everything looks to be working. The account info is showing fine for me.


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on December 12, 2013, 07:39:03 PM
Please edit the goxtool.ini and set use_tonce=True (and while you are at it also set use_http_api=True). It seems that with my current implementation some API requests during initialization come out of chronological sequence, making some API requests fail sometimes but the "tonce" which is only requres a 10 second time window has not such strict requirements and stilll works.

I have made this the default for new installations now but existing installations will still have the old settings in the ini.

Edit: and please git pull once a day, I'm still not finished with the pubnub stuff, its still a huge mess, their python API is ugly and incomplete and therefore the goxtool side of this is a huge pile of workarounds, I am still trying to fix it and make it more elegant and more reliable.

Thanks, it's working now.


Title: Re: goxtool bot: portfolio rebalancing
Post by: btcrun on December 17, 2013, 06:13:43 PM
I don't know what happened, but my instance isn't responding to the balance command (pressing b)
I tried using websocket and pubnub, tried a new API key and am up to date.

Does anybody how to solve this?

EDIT: I converted everything I got in my account (only 0.05BTC to test, maybe this isn't enough?) into BTC and as I pressed "b" after this, the bot rebalanced (it wasn't balanced before, but it wouldn't do it automatically).
New orders were placed and I will let it run through the night and see tomorrow :)


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on December 17, 2013, 07:39:27 PM
0.05BTC
Is not enough. please read the thread, I have mentioned it multiple times. Load it at least with a few thousand dollars for it to make any sense. Minimum order size on gox is 0.01BTC, if you do the math you will see that your rebalancing orders would be too small by orders of magnitude.


Title: Re: goxtool bot: portfolio rebalancing
Post by: btcrun on December 18, 2013, 09:45:05 AM
0.05BTC
Is not enough. please read the thread, I have mentioned it multiple times. Load it at least with a few thousand dollars for it to make any sense. Minimum order size on gox is 0.01BTC, if you do the math you will see that your rebalancing orders would be too small by orders of magnitude.

I'm sorry, I wasn't thinking straight!
Was reading through the code and let it run simultaneously to test it...without thinking about the minimum order size. I will try it again later.
Thanks for your work!


Title: Re: goxtool bot: portfolio rebalancing
Post by: leela on December 23, 2013, 12:31:49 AM
I'm trying to get this to run on my linux box. I'm not normally a noob (been using linux since mid 90s) but I am a Python noob. If this was written in perl or something, no problem. :P

First problem was python-crypto wasn't installed. Second problem was python-simplejson wasn't installed.

 1807  apt-get install python-crypto
 1808  apt-get install python-simplejson

So after that, we have a new problem. (sorry for the spam, but this is how the output came out. I did delete screenfulls of blank lines at least.)


:~/goxtool$ ./goxtool.py --strategy=balancer.py
enter passphrase for secret:
testing secret...
testing key...
ok :-)

Price: 0.000000 - 0.000000 | Market: BTCUSD | Account: No info (yet)
sum_bid: 0 USD | sum_ask: 0 BTC | ratio: - USD/BTC | lag:  / 0.000 s (order / socket)

                                                                   
### shutdown...                                                     
                                                                   


*** error(s) in curses_loop() that caused unclean shutdown:

                                                           Traceback (most recent call last):
                                                                                               File "./goxtool.py", line 1592, in curses_loop
             strategy_manager = StrategyManager(gox, strat_mod_list)
                                                                      File "./goxtool.py", line 1476, in __init__
                                                                                                                     self.reload()
                                                                                                                                    File "./goxtool.py", line 1490, in reload
                                             strategy_module = __import__(name)
                                                                                 File "/home/leela/goxtool/balancer.py", line 16, in <module>
              conf = json.load(open("user.conf"))
                                                 IOError: [Errno 2] No such file or directory: 'user.conf'

                                                                                                          Traceback (most recent call last):
          File "./goxtool.py", line 1679, in curses_loop
                                                            strategy_manager.unload()
                                                                                     UnboundLocalError: local variable 'strategy_manager' referenced before assignment


Exception in thread Thread-1 (most likely raised during interpreter shutdown):
                                                                              Traceback (most recent call last):
                                                                                                                  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
                                                      File "/usr/lib/python2.7/threading.py", line 757, in run
                                                                                                                File "/usr/lib/python2.7/threading.py", line 403, in wait
                                       File "/usr/lib/python2.7/threading.py", line 267, in wait
                                                                                                <type 'exceptions.ValueError'>: list.remove(x): x not in list
                         :~/goxtool$


Okay, so lets create user.conf.


:~/goxtool$ touch user.conf
:~/goxtool$ ./goxtool.py --strategy=balancer.py
enter passphrase for secret:
testing secret...
testing key...
ok :-)


Price: 0.000000 - 0.000000 | Market: BTCUSD | Account: No info (yet)
sum_bid: 0 USD | sum_ask: 0 BTC | ratio: - USD/BTC | lag:  / 0.000 s (order / socket)

                                                                   
### shutdown...                                                     
                                                                                                                 

*** error(s) in curses_loop() that caused unclean shutdown:

                                                           Traceback (most recent call last):
                                                                                               File "./goxtool.py", line 1592, in curses_loop
             strategy_manager = StrategyManager(gox, strat_mod_list)
                                                                      File "./goxtool.py", line 1476, in __init__
                                                                                                                     self.reload()
                                                                                                                                    File "./goxtool.py", line 1490, in reload
                                             strategy_module = __import__(name)
                                                                                 File "/home/leela/goxtool/balancer.py", line 16, in <module>
              conf = json.load(open("user.conf"))
                                                   File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 357, in load
    use_decimal=use_decimal, **kw)
                                    File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 413, in loads
                                                                                                                          return _default_decoder.decode(s)
                         File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 402, in decode
                                                                                                               obj, end = self.raw_decode(s, idx=_w(s, 0).end())
                              File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 420, in raw_decode
                                                                                                                        raise JSONDecodeError("No JSON object could be decoded", s, idx)
                                                    JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)

                                                                                                                              Traceback (most recent call last):
                              File "./goxtool.py", line 1679, in curses_loop
                                                                                strategy_manager.unload()
                                                                                                         UnboundLocalError: local variable 'strategy_manager' referenced before assignment


Exception in thread Thread-1 (most likely raised during interpreter shutdown):
                                                                              Traceback (most recent call last):
                                                                                                                  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
                                                      File "/usr/lib/python2.7/threading.py", line 757, in run
                                                                                                                File "/usr/lib/python2.7/threading.py", line 403, in wait
                                       File "/usr/lib/python2.7/threading.py", line 267, in wait
                                                                                                <type 'exceptions.ValueError'>: list.remove(x): x not in list
                          Exception in thread Thread-2 (most likely raised during interpreter shutdown):
                                                                                                        Traceback (most recent call last):
        File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
                                                                                File "/usr/lib/python2.7/threading.py", line 759, in run
      File "/home/leela/goxtool/goxapi.py", line 431, in _fire
                                                                 File "/home/leela/goxtool/goxapi.py", line 371, in __call__
                                                                                                                               File "/usr/lib/python2.7/threading.py", line 121, in acquire
                                                       <type 'exceptions.TypeError'>: 'NoneType' object is not callable
                                                                                                                       :~/goxtool$



Urghh.

The code in balancer.py has:


# Load user.conf
conf = json.load(open("user.conf"))

# Set defaults
conf.setdefault('balancer_simulate', True)
conf.setdefault('balancer_distance', 7)
conf.setdefault('balancer_fiat_cold', 0)
conf.setdefault('balancer_coin_cold', 0)
conf.setdefault('balancer_marker', 7)
conf.setdefault('balancer_compensate_fees', False)
conf.setdefault('balancer_target_margin', 1)


So I assume it would use those as defaults if there's nothing in the conf file...

Anyway, I don't know if I've pulled some new version from git or what because there's no instructions in this thread or the goxtool website about needing this conf file or what to put in it...


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on December 23, 2013, 12:53:13 AM
user.conf

The _balancer.py this thread is about has no "user.conf", please see the link to the original in post #1

You also wouldn't have needed any additional json packages, all of goxtool is using the built in json moule that comes with a standard python installation, I don't know what this balancer fork is doing or what it needs exotic additional json libs for.


Title: Re: goxtool bot: portfolio rebalancing
Post by: leela on December 23, 2013, 12:57:36 AM
So you're telling me this has nothing to do with balancer.py from https://github.com/caktux/goxtool ?  Hmmmm.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on December 23, 2013, 01:00:51 AM
So you're telling me this has nothing to do with balancer.py from https://github.com/caktux/goxtool ?  Hmmmm.
Thats a fork of my original bot. I don't know what was changed in this fork and how to use it, I can only recommend my original as it is found in the link on page 1.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on December 23, 2013, 01:03:24 AM
and in my signature the link for the main goxtool app. The only recommended and supported version.


Title: Re: goxtool bot: portfolio rebalancing
Post by: leela on December 23, 2013, 01:04:55 AM
So you're telling me this has nothing to do with balancer.py from https://github.com/caktux/goxtool ?  Hmmmm.
Thats a fork of my original bot. I don't know what was changed in this fork and how to use it, I can only recommend my original as it is found in the link on page 1.

Yes, I see, I'm studying the diff now. I didn't realise he imported your code into goxtool and made a few changes around the place (hence my confusion). It seems he did this relatively recently too.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on December 23, 2013, 01:12:26 AM
He probably added the user.conf stuff to support multiple installations on his multi user hosted goxtool server, probably heavy modifications because also every user needs his own account api secret.

The original _balancer does not need a config file, the way it is supposed to work in a single user setup is to edit the .py file of the strategy directly and then just press "l" (lowercase L) to dynamically reload the strategy at runtime (keep it simple approach, also for making code changes to the bot or similar experiments without needing to restart the entire application).


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on December 23, 2013, 01:18:20 AM
he imported your code into goxtool
Its probably also a modified goxtool. Original code for original goxtool is at my repository (link in my sig)


Title: Re: goxtool bot: portfolio rebalancing
Post by: shermozle on January 08, 2014, 12:52:30 AM
He probably added the user.conf stuff to support multiple installations on his multi user hosted goxtool server, probably heavy modifications because also every user needs his own account api secret.

(Second attempt to post this. Bitcointalk is rubbish)

Interesting service. I like his visualization:
https://zerogox.com/sites/zerogox.com/files/chart-screenshot.png

What are people using to track their bots' progress? I've got a simple Google Spreadsheet that I manually update periodically. One of these days I plan to learn enough Python to automatically push trades to it as they happen, which would be much more interesting.

But more relevant, how do you visualize and assess success from the bot? I look at both the 24 hour average exchange rate as well as the price at the time of the trade. They're both interesting views, and there's been a reasonable appreciation in balance by both measures.


Title: Re: goxtool bot: portfolio rebalancing
Post by: smooth on January 08, 2014, 01:26:56 AM
What are people using to track their bots' progress?

Its pretty hard to do this in a meaningful way if you are running a balancer. If you do some simulations you see that results can be all over the place just due to luck.

You can draw pretty pictures of course, but if you are drawing conclusions from results over a reasonable time scale you are probably fooling yourself.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on January 08, 2014, 10:32:18 AM
What are people using to track their bots' progress?

You can use this:
Code:
#!/usr/bin/gnuplot

set terminal wxt size 1000,650
set datafile sep ','

set xlabel "USD Account Balance"
set ylabel "BTC Account Balance"
plot '_balancer.log' using 3:4 with lines
pause -1

it will produce plots like these: https://bitcointalk.org/index.php?topic=181584.msg3911898#msg3911898

or here (same plot as above after a few more weeks):
https://i.imgur.com/2NLNNel.png



Title: Re: goxtool bot: portfolio rebalancing
Post by: shermozle on January 11, 2014, 07:10:01 AM
it will produce plots like these: https://bitcointalk.org/index.php?topic=181584.msg3911898#msg3911898

This is awesome, and has given me a nice gentle way into gnuplot which has always seemed scary and hairy. I like with this plot how you can see the total edging forward slightly with each gyration of the price. Would be nice to show the time dimension in there somehow.


Title: Re: goxtool bot: portfolio rebalancing
Post by: whizter on January 11, 2014, 03:38:31 PM
Bot is running nice, made about 1k eur in the last month. I'm tracking everything with excel.


Title: Re: goxtool bot: portfolio rebalancing
Post by: shermozle on January 13, 2014, 05:42:03 AM
You can use this:
Code:
#!/usr/bin/gnuplot

set terminal wxt size 1000,650
set datafile sep ','

set xlabel "USD Account Balance"
set ylabel "BTC Account Balance"
plot '_balancer.log' using 3:4 with lines
pause -1

I've made a tiny change to this. It adds a circle to the latest data point (a la sparklines) which aids in readability. I'm looking at other changes too as I get into gnuplot.

Code:
set datafile sep ','
unset key

set xlabel "AUD Account Balance"
set ylabel "BTC Account Balance"

stats '/tmp/_balancer.log' nooutput
last_index = int(STATS_records - 1)
plot    '/tmp/_balancer.log' using 3:4 with lines,\
        '/tmp/_balancer.log' using 3:4 every ::last_index with points pointtype 7 lc 1

pause -1

http://dl.dropboxusercontent.com/u/62533350/graph.png


Title: Re: goxtool bot: portfolio rebalancing
Post by: nitrox on January 19, 2014, 08:41:09 PM
can't start
Code:
./goxtool.py --strategy=_balancer.py --protocol=websocket --use-http
in log have only
Code:
2014-01-19 22:38:48,050:DEBUG:goxapi.Gox:### shutdown...


but
Code:
./goxtool.py --protocol=websocket --use-http
start normaly but not do traiding.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on January 19, 2014, 10:20:33 PM
can't start
Code:
./goxtool.py --strategy=_balancer.py --protocol=websocket --use-http
in log have only
Code:
2014-01-19 22:38:48,050:DEBUG:goxapi.Gox:### shutdown...

Did you make any modifications to the _balancer.py? Does it work and just not logging or does it shut down immediately? is goxtool the very latest version from github?


Title: Re: goxtool bot: portfolio rebalancing
Post by: pizzaman1337 on January 19, 2014, 10:45:13 PM
Bot is running nice, made about 1k eur in the last month. I'm tracking everything with excel.

Just curious, that return is from what amount of fiat and BTC?


Title: Re: goxtool bot: portfolio rebalancing
Post by: nitrox on January 19, 2014, 11:16:52 PM
Did you make any modifications to the _balancer.py? Does it work and just not logging or does it shut down immediately? is goxtool the very latest version from github?

it is shutdown immediately, no modifications, it is up to date.

only one modifications in goxtool.ini
Code:
guote_currency = USD
to
Code:
guote_currency = EUR

have no idea what is going on.
i try this https://github.com/Timmeey/rangerBot
this is start and working but not _balancer.py



Title: Re: goxtool bot: portfolio rebalancing
Post by: nitrox on January 19, 2014, 11:22:17 PM
after all delete and config again
i get that error in log
Code:
 File "/home/user/goxtool/goxapi.py", line 385, in __call__
    func(instance, sender, data)
  File "/home/user/goxtool/_balancer.py", line 67, in slot_keypress
    self.place_orders()
  File "/home/user/goxtool/_balancer.py", line 164, in place_orders
    center = self.get_price_where_it_was_balanced()
  File "/home/user/goxtool/_balancer.py", line 132, in get_price_where_it_was_balanced
    fiat_have = gox.quote2float(gox.wallet[gox.curr_quote]) + FIAT_COLD
KeyError: 'EUR'


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on January 20, 2014, 01:23:07 PM
KeyError: 'EUR'
Is this a fresh account and you have never bought or possessed any EUR before? Then the EUR wallet will be missing. buy a few EUR manually and the error will go away. If you do not intend to trade in EUR then set it to USD in goxtool.ini. Are you using the original goxtool from the prof7bit github or some fork from somebody else?


Title: Re: goxtool bot: portfolio rebalancing
Post by: nitrox on January 20, 2014, 06:36:48 PM
Is this a fresh account and you have never bought or possessed any EUR before? Then the EUR wallet will be missing. buy a few EUR manually and the error will go away. If you do not intend to trade in EUR then set it to USD in goxtool.ini. Are you using the original goxtool from the prof7bit github or some fork from somebody else?
i using the original goxtool from the prof7bit github.
i have already EUR in account.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on January 20, 2014, 07:49:05 PM
i using the original goxtool from the prof7bit github.
i have already EUR in account.
Does it show the EUR balance in the status bar at the top? I cannot currently imagine what could cause this error because if you have an EUR account then gox.wallet['EUR'] must exist. Did you press the "b" key before it was fully initialized, before it had downloaded the account info and the account balance showed up in the status bar?


Title: Re: goxtool bot: portfolio rebalancing
Post by: nitrox on January 20, 2014, 08:02:09 PM
Does it show the EUR balance in the status bar at the top? I cannot currently imagine what could cause this error because if you have an EUR account then gox.wallet['EUR'] must exist. Did you press the "b" key before it was fully initialized, before it had downloaded the account info and the account balance showed up in the status bar?
yes it show the EUR balance in the status bar at the top.
i do not press  the "b" key at all.


Title: Re: goxtool bot: portfolio rebalancing
Post by: prof7bit on January 20, 2014, 08:25:48 PM
yes it show the EUR balance in the status bar at the top.
i do not press  the "b" key at all.
or "p" or "i", from your stack trace it happened inside the keypress slot.


Title: Re: goxtool bot: portfolio rebalancing
Post by: kocur on January 22, 2014, 08:53:13 PM
Hi

I try use this bot on gox and working fine. Great work .) Is possible use this tool on btc-e dot com ? With some changes in configs sure, or need to rewrite more code ? It would be nice to have same tool for btc-e.
Thx