Author

Topic: MtGox with python (Read 2448 times)

member
Activity: 98
Merit: 10
April 18, 2013, 10:43:12 AM
#7
Anyone who wants to contribute shoot me a PM. This will be private as of now. There is ample opportunity to contribute. I will give intros how to get things running to people who give back.
member
Activity: 98
Merit: 10
April 16, 2013, 04:41:55 PM
#6
Datastorage: good idea. Anyone in, for a team effort collecting data? Somebody even postet market depth (300MB). Haven't checked it. Links welcome, I will have a look at it and write some sanity checks. If somebody tells me how I can store 1-2 GB anonymously.

Goxtools uses websockets and socketIO and is well coded.

hero member
Activity: 630
Merit: 500
April 16, 2013, 01:33:07 PM
#5
Have you seen this?  https://github.com/ahihi/goxsh
I've been using an older version of it forever.  Decided to use it as my baseline to create a similar app for BTC-E trading.
member
Activity: 78
Merit: 10
April 16, 2013, 11:41:08 AM
#4
The HTTP API is a lot easier to use, but is there any advantage over the streaming API ? Initially it might be a little harder to create a proper streaming API (there is at least one you listed there, but it doesn't fully use the messages and discard some data that might be relevant; I also have one running here, but it is not public at this point), but to me it looks like to be a much better choice since you will be getting results as soon as they are available, basicly. With the HTTP API you need a pooling loop that might do nothing a lot of times, with the streaming API you have an infinite loop that blocks as long as there is no new information.

Now, are you aware if all the current bitcoin exchanges provide an API ? It would be great to collect data from all the different exchanges.
member
Activity: 98
Merit: 10
April 16, 2013, 04:24:52 AM
#3
printing the balance

Quote
m = MTGox(GOX_key,GOX_secret)      
r = m.query("")
d = json.loads(r)

btcbalance = float(d['return']['Wallets']['BTC']['Balance']['value'])
usdbalance = float(d['return']['Wallets']['USD']['Balance']['value'])

print 'Balance %6.2f BTC   %6.2f USD'%(btcbalance,usdbalance)
member
Activity: 98
Merit: 10
April 16, 2013, 04:12:17 AM
#2
Working python2.7, API v1

Quote
GOX_secret = '==================================================='
GOX_key = '==============='

from hashlib import sha512
from hmac import HMAC
from base64 import b64decode, b64encode
from urllib import urlencode

from time import time

import requests

url = "https://data.mtgox.com/api/1/generic/info"

class MTGox:
   def __init__(self, key, secret):
      self.key = key
      self.secret = b64decode(secret)
      #self.base = base

   def query(self, path, args={}):
      args['nonce'] = int(time()*100000)
      sign = b64encode(str(HMAC(self.secret, urlencode(args), sha512).digest()))
      print sign

      headers = {
         'User-Agent': 'BitcoinTalk',
         'Rest-Key': self.key,
         'Rest-Sign': sign
      }
      #url = self.base + path
      print url
      r = requests.post(url, data=args, headers=headers)
      print r.text

m = MTGox(GOX_key,GOX_secret)      
m.query("")
member
Activity: 98
Merit: 10
April 16, 2013, 03:30:08 AM
#1
I'm going to a create trading app in python. Might opensource later. I've got connections to all exchanges and will create an abstraction layer, adding some GUI fancies, storage in database, strategy layer etc. Anyone in? Then PM me.

Here is a collection of code bases and snippets.

https://bitbucket.org/nitrous/mtgox-api/overview
http://pastebin.com/aXQfULyq
https://github.com/maxme/bitcoin-arbitrage
https://github.com/viorels/mtgox-trader
https://github.com/prof7bit/goxtool (Websockets and SocketIO)

https://github.com/ezl/mtgox (2years old)
https://github.com/goncalopp/python-mtgox (API v0)
Jump to: