Bitcoin Forum
November 18, 2017, 11:34:08 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: « 1 2 3 [4] 5 6 7 8 9 10 11 »  All
  Print  
Author Topic: MtGox API version 2: Unofficial Documentation  (Read 62071 times)
MikeH
Sr. Member
****
Offline Offline

Activity: 406


View Profile
April 16, 2013, 11:20:36 AM
 #61

I see in the pastebin java code that this is being assigned:

Code:
String post_data = this.buildQueryString(args);

but not used except as part of 'Rest-Sign'


Code:
$req->content($nonce . $args);

$hash_data = $method . chr(0) . $nonce . $args;
$req->header('Rest-Sign' => encode_base64( hmac_sha512( $hash_data, decode_base64($secret) ) ));

notice the nonce and args are being used in both 'Rest-Sign' and 'content' - this content is needed with POST but not GET where it forms part of the url.
1511048048
Hero Member
*
Offline Offline

Posts: 1511048048

View Profile Personal Message (Offline)

Ignore
1511048048
Reply with quote  #2

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

Posts: 1511048048

View Profile Personal Message (Offline)

Ignore
1511048048
Reply with quote  #2

1511048048
Report to moderator
1511048048
Hero Member
*
Offline Offline

Posts: 1511048048

View Profile Personal Message (Offline)

Ignore
1511048048
Reply with quote  #2

1511048048
Report to moderator
1511048048
Hero Member
*
Offline Offline

Posts: 1511048048

View Profile Personal Message (Offline)

Ignore
1511048048
Reply with quote  #2

1511048048
Report to moderator
MikeH
Sr. Member
****
Offline Offline

Activity: 406


View Profile
April 16, 2013, 11:29:08 AM
 #62

doesn't help that I've only done a bit of maintenance of java code but are you doing the following for the post?  seems this 'content' i'm referring is sent afterwards via DataOutputStream.

so ugly compared to perl.. may as well be using C Smiley

Code:
String urlParameters = "param1=a&param2=b&param3=c";
String request = "http://example.com/index.php";
URL url = new URL(request);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();          
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("charset", "utf-8");
connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
connection.setUseCaches (false);

DataOutputStream wr = new DataOutputStream(connection.getOutputStream ());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
connection.disconnect();
advanced
Sr. Member
****
Offline Offline

Activity: 263


Woodwallets.io


View Profile WWW
April 16, 2013, 11:36:55 AM
 #63

yes its ugly and it doesn't work I don't understand why.

if you want to see how it looks like at the moment : http://pastebin.com/4UZWYZix . Maybe another pair of eye can help me in finding what should be something really small and stupid compared to this which work http://pastebin.com/SmrxuJQj

Bitmessage : BM-NAx31aEiqeq5zKUtxhKscXQ7Dwn1jJfR
advanced
Sr. Member
****
Offline Offline

Activity: 263


Woodwallets.io


View Profile WWW
April 16, 2013, 11:42:03 AM
 #64

