Pages:
Author

Topic: goxtool bot: portfolio rebalancing - page 7. (Read 26597 times)

hero member
Activity: 938
Merit: 500
https://youengine.io/
April 24, 2013, 06:36:06 AM
#33
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.
sr. member
Activity: 360
Merit: 250
April 24, 2013, 06:05:49 AM
#32
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?

hero member
Activity: 938
Merit: 500
https://youengine.io/
April 23, 2013, 02:21:50 PM
#31
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.
newbie
Activity: 56
Merit: 0
April 23, 2013, 02:15:49 PM
#30
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.
sr. member
Activity: 360
Merit: 250
April 23, 2013, 12:37:49 PM
#29
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.
legendary
Activity: 1792
Merit: 1008
/dev/null
member
Activity: 105
Merit: 10
April 23, 2013, 11:29:25 AM
#27
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.
legendary
Activity: 1792
Merit: 1008
/dev/null
April 23, 2013, 11:27:08 AM
#26
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 Wink
member
Activity: 105
Merit: 10
April 23, 2013, 11:26:27 AM
#25
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 ?
legendary
Activity: 1437
Merit: 1002
https://bitmynt.no
April 23, 2013, 11:07:18 AM
#24
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.
member
Activity: 105
Merit: 10
April 22, 2013, 04:00:44 PM
#23
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")
hero member
Activity: 560
Merit: 500
I am the one who knocks
April 22, 2013, 03:17:33 PM
#22
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.
hero member
Activity: 588
Merit: 500
April 22, 2013, 03:12:51 PM
#21
Nice, never heard of screen. thanks for the info, it's working now, even if I close the ssh client.
hero member
Activity: 560
Merit: 500
I am the one who knocks
April 22, 2013, 03:06:56 PM
#20
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://bitcointalksearch.org/topic/m.1886914

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.
member
Activity: 105
Merit: 10
April 22, 2013, 02:48:29 PM
#19
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
legendary
Activity: 1199
Merit: 1012
April 22, 2013, 02:45:12 PM
#18
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
hero member
Activity: 588
Merit: 500
April 22, 2013, 02:41:07 PM
#17
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.
legendary
Activity: 1792
Merit: 1008
/dev/null
April 22, 2013, 10:49:14 AM
#16
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? Tongue
member
Activity: 105
Merit: 10
April 22, 2013, 10:44:02 AM
#15
Thanks...
maybe the "name" parameter in config file is a KISS solution (Keep it Simple, Stupid)
(even for log file)

good luck hunting bugs  Wink
hero member
Activity: 938
Merit: 500
https://youengine.io/
April 22, 2013, 10:32:05 AM
#14
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.
Pages:
Jump to: