Giter Site home page Giter Site logo

chrislennon / crypto-touchbar-app Goto Github PK

View Code? Open in Web Editor NEW
154.0 11.0 20.0 13.4 MB

A web app to build Apple touch bar elements for crytpo currencies. Requires BetterTouchTool. Supports wide range of cryptos and converts to a variety of fiat monies.

Home Page: https://chrislennon.github.io/Crypto-Touchbar-App/

License: MIT License

JavaScript 59.44% HTML 14.38% CSS 15.28% Python 10.90%
bettertouchtool bitcoin cryptocurrency touchbar cryptocurrency-website

crypto-touchbar-app's People

Contributors

bjjlangedijk avatar chrislennon avatar fifafu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crypto-touchbar-app's Issues

Keep last price when no Internet connection

Hi, thanks for such cool feature!

When a computer is not connected to Internet (bus, plane, etc.) or the connection drops, the currency label shows a long error message instead of the currency details (price, arrows, etc.).

Would it be possible to add a feature that would keep displayed the last price which was available before the connection dropped rather than displaying an error message that takes the whole Touch Bar?

Thank you :)

show market cap

First; Thanks for making this!

Would be great if market cap would be included.

Bug in comma seperator

looks like certain outputs are not being interpreted correctly for certain values and cannot input a comma to separate the thousands.

reported via this reddit comment

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: Cannot specify ',' with 's'.

Implement User defined decimal places

Some coins have a large number of decimal places - typically when their value is ~$1 or less.

Implement an override that the user can specify the maximum number of decimals before they export it.

Update visual elements on FIAT/colour change

When a user changes the FIAT currency for conversion after touchbar elements are added the existing elements should be removed.

This doesn't effect the JSON output, however does effect the visual effect of the application

Remove applescript logic

BTT looks to be moving towards allowing shell script directly rather than looping it though applescript - https://twitter.com/boastr_net/status/952544253628076032.

This should provide us a few benefits:

  • no more applescript - hell yeah! 🎉
  • better handling of numbers and formats
  • better access to other binaries and OS functions without jumping though loops

Thanks @fifafu! this is awesome - any approximation on the alpha -> stable date?

Script return nothing w/ direct import and not displayed properly w/ JSON import

I'm on MacOS High Sierra V10.13.6. / BTT v2.627

When I do a direct import to BTT, no price is displayed in the BTC indicator on the touch bar. If i run the script imported from BTT, it returns "Error/Nothing was returned".

When I do JSON import, raw script code is displayed in the BTC indicator. If I run the script imported from BTT, I get the right price returned.

It happens no matter the advanced options selected.

Script from direct import :


#!_usr_bin_python
# -*- coding: utf-8 -*-
import urllib2,json,sys

coin_ticker = "BTC" if "BTC"[0] != "{" else "BTC"
fiat_ticker = "USD" if "USD"[0] != "{" else "USD"
fiat_symbol = "$" if "$"[0] != "{" else  "$"
num_format = "{}" if "{}"[2:8] != "format" else  "{}"
mod_percent = float("0") if "0"[0] != "{" else float(0)
output_type = "no" if "no"[0] != "{" else  "mktcap"
api_type = "live" if "live"[0] != "{" else  "live"
extraOptions = "False" if "False"[0] != "{" else  "&limit=1&aggregate=1&toTs=1514376000"
offline_cache = "false" if "false"[0] != "{" else "false"
percentageRound = int("0") if "0"[0] != "{" else int(0)
literalRound = int("0") if "0"[0] != "{" else int(0)

try:
    if (api_type == "live"):

        url = "https:__min-api.cryptocompare.com_data_pricemultifull?fsyms={}&tsyms={}".format(coin_ticker, fiat_ticker)

        data = urllib2.urlopen(url)
        obj=json.load(data)

        raw_current = float(obj["RAW"][coin_ticker][fiat_ticker]["PRICE"])
        raw_opening = float(obj["RAW"][coin_ticker][fiat_ticker]["OPEN24HOUR"])
        raw_high = float(obj["RAW"][coin_ticker][fiat_ticker]["HIGHDAY"])
        raw_low = float(obj["RAW"][coin_ticker][fiat_ticker]["LOWDAY"])
        raw_mktcap = float(obj["RAW"][coin_ticker][fiat_ticker]["MKTCAP"])
        current = num_format.format(raw_current)
        opening = num_format.format(raw_opening)
        high = num_format.format(raw_high)
        low = num_format.format(raw_low)

        if (raw_mktcap > 1000000):
            mktcap = str("{:,."+str(literalRound)+"f}").format(raw_mktcap _ 1000000) + " M"
        else:
            mktcap = str("{:,."+str(literalRound)+"f}").format(raw_mktcap)

        if (raw_current > raw_opening):
            trend = "▲"
        else:
            trend = "▼"

        if (output_type is "no"):
            output = fiat_symbol + current
        elif (output_type is "simple"):
            output = fiat_symbol + current + " " + trend
        elif (output_type is "mktcap"):
            output = fiat_symbol + current + " (" + fiat_symbol + mktcap + ")"
        elif (output_type is "absolute"):
            output = fiat_symbol + current + " (L: " + fiat_symbol + low + " H: " + fiat_symbol + high + ")"
        elif (output_type is "relative"):
            output = fiat_symbol + current + " (L: -" + fiat_symbol + str(round(raw_current - raw_low, literalRound)) + " H: +" + fiat_symbol + str(round(raw_high - raw_current,literalRound)) + ")"
        elif (output_type is "current-percentage"):
            output = fiat_symbol + current + " (" + str(round(((raw_current - raw_opening) _ raw_current) * 100, percentageRound)) + "%)"
        elif (output_type is "range-percentage"):
            output = fiat_symbol + current + " (L: -" + str(round (((raw_current - raw_low) _ raw_current) * 100, percentageRound)) + "% H: +" + str(round (((raw_high - raw_current) _ raw_current) * 100, percentageRound)) + "%)"
        elif (output_type is "user-percentage"):
            output = fiat_symbol + current + " (L: " + fiat_symbol + str(round(raw_current - (raw_current * mod_percent), literalRound)) + " H: " + fiat_symbol + str(round(raw_current + (raw_current * mod_percent), literalRound)) + ")"

        if (offline_cache is "true"):
            tmp_file = open("_tmp_"+coin_ticker+"-"+fiat_ticker+"-"+output_type+".txt", "w")
            tmp_file.write(output)
            tmp_file.close()

        print(output)

    elif (api_type == "historical"):
        url = "https:__min-api.cryptocompare.com_data_histohour?fsym={}&tsym={}" + extraOptions
        url = url.format(coin_ticker, fiat_ticker)

        data = urllib2.urlopen(url)
        obj=json.load(data)

        raw_high = float(obj["Data"][1]["high"])
        high = num_format.format(raw_high)

        output = fiat_symbol + high

        if (offline_cache is "true"):
            tmp_file = open("_tmp_"+coin_ticker+"-"+fiat_ticker+"-"+output_type+".txt", "w")
            tmp_file.write(output)
            tmp_file.close() 

        print(output)
except urllib2.URLError, e:
    try:
        tmp_file = open("_tmp_"+coin_ticker+"-"+fiat_ticker+"-"+output_type+".txt", "r")
        print 'CACHED ' + tmp_file.read() 
    except IOError, e:
        print('Unable to get data from API & no cache available')
except ValueError, e:
    print('There was an error formatting the output: %s' % e)
# Please submit any issues https:__github.com_chrislennon_Crypto-Touchbar-App_issues with the above script

Script from JSON import :

#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib2,json,sys

coin_ticker = "BTC" if "BTC"[0] != "{" else "BTC"
fiat_ticker = "USD" if "USD"[0] != "{" else "USD"
fiat_symbol = "$" if "$"[0] != "{" else  "$"
num_format = "{}" if "{}"[2:8] != "format" else  "{}"
mod_percent = float("0") if "0"[0] != "{" else float(0)
output_type = "no" if "no"[0] != "{" else  "mktcap"
api_type = "live" if "live"[0] != "{" else  "live"
extraOptions = "False" if "False"[0] != "{" else  "&limit=1&aggregate=1&toTs=1514376000"
offline_cache = "false" if "false"[0] != "{" else "false"
percentageRound = int("0") if "0"[0] != "{" else int(0)
literalRound = int("0") if "0"[0] != "{" else int(0)

try:
    if (api_type == "live"):

        url = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms={}&tsyms={}".format(coin_ticker, fiat_ticker)

        data = urllib2.urlopen(url)
        obj=json.load(data)

        raw_current = float(obj["RAW"][coin_ticker][fiat_ticker]["PRICE"])
        raw_opening = float(obj["RAW"][coin_ticker][fiat_ticker]["OPEN24HOUR"])
        raw_high = float(obj["RAW"][coin_ticker][fiat_ticker]["HIGHDAY"])
        raw_low = float(obj["RAW"][coin_ticker][fiat_ticker]["LOWDAY"])
        raw_mktcap = float(obj["RAW"][coin_ticker][fiat_ticker]["MKTCAP"])
        current = num_format.format(raw_current)
        opening = num_format.format(raw_opening)
        high = num_format.format(raw_high)
        low = num_format.format(raw_low)

        if (raw_mktcap > 1000000):
            mktcap = str("{:,."+str(literalRound)+"f}").format(raw_mktcap / 1000000) + " M"
        else:
            mktcap = str("{:,."+str(literalRound)+"f}").format(raw_mktcap)

        if (raw_current > raw_opening):
            trend = "▲"
        else:
            trend = "▼"

        if (output_type is "no"):
            output = fiat_symbol + current
        elif (output_type is "simple"):
            output = fiat_symbol + current + " " + trend
        elif (output_type is "mktcap"):
            output = fiat_symbol + current + " (" + fiat_symbol + mktcap + ")"
        elif (output_type is "absolute"):
            output = fiat_symbol + current + " (L: " + fiat_symbol + low + " H: " + fiat_symbol + high + ")"
        elif (output_type is "relative"):
            output = fiat_symbol + current + " (L: -" + fiat_symbol + str(round(raw_current - raw_low, literalRound)) + " H: +" + fiat_symbol + str(round(raw_high - raw_current,literalRound)) + ")"
        elif (output_type is "current-percentage"):
            output = fiat_symbol + current + " (" + str(round(((raw_current - raw_opening) / raw_current) * 100, percentageRound)) + "%)"
        elif (output_type is "range-percentage"):
            output = fiat_symbol + current + " (L: -" + str(round (((raw_current - raw_low) / raw_current) * 100, percentageRound)) + "% H: +" + str(round (((raw_high - raw_current) / raw_current) * 100, percentageRound)) + "%)"
        elif (output_type is "user-percentage"):
            output = fiat_symbol + current + " (L: " + fiat_symbol + str(round(raw_current - (raw_current * mod_percent), literalRound)) + " H: " + fiat_symbol + str(round(raw_current + (raw_current * mod_percent), literalRound)) + ")"

        if (offline_cache is "true"):
            tmp_file = open("/tmp/"+coin_ticker+"-"+fiat_ticker+"-"+output_type+".txt", "w")
            tmp_file.write(output)
            tmp_file.close()

        print(output)

    elif (api_type == "historical"):
        url = "https://min-api.cryptocompare.com/data/histohour?fsym={}&tsym={}" + extraOptions
        url = url.format(coin_ticker, fiat_ticker)

        data = urllib2.urlopen(url)
        obj=json.load(data)

        raw_high = float(obj["Data"][1]["high"])
        high = num_format.format(raw_high)

        output = fiat_symbol + high

        if (offline_cache is "true"):
            tmp_file = open("/tmp/"+coin_ticker+"-"+fiat_ticker+"-"+output_type+".txt", "w")
            tmp_file.write(output)
            tmp_file.close() 

        print(output)
except urllib2.URLError, e:
    try:
        tmp_file = open("/tmp/"+coin_ticker+"-"+fiat_ticker+"-"+output_type+".txt", "r")
        print 'CACHED ' + tmp_file.read() 
    except IOError, e:
        print('Unable to get data from API & no cache available')
except ValueError, e:
    print('There was an error formatting the output: %s' % e)
# Please submit any issues https://github.com/chrislennon/Crypto-Touchbar-App/issues with the above script

Add checkbox for light/dark icons

Currently all currency icons are output in white (except a few manually added ones - BCG etc.)

Look to add either a light/dark checkbox or an additional colour picker per coin for the coin's symbol.

Random display of "raw code" instead of crypto values

I am using the Crypto Touchbar App tool for 2 hours now and I have seen several times this kind of bug instead of my favorite crypto-values (see picture)

crypto

On this picture it appears instead of BTC value but it appears also on others crypto.
The raw code appears until the next auto-refresh (set in my case at 5 seconds)

Redd Coin won't update

Reddcoin won't update on touchbar. Shows an error.

Traceback (most recent call last):
File "", line 5, in
ValueError: Unknown format code 'f' for object of type 'unicode'

Add round parameter

Hi, I think it's useful to add a setting in the webpage to let the user customise the rounding parameter. I've modified the code to round the % to 2 decimals:

elif (output_type is "current-percentage"):
            output = fiat_symbol + current + " (" + str(round((((raw_current - raw_opening) / raw_current) * 100), 2)) + "%)"

I've made this because I thought it was strange to have the percentage changing from 1 to 1%.

Thanks and nice work!

Tidy up main list - keeping icon & colour when available

Current:
loads all coins from coins.js which have an icon and provides search for others that don't.

Todo:
Load top X coins from list, search for others - apply the colours and icons to all coins by matching on the ticker.

Add colour selections

Currently the crypto touchbar elements all output to a standard orange (BTC) colour, the users should be allowed to change the default colour, or colour of each element individually.

Add all coins that have an icon

Request from twitter that coins that have an icon in the SVG package are not available in the app.

Add all available coin/icon pairs and fix the ordering of them, alphabetical by ticker?

Donation Addresses

probably should add some donation addresses to the site/github repo on the off chance that people find this useful. 🤑

Documentation Additions

  • Add video/gif of usage and operation
  • Add images to show different output types
  • Update acknowledgements (and main site) to reflect API calls and source

Switch API call from `pricemultifull` to `generateAvg`

From a brief read over the API I am using the pricemultifull which will respond with the latest data received from any given exchange.

This could mean that the price may fluctuate significantly even inside the touch bar - i.e. BTC - GDAX price is received and then on refresh BTC - Kraken price is received.

Two ways could be used to combat this:

  • look into changing over to generateAvg this will generate a price average across all the exchanges available to cryptocompare
  • look into providing a mechanism to select their preferred exchange, however this may give issues when uses select exchanges that trading pairs are not available on.

Rename download file (data.json) & Import Name

Download file is currently called data.json - could be something more useful.

File imported is called Crypto-Touchbar-App - I have been renaming mine locally to Crypto-Touchbar-App-USD etc. Should probably put this in the codebase for people who use multiple imports.

Cardano icon not showing

Thanks for making this! Looks nicer and has more options than the previous one I had.
Just one issue, the ADA icon is not showing up and I don't how to fix it, any ideas?

Unit Testing

The formatting issues experienced within python (assumed to be resolved in #76) were a bit of a headache for users. The debugging it was also not as easy as it could of been on my end.

To implement - a way of testing the JS generation of python code, and the testing of the python code in a way that means I can be confident changes that are made apply to all coins/formats/output styles.

Currency graphs

Show the currency graph/trend with some meaningful values attached.

pasted image at 2017_12_29 11_47 am

  • Trend of coin
  • Percentage of change
  • Actual coin value change based on the currency set for that coin

This graph could be shown whenever the user clicks on a coin.

Layout of application

Enhance the layout of the webapp, current ideas:

  • Have touchbar element buttons instead of checkboxes
  • use a grid layout with static width for the buttons
  • uncrapify the fiat dropdown and export button
  • Include links to BTT and jq

append (custom/derived) variance to output

Show the price with a variance appended to the output, 3 options:

  • User defined percentage
  • Derived price 'gap' (highest sale - lowest sale)
  • Derived -/+ % change
  • 'Change' Window:
    • 1h/4h/12h/1d/1w/1m

Ways of displaying each of above:

  • Actual values: $1000 +$1100 -$900
  • Change values: $1000 +$100 -$100
  • Percentage Values: $1000 +10%

suggestion source: reddit

Toggle for group

Currently cyrpto elements are automatically included in a group.
The groups look as such:
img_20171218_141547
The group consists of an icon (see last pending work on #12), 'Crypto' and 🤑.
this should be enabled for user configuration or be allowed to be disabled.

Portfolio "tracking"

Add an optional 'point in time' selection to the web-app and create static outputs of price for that specified time.

To investigate:

  • API source for one time or continual (but why?!) checking of the historic price.
  • How to layout the elements:
    • Single element, append datetime. i.e. $1000 - 29/12/2017 00:00
    • Grouped element, show datetime as group name.

suggestion source: reddit

Exporting Multiple Jsons can cause issues

Found a small (yet annoying) issue where if change the group toggle box on/off/on and export each time you toggle the value - the group on the 3rd export will not work and will have the icon set that was destined for the group.

Adding A Coin Icon

The instructions for adding a custom coin icon are missing. Please add instructions so we can add our own coins.

fix scroll within the webapp

Currently if to many currencies are selected within the webapp the apple icons (volume etc.) will progress down the screen.

Implement a proper scrolling element for the middle section of the touchbar to represent a closer feel to the apple touch bar.

JS refactor

Refactor some of the hack and slash JS that goes on within the application - make it more likely that other developers wont vomit at my implementation of this application :neckbeard:

Random CSS issues

So at some point it seems that scrollbars started appearing and it looks nasty, also box shadowing on the colour selectors.

No code changes since end of Jan, any ideas @BJJLangedijk ?

Add default colours for each coin

Coins typically have a default colour. Currently all colours are set to a BTC style orange.

Add to the coins.js a colour preset that will populate on load of the coins list.

Better error handling

when encountering errors in python either timeouts of bad listing of output, specify a better error output than a large error dump.

remove jq dependancy

jq install has annoyed a few users, try to remove this and parse with OS specific tools

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.