Bitcoin Forum
October 20, 2017, 10:16:22 PM
 News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 Home Help Search Donate Login Register
 Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [17] 18 19 20 21 22 23 24 25 26 27 28
TobbeLino
Jr. Member

Offline

Activity: 42

 May 09, 2013, 09:59:05 AM

Tobbe

Your modified extension is Ba Dass!

A couple of thoughts:

You should add a space to line 22 of popup.js for the ticks element.

document.getElementById("ticks").innerHTML=bp.tickCount+ " samples"

And I added a new Ema s/l % metric to the graph tooltip (You won't want to add it like this, it's just a hack):

function formatEMALongTooltip(sp, options, fields){
var trend='?';
if (lastEmaTime==fields.x)
trend=(fields.y<lastEmaShort?'<span style="font-weight:bold;color:#6F6">UP</span>':(fields.y>lastEmaShort?'<span style="font-weight:bold;color:#F66">DOWN</span>':'none'));

//
// Display EMA S/L %. Helpful for gauging on the graph when trades execute on new trend directions.
// Round to 3 decimal places.
//
var per = ((lastEmaShort-fields.y) / ((lastEmaShort+fields.y)/2)) * 100;
trend = trend + ' ' + Math.abs(Math.round(per*1000)/1000) + '%';

return '<span style="color: '+fields.color+'">&#9679;</span> EMA'+bp.EmaLongPar+': '+formatChartNumbers(fields.y)+'</td></tr></table>Trend: '+trend;
}

I wanted to see from the chart when trades would be placed having different thresholds....

Cheers.
Jon

I've also thought about trying to add some kind of indication in the chart where the trend switches and the bot would trigger a trade.

But today I'll celebrate my birthday

Try my modified trading bot for Chrome:
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
TobbeLino
Jr. Member

Offline

Activity: 42

 May 09, 2013, 10:09:45 AM

- Keep an amount of BTC away from trading

- Can you do the same for fiat ? (usefull to test)

I started implementing that, but it turned out to be a bit tricky.

When making a "buy" with the MtGox API, the bot calls "buyBTC" and specify how many BTC to buy. Or in fact 1000 BTC right now, so in practice it will buy as much as you can afford (if your not filthy rich!   The bot doesn't know what the exact price will be in fiat before the trade, so it doesn't know how much BTC to buy to keep a certain amount of fiat.

It would however be possible to make an estimate based on last price, but it would not be exact.
But maybe that's ok...

Try my modified trading bot for Chrome:
Raymgiv
Newbie

Offline

Activity: 12

 May 09, 2013, 12:21:12 PM

But today I'll celebrate my birthday

Happy Birthday Tobbelino!

I played around with it briefly last night and liked what I saw. No official trading just seeing what different options produced.  I hope to use it in the future and hope to see it continually evolve.

-R
funkymunky
Sr. Member

Offline

Activity: 283

 May 09, 2013, 02:36:48 PM

Thank you

Just released a new version of my (free) trading bot modification: https://github.com/TobbeLino/GoxTradingBotTobli

It now also has a chart!

StarenseN
Legendary

Offline

Activity: 1456

 May 09, 2013, 04:52:28 PM

Wich threshold do you suggest? Are 0.25% (Buy/Sell T) by default, suitable?
maverick1337
Jr. Member

Offline

Activity: 38

 May 09, 2013, 08:02:00 PM

I want to first thank you for your hard work on your free bot. I am a little confused how it trades. According to your description, it buys and sells based on the "absolute difference between EMA %" and that statement worries me. I thought you would initiate a buy when it's positive difference and a sell when the difference is negative. How does it determine when to buy and sell based off absolute values?
virtimus
Newbie

Offline

Activity: 27

 May 10, 2013, 10:03:42 AM

It seems to be "unproof" from minimal price fluctuations (like those from 2013-05-09 09:00).

I think it could be improved adding more smart algo to decide if to buy/sell (ie concerning also wallet history)
Did first step in this direction - just pushed mod which gets wallet history and displays it under chart.
Now we can think how to use the data deciding on current trade ... maybe some additional "wait" mode ? (as extention of currrent tradeEnabled flag)

BTC:13eJdr8ndc3MJAeHGpVTNMPUtTGE8ANHpL
TobbeLino
Jr. Member

Offline

Activity: 42

 May 10, 2013, 12:34:24 PM

Wich threshold do you suggest? Are 0.25% (Buy/Sell T) by default, suitable?

Well, I'm no expert in trading, so other people are probably better to help you with that...
I think the optimal threshold setting depends on the sample interval and how "long trends" you try to catch with the bot, and it also depends on how volatile the market is at the moment...

The default 0.25% thresholds and 1 hour sample interval comes from the original bot.
Many seem to prefer to lower the sample interval and lower the thresholds to allow "faster trading".
I can't judge if that's a wise strategy, and I personally think that the biggest problem when trading manually (without a bot) is that you react too quickly and too strong, so the whole point for me using the bot is that it will take it more easy
Yesterday when the market was very calm without a distinct trend, my bot lost money because the thresholds where too low and the fees where higher than the profit. On a very calm market, it's probably better not to trade at all (by setting the thresholds higher). But as I said, I'm no expert in trading - I just modified the bot, allowing more settings...

Try my modified trading bot for Chrome:
TobbeLino
Jr. Member

Offline

Activity: 42

 May 10, 2013, 12:39:12 PM

I want to first thank you for your hard work on your free bot. I am a little confused how it trades. According to your description, it buys and sells based on the "absolute difference between EMA %" and that statement worries me. I thought you would initiate a buy when it's positive difference and a sell when the difference is negative. How does it determine when to buy and sell based off absolute values?

That description is a leftover from the original bot (that didn't have separate buy/sell thresholds).
I'll commit a new version soon with a more correct description.

Try my modified trading bot for Chrome:
TobbeLino
Jr. Member

Offline

Activity: 42

 May 10, 2013, 12:49:04 PM

It seems to be "unproof" from minimal price fluctuations (like those from 2013-05-09 09:00).

I think it could be improved adding more smart algo to decide if to buy/sell (ie concerning also wallet history)
Did first step in this direction - just pushed mod which gets wallet history and displays it under chart.
Now we can think how to use the data deciding on current trade ... maybe some additional "wait" mode ? (as extention of currrent tradeEnabled flag)

When the market is calm, like yesterday, it's probably better not to trade at all. No bot (or person), regardless how smart they are can make money on a market that stands still. You need a swing (that is larger than the fees).

Also, taking wallet history into account when making buy/sell-decisions sounds wrong for a bot. Because that's exactly what people do when they trade, and that's why we need a bot to keep our feelings AWAY from the decision making
After all, your personal wallet history or trading history never ever affects the future of the market, and if you think the price will go down you should sell - no matter what you paid, and if you think the market will go up, you should buy, no matter how you have traded before... But for people it's very difficult to keep the emotions away - at least for me

Try my modified trading bot for Chrome:
virtimus
Newbie

Offline

Activity: 27

 May 10, 2013, 02:37:18 PM

You're right. That's just my emotions with the bot - I don't like to loose BTC I would prefer loosing fiat ...
So I'm going to do something about it.
I m going to make an emotional bet: "BTC will raise in long therm" - and in this case - I would prefer to stay on BTC than sell it too low.
So I think to myself: I'm going to implement an algo which will prevent my stupid bot  from selling bTC lower than they were bought
How do You think about it ?

BTC:13eJdr8ndc3MJAeHGpVTNMPUtTGE8ANHpL
rikigst
Jr. Member

Offline

Activity: 46

So long and thanks for all the fish

 May 10, 2013, 02:59:14 PM

How about crappy gox apis that get stuck now and then?
For instance,now I only get prices up to 16.25 (it's 16.52 now, interval is 5 min).
If I manually look up the page this bot is trying to reach, i only get empty [] brackets instead of the transactions list.
It has happened before, but having a bot that randomly stops working for half an hour or more at any given time makes it all potentially useless!
What about v1 and v2 apis? I've been told they behave much better.
TobbeLino, any chance you could address this issue? I've seen you've reduced to 1 m the refresh interval in the last commit, so I think it's definitely a problem with v0 apis.
By the way, thank you for the excellent work by far!

bitboat.net - Compra Bitcoin con ricarica Superflash!
rikigst
Jr. Member

Offline

Activity: 46

So long and thanks for all the fish

 May 10, 2013, 04:45:04 PM

Here's a (very brutal, indeed) fix for everyone having issues with v0 gox apis: v1 work very well indeed!
You need to change the following lines in background.js:

Line 128:
Code:
req.open("GET", url);
becomes (preventing chrome to use cached pages)
Code:
req.open("GET", url+"?sid=" + Math.random());

Line 271:
Code:
becomes
Code:

Line 283:
Code:
var trs = JSON.parse(req.responseText);
becomes (quite raw, but it works!)
Code:
var trs = JSON.parse(req.responseText.replace("{\"result\":\"success\",\"return\":","").replace("]}","]"));

Line 304:
Code:
becomes
Code:

The bot is behaving MUCH better now thanks to the new apis

EDIT: probably the big issue was Chrome using the cached content, which stopped the bot any time it went through an empty page. With the line 128 workaround (above), v0 apis should work well, too!

bitboat.net - Compra Bitcoin con ricarica Superflash!
TobbeLino
Jr. Member

Offline

Activity: 42

 May 10, 2013, 05:52:27 PM

Here's a (very brutal, indeed) fix for everyone having issues with v0 gox apis: v1 work very well indeed!
You need to change the following lines in background.js:

Thanks, I'll have a look at it!
The v0 API is unreliable indeed...

Try my modified trading bot for Chrome:
TobbeLino
Jr. Member

Offline

Activity: 42

 May 10, 2013, 06:19:01 PM

You're right. That's just my emotions with the bot - I don't like to loose BTC I would prefer loosing fiat ...
So I'm going to do something about it.
I m going to make an emotional bet: "BTC will raise in long therm" - and in this case - I would prefer to stay on BTC than sell it too low.
So I think to myself: I'm going to implement an algo which will prevent my stupid bot  from selling bTC lower than they were bought
How do You think about it ?

Well, I know the feeling about wanting to improve the strategy But my experience is that it often results in less profit in the long run... There are some very smart people who have developed these strategies, and at least I am not good enough to improve them yet. I often think my bot is stupid, and sometimes it DOES make wrong decisions of course. But more often it's right in the end, and it turns out that it made a BETTER decision than I would have. The thing is that you would like to buy at the exact bottom, and sell at the exact top of every swing, but no bot (or human) can ever predict that (and if you try to achieve that, you would have to take too high risk and end up losing in the long run).

The problem with your argument that "it would be better to stay on BTC than selling too low" is that if you (or your bot) truly believes that the price will drop even lower in a moment, it's always smarter to sell now and buy again after some time. Your decision should always be based on "where the price is going" rather than "what the price is". And I think you're always better off trying to "forget" what you actually paid for your BTC when you bought it. The only thing that could make a diferece is the actual trading fees

But of course, there can be better strategies out there to discover and develop, so go for it!

Try my modified trading bot for Chrome:
maverick1337
Jr. Member

Offline

Activity: 38

 May 10, 2013, 07:22:40 PM

Here's a (very brutal, indeed) fix for everyone having issues with v0 gox apis: v1 work very well indeed!
You need to change the following lines in background.js:

Line 128:
Code:
req.open("GET", url);
becomes (preventing chrome to use cached pages)
Code:
req.open("GET", url+"?sid=" + Math.random());

Line 271:
Code:
becomes
Code:

Line 283:
Code:
var trs = JSON.parse(req.responseText);
becomes (quite raw, but it works!)
Code:
var trs = JSON.parse(req.responseText.replace("{\"result\":\"success\",\"return\":","").replace("]}","]"));

Line 304:
Code:
becomes
Code:

The bot is behaving MUCH better now thanks to the new apis

EDIT: probably the big issue was Chrome using the cached content, which stopped the bot any time it went through an empty page. With the line 128 workaround (above), v0 apis should work well, too!
I can attest that these changes do make the bot work better. Before, when I clicked on "chart" it wouldn't show anything, just a blank screen. Now it actually works and things seem to be running more smoothly. Thanks for delving into this matter.

EDIT - One thing I noticed in the console, almost every line says "TypeError". What does this mean? The bot works fine but in the console I just see this a lot.
TobbeLino
Jr. Member

Offline

Activity: 42

 May 10, 2013, 08:40:31 PM

Here's a (very brutal, indeed) fix for everyone having issues with v0 gox apis: v1 work very well indeed!
You need to change the following lines in background.js:

Line 128:
Code:
req.open("GET", url);
becomes (preventing chrome to use cached pages)
Code:
req.open("GET", url+"?sid=" + Math.random());

Line 271:
Code:
becomes
Code:

Line 283:
Code:
var trs = JSON.parse(req.responseText);
becomes (quite raw, but it works!)
Code:
var trs = JSON.parse(req.responseText.replace("{\"result\":\"success\",\"return\":","").replace("]}","]"));

Line 304:
Code:
becomes
Code:

The bot is behaving MUCH better now thanks to the new apis

EDIT: probably the big issue was Chrome using the cached content, which stopped the bot any time it went through an empty page. With the line 128 workaround (above), v0 apis should work well, too!

Hmmm - I just got API v2 working here BUT there's a bit of a problem fetching trades with API v1 and API v2 - MtGox will return 1000 trades instead of 100 (with API 0), so the data traffic will increase 10-fold (and it will update a lot slower!) :/
Unfortunately there doesn't seem to be any parameter to specify how many trades we want to fetch (we only need ONE sample for each interval!) The docs for API v2 is quite limited however - anyone know if there's a way to fetch single historical trades using API v2?

Try my modified trading bot for Chrome:
Member

Offline

Activity: 74

 May 10, 2013, 09:26:47 PM

Hmmm - I just got API v2 working here BUT there's a bit of a problem fetching trades with API v1 and API v2 - MtGox will return 1000 trades instead of 100 (with API 0), so the data traffic will increase 10-fold (and it will update a lot slower!) :/
Unfortunately there doesn't seem to be any parameter to specify how many trades we want to fetch (we only need ONE sample for each interval!) The docs for API v2 is quite limited however - anyone know if there's a way to fetch single historical trades using API v2?

The reason it's replying with a lot of trades is that in API v2, it will return the last 24h history by default if you don't specify anything and just fetch /money/trades

You can add a ?since= parameter at the end of the url to have it return only trades since that order id. Also, if you do that it'll then reply in chunks of 100 trades like you want.

To quote this post https://bitcointalk.org/index.php?topic=150786.msg1690500#msg1690500

since is in time units*1000000
to start x hours ago you can calculate
since = int(time() - x*60*60)*1000000

You will get batches of 100 trades, so you need to keep calling
with since set to highest tid in previous batch

Hope this helps.
TobbeLino
Jr. Member

Offline

Activity: 42

 May 10, 2013, 09:53:30 PM

Hmmm - I just got API v2 working here BUT there's a bit of a problem fetching trades with API v1 and API v2 - MtGox will return 1000 trades instead of 100 (with API 0), so the data traffic will increase 10-fold (and it will update a lot slower!) :/
Unfortunately there doesn't seem to be any parameter to specify how many trades we want to fetch (we only need ONE sample for each interval!) The docs for API v2 is quite limited however - anyone know if there's a way to fetch single historical trades using API v2?

The reason it's replying with a lot of trades is that in API v2, it will return the last 24h history by default if you don't specify anything and just fetch /money/trades

You can add a ?since= parameter at the end of the url to have it return only trades since that order id. Also, if you do that it'll then reply in chunks of 100 trades like you want.

To quote this post https://bitcointalk.org/index.php?topic=150786.msg1690500#msg1690500

since is in time units*1000000
to start x hours ago you can calculate
since = int(time() - x*60*60)*1000000

You will get batches of 100 trades, so you need to keep calling
with since set to highest tid in previous batch

Hope this helps.

Yes, the bot uses the "since"-parameter, and it will make one fetch for each sample interval back in time to calculate EMA. Total 144 calls when starting the bot or changing sample interval (EMA-values need to be recalculated). This many calls may be a problem in itself since I think MtGox's (or Couldflare's) DDoS-protection might kick in and block your IP when making so many calls in a short time.

But the problem with API v1 and v2 is that it seems that the size of the chunks has been increased from 100 to 1000.

Try my modified trading bot for Chrome:
Member

Offline

Activity: 74

 May 11, 2013, 09:33:19 AM

Yes, the bot uses the "since"-parameter, and it will make one fetch for each sample interval back in time to calculate EMA. Total 144 calls when starting the bot or changing sample interval (EMA-values need to be recalculated). This many calls may be a problem in itself since I think MtGox's (or Couldflare's) DDoS-protection might kick in and block your IP when making so many calls in a short time.

But the problem with API v1 and v2 is that it seems that the size of the chunks has been increased from 100 to 1000.