From b9d4ca9122ab880febfed4d5e7613eda782b74fd Mon Sep 17 00:00:00 2001 From: Neythen Treloar Date: Mon, 21 Feb 2022 18:33:19 +0000 Subject: [PATCH] crypto database update, initial feature settings --- csv/system_info.json | 0 database_caller.py | 15 ++++++++++----- setup_config_files.sh | 14 +++++++------- stockTicker.py | 5 +---- 4 files changed, 18 insertions(+), 16 deletions(-) mode change 100644 => 100755 csv/system_info.json diff --git a/csv/system_info.json b/csv/system_info.json old mode 100644 new mode 100755 diff --git a/database_caller.py b/database_caller.py index 8f781bc..921e23f 100755 --- a/database_caller.py +++ b/database_caller.py @@ -65,7 +65,8 @@ def updateStocks(api_key): url += '&apiKey=' + api_key response = requests.get(url) data = response.json() - + print(response) + print(data) stock_info = {} @@ -80,7 +81,7 @@ def updateStocks(api_key): json.dump(all_stocks_settings, open('csv/stocks_settings.json', 'w+')) except Exception as e: - + exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] logf.write(str(e)) @@ -120,9 +121,13 @@ def updateCrypto(api_key): print(data) - + coin_info = {} for i,d in enumerate(data): #TODO get base from the server - coin_info[symbol_base[i]] = {'current': d['price'], '24hr_change': d['percent_over_24hr']} + + symbol = d['symbol'] + base = d['currency'] + + coin_info[symbol.upper() + ',' + base.upper()] = {'current': d['price'], '24hr_change': d['percent_over_24hr']} all_crypto_settings['symbols'] = coin_info @@ -545,7 +550,7 @@ if __name__ == '__main__': - update_frequencies = {'stocks':1, 'crypto':5, 'forex':60, 'news':120, 'weather': 120, 'sports': 120} #minutes + update_frequencies = {'stocks':1, 'crypto':5, 'forex':60, 'news':120, 'weather': 120, 'sports': 1440} #minutes NY_zone = pytz.timezone('America/New_York') CET_zone = pytz.timezone('Europe/Berlin') diff --git a/setup_config_files.sh b/setup_config_files.sh index 87c405b..2525787 100755 --- a/setup_config_files.sh +++ b/setup_config_files.sh @@ -2,14 +2,14 @@ touch log.txt touch api_keys.txt - +rm -rf user_uploads mkdir user_uploads rm -rf csv mkdir csv cd csv -touch coin_list.json last_update.csv scroll_text.csv crypto_settings.json last_updates.json settings.csv +touch coin_list.json last_update.csv scroll_text.csv crypto_settings.json last_updates.json settings.csv system_info.json touch currency.json league_tables.json mkdir sports touch current_weather.json stocks_settings.json daily_weather.json live_games.json @@ -18,21 +18,21 @@ touch GIF_settings.json news_settings.json image_settings.json past_games.json g filenames="coin_list.json last_update.csv scroll_text.csv crypto_settings.json last_updates.json settings.csv league_tables.json current_weather.json stocks_settings.json daily_weather.json live_games.json display_settings.json message_settings.json upcoming_games.json forex_settings.json multiple.csv GIF_settings.json news_settings.json image_settings.json past_games.json" - -echo [\"Standard\", [\"Crypto\", \"Forex\"]] >> display_settings.json +echo '{"update_available": false, "first_boot": true}' >> system_info.json +echo [\"Standard\", [\"Stocks\", \"Crypto\", \"Forex\"]] >> display_settings.json echo hello world!,255,255,0 >> scroll_text.csv -echo {\"feature\": \"Stocks\", \"speed\": \"medium\", \"animation\": \"down\", \"percent\": false, \"point\": false, \"logos\": true, \"chart\": false, \"title\": true, \"symbols\": {\"NEO,USD\": {\"current\": 40.64, \"24hr_change\": -4.545324570981437}, \"BTC,USD\": {\"current\": 56740, \"24hr_change\": -5.016422821619689}, \"ETH,BTC\": {\"current\": 0.07348605, \"24hr_change\": -4.828763639147195}, \"ADA,GBP\": {\"current\": 1.33, \"24hr_change\": -4.802144813755147}}} >> crypto_settings.json +echo '{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": false, "logos": true, "chart": false, "title": true, "symbols": {"ETH,USD": {"current": "2659.40", "24hr_change": "0.03"}, "BTC,USD": {"current": "38111.00", "24hr_change": "-0.54"}, "BNB,USD": {"current": "372.35", "24hr_change": "-2.73"}, "ADA,BTC": {"current": "0.0000", "24hr_change": "-1.55"}}}' >> crypto_settings.json echo -e "speed,brightness\nf,3" >> settings.csv echo '{"feature": "Sports (Team Stats)", "speed": "medium", "animation": "down", "title": true, "leagues": {}}' >> league_tables.json echo {\"feature\": \"Current Weather\", \"speed\": \"medium\", \"animation\": \"down\", \"temp\": \"celsius\", \"wind_speed\": \"miles/sec\", \"colour\": \"white\", \"city_colour\": \"yellow\", \"title\": true, \"locations\": {}, \"current_weather\": true} >> current_weather.json -echo {\"feature\": \"Stocks\", \"speed\": \"medium\", \"animation\": \"down\", \"percent\": true, \"point\": true, \"logos\": false, \"chart\": false, \"title\": true, \"symbols\": {\"MSFT\": {\"current\": 342.875, \"opening\": 344.57}, \"GOOG\": {\"current\": 2956.35, \"opening\": 3006.525}}} >> stocks_settings.json +echo '{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": true, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"AAPL": {"current": "167.48", "opening": 173.07}, "MSFT": {"current": "288.00", "opening": 309.93}, "GOOG": {"current": "2610.82", "opening": 2793.9100000000003}, "NFLX": {"current": "391.32", "opening": 526.71}}}' >> stocks_settings.json echo {\"feature\": \"Current Weather\", \"speed\": \"medium\", \"animation\": \"down\", \"temp\": \"celsius\", \"wind_speed\": \"miles/sec\", \"colour\": \"white\", \"city_colour\": \"yellow\", \"title\": true, \"locations\": {}, \"current_weather\": true} >> daily_weather.json echo '{"feature": "Sports (Live Games)", "speed": "medium", "animation": "down", "title": true, "leagues": {}}' >> live_games.json echo '{"feature": "Custom Messages", "speed": "Medium", "animation": "down", "title": true, "messages": [{"name": "1", "text": "123", "text_colour": "White", "size": "Medium", "background_colour": "Black"}, {"name": "13", "text": "123", "text_colour": "Red", "size": "Medium", "background_colour": "Purple"}]}' >> message_settings.json echo '{"feature": "Sports (Upcoming Games)", "speed": "medium", "animation": "down", "title": true, "leagues": {"NFL": [{"date": "2021-11-22", "time": "01:20:00", "round": "11", "home_team": "Los Angeles Chargers", "home_score": "41", "away_team": "Pittsburgh Steelers", "away_score": "37"}, {"date": "2021-11-23", "time": "01:15:00", "round": "11", "home_team": "Tampa Bay Buccaneers", "home_score": "0", "away_team": "New York Giants", "away_score": "0"}, {"date": "2021-11-25", "time": "17:30:00", "round": "12", "home_team": "Detroit Lions", "home_score": null, "away_team": "Chicago Bears", "away_score": null}, {"date": "2021-11-25", "time": "21:30:00", "round": "12", "home_team": "Dallas Cowboys", "home_score": null, "away_team": "Las Vegas Raiders", "away_score": null}, {"date": "2021-11-26", "time": "01:20:00", "round": "12", "home_team": "New Orleans Saints", "home_score": null, "away_team": "Buffalo Bills", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Cincinnati Bengals", "home_score": null, "away_team": "Pittsburgh Steelers", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Houston Texans", "home_score": null, "away_team": "New York Jets", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Indianapolis Colts", "home_score": null, "away_team": "Tampa Bay Buccaneers", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Jacksonville Jaguars", "home_score": null, "away_team": "Atlanta Falcons", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Miami Dolphins", "home_score": null, "away_team": "Carolina Panthers", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "New England Patriots", "home_score": null, "away_team": "Tennessee Titans", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "New York Giants", "home_score": null, "away_team": "Philadelphia Eagles", "away_score": null}, {"date": "2021-11-28", "time": "21:05:00", "round": "12", "home_team": "Denver Broncos", "home_score": null, "away_team": "Los Angeles Chargers", "away_score": null}, {"date": "2021-11-28", "time": "21:25:00", "round": "12", "home_team": "Green Bay Packers", "home_score": null, "away_team": "Los Angeles Rams", "away_score": null}, {"date": "2021-11-28", "time": "21:25:00", "round": "12", "home_team": "San Francisco 49ers", "home_score": null, "away_team": "Minnesota Vikings", "away_score": null}], "NBA": [{"date": "2021-11-22", "time": "01:20:00", "round": "11", "home_team": "Los Angeles Chargers", "home_score": "41", "away_team": "Pittsburgh Steelers", "away_score": "37"}, {"date": "2021-11-23", "time": "01:15:00", "round": "11", "home_team": "Tampa Bay Buccaneers", "home_score": "0", "away_team": "New York Giants", "away_score": "0"}, {"date": "2021-11-25", "time": "17:30:00", "round": "12", "home_team": "Detroit Lions", "home_score": null, "away_team": "Chicago Bears", "away_score": null}, {"date": "2021-11-25", "time": "21:30:00", "round": "12", "home_team": "Dallas Cowboys", "home_score": null, "away_team": "Las Vegas Raiders", "away_score": null}, {"date": "2021-11-26", "time": "01:20:00", "round": "12", "home_team": "New Orleans Saints", "home_score": null, "away_team": "Buffalo Bills", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Cincinnati Bengals", "home_score": null, "away_team": "Pittsburgh Steelers", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Houston Texans", "home_score": null, "away_team": "New York Jets", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Indianapolis Colts", "home_score": null, "away_team": "Tampa Bay Buccaneers", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Jacksonville Jaguars", "home_score": null, "away_team": "Atlanta Falcons", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "Miami Dolphins", "home_score": null, "away_team": "Carolina Panthers", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "New England Patriots", "home_score": null, "away_team": "Tennessee Titans", "away_score": null}, {"date": "2021-11-28", "time": "18:00:00", "round": "12", "home_team": "New York Giants", "home_score": null, "away_team": "Philadelphia Eagles", "away_score": null}, {"date": "2021-11-28", "time": "21:05:00", "round": "12", "home_team": "Denver Broncos", "home_score": null, "away_team": "Los Angeles Chargers", "away_score": null}, {"date": "2021-11-28", "time": "21:25:00", "round": "12", "home_team": "Green Bay Packers", "home_score": null, "away_team": "Los Angeles Rams", "away_score": null}, {"date": "2021-11-28", "time": "21:25:00", "round": "12", "home_team": "San Francisco 49ers", "home_score": null, "away_team": "Minnesota Vikings", "away_score": null}]}}' >> upcoming_games.json -echo '{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": false, "logos": false, "chart": false, "title": true, "symbols": {"NZD,GBP": {"current": 1.9181, "24hr_change": 0.0046999999999999265}, "CAD,USD": {"current": 1.2647, "24hr_change": 0.0046999999999999265}}}' >> forex_settings.json +echo '{"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": false, "logos": true, "chart": false, "title": true, "symbols": {"EUR,USD": {"current": "1.1342", "24hr_change": "0.0000"}, "USD,JPY": {"current": "114.855", "24hr_change": "0.0000"}, "GBP,USD": {"current": "1.3610", "24hr_change": "0.0000"}, "USD,CHF": {"current": "0.9169", "24hr_change": "0.0000"}}}' >> forex_settings.json echo '{"speed": "medium", "animation": "down", "title": true, "pause": "2", "images": []}'>> GIF_settings.json echo '{"feature": "News", "speed": "medium", "animation": "down", "country": "USA", "category": "general", "title": true, "use_sources": true, "sources": [], "headlines": []}' >> news_settings.json echo '{"speed": "slow", "animation": "down", "title": true, "pause": "/", "images": []}' >> image_settings.json diff --git a/stockTicker.py b/stockTicker.py index ce76248..e5d12e3 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -57,7 +57,7 @@ class StockTicker(): options.chain_length = 2 options.parallel = 1 options.hardware_mapping = 'adafruit-hat' # If you have an Adafruit HAT: 'adafruit-hat' - options.gpio_slowdown = 1 + options.gpio_slowdown = 4 options.brightness = self.brightness self.matrix = RGBMatrix(options = options) print(dir(self.matrix)) @@ -931,9 +931,6 @@ class StockTicker(): current = float(coin_info[cb]["current"]) change = float(coin_info[cb]["24hr_change"]) - - - percent_change = '%.2f' % abs(change) +'%'