Supported Feathercoin client versions: Current production Version: 0.16.0.

Old Production Version: 0.13.2

Info: If you have problems to post, create one post in the ‘newbies’ category and try again. If you have further problems, find support under Guides or use the shoutbox

Simple real time FTC price ticker python script



  • Latest version now converts ftc price to usd/gbp/eur/aud/cad to whole value pennies (0.01), percent price diff now displays correct sign(i.e. up or down), and some timeout errors are handled. Note some server errors may still occur due to an inability to contact the host site for the prices - I am currently trying to work around these but I hope you enjoy this version 😃

    download:
    http://uploaded.net/file/durqk8pa

    copy & paste code:
    import json
    import urllib2
    from pprint import pprint
    import time
    from time import strftime
    import math
    import httplib
    #get initial prices and exchange rates & trading volume on script start
    initial_scan = json.load(urllib2.urlopen(“https://btc-e.com/api/2/ftc_btc/ticker”))
    initial_ftcprice = initial_scan[‘ticker’][‘last’]
    initial_btcusdscan = json.load(urllib2.urlopen(“https://btc-e.com/api/2/btc_usd/ticker”))
    initial_btcusd = initial_btcusdscan[‘ticker’][‘last’]
    initial_btceurscan = json.load(urllib2.urlopen(“https://btc-e.com/api/2/btc_eur/ticker”))
    initial_btceur = initial_btceurscan[‘ticker’][‘last’]
    initial_usdgbpscan = json.load(urllib2.urlopen(“http://rate-exchange.appspot.com/currency?from=USD&to=GBP&q=1”))
    initial_usdgbp = initial_usdgbpscan[“rate”]
    initial_usdaudscan = json.load(urllib2.urlopen(“http://rate-exchange.appspot.com/currency?from=USD&to=AUD&q=1”))
    initial_usdaud = initial_usdaudscan[“rate”]
    initial_usdcadscan = json.load(urllib2.urlopen(“http://rate-exchange.appspot.com/currency?from=USD&to=CAD&q=1”))
    initial_usdcad = initial_usdcadscan[“rate”]
    initial_volinftc = initial_scan[‘ticker’][‘vol_cur’]
    initial_volinbtc = initial_scan[‘ticker’][‘vol’]
    currenttime = strftime("%Y-%m-%d %H:%M:%S")
    #do currency conversions from ftc-btc & btc-usd prices
    initial_ftcusd = math.ceil(initial_ftcprice*initial_btcusd*100)/100
    initial_ftceur = math.ceil(initial_ftcprice*initial_btceur*100)/100
    initial_ftcgbp = math.ceil(initial_ftcprice*initial_btcusd*initial_usdgbp*100)/100
    initial_ftcaud = math.ceil(initial_ftcprice*initial_btcusd*initial_usdaud*100)/100
    initial_ftccad = math.ceil(initial_ftcprice*initial_btcusd*initial_usdcad*100)/100
    #print initial prices & trading volume
    print (str(initial_ftcprice) + " BTC")
    print (str(initial_ftcusd) + " USD")
    print (str(initial_ftceur) + " EUR")
    print (str(initial_ftcgbp) + " GBP")
    print (str(initial_ftcaud) + " AUD")
    print (str(initial_ftccad) + " CAD")
    print (“Trading Volume: " + str(initial_volinftc) + " FTC / " + str(initial_volinbtc) + " BTC”)
    print currenttime
    print ("==================================================")
    while True:
    #scan for prices & trading volume again
    try:
    data = json.load(urllib2.urlopen(“https://btc-e.com/api/2/ftc_btc/ticker”, timeout = 3))
    data2 = json.load(urllib2.urlopen(“https://btc-e.com/api/2/btc_usd/ticker”, timeout = 3))
    data3 = json.load(urllib2.urlopen(“https://btc-e.com/api/2/btc_eur/ticker”, timeout = 3))
    data4 = json.load(urllib2.urlopen(“http://rate-exchange.appspot.com/currency?from=USD&to=GBP&q=1”, timeout = 3))
    data5 = json.load(urllib2.urlopen(“http://rate-exchange.appspot.com/currency?from=USD&to=AUD&q=1”, timeout = 3))
    data6 = json.load(urllib2.urlopen(“http://rate-exchange.appspot.com/currency?from=USD&to=CAD&q=1”, timeout = 3))
    except (urllib2.HTTPError, urllib2.URLError, httplib.BadStatusLine, SSLError) as err:
    print (“Unable to load source for ticker!”)
    time.sleep(1)
    else:
    btcEUR = data3[‘ticker’][‘last’]
    btcUSD = data2[‘ticker’][‘last’]
    usdGBP = data4[“rate”]
    usdAUD = data5[“rate”]
    usdCAD = data6[“rate”]
    volFTC = data[‘ticker’][‘vol_cur’]
    volBTC = data[‘ticker’][‘vol’]
    #new prices
    ftcBTC = data[‘ticker’][‘last’]
    ftcUSD = math.ceil(ftcBTC*btcUSD*100)/100
    ftcEUR = math.ceil(ftcBTC*btcEUR*100)/100
    ftcGBP = math.ceil(ftcUSD*usdGBP*100)/100
    ftcAUD = math.ceil(ftcUSD*usdAUD*100)/100
    ftcCAD = math.ceil(ftcUSD*usdCAD*100)/100
    newtime = strftime("%Y-%m-%d %H:%M:%S")
    #percent change in price
    diff = initial_ftcprice - ftcBTC
    a = abs(diff)
    change = math.ceil(100*100*a/initial_ftcprice)/100
    #are the new prices different from the old ones?
    if ftcBTC != initial_ftcprice:
    print (str(ftcBTC) + " BTC")
    print (str(ftcUSD) + " USD")
    print (str(ftcEUR) + " EUR")
    print (str(ftcGBP) + " GBP")
    print (str(ftcAUD) + " AUD")
    print (str(ftcCAD) + " CAD")
    print(“Trading Volume: " + str(volFTC) + " FTC / " + str(volBTC) + " BTC”)
    if diff < 0:
    print(“Price Change: +” + str(change) + “%”)
    elif diff > 0:
    print(“Price Change: -” + str(change) + “%”)
    print newtime
    print("==================================================")
    initial_ftcprice = ftcBTC
    time.sleep(1)

    [attachment deleted by admin]



  • Excellent script, currently working with it and trying to figure out how to host on my project website.

    Thanks Again. Once all is working ill send a donation your way.



  • [quote name=“BatesResearch” post=“22561” timestamp=“1374451722”]
    Excellent script, currently working with it and trying to figure out how to host on my project website.

    Thanks Again. Once all is working ill send a donation your way.
    [/quote]
    I’m still working on the SSLError as I’m not handling it properly. Also I’ve noticed if you change the sleep times to at least 1 minute the servers the script calls are less likely to reject the communication - which results in the timeout errors



  • Any update on the SSLError.


  • Regular Member

    [quote name=“BatesResearch” post=“26975” timestamp=“1378067151”]
    Any update on the SSLError.
    [/quote]

    If you’re still interested: https://www.crypto-trade.com/api/1/ticker/ftc_usd



  • Thanks d2, but I’m looking for a system to show FTC/GBP.

    Sp495 has already created an amazing script which when cut down just shows FTC/GBP but I’m trying to work how to get it displayed on a website



  • [quote name=“BatesResearch” post=“27024” timestamp=“1378119815”]
    Thanks d2, but I’m looking for a system to show FTC/GBP.

    Sp495 has already created an amazing script which when cut down just shows FTC/GBP but I’m trying to work how to get it displayed on a website
    [/quote]

    To parse and display:
    [url=http://api.feathercoin.com?amount=1&output=json]api.feathercoin.com?amount=1&output=json[/url]

    To simply display:
    [url=http://api.feathercoin.com?amount=1&output=gbp]api.feathercoin.com?amount=1&output=gbp[/url]



  • WOW. Who made this or was I that blind that I totally missed it.

    That is exactly what am I looking for.

    With the name UKMark I guessed your based in the UK, if your ever near Manchester let me know Ill buy you a few drinks



  • [quote name=“BatesResearch” post=“27035” timestamp=“1378129467”]
    WOW. Who made this or was I that blind that I totally missed it.

    That is exactly what am I looking for.

    With the name UKMark I guessed your based in the UK, if your ever near Manchester let me know Ill buy you a few drinks
    [/quote]

    Yes you missed it :’(
    I’m near Liverpool so you may not want to buy me that pint. 😃

    BTW more info on the API and its uses can be found here:

    [url=http://api.feathercoin.com/?output=info]http://api.feathercoin.com/?output=info[/url]



  • Thanks.

    If you ever visit Manchester let me know 😃

    Thank you


 

Looks like your connection to Feathercoin Forum was lost, please wait while we try to reconnect.