Question

In this doc we have an info about webstream MtGox-API.

So the question. We have the next:

query = {
  "id":id,
  "call":apicall,
  "nonce":nonce,
  "currency":cry,
  "parameters":params,
  "item":item
}
output = serialize({
           "op":"call",
           "id":id,
           "call":self.encode_and_sign(serialize(query)),
           "context":"mtgox.com"
         })
ws.send(output)

this code is based on this example

I can't make an isomorphism between HTTP-API and Webstreaming API (of MtGox). Can you give a valid examples of {apicall,params,item}. For example for this queries:

https://mtgox.com/api/1/generic/info
https://mtgox.com/api/1/generic/orders
maybe some more complex... 
Était-ce utile?

La solution

Ok, I found answers:

we have the base:

query = {
  "id":id,
  "call":apicall,
  "nonce":nonce,
  "currency":cry,
  "parameters":params,
  "item":item
}

For the url =~ https://mtgox.com/api/1/generic/info => result Query will be the next:

info_query = {
  "id":"1",
  "call":"private/info",
  "nonce":["0.63745499","1364911980"]
}

res_query = {
  "op":"call",
  "id":"1",
  "call":f_sing_query(apikey,secretkey,info_query),
  "context":"mtgox.com"
}

where f_sign_query eq to this

if we replace "private/info" -> "private/orders" we will get our own orders.

Now, let us to fetch trades by date

fetch_query = {
  "id":"1",
  "call":"BTCUSD/trades/fetch",
  "nonce":["0.63745499","1364911980"],
  "params":{"since":"1363425799999469"}
}

result_query will be the same (!info_query <- fetch_query)

Now, moment for add_trade. Example: We want to sell 0.01 BTC for 1BTC-56.12345USD

add_query = {
  "id":"1",
  "call":"BTCUSD/order/add",
  "nonce":["0.63745499","1364911980"],
  "params":{"type":"ask","amount_int":str(100000000*0.01),"price_int":str(56.1234*100000)}
}

and so on...

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top