Ejemplo n.º 1
0
    def getPrice(self):
        data = req.get_res('1/BTCUSD/public/ticker', {})
        buyPrice = data['return']['buy']['value_int']
        sellPrice = data['return']['sell']['value_int']
        volume = data['return']['vol']['value_int']
        price = {
            'buy':Decimal(int(buyPrice) * .00001).quantize(Decimal('1.00000')),
            'sell':Decimal(int(sellPrice) * .00001).quantize(Decimal('1.00000')),
            'volume':Decimal(int(volume) * .00000001).quantize(Decimal('1.00000')),
            'my_btc':Decimal(int(self.BTC) * .00000001).quantize(Decimal('1.00000000')),
            'my_usd':Decimal(int(self.USD) * .00001).quantize(Decimal('1.00000'))
            }

        db.db.priceindex.insert({'buy':str(price['buy']),
                                 'sell':str(price['sell']),
                                 'volume':str(price['volume']),
                                 'exchange':'mtgox',
                                 'holdings':
                                     {'btc':str(price['my_btc']),
                                      'usd':str(price['my_usd'])
                                      }
                                 })
        return price
Ejemplo n.º 2
0
 def __init__(self):
     self.info = req.get_res('0/info.php', {})
     self.USD = self.info['Wallets']['USD']['Balance']['value_int']
     self.BTC = self.info['Wallets']['BTC']['Balance']['value_int']
     pass
Ejemplo n.º 3
0
 def __init__ (self, amount):
   info = req.get_res('0/info.php', {})
   self.tradefee = info['Trade_Fee'] * .01
   self.tmp = amount
Ejemplo n.º 4
0
 def __init__(self):
   print 'Initialized...'
   self.info = req.get_res('0/info.php', {})
   self.priceInfo = req.get_res('1/BTCUSD/public/ticker', {})
Ejemplo n.º 5
0
#!/usr/bin/python
'''
This is used to download the mtgox price data every 10 seconds. This implementation
will save the data to a mongodb instance.  The mongodb instance information is stored
in dbConnection.  The connection used in this iteration does not use a user:pass
combo and is pretty insecure as is
'''

import getMtGoxRequest as req
import dbConnection as data
import time

##Testing getting the data from mtgox
x = 1
err = 0
while x > 0:
  try:
    info = req.get_res('1/BTCUSD/public/ticker', {})
    data.db.tradedata.save({'buy':info['return']['buy']['value_int'], 'sell':info['return']['sell']['value_int'], 'volume':info['return']['vol']['value_int']})
    print 'Added!', 'Sleeping...', 'Count at:', '\033[1;32m' + str(x) + '\033[1;m', 'Errors:', '\033[1;31m' + str(err) + '\033[1;m'
    time.sleep(10)
    x+=1
  except:
    time.sleep(10)
    err += 1