- Fixed colons in backup filenames
- Fixed shallow copy in config handler - Fixed no URL encoding for Telegram messages - Fixed no SQLite thread safety
This commit is contained in:
parent
ffe58e2c0d
commit
7b19aaa11f
|
|
@ -1,5 +1,6 @@
|
||||||
from time import time
|
from time import time
|
||||||
from json import dumps, load
|
from json import dumps, load
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
class ConfigHandler:
|
class ConfigHandler:
|
||||||
'''
|
'''
|
||||||
|
|
@ -55,7 +56,7 @@ class ConfigHandler:
|
||||||
|
|
||||||
|
|
||||||
def reset_to_default(self):
|
def reset_to_default(self):
|
||||||
self.config_dictionary = self.default_config_dictionary.copy()
|
self.config_dictionary = deepcopy(self.default_config_dictionary)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def get_pair(self):
|
def get_pair(self):
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class duster:
|
||||||
self.broker = broker
|
self.broker = broker
|
||||||
if not importing:
|
if not importing:
|
||||||
order = self.broker.get_order(status_info["tp_order_id"],status_info["market"]["symbol"])
|
order = self.broker.get_order(status_info["tp_order_id"],status_info["market"]["symbol"])
|
||||||
self.duster_status = {"duster_id": status_info["tp_order_id"],
|
self.duster_status = {"id": status_info["tp_order_id"],
|
||||||
"pair": status_info["market"]["symbol"],
|
"pair": status_info["market"]["symbol"],
|
||||||
"amount_spent": status_info["quote_spent"],
|
"amount_spent": status_info["quote_spent"],
|
||||||
"current_price": current_price,
|
"current_price": current_price,
|
||||||
|
|
@ -51,7 +51,7 @@ class duster:
|
||||||
#Check if necessary
|
#Check if necessary
|
||||||
mid_price = 0
|
mid_price = 0
|
||||||
high_price = 0
|
high_price = 0
|
||||||
if self.duster_status["price"] is not None:
|
if self.duster_status.get("current_price") is not None:
|
||||||
mid_price = self.duster_status["current_price"]
|
mid_price = self.duster_status["current_price"]
|
||||||
if self.duster_status["deal_close_price"] is not None:
|
if self.duster_status["deal_close_price"] is not None:
|
||||||
high_price = self.duster_status["deal_close_price"]
|
high_price = self.duster_status["deal_close_price"]
|
||||||
|
|
@ -189,7 +189,7 @@ class duster:
|
||||||
|
|
||||||
if self.broker.get_exchange_name()=="binance": #CCXT still to this day does not take Binance fees into account.
|
if self.broker.get_exchange_name()=="binance": #CCXT still to this day does not take Binance fees into account.
|
||||||
try:
|
try:
|
||||||
market = self.broker.fetch_maker(self.duster_status["pair"])
|
market = self.broker.fetch_market(self.duster_status["pair"])
|
||||||
fee_rate = market["maker"] if order["type"]=="limit" else market["taker"]
|
fee_rate = market["maker"] if order["type"]=="limit" else market["taker"]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.broker.logger.log_this(f"Exception fetching market information: {e}. Using default fee rate of 0.1%",1,f"{base}{quote}")
|
self.broker.logger.log_this(f"Exception fetching market information: {e}. Using default fee rate of 0.1%",1,f"{base}{quote}")
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ from contextlib import contextmanager
|
||||||
from requests import get as requests_get
|
from requests import get as requests_get
|
||||||
from json import load, dumps
|
from json import load, dumps
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
|
|
||||||
class Broker:
|
class Broker:
|
||||||
|
|
@ -34,6 +35,8 @@ class Broker:
|
||||||
self._db = sqlite3.connect(self.profits_database_filename,
|
self._db = sqlite3.connect(self.profits_database_filename,
|
||||||
detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES,
|
detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES,
|
||||||
check_same_thread=False)
|
check_same_thread=False)
|
||||||
|
self._db.execute("PRAGMA journal_mode=WAL")
|
||||||
|
self._db.execute("PRAGMA synchronous=NORMAL")
|
||||||
self._db.row_factory = sqlite3.Row
|
self._db.row_factory = sqlite3.Row
|
||||||
with self._db:
|
with self._db:
|
||||||
self._db.execute('''
|
self._db.execute('''
|
||||||
|
|
@ -1120,7 +1123,7 @@ class Logger:
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
tg_credentials = credentials.get_credentials("telegram")
|
tg_credentials = credentials.get_credentials("telegram")
|
||||||
send_text = f"https://api.telegram.org/bot{tg_credentials['token']}/sendMessage?chat_id={tg_credentials['chatid']}&parse_mode=Markdown&text={message}"
|
send_text = f"https://api.telegram.org/bot{tg_credentials['token']}/sendMessage?chat_id={tg_credentials['chatid']}&parse_mode=Markdown&text={quote(message)}"
|
||||||
output = None
|
output = None
|
||||||
if self.broker_config["telegram"] or ignore_config:
|
if self.broker_config["telegram"] or ignore_config:
|
||||||
output = requests_get(send_text,timeout=5).json() #5 seconds timeout. This could also be a tunable.
|
output = requests_get(send_text,timeout=5).json() #5 seconds timeout. This could also be a tunable.
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,7 @@ class StatusHandler:
|
||||||
file_path = self.status_file_path
|
file_path = self.status_file_path
|
||||||
if is_backup:
|
if is_backup:
|
||||||
try:
|
try:
|
||||||
with open(strftime(f"{file_path}_%Y-%m-%d_%H:%M:%S.json"), "w") as f:
|
with open(strftime(f"{file_path}_%Y-%m-%d_%H-%M-%S.json"), "w") as f:
|
||||||
f.write(dumps(self.status_dictionary, indent=4))
|
f.write(dumps(self.status_dictionary, indent=4))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.broker.logger.log_this(f"Error creating status backup file: {e}",1)
|
self.broker.logger.log_this(f"Error creating status backup file: {e}",1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue