def get_vol_90d(symbol, exchange): db = InfluxClientHost2() data = db.query_tables(measurement, ["*", "where time > now() - 90d and exchange = '{}'".format(exchange)], "raw") vol_tot = 0 numPeriod = 0 for db in data: numPeriod += 1 vol_tot += db[symbol] vol_7d = vol_tot / numPeriod return vol_7d
import time import requests import socket import json import websocket import threading current_dir = os.path.dirname(os.path.abspath(__file__)) pkg_dir = os.path.dirname(current_dir) sys.path.append(pkg_dir) from influxdb_client.influxdb_client_host_1 import InfluxClientHost1 from influxdb_client.influxdb_client_host_2 import InfluxClientHost2 from utility.error_logger_writer import logger host_1 = InfluxClientHost1() host_2 = InfluxClientHost2() # Global Default Variables app_id = '256' #app_id = '2bd36ad5581c4ff0b9914641a40480316ab28105' auth_url = 'https://api.refinitiv.com:443/auth/oauth2/v1/token' discovery_url = 'https://api.refinitiv.com/streaming/pricing/v1/' password = '******' position = '' sts_token = '' refresh_token = '' user = '******' clientid = '2bd36ad5581c4ff0b9914641a40480316ab28105' client_secret = '' scope = 'trapi' region = 'amer'
from email.mime.text import MIMEText import pandas as pd import numpy as np current_dir = os.path.dirname(os.path.abspath(__file__)) pd.set_option('display.float_format', lambda x: '%.2f' % x) sys.path.append(os.path.dirname(current_dir)) from api_binance.BinanceRestApi import get_spot24 from api_coinbase.coinbaseRestApi import get_market_stats from api_huobi.HuobiRestApi import get_spot_market_info from api_okex.OkexRestApi import get_spot_tickers from api_kraken.KrakenRestApi import get_tickers from influxdb_client.influxdb_client_host_2 import InfluxClientHost2 pd.set_option('display.float_format', lambda x: '%.3f' % x) db = InfluxClientHost2() measurement = "log_ethbtc_volume_report" def checkIfUTCMidnight(): utcnow = datetime.datetime.utcnow() seconds_since_utcmidnight = (utcnow - utcnow.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds() if int(seconds_since_utcmidnight) == 0: run_script = True time.sleep(1) else: run_script = False return run_script def get_vol_7d(symbol, exchange): db = InfluxClientHost2() data = db.query_tables(measurement, ["*", "where time > now() - 7d and exchange = '{}'".format(exchange)], "raw")