Bitcoin Forum
December 02, 2016, 08:23:53 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   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 »
  Print  
Author Topic: Chrome Browser extension: MtGox trading bot  (Read 67208 times)
TobbeLino
Jr. Member
*
Offline Offline

Activity: 42



View Profile WWW
May 09, 2013, 09:59:05 AM
 #321

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

Thanks, I'll fix the typo and check your addition!
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 Smiley

Try my modified trading bot for Chrome:
https://github.com/TobbeLino/GoxTradingBotTobli
1480710233
Hero Member
*
Offline Offline

Posts: 1480710233

View Profile Personal Message (Offline)

Ignore
1480710233
Reply with quote  #2

1480710233
Report to moderator
1480710233
Hero Member
*
Offline Offline

Posts: 1480710233

View Profile Personal Message (Offline)

Ignore
1480710233
Reply with quote  #2

1480710233
Report to moderator
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480710233
Hero Member
*
Offline Offline

Posts: 1480710233

View Profile Personal Message (Offline)

Ignore
1480710233
Reply with quote  #2

1480710233
Report to moderator
1480710233
Hero Member
*
Offline Offline

Posts: 1480710233

View Profile Personal Message (Offline)

Ignore
1480710233
Reply with quote  #2

1480710233
Report to moderator
TobbeLino
Jr. Member
*
Offline Offline

Activity: 42



View Profile WWW
May 09, 2013, 10:09:45 AM
 #322



- 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! Smiley  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:
https://github.com/TobbeLino/GoxTradingBotTobli
Raymgiv
Newbie
*
Offline Offline

Activity: 12


View Profile
May 09, 2013, 12:21:12 PM
 #323


But today I'll celebrate my birthday Smiley

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 Offline

Activity: 284



View Profile
May 09, 2013, 02:36:48 PM
 #324

Thank you  Grin

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 Offline

Activity: 1148



View Profile
May 09, 2013, 04:52:28 PM
 #325

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

Je donne des conseils et des cours de trading. MP Pour plus d'infos.
maverick1337
Jr. Member
*
Offline Offline

Activity: 38


View Profile
May 09, 2013, 08:02:00 PM
 #326

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 Offline

Activity: 26


View Profile
May 10, 2013, 10:03:42 AM
 #327

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)

https://github.com/virtimus/GoxTradingBot
BTC:13eJdr8ndc3MJAeHGpVTNMPUtTGE8ANHpL
TobbeLino
Jr. Member
*
Offline Offline

Activity: 42



View Profile WWW
May 10, 2013, 12:34:24 PM
 #328

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 Smiley
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:
https://github.com/TobbeLino/GoxTradingBotTobli
TobbeLino
Jr. Member
*
Offline Offline

Activity: 42



View Profile WWW
May 10, 2013, 12:39:12 PM
 #329

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:
https://github.com/TobbeLino/GoxTradingBotTobli
TobbeLino
Jr. Member
*
Offline Offline

Activity: 42



View Profile WWW
May 10, 2013, 12:49:04 PM
 #330

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 Smiley
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 Smiley

Try my modified trading bot for Chrome:
https://github.com/TobbeLino/GoxTradingBotTobli
virtimus
Newbie
*
Offline Offline

Activity: 26


View Profile
May 10, 2013, 02:37:18 PM
 #331

You're right. That's just my emotions with the bot - I don't like to loose BTC Smiley 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 Smiley
How do You think about it ?

https://github.com/virtimus/GoxTradingBot
BTC:13eJdr8ndc3MJAeHGpVTNMPUtTGE8ANHpL
rikigst
Jr. Member
*
Offline Offline

Activity: 46


So long and thanks for all the fish


View Profile
May 10, 2013, 02:59:14 PM
 #332

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 Offline

Activity: 46


So long and thanks for all the fish


View Profile
May 10, 2013, 04:45:04 PM
 #333

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:
var url = "https://data.mtgox.com/api/0/data/getTrades.php?Currency="+currency+"&since="+since;
becomes
Code:
var url = "https://data.mtgox.com/api/1/BTC"+currency+"/trades?since="+since;

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:
url = "https://data.mtgox.com/api/0/data/getTrades.php?Currency="+currency+"&since="+since;
becomes
Code:
url = "https://data.mtgox.com/api/1/BTC"+currency+"/trades?since="+since;

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

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 Offline

Activity: 42



View Profile WWW
May 10, 2013, 05:52:27 PM
 #334

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:
https://github.com/TobbeLino/GoxTradingBotTobli
TobbeLino
Jr. Member
*
Offline Offline

Activity: 42



View Profile WWW
May 10, 2013, 06:19:01 PM
 #335

You're right. That's just my emotions with the bot - I don't like to loose BTC Smiley 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 Smiley
How do You think about it ?

Well, I know the feeling about wanting to improve the strategy Smiley 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! Smiley

Try my modified trading bot for Chrome:
https://github.com/TobbeLino/GoxTradingBotTobli
maverick1337
Jr. Member
*
Offline Offline

Activity: 38


View Profile
May 10, 2013, 07:22:40 PM
 #336

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:
var url = "https://data.mtgox.com/api/0/data/getTrades.php?Currency="+currency+"&since="+since;
becomes
Code:
var url = "https://data.mtgox.com/api/1/BTC"+currency+"/trades?since="+since;

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:
url = "https://data.mtgox.com/api/0/data/getTrades.php?Currency="+currency+"&since="+since;
becomes
Code:
url = "https://data.mtgox.com/api/1/BTC"+currency+"/trades?since="+since;

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

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 Offline

Activity: 42



View Profile WWW
May 10, 2013, 08:40:31 PM
 #337

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:
var url = "https://data.mtgox.com/api/0/data/getTrades.php?Currency="+currency+"&since="+since;
becomes
Code:
var url = "https://data.mtgox.com/api/1/BTC"+currency+"/trades?since="+since;

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:
url = "https://data.mtgox.com/api/0/data/getTrades.php?Currency="+currency+"&since="+since;
becomes
Code:
url = "https://data.mtgox.com/api/1/BTC"+currency+"/trades?since="+since;

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

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:
https://github.com/TobbeLino/GoxTradingBotTobli
tagada
Member
**
Offline Offline

Activity: 74


View Profile
May 10, 2013, 09:26:47 PM
 #338

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
   url = "http://data.mtgox.com/api/1/BTCUSD/trades?since=" + str(since)

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 Offline

Activity: 42



View Profile WWW
May 10, 2013, 09:53:30 PM
 #339

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
   url = "http://data.mtgox.com/api/1/BTCUSD/trades?since=" + str(since)

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.

For instance: https://data.mtgox.com/api/2/BTCUSD/money/trades/fetch?since=1354250571691361 will return 1000 trades
And: https://data.mtgox.com/api/0/data/getTrades.php?Currency=USD&since=1354250571691361 will return 100.



Try my modified trading bot for Chrome:
https://github.com/TobbeLino/GoxTradingBotTobli
tagada
Member
**
Offline Offline

Activity: 74


View Profile
May 11, 2013, 09:33:19 AM
 #340

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.

For instance: https://data.mtgox.com/api/2/BTCUSD/money/trades/fetch?since=1354250571691361 will return 1000 trades
And: https://data.mtgox.com/api/0/data/getTrades.php?Currency=USD&since=1354250571691361 will return 100.

I've taken a quick look at the code, and a few things come to mind. First, that 144 is pretty arbitrary: since EMA is a recursive calculation, its accuracy is very dependent on the number of samples. After a certain point it becomes less relevant since the further you go back, the less the weight given to the data, but 200 * whatever timeframe you're trading is a generally accepted sample size. I remember someone complaining that the initial sample size was not accurate enough so Piotr increased it to 144 which should be an ok compromise, but it won't hurt if you have more.

So you could either keep making these 144 requests of 1000 trades and then divide that by your trading sample size, which would give you about 10 times more candles to back your calculations on, or you can make that 144 dynamic by making requests with a timestamp equal to (number of samples required for accuracy x trading sample size) instead of this fixed 144. In other words, fetch only as much as you need according to your sample size instead of making an arbitrary number of requests. This fixed value made sense when the original bot only dealt with H1 trading and needed 144H of backdata, but not so much now that you allow users to define the trading candle size.

Also, this history and its subsequent updated candles should probably be cached into localstorage until next launch. Since for a 60m candle you're fetching about 5 days worth of history, chances are that some of that data will still be valid on next bot launch, and that would also prevent from refetching everything upon a simple change of parameters.
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 »
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!