market update
This commit is contained in:
17
app.py
17
app.py
@ -1,11 +1,11 @@
|
||||
import time
|
||||
from datetime import datetime
|
||||
import threading
|
||||
from market import market_info_loop, get_latest_price, get_all_latest_prices, get_latest_price_with_timestamp, set_debug
|
||||
from market import market_info_loop, get_latest_price, get_all_latest_prices, get_latest_price_with_timestamp
|
||||
|
||||
def start_market_data_thread(debug=False):
|
||||
"""Start market data collection in a separate thread"""
|
||||
market_thread = threading.Thread(target=market_info_loop, daemon=True)
|
||||
market_thread = threading.Thread(target=lambda: market_info_loop(debug), daemon=True)
|
||||
market_thread.start()
|
||||
return market_thread
|
||||
|
||||
@ -14,11 +14,9 @@ def main():
|
||||
print("-" * 40)
|
||||
|
||||
# Start market data collection in background thread (debug=False by default)
|
||||
start_market_data_thread(debug=True)
|
||||
start_market_data_thread()
|
||||
|
||||
# Give some time for initial market data to be collected
|
||||
print("Waiting for initial market data...")
|
||||
time.sleep(10)
|
||||
|
||||
try:
|
||||
while True:
|
||||
@ -28,14 +26,17 @@ def main():
|
||||
# Show some sample prices with timestamps
|
||||
eth_data = get_latest_price_with_timestamp("ETHUSD")
|
||||
btc_data = get_latest_price_with_timestamp("BTCUSD")
|
||||
shib_data = get_latest_price_with_timestamp("SHIBUSD")
|
||||
sol_data = get_latest_price_with_timestamp("SOLUSD")
|
||||
# shib_data = get_latest_price_with_timestamp("SHIBUSD")
|
||||
|
||||
if eth_data:
|
||||
print(f"ETH/USD: ${eth_data['price']:.2f} (updated: {eth_data['timestamp_str']})")
|
||||
if btc_data:
|
||||
print(f"BTC/USD: ${btc_data['price']:.2f} (updated: {btc_data['timestamp_str']})")
|
||||
if shib_data:
|
||||
print(f"SHIB/USD: ${shib_data['price']:.8f} (updated: {shib_data['timestamp_str']})")
|
||||
if sol_data:
|
||||
print(f"SOL/USD: ${sol_data['price']:.2f} (updated: {sol_data['timestamp_str']})")
|
||||
# if shib_data:
|
||||
# print(f"SHIB/USD: ${shib_data['price']:.8f} (updated: {shib_data['timestamp_str']})")
|
||||
|
||||
# Show total number of markets with prices
|
||||
all_prices = get_all_latest_prices()
|
||||
|
||||
Reference in New Issue
Block a user