Spotted another difference in my code (which doesn't seem to make a difference Sad ) :

Code:
connection.setRequestProperty("Rest-Sign", signature.replaceAll("\n", ""));

Bitmessage : BM-NAx31aEiqeq5zKUtxhKscXQ7Dwn1jJfR
MikeH
Sr. Member
****
Offline Offline

Activity: 406


View Profile
April 16, 2013, 11:51:53 AM
 #65

the + "000" might be needed:

Code:
String nonce = "nonce=" + String.valueOf(System.currentTimeMillis()) + "000";

plus you probably need this before reading response:

Code:
DataOutputStream output = new DataOutputStream(c.getOutputStream());
            output.writeBytes(post_data);
            output.close();
advanced
Sr. Member
****
Offline Offline

Activity: 263


Woodwallets.io


View Profile WWW
April 16, 2013, 12:40:24 PM
 #66

 Cool Where is your "donate to" address ? Cheesy

Thanks!  It was that! Now it works the ticker only with POST too Wink Yeeeeeeeeeeeeeeee

Bitmessage : BM-NAx31aEiqeq5zKUtxhKscXQ7Dwn1jJfR
MikeH
Sr. Member
****
Offline Offline

Activity: 406


View Profile
April 16, 2013, 01:09:33 PM
 #67

nice, unless you're a bitcoin miliionaire don't worry bout it Smiley
nitrous
Sr. Member
****
Offline Offline

Activity: 246


View Profile
April 16, 2013, 01:41:36 PM
 #68

Glad you finally got it working, advanced. Clearly MikeH was paying closer attention  Wink
I was just giving the query as a string because I wanted to set it up quickly, using a HashMap is better.

Donations: 1Q2EN7TzJ6z82xvmQrRoQoMf3Tf4rMCyvL
MtGox API v2 Unofficial Documentation: https://bitbucket.org/nitrous/mtgox-api/overview
MtGox API v2 Unofficial Documentation Forum Thread: https://bitcointalk.org/index.php?topic=164404.0
advanced
Sr. Member
****
Offline Offline

Activity: 263


Woodwallets.io


View Profile WWW
April 17, 2013, 08:14:32 AM
 #69

Thank you nitrous Wink I'm reporting new findings here :

I'm currently using ticker_fast and it works pretty good, despite I'm not sure how. "BTCUSD/money/ticker_fast"

Works pretty good with USD, even though the answer is slightly different in the ordering:

Code:
Query to :BTCUSD/money/ticker_fast - HTTP response :

{"result":"success","data":{"last_local":{"value":"77.60002","value_int":"7760002","display":"$77.60002","display_short":"$77.60","currency":"USD"},"last":{"value":"77.60002","value_int":"7760002","display":"$77.60002","display_short":"$77.60","currency":"USD"},"last_orig":{"value":"77.60002","value_int":"7760002","display":"$77.60002","display_short":"$77.60","currency":"USD"},"last_all":{"value":"77.60002","value_int":"7760002","display":"$77.60002","display_short":"$77.60","currency":"USD"},"buy":{"value":"77.61110","value_int":"7761110","display":"$77.61110","display_short":"$77.61","currency":"USD"},"sell":{"value":"77.61641","value_int":"7761641","display":"$77.61641","display_short":"$77.62","currency":"USD"},"now":"1366188127158506"}}
Query to :BTCUSD/money/ticker - HTTP response :

{"result":"success","data":{"high":{"value":"82.39000","value_int":"8239000","display":"$82.39000","display_short":"$82.39","currency":"USD"},"low":{"value":"53.61111","value_int":"5361111","display":"$53.61111","display_short":"$53.61","currency":"USD"},"avg":{"value":"68.58637","value_int":"6858637","display":"$68.58637","display_short":"$68.59","currency":"USD"},"vwap":{"value":"68.56407","value_int":"6856407","display":"$68.56407","display_short":"$68.56","currency":"USD"},"vol":{"value":"337373.36971644","value_int":"33737336971644","display":"337,373.36971644\u00a0BTC","display_short":"337,373.37\u00a0BTC","currency":"BTC"},"last_local":{"value":"77.60002","value_int":"7760002","display":"$77.60002","display_short":"$77.60","currency":"USD"},"last_orig":{"value":"77.60002","value_int":"7760002","display":"$77.60002","display_short":"$77.60","currency":"USD"},"last_all":{"value":"77.60002","value_int":"7760002","display":"$77.60002","display_short":"$77.60","currency":"USD"},"last":{"value":"77.60002","value_int":"7760002","display":"$77.60002","display_short":"$77.60","currency":"USD"},"buy":{"value":"77.60002","value_int":"7760002","display":"$77.60002","display_short":"$77.60","currency":"USD"},"sell":{"value":"77.61641","value_int":"7761641","display":"$77.61641","display_short":"$77.62","currency":"USD"},"item":"BTC","now":"1366188104561566"}}


Be careful with EUROS because is not working as expected, giving different values. I will stick to the normal ticker for now with euros (...):

Code:
Query to :BTCEUR/money/ticker - HTTP response :

{"result":"success","data":{"high":{"value":"64.51361","value_int":"6451361","display":"64.51361\u00a0\u20ac","display_short":"64.51\u00a0\u20ac","currency":"EUR"},"low":{"value":"41.78000","value_int":"4178000","display":"41.78000\u00a0\u20ac","display_short":"41.78\u00a0\u20ac","currency":"EUR"},"avg":{"value":"52.17449","value_int":"5217449","display":"52.17449\u00a0\u20ac","display_short":"52.17\u00a0\u20ac","currency":"EUR"},"vwap":{"value":"53.49364","value_int":"5349364","display":"53.49364\u00a0\u20ac","display_short":"53.49\u00a0\u20ac","currency":"EUR"},"vol":{"value":"30454.26156026","value_int":"3045426156026","display":"30,454.26156026\u00a0BTC","display_short":"30,454.26\u00a0BTC","currency":"BTC"},"last_local":{"value":"60.72397","value_int":"6072397","display":"60.72397\u00a0\u20ac","display_short":"60.72\u00a0\u20ac","currency":"EUR"},"last_orig":{"value":"77.77699","value_int":"7777699","display":"$77.77699","display_short":"$77.78","currency":"USD"},"last_all":{"value":"59.24060","value_int":"5924060","display":"59.24060\u00a0\u20ac","display_short":"59.24\u00a0\u20ac","currency":"EUR"},"last":{"value":"60.72397","value_int":"6072397","display":"60.72397\u00a0\u20ac","display_short":"60.72\u00a0\u20ac","currency":"EUR"},"buy":{"value":"60.10000","value_int":"6010000","display":"60.10000\u00a0\u20ac","display_short":"60.10\u00a0\u20ac","currency":"EUR"},"sell":{"value":"60.72397","value_int":"6072397","display":"60.72397\u00a0\u20ac","display_short":"60.72\u00a0\u20ac","currency":"EUR"},"item":"BTC","now":"1366188316676566"}}
Query to :BTCEUR/money/ticker_fast - HTTP response :

{"result":"success","data":{"last_local":{"value":"60.22337","value_int":"6022337","display":"60.22337\u00a0\u20ac","display_short":"60.22\u00a0\u20ac","currency":"EUR"},"last":{"value":"60.22337","value_int":"6022337","display":"60.22337\u00a0\u20ac","display_short":"60.22\u00a0\u20ac","currency":"EUR"},"last_orig":{"value":"77.79000","value_int":"7779000","display":"$77.79000","display_short":"$77.79","currency":"USD"},"last_all":{"value":"59.25051","value_int":"5925051","display":"59.25051\u00a0\u20ac","display_short":"59.25\u00a0\u20ac","currency":"EUR"},"buy":{"value":"60.22337","value_int":"6022337","display":"60.22337\u00a0\u20ac","display_short":"60.22\u00a0\u20ac","currency":"EUR"},"sell":{"value":"60.73178","value_int":"6073178","display":"60.73178\u00a0\u20ac","display_short":"60.73\u00a0\u20ac","currency":"EUR"},"now":"1366188333851800"}}

 





Bitmessage : BM-NAx31aEiqeq5zKUtxhKscXQ7Dwn1jJfR
advanced
Sr. Member
****
Offline Offline

Activity: 263


Woodwallets.io


View Profile WWW
April 17, 2013, 08:30:44 AM
 #70

I have another question: in the ticker, what is the difference between last, last_all, last_local?

Bitmessage : BM-NAx31aEiqeq5zKUtxhKscXQ7Dwn1jJfR
MikeH
Sr. Member
****
Offline Offline

Activity: 406


View Profile
April 17, 2013, 01:55:50 PM
 #71

it's documented somewhere - last_all is last sale price in any currency converted to your specified currency, not sure difference between other 2 - not looking at documentation now Smiley


I have a question too - anyone know when buying through the api whether you're able to issue a buy at say 10 bitcoins at a specified price even if you only have funds for 5 ?

Just wondering if it will just buy the 5 - otherwise you have to do the calculations work out how many bitcoins you can buy.

--

edit: never mind, I tested it and you don't need to specify exact # of bitcoins to clean out your $ balance.
||bit
Hero Member
*****
Offline Offline

Activity: 644


View Profile
April 17, 2013, 02:34:52 PM
 #72

I'm interested in an automated trading platform myself. Glad you did some compiling for the API at least.

I had a fairly strict trailing stop strategy, and was using it in the recent climb. However, because there is no way to enter dynamic stops & sleep is a requirement - for normal humans - I found myself waking up to the recent crash. Tongue

Anyway, maybe some automatic trading software could have helped. I didn't think there was a DDOS according to the MtGox report. Evenso, I think the stop would have been placed & executed before the peak velocity of the crash.

Anyone know of any available automated trading applications out there yet?
nitrous
Sr. Member
****
Offline Offline

Activity: 246


View Profile
April 17, 2013, 02:52:48 PM
 #73

I have another question: in the ticker, what is the difference between last, last_all, last_local?

From what I can tell:
 - last and last_local are the same, and give the last trade of the selected currency
 - last_orig is the most recent trade of ALL currencies (so could be USD, GBP, EUR, anything...)
 - last_all is the same as last_orig, but it has been converted to the selected currency

As for ticker_fast, I imagine it was quickly put together so may have bugs in it. I just tested it now for BTCEUR and BTCUSD, however, and they both seemed to work and returned the same JSON properties, can you tell me what part seems not to work for EUR for you? Were you confused by last_orig being in USD?

Donations: 1Q2EN7TzJ6z82xvmQrRoQoMf3Tf4rMCyvL
MtGox API v2 Unofficial Documentation: https://bitbucket.org/nitrous/mtgox-api/overview
MtGox API v2 Unofficial Documentation Forum Thread: https://bitcointalk.org/index.php?topic=164404.0
nitrous
Sr. Member
****
Offline Offline

Activity: 246


View Profile
April 17, 2013, 02:54:57 PM
 #74

it's documented somewhere - last_all is last sale price in any currency converted to your specified currency, not sure difference between other 2 - not looking at documentation now Smiley


I have a question too - anyone know when buying through the api whether you're able to issue a buy at say 10 bitcoins at a specified price even if you only have funds for 5 ?

Just wondering if it will just buy the 5 - otherwise you have to do the calculations work out how many bitcoins you can buy.

--

edit: never mind, I tested it and you don't need to specify exact # of bitcoins to clean out your $ balance.


Don't rely on being able to buy however many btc you want even if unfunded, MtGox claims this is the source of a lot of lag and they are transitioning their engine to deny such requests.

Can you clarify what happened in your test? i.e: what you asked the api to do (how many and for how much), and what happened, and whether you still had an incomplete order pending afterwards or not?

Donations: 1Q2EN7TzJ6z82xvmQrRoQoMf3Tf4rMCyvL
MtGox API v2 Unofficial Documentation: https://bitbucket.org/nitrous/mtgox-api/overview
MtGox API v2 Unofficial Documentation Forum Thread: https://bitcointalk.org/index.php?topic=164404.0
nitrous
Sr. Member
****
Offline Offline

Activity: 246


View Profile
April 17, 2013, 03:06:12 PM
 #75

I'm interested in an automated trading platform myself. Glad you did some compiling for the API at least.

I had a fairly strict trailing stop strategy, and was using it in the recent climb. However, because there is no way to enter dynamic stops & sleep is a requirement - for normal humans - I found myself waking up to the recent crash. Tongue

Anyway, maybe some automatic trading software could have helped. I didn't think there was a DDOS according to the MtGox report. Evenso, I think the stop would have been placed & executed before the peak velocity of the crash.

Anyone know of any available automated trading applications out there yet?

I'm sorry to hear that, that's really unlucky especially with your strategy! Did you lose a lot?

I have heard sporadic reports of user-friendly automated trading platforms for MtGox, but I'm not sure how much you can trust these. Look out for a MetaTrader extension, as MT is the norm for trading fiat forex currencies, and I think is quite easy to use. It's tailored for monitoring and auto trading, but I don't think there's any MtGox extension yet (or any other exchanges, for that matter). I was thinking of releasing a graphical client whilst I work on my own high frequency trader, but I don't currently have the time to do any major development (not for a couple months at least).

Do you know any programming languages? If not, maybe you could take this opportunity to learn one - you would then have full control over how it works (although you'd also be responsible for any money lost due to program failures Tongue).

Donations: 1Q2EN7TzJ6z82xvmQrRoQoMf3Tf4rMCyvL
MtGox API v2 Unofficial Documentation: https://bitbucket.org/nitrous/mtgox-api/overview
MtGox API v2 Unofficial Documentation Forum Thread: https://bitcointalk.org/index.php?topic=164404.0
MikeH
Sr. Member
****
Offline Offline

Activity: 406


View Profile
April 17, 2013, 03:15:39 PM
 #76

I put in an order of 10 btc at $90 even though I only had funds for 5.. the order completed and I don't think I had any orders outstanding - don't now anyway.

I'm guessing it just checked my balance and adjusted # of btc before placing the order.
nitrous
Sr. Member
****
Offline Offline

Activity: 246


View Profile
April 17, 2013, 03:55:55 PM
 #77

I put in an order of 10 btc at $90 even though I only had funds for 5.. the order completed and I don't think I had any orders outstanding - don't now anyway.

I'm guessing it just checked my balance and adjusted # of btc before placing the order.


That sounds likely, I guess it would confuse a lot of people if they just denied all orders over the current balance.

Donations: 1Q2EN7TzJ6z82xvmQrRoQoMf3Tf4rMCyvL
MtGox API v2 Unofficial Documentation: https://bitbucket.org/nitrous/mtgox-api/overview
MtGox API v2 Unofficial Documentation Forum Thread: https://bitcointalk.org/index.php?topic=164404.0
advanced
Sr. Member
****
Offline Offline

Activity: 263


Woodwallets.io


View Profile WWW
April 17, 2013, 05:29:07 PM
 #78

Nitrous, my fault. The fast ticker seem to work with EUR too. I got confused with last_all in the crowded debug console Wink

OT:

I'm actually building a simple trading bot myself if anybody is interested in participating to the beta test, PM me!  I already collected 15 volunteers + myself. Of course you should trust it with your life, but this bot here runs locally on your machine. you can see the code yourself and the API keys are stored locally on your machine Wink

Here you can see an example of the readme :> http://www.lize.it/up/prototype-botcoin/

This was how the node version looked like  it saved me from big price drops), now I'm doing it better with java.

If any suggestion , please add Grin

Bitmessage : BM-NAx31aEiqeq5zKUtxhKscXQ7Dwn1jJfR
nitrous
Sr. Member
****
Offline Offline

Activity: 246


View Profile
April 17, 2013, 08:47:09 PM
 #79

Nitrous, my fault. The fast ticker seem to work with EUR too. I got confused with last_all in the crowded debug console Wink

OT:

I'm actually building a simple trading bot myself if anybody is interested in participating to the beta test, PM me!  I already collected 15 volunteers + myself. Of course you should trust it with your life, but this bot here runs locally on your machine. you can see the code yourself and the API keys are stored locally on your machine Wink

Here you can see an example of the readme :> http://www.lize.it/up/prototype-botcoin/

This was how the node version looked like  it saved me from big price drops), now I'm doing it better with java.

