Skip to content

Commit

Permalink
OTCWebsite: use new mtgox ticker api.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Folkinshteyn committed Mar 24, 2013
1 parent 7653ce0 commit f11d141
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions OTCWebsite/createticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def _queryGoogleRate(self, cur1, cur2):
def _getIndexedValue(self, rawprice, inverse=False):
try:
if self.ticker is not None:
indexedprice = re.sub(r'{mtgoxask}', self.ticker['sell'], rawprice)
indexedprice = re.sub(r'{mtgoxbid}', self.ticker['buy'], indexedprice)
indexedprice = re.sub(r'{mtgoxlast}', self.ticker['last'], indexedprice)
indexedprice = re.sub(r'{mtgoxask}', self.ticker['sell']['value'], rawprice)
indexedprice = re.sub(r'{mtgoxbid}', self.ticker['buy']['value'], indexedprice)
indexedprice = re.sub(r'{mtgoxlast}', self.ticker['last']['value'], indexedprice)
else:
indexedprice = rawprice
indexedprice = self._getCurrencyConversion(indexedprice)
Expand Down Expand Up @@ -127,9 +127,9 @@ def run(self):
self.write_json()

def get_mtgox_quote(self):
mtgox_ticker = urllib2.urlopen('https://mtgox.com/code/ticker.php').read()
mtgox_ticker = urllib2.urlopen('https://data.mtgox.com/api/2/BTCUSD/money/ticker').read()
self.mtgox_ticker = json.loads(mtgox_ticker, parse_float=str, parse_int=str)
self.mtgox_ticker = self.mtgox_ticker['ticker']
self.mtgox_ticker = self.mtgox_ticker['data']

def create_quotes(self):
cursor = self.db1.cursor()
Expand Down
10 changes: 5 additions & 5 deletions OTCWebsite/somefunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

try {
$f = fopen("mtgox.json", "r");
$ticker = fread($f, 1024);
$ticker = fread($f, 2048);
fclose($f);
$ticker = json_decode($ticker, true);
$ticker = $ticker['ticker'];
$ticker = $ticker['data'];
$f = fopen("exchangerates.json", "r");
$rates = fread($f, 4096);
fclose($f);
Expand Down Expand Up @@ -49,9 +49,9 @@ function doNothing() { return(true); }
function index_prices($rawprice){
global $ticker;
try {
$indexedprice = preg_replace("/{mtgoxask}/", $ticker['sell'], $rawprice);
$indexedprice = preg_replace("/{mtgoxbid}/", $ticker['buy'], $indexedprice);
$indexedprice = preg_replace("/{mtgoxlast}/", $ticker['last'], $indexedprice);
$indexedprice = preg_replace("/{mtgoxask}/", $ticker['sell']['value'], $rawprice);
$indexedprice = preg_replace("/{mtgoxbid}/", $ticker['buy']['value'], $indexedprice);
$indexedprice = preg_replace("/{mtgoxlast}/", $ticker['last']['value'], $indexedprice);
$indexedprice = get_currency_conversion($indexedprice);
$code = 'set_error_handler("doNothing");return(' . $indexedprice . ');restore_error_handler();';
ob_start();
Expand Down

0 comments on commit f11d141

Please sign in to comment.