Bitcoin Forum

Economy => Services => Topic started by: podizzle on March 29, 2013, 02:35:07 PM



Title: [REQUEST] Alarm for Mt gox Lag
Post by: podizzle on March 29, 2013, 02:35:07 PM
can anyone take the api information for lag and set up an alarm to go off if it gets above a certain time? This doesnt seem too difficult but i will offer a .1btc bounty


Title: Re: [REQUEST] Alarm for Mt gox Lag
Post by: J.P. Larocque on March 30, 2013, 04:21:45 AM
I'll take that on, it sounds pretty straightforward.  I'm sending you a private message to discuss details.


Title: Re: [REQUEST] Alarm for Mt gox Lag
Post by: mrlithium on March 30, 2013, 10:06:42 AM
#!/usr/bin/env python
#Alarm lag#
# Created 3/30/2013

import urllib2
import json
import winsound         #plays beeps for alerts
import time

from decimal import Decimal as D    #renamed to D for simplicity.

url = "https://data.mtgox.com/api/1/generic/order/lag"
req = urllib2.Request(url)

threshhold = raw_input("Lag Alarm Threshhold? (in seconds):  ")
threshhold = int(threshhold)
delaytime = raw_input("How often do you want to check? (in seconds):  ")
delaytime = int(delaytime)
while True:                                 #infinite loop
    resp = urllib2.urlopen(req)
    data = json.load(resp)

    lag = D(str(data["return"]["lag_secs"]))

    if lag >= D(threshhold):
        while True:
            for x in range(2,25):           # create a sequence of beeps
                winsound.Beep(x*100,100)    # each beep is at x*100hz for 100ms
            time.sleep(5)                   # repeat the alarm every 5 seconds
    print "The lag was normal. %s seconds" % lag
    time.sleep(delaytime)                   # pause for however long specified


Just download python 2.7.3, save the above script and run the script from the windows command prompt. (ie: python mtgox_alarm.py)


Title: Re: [REQUEST] Alarm for Mt gox Lag
Post by: podizzle on March 30, 2013, 04:32:41 PM
thanks a lot mrlithium post your address and ill hook you up. jp i hope you'll keep your offer on the table because i still may be interested since you are offering additional functionality.


Title: Re: [REQUEST] Alarm for Mt gox Lag
Post by: mrlithium on March 30, 2013, 10:44:21 PM
1A1dhB53bFh2n11VJG8kt6SawY5b7Biuzb

Thanks


Title: Re: [REQUEST] Alarm for Mt gox Lag
Post by: podizzle on March 31, 2013, 08:09:56 PM
got u