If any suggestion , please add Grin

Have you got the JSON decoded yet? You could make debugging easier by pretty-printing it Smiley I've updated the documentation with my findings for the new method so hopefully that will be helpful - although I still haven't been able to test the differences during a high lag period.

That sounds interesting Smiley Does it generate the trading strategy automatically or is it user-programmable? I haven't been able to dedicate any large amounts of time to tradebot development but I was planning to incorporate some forex technical indicators, have a look at http://en.wikipedia.org/wiki/MACD for example. It seems fairly accurate (although there is a bit of lag), moreso than simple limit orders. I think bitcoin needs a trading platform to monitor forex technical indicators in order to make more informed trading decisions, especially with the high volatility, you could make a really powerful tool here Cheesy

Donations: 1Q2EN7TzJ6z82xvmQrRoQoMf3Tf4rMCyvL
MtGox API v2 Unofficial Documentation: https://bitbucket.org/nitrous/mtgox-api/overview
MtGox API v2 Unofficial Documentation Forum Thread: https://bitcointalk.org/index.php?topic=164404.0
advanced
Sr. Member
****
Offline Offline

Activity: 263


Woodwallets.io


View Profile WWW
April 18, 2013, 06:55:03 AM
 #80

Nitrous, my fault. The fast ticker seem to work with EUR too. I got confused with last_all in the crowded debug console Wink

OT:

I'm actually building a simple trading bot myself if anybody is interested in participating to the beta test, PM me!  I already collected 15 volunteers + myself. Of course you should trust it with your life, but this bot here runs locally on your machine. you can see the code yourself and the API keys are stored locally on your machine Wink

Here you can see an example of the readme :> http://www.lize.it/up/prototype-botcoin/

This was how the node version looked like  it saved me from big price drops), now I'm doing it better with java.

If any suggestion , please add Grin

Have you got the JSON decoded yet? You could make debugging easier by pretty-printing it Smiley I've updated the documentation with my findings for the new method so hopefully that will be helpful - although I still haven't been able to test the differences during a high lag period.

That sounds interesting Smiley Does it generate the trading strategy automatically or is it user-programmable? I haven't been able to dedicate any large amounts of time to tradebot development but I was planning to incorporate some forex technical indicators, have a look at http://en.wikipedia.org/wiki/MACD for example. It seems fairly accurate (although there is a bit of lag), moreso than simple limit orders. I think bitcoin needs a trading platform to monitor forex technical indicators in order to make more informed trading decisions, especially with the high volatility, you could make a really powerful tool here Cheesy

Yes I decoded the JSON and prettified it Wink



The strategy is totally up to the user, I'm not a trading expert my self and I just want to provide a powerful tools to the people. The strategy(.csv) could then be shared among users and exchanged according to domain experties, forex indicators, and others.

I'm myself a follower of the mailing list on bitcoinbullbear.com  and I take decisions accordingly, but I'm not a speculator crazy trader Wink

thanks for the feedback!

Bitmessage : BM-NAx31aEiqeq5zKUtxhKscXQ7Dwn1jJfR
Pages: « 1 2 3 [4] 5 6 7 8 9 10 11 »  All
  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!