Pages:
Author

Topic: [BETA] MTGox websocket API, testers wanted (Read 77681 times)

hero member
Activity: 938
Merit: 500
https://youengine.io/
February 18, 2014, 11:44:34 AM
i doubt it, btw thx
Doubt what? Just have look at the json that is sent by gox and see for yourself what it contains!
hero member
Activity: 938
Merit: 500
https://youengine.io/
Any suggestions ?
Use the integer values for everything, they are contained in every json object that carries any numbers. For BTC (order volume) they represent integer number of satoshi, for fiat currency (quote prices) they represent either 1e-5 or 1e-3 units of the quote currency (depends on what currency it is, USD and most others is 1e-5, JPY and SEK its 1e-3).
sr. member
Activity: 471
Merit: 262
I subscribed to the market depth channel via the websocket and I'm parsing the data with Json.net (c#), but there is a problem when I receive a volume in scientific notation.

The volume is treated as string whenever it is in scientific notation and this leads to problems with parsing.

Code:
"volume":"1.0E-8"

In this case Json.Net is unable to parse the string to decimal by default.

To get around this, I currently use this construct:

Code:
        public decimal Volume
        {
            get { return _volume; }
            set { _volume = value; }
        }

        [JsonProperty("volume", Required = Required.Always)]
        public String VolumeString
        {
            get { return Volume.ToString(CultureInfo.InvariantCulture); }
            set { Volume = Decimal.Parse(value, NumberStyles.Any, CultureInfo.InvariantCulture); }
        }

Any suggestions ?
member
Activity: 102
Merit: 10
This is what I do (python code) and it works (doesn't seem to have ever changed, I never had to change my code):

Code:
self.client.send(json.dumps({"op":"mtgox.subscribe", "key":result}))

result contains the idkey exactly as it resulted from the idkey request. The above code is from goxapi.py around line 1497 in the on_op_result() method.

Is it anyhow possible to add a module which would collect info and construct historical database of orderbook and trades?

hero member
Activity: 938
Merit: 500
https://youengine.io/
December 27, 2013, 03:35:33 PM
Is the gox websocket crap? Or is the problem with the Xchange implementation or the websocket java lib?
Any idea suggestion or wisdom is welcomed.

MtGox websocket is excellent, 99.9% uptime and <200ms delay. Try goxtool (see my sig) for a proper implementation and reference.
full member
Activity: 129
Merit: 100
December 27, 2013, 02:44:11 PM
Hi websocket uber pros,

I have been testing GOX websocket stream using Xchange java framework.

There are horrible data gaps(sometimes 90% of quotes missed) and lags all the time, both the book and the ticker.

Is the gox websocket crap? Or is the problem with the Xchange implementation or the websocket java lib?
Any idea suggestion or wisdom is welcomed.

thx
f
member
Activity: 80
Merit: 11
In case any developer is following this thread I added a suggestion about the websocket API here:

https://bitcointalksearch.org/topic/mtgox-websocket-api-suggestion-319546
member
Activity: 80
Merit: 11
All is good now, you were right, the private channel server must have been down.

I am continuing to experience the same problem.

Steps I am doing:

1. Grab the idkey from either /1/generic/private/idkey or /2/money/idkey.
2. Over WebSocket, send {"op":"mtgox.subscribe","key":"idkey_as_from_API_call"}
3. Get response over WebSocket socket: {"message":"Invalid key provided","op":"remark","success":false}

@alikim You say it works for you. Can you verify the message you are sending over the WebSocket to subscribe to the private channel.


This is what I do over the websocket, the first message is a signed encrypted one:

{"call":"idkey","id":"2a4b88398c872f7150ea4f3a6f.....","nonce":13828......}

The response:

{"id":"2a4b88398c872f7150ea4f.....","op":"result","result":"GhXJXwx......."}

Subscribe command, goes out as plain text:

{"op":"mtgox.subscribe","key":"GhXJXwx......."}

After that I don't receive anything, but the private channel - when /if it's up - will send it's proper messages, for example when you place an order.

I believe if the channel is not working it just won't send you messages but you can still get silently subscribed.

Maybe it's working over the websocket but not working over http API?

Programming and maintenance of various gox servers and services is very sloppy to say the least, these people don't seem to care much...


P.S. On second thought, do you grab the key from http API and then try to use it in websocket API?
Maybe all three steps you've mentioned should go through the websocket, including step one (not using  /1/generic/private/idkey or /2/money/idkey); the websocket will accept the key issued only through the websocket message?
hero member
Activity: 938
Merit: 500
https://youengine.io/
This is what I do (python code) and it works (doesn't seem to have ever changed, I never had to change my code):

Code:
self.client.send(json.dumps({"op":"mtgox.subscribe", "key":result}))

result contains the idkey exactly as it resulted from the idkey request. The above code is from goxapi.py around line 1497 in the on_op_result() method.
hero member
Activity: 548
Merit: 502
So much code.
All is good now, you were right, the private channel server must have been down.

I am continuing to experience the same problem.

Steps I am doing:

1. Grab the idkey from either /1/generic/private/idkey or /2/money/idkey.
2. Over WebSocket, send {"op":"mtgox.subscribe","key":"idkey_as_from_API_call"}
3. Get response over WebSocket socket: {"message":"Invalid key provided","op":"remark","success":false}

@alikim You say it works for you. Can you verify the message you are sending over the WebSocket to subscribe to the private channel.
member
Activity: 80
Merit: 11
Yes, if I artificially add another symbol at the end of the key in subscribe call, I get that message that the key is not valid.

If I subscribe with the key as it is, I get no message, no error neither success.

Do I understand it right that you do not sign the subscribe message?

Interesting. I am sending the key as-is and getting an 'invalid key' message.

I am not signing the message, simply sending under mtgox.subscribe.

All is good now, you were right, the private channel server must have been down.
hero member
Activity: 548
Merit: 502
So much code.
Yes, if I artificially add another symbol at the end of the key in subscribe call, I get that message that the key is not valid.

If I subscribe with the key as it is, I get no message, no error neither success.

Do I understand it right that you do not sign the subscribe message?

Interesting. I am sending the key as-is and getting an 'invalid key' message.

I am not signing the message, simply sending under mtgox.subscribe.
member
Activity: 80
Merit: 11
Then subscribe:

{"op":"mtgox.subscribe","key":"GhXJXwx..."}

... and I don't get any response to the subscribe message and after sending orders or their execution I don't get any messages in the private "own" channel.

What am I doing wrong?

Thank you!

Mt. Gox has been sending a message that my key is not valid. Are you seeing a "remark" message coming in after you attempt to subscribe?

My guess: Either the API has changed, or the private-channel server is down.

Yes, if I artificially add another symbol at the end of the key in subscribe call, I get that message that the key is not valid.

If I subscribe with the key as it is, I get no message, no error neither success.

Do I understand it right that you do not sign the subscribe message?
hero member
Activity: 548
Merit: 502
So much code.
Then subscribe:

{"op":"mtgox.subscribe","key":"GhXJXwx..."}

... and I don't get any response to the subscribe message and after sending orders or their execution I don't get any messages in the private "own" channel.

What am I doing wrong?

Thank you!

Mt. Gox has been sending a message that my key is not valid. Are you seeing a "remark" message coming in after you attempt to subscribe?

My guess: Either the API has changed, or the private-channel server is down.
member
Activity: 80
Merit: 11
Does anyone know how to subscribe to "own" private channel?

I start with this message:

{"call":"idkey","id":".....","nonce":...}

Successfully get the key:

{"id":"....","op":"result","result":"GhXJXwx..."}

Then subscribe:

{"op":"mtgox.subscribe","key":"GhXJXwx..."}

... and I don't get any response to the subscribe message and after sending orders or their execution I don't get any messages in the private "own" channel.

What am I doing wrong?

Thank you!
newbie
Activity: 5
Merit: 0
September 20, 2013, 05:26:21 PM
I was using modified C# http://socketio4net.codeplex.com/ library to consume depths updates from https://socketio.mtgox.com/mtgox. It was working fine till the biggining of this month. Now it may work for several hours, then just drop and stop accepting connections (Error: The connection was closed unexpectedly.).

So I tried to switch to https://github.com/sta/websocket-sharp and connect to wss://websocket.mtgox.com/mtgox. The library seems to be recommended on https://en.bitcoin.it/wiki/MtGox/API/Streaming. First I spent several hours before I found I need to specify Origin. Now it works fine expect that server sends close frame every 5-60 seconds.

Any idea what could be the reason? Thanks.
Code:
01:49:02.874|DEBUG|26 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"132.13605","type":2,"type_str":"bid","volume":"-0.10083051","price_int":"13213605","volume_int":"-10083051","item":"BTC","currency":"USD","now":"1379713750305094","total_volume_int":"0"}}
01:49:02.960|DEBUG|31 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"123.90414","type":2,"type_str":"bid","volume":"0.60778582","price_int":"12390414","volume_int":"60778582","item":"BTC","currency":"USD","now":"1379713750414105","total_volume_int":"60778582"}}
01:49:04.186|DEBUG|31 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"139.39536","type":1,"type_str":"ask","volume":"1.103871","price_int":"13939536","volume_int":"110387100","item":"BTC","currency":"USD","now":"1379713751538095","total_volume_int":"110387100"}}
01:49:07.415|DEBUG|8  |MtGoxApi: Close Event raised
01:49:08.622|DEBUG|31 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"135.986","type":1,"type_str":"ask","volume":"5.196","price_int":"13598600","volume_int":"519600000","item":"BTC","currency":"USD","now":"1379713756075743","total_volume_int":"519600000"}}
01:49:08.661|DEBUG|30 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"133.85221","type":2,"type_str":"bid","volume":"-3.855","price_int":"13385221","volume_int":"-385500000","item":"BTC","currency":"USD","now":"1379713756090538","total_volume_int":"0"}}
01:49:08.676|DEBUG|31 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"134.00225","type":2,"type_str":"bid","volume":"-10.8","price_int":"13400225","volume_int":"-1080000000","item":"BTC","currency":"USD","now":"1379713756105880","total_volume_int":"540000000"}}
01:49:09.511|DEBUG|30 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"134.00225","type":2,"type_str":"bid","volume":"-5.4","price_int":"13400225","volume_int":"-540000000","item":"BTC","currency":"USD","now":"1379713756934842","total_volume_int":"0"}}
01:49:09.571|DEBUG|31 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"131.41101","type":2,"type_str":"bid","volume":"-5.4","price_int":"13141101","volume_int":"-540000000","item":"BTC","currency":"USD","now":"1379713756950113","total_volume_int":"1080000000"}}
01:49:09.607|DEBUG|30 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"133.27742","type":2,"type_str":"bid","volume":"5.4","price_int":"13327742","volume_int":"540000000","item":"BTC","currency":"USD","now":"1379713757041934","total_volume_int":"1620000000"}}
01:49:13.229|DEBUG|8  |MtGoxApi: Close Event raised
01:49:14.963|DEBUG|30 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"129.6864","type":2,"type_str":"bid","volume":"0.25","price_int":"12968640","volume_int":"25000000","item":"BTC","currency":"USD","now":"1379713762412059","total_volume_int":"125000000"}}
01:49:15.040|DEBUG|31 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"134.00226","type":2,"type_str":"bid","volume":"-10.34395506","price_int":"13400226","volume_int":"-1034395506","item":"BTC","currency":"USD","now":"1379713762427277","total_volume_int":"0"}}
01:49:15.101|DEBUG|30 |MtGoxApi: {"channel":"24e67e0d-1cad-4cc0-9e7a-f8523ef460fe","channel_name":"depth.BTCUSD","op":"private","origin":"broadcast","private":"depth","depth":{"price":"134.00228","type":2,"type_str":"bid","volume":"10.34331649","price_int":"13400228","volume_int":"1034331649","item":"BTC","currency":"USD","now":"1379713762550896","total_volume_int":"1034331649"}}
hero member
Activity: 548
Merit: 502
So much code.
September 14, 2013, 11:10:08 AM
WebSocket + JSON == WASTED_BANDWIDTH

I plan to investigate the option of using WebSocket + BJSON to prevent bandwidth wasting in ICBIT. We are fine as it is so far, but it's always good to plan for future.

Have you had a look at MessagePack? http://msgpack.org/
hero member
Activity: 674
Merit: 500
September 14, 2013, 10:14:56 AM
WebSocket + JSON == WASTED_BANDWIDTH

I plan to investigate the option of using WebSocket + BJSON to prevent bandwidth wasting in ICBIT. We are fine as it is so far, but it's always good to plan for future.
full member
Activity: 217
Merit: 100
September 13, 2013, 07:36:04 PM
OK, I got websocket working in my client again.

I'm implementing the websocket protocol myself in C++ on a raw socket so this is probably not relevant to those using javascript in browsers.

It turns out that the MtGox websocket now requires properly framed messages as per RFC6455.

A while ago only the Socket.IO required the RFC6455 framing.

Before I was getting away with just this minimal framing for websocket: [0x00] ....RAW STRING DATA... [0xFF]

Now you need the RFC6455 framing function, I posted C code earlier in this thread.

Now I need to get my socket.io implementation working also Tongue

WebSocket + JSON == WASTED_BANDWIDTH

full member
Activity: 217
Merit: 100
September 13, 2013, 04:08:52 PM
wait a second, now you have to subscribe on your own?
They really changed the default behavior when on connect you were subscribed automatically?

Yes, it changed for websocket some time ago, or maybe websocket has always been like that I don't know.

And I just noticed that socket.io now also serves a dead stream to start with, you need to subscribe (i think/hope).

For socket.io I was passing all needed currencies as args in initial GET, that doesn't work now.
Pages:
Jump to: