fixes
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import sys
|
||||
import sqlite3
|
||||
from typing import Dict, Tuple
|
||||
from typing import Dict
|
||||
import pandas as pd
|
||||
|
||||
from tools.trading_pair import TradingPair
|
||||
|
||||
|
||||
def load_sqlite_to_dataframe(db_path, query):
|
||||
@@ -15,15 +13,15 @@ def load_sqlite_to_dataframe(db_path, query):
|
||||
except sqlite3.Error as excpt:
|
||||
print(f"SQLite error: {excpt}")
|
||||
raise
|
||||
except Exception as e:
|
||||
except Exception as excpt:
|
||||
print(f"Error: {excpt}")
|
||||
raise
|
||||
raise Exception() from excpt
|
||||
finally:
|
||||
if "conn" in locals():
|
||||
conn.close()
|
||||
|
||||
|
||||
def convert_time_to_UTC(value: str, timezone: str):
|
||||
def convert_time_to_UTC(value: str, timezone: str) -> str:
|
||||
|
||||
from zoneinfo import ZoneInfo
|
||||
from datetime import datetime
|
||||
@@ -32,12 +30,9 @@ def convert_time_to_UTC(value: str, timezone: str):
|
||||
local_dt = datetime.strptime(value, "%Y-%m-%d %H:%M:%S")
|
||||
|
||||
zinfo = ZoneInfo(timezone)
|
||||
result = local_dt.replace(tzinfo=zinfo)
|
||||
result: datetime = local_dt.replace(tzinfo=zinfo).astimezone(ZoneInfo("UTC"))
|
||||
|
||||
result = result.astimezone(ZoneInfo("UTC"))
|
||||
result = result.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
return result
|
||||
return result.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
def load_market_data(datafile: str, config: Dict) -> pd.DataFrame:
|
||||
@@ -52,7 +47,7 @@ def load_market_data(datafile: str, config: Dict) -> pd.DataFrame:
|
||||
|
||||
query = "select"
|
||||
if security_type == "CRYPTO":
|
||||
query += " strftime('%Y-%m-%d %H:%M:%S', tstamp/1000000000, 'unixepoch') as tstamp"
|
||||
query += " strftime('%Y-%m-%d %H:%M:%S', tstamp_ns/1000000000, 'unixepoch') as tstamp"
|
||||
query += ", tstamp as time_ns"
|
||||
else:
|
||||
query += " tstamp"
|
||||
|
||||
Reference in New Issue
Block a user