Pages:
Author

Topic: goxtool bot: portfolio rebalancing - page 6. (Read 26586 times)

newbie
Activity: 29
Merit: 0
May 07, 2013, 06:50:34 AM
#53
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...
hero member
Activity: 560
Merit: 500
I am the one who knocks
May 02, 2013, 11:16:11 AM
#52
Is the goxtool keeps getting stuck today? Or it 's just me and my system?
Seems fine for me... although lots of trades today
full member
Activity: 227
Merit: 100
May 02, 2013, 07:22:08 AM
#51
Is the goxtool keeps getting stuck today? Or it 's just me and my system?
full member
Activity: 224
Merit: 100
April 30, 2013, 07:26:50 AM
#50
Thanks, and you did understand what I meant.  Guess I should have just asked about "use-http"  Cheesy
hero member
Activity: 938
Merit: 500
https://youengine.io/
April 30, 2013, 03:40:06 AM
#49
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.
full member
Activity: 224
Merit: 100
April 29, 2013, 03:12:33 PM
#48
[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.  Wink
hero member
Activity: 938
Merit: 500
https://youengine.io/
April 26, 2013, 05:54:39 AM
#47

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!
newbie
Activity: 58
Merit: 0
April 26, 2013, 01:30:42 AM
#46
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
newbie
Activity: 56
Merit: 0
April 24, 2013, 10:39:58 PM
#45
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.
hero member
Activity: 938
Merit: 500
https://youengine.io/
April 24, 2013, 03:23:51 PM
#44
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.
legendary
Activity: 2968
Merit: 1198
April 24, 2013, 02:27:37 PM
#43
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. 
hero member
Activity: 560
Merit: 500
I am the one who knocks
April 24, 2013, 12:55:52 PM
#42
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!
hero member
Activity: 938
Merit: 500
https://youengine.io/
April 24, 2013, 12:09:29 PM
#41
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.
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).
hero member
Activity: 560
Merit: 500
I am the one who knocks
April 24, 2013, 12:02:20 PM
#40
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://bitcointalksearch.org/topic/m.1932608
full member
Activity: 160
Merit: 100
April 24, 2013, 11:57:37 AM
#39
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).
sr. member
Activity: 360
Merit: 250
April 24, 2013, 11:30:34 AM
#38
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.
hero member
Activity: 560
Merit: 500
I am the one who knocks
April 24, 2013, 11:16:15 AM
#37
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 Huh):
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?
hero member
Activity: 560
Merit: 500
I am the one who knocks
April 24, 2013, 10:11:04 AM
#36
Would it also be worth calculating USD Worth (USD+(BTC*PRICE))  I have found that is a a better indicator with my personal results.
hero member
Activity: 938
Merit: 500
https://youengine.io/
April 24, 2013, 09:48:41 AM
#35
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?
sr. member
Activity: 360
Merit: 250
April 24, 2013, 09:07:38 AM
#34
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!
 
Pages:
Jump to: