converted to single threaded
This commit is contained in:
parent
7df8b3a519
commit
c46b184627
|
|
@ -8,6 +8,7 @@ import time
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import math
|
import math
|
||||||
import statistics
|
import statistics
|
||||||
|
import sys
|
||||||
from credentials import get_credentials
|
from credentials import get_credentials
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
|
|
@ -145,7 +146,7 @@ def fetch_data(broker: str, pair_list: list, timeframe: str, samples: int):
|
||||||
continue
|
continue
|
||||||
for item in data:
|
for item in data:
|
||||||
trading_volume += item[4]*item[5]
|
trading_volume += item[4]*item[5]
|
||||||
volatilities[broker][pair] = [round(yangzhang_volatility*100,2),round(parkinson_volatility*100,2),int(trading_volume)]
|
volatilities[pair] = [round(yangzhang_volatility*100,2),round(parkinson_volatility*100,2),int(trading_volume)]
|
||||||
print(f"{pair} on {broker} ready, {len(pair_list)-index} pairs remaining.")
|
print(f"{pair} on {broker} ready, {len(pair_list)-index} pairs remaining.")
|
||||||
time.sleep(wait_time)
|
time.sleep(wait_time)
|
||||||
|
|
||||||
|
|
@ -155,17 +156,14 @@ def fetch_data(broker: str, pair_list: list, timeframe: str, samples: int):
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
|
|
||||||
threads = []
|
threads = []
|
||||||
exchanges = ["binance","gateio","kucoin","okx","bybit"]
|
|
||||||
pair_list = []
|
pair_list = []
|
||||||
volatilities = {item:{} for item in exchanges}
|
volatilities = {}
|
||||||
exchange_list = [item for item in volatilities]
|
|
||||||
samples = 288
|
samples = 288
|
||||||
timeframe = "5m"
|
timeframe = "5m"
|
||||||
minimum_volume = 0
|
minimum_volume = 0
|
||||||
|
|
||||||
#Create databases for each exchange
|
#Create database if it does not exist
|
||||||
for item in exchange_list:
|
database_connection = sqlite3.connect(f"{get_credentials('VOL_DB_PATH')['path']}{sys.argv[1]}.db")
|
||||||
database_connection = sqlite3.connect(f"{get_credentials('VOL_DB_PATH')['path']}{item}.db")
|
|
||||||
database_cursor = database_connection.cursor()
|
database_cursor = database_connection.cursor()
|
||||||
database_cursor.execute('''
|
database_cursor.execute('''
|
||||||
CREATE TABLE IF NOT EXISTS volatilities_table (
|
CREATE TABLE IF NOT EXISTS volatilities_table (
|
||||||
|
|
@ -178,14 +176,7 @@ if __name__=="__main__":
|
||||||
database_connection.close()
|
database_connection.close()
|
||||||
|
|
||||||
|
|
||||||
for broker in exchange_list:
|
fetch_data(sys.argv[1], get_pair_list(sys.argv[1]), timeframe, samples)
|
||||||
threads.append(Thread(target=fetch_data,args=(broker, get_pair_list(broker), timeframe, samples,)))
|
|
||||||
|
|
||||||
for thread in threads:
|
write_to_db(sys.argv[1],volatilities)
|
||||||
thread.start()
|
|
||||||
for thread in threads:
|
|
||||||
thread.join()
|
|
||||||
|
|
||||||
for item in exchange_list:
|
|
||||||
write_to_db(item,volatilities[item])
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue