2025.11.08
This commit is contained in:
parent
96d1cf6d78
commit
7c33dd231d
|
|
@ -1,3 +1,7 @@
|
||||||
|
2025.11.08:
|
||||||
|
. broker.set_default_order_size() now saves the config file to disk after changing the value.
|
||||||
|
. Variable renaming and other small stuff.
|
||||||
|
|
||||||
2025.10.24:
|
2025.10.24:
|
||||||
. Toggling liquidate_after_switch now writes the config file to disk so the setting persists between trades.
|
. Toggling liquidate_after_switch now writes the config file to disk so the setting persists between trades.
|
||||||
. Manually switching to long now sets double_check_price to false.
|
. Manually switching to long now sets double_check_price to false.
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,7 @@ class Broker:
|
||||||
def set_default_order_size(self,size):
|
def set_default_order_size(self,size):
|
||||||
try:
|
try:
|
||||||
self.broker_config["default_order_size"] = float(size)
|
self.broker_config["default_order_size"] = float(size)
|
||||||
|
self.rewrite_config_file()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.log_this(f"Exception in set_default_order_size: {e}",1)
|
self.logger.log_this(f"Exception in set_default_order_size: {e}",1)
|
||||||
return 1
|
return 1
|
||||||
|
|
|
||||||
2
main.py
2
main.py
|
|
@ -18,7 +18,7 @@ import exchange_wrapper
|
||||||
import trader
|
import trader
|
||||||
|
|
||||||
|
|
||||||
version = "2025.10.24"
|
version = "2025.11.08"
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||||
|
|
|
||||||
26
trader.py
26
trader.py
|
|
@ -42,8 +42,8 @@ class trader:
|
||||||
if self.config.get_is_short():
|
if self.config.get_is_short():
|
||||||
#Check if there is an old_long file. If so, load it.
|
#Check if there is an old_long file. If so, load it.
|
||||||
try:
|
try:
|
||||||
with open(f"status/{self.base}{self.quote}.oldlong") as ol:
|
with open(f"status/{self.base}{self.quote}.oldlong") as old_long_file_handler:
|
||||||
self.status.set_old_long(load(ol))
|
self.status.set_old_long(load(old_long_file_handler))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.broker.logger.log_this(f"Exception: No old_long file. {e}",1,base_quote)
|
self.broker.logger.log_this(f"Exception: No old_long file. {e}",1,base_quote)
|
||||||
|
|
||||||
|
|
@ -572,8 +572,8 @@ class trader:
|
||||||
"datetime": time.strftime("[%Y/%m/%d %H:%M:%S]")
|
"datetime": time.strftime("[%Y/%m/%d %H:%M:%S]")
|
||||||
})
|
})
|
||||||
try:
|
try:
|
||||||
with open(f"status/{self.base}{self.quote}.oldlong","w") as s:
|
with open(f"status/{self.base}{self.quote}.oldlong","w") as old_long_file_handler:
|
||||||
s.write(dumps(self.status.get_old_long(),indent=4))
|
old_long_file_handler.write(dumps(self.status.get_old_long(),indent=4))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.broker.logger.log_this(f"Exception while saving old_long file: {e}",1,self.status.get_pair())
|
self.broker.logger.log_this(f"Exception while saving old_long file: {e}",1,self.status.get_pair())
|
||||||
|
|
||||||
|
|
@ -617,8 +617,8 @@ class trader:
|
||||||
if not ignore_old_long and self.status.get_old_long()=={}:
|
if not ignore_old_long and self.status.get_old_long()=={}:
|
||||||
self.broker.logger.log_this("Can't find old long info on status_dict, searching for oldlong file",1,self.status.get_pair())
|
self.broker.logger.log_this("Can't find old long info on status_dict, searching for oldlong file",1,self.status.get_pair())
|
||||||
try:
|
try:
|
||||||
with open(f"status/{self.base}{self.quote}.oldlong") as f:
|
with open(f"status/{self.base}{self.quote}.oldlong") as old_long_file_handler:
|
||||||
self.status.set_old_long(load(f))
|
self.status.set_old_long(load(old_long_file_handler))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
#self.write_to_log(time.strftime(f"[%Y/%m/%d %H:%M:%S] | {self.status.get_pair()} | Can't find old long file"))
|
#self.write_to_log(time.strftime(f"[%Y/%m/%d %H:%M:%S] | {self.status.get_pair()} | Can't find old long file"))
|
||||||
self.broker.logger.log_this(f"Can't file oldlong file. Exception: {e}",1,self.status.get_pair())
|
self.broker.logger.log_this(f"Can't file oldlong file. Exception: {e}",1,self.status.get_pair())
|
||||||
|
|
@ -639,17 +639,17 @@ class trader:
|
||||||
self.liquidate_base(ignore_profits=ignore_old_long, already_received_quote=already_received_quote)
|
self.liquidate_base(ignore_profits=ignore_old_long, already_received_quote=already_received_quote)
|
||||||
|
|
||||||
if self.config.get_liquidate_after_switch():
|
if self.config.get_liquidate_after_switch():
|
||||||
self.broker.logger.log_this("Liquidate after switch active. Raising quit flag.",2,self.status.get_pair())
|
self.broker.logger.log_this("Liquidate after switch active. Raising quit flag.",1,self.status.get_pair())
|
||||||
self.quit = True
|
self.quit = True
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#Rewrite config file (if it exists)
|
#Rewrite config file (if it exists)
|
||||||
if path.isfile(f"configs/{self.base}{self.quote}.bak") and path.isfile(f"configs/{self.base}{self.quote}.json"):
|
if path.isfile(f"configs/{self.base}{self.quote}.bak") and path.isfile(f"configs/{self.base}{self.quote}.json"):
|
||||||
self.broker.logger.log_this("Restoring config file from backup",2,self.status.get_pair())
|
self.broker.logger.log_this("Restoring config file from backup",2,self.status.get_pair())
|
||||||
with open(f"configs/{self.base}{self.quote}.bak") as c:
|
with open(f"configs/{self.base}{self.quote}.bak") as backup_config_file_handler:
|
||||||
old_config = load(c)
|
old_config = load(backup_config_file_handler)
|
||||||
with open(f"configs/{self.base}{self.quote}.json","w") as c:
|
with open(f"configs/{self.base}{self.quote}.json","w") as config_file_handler:
|
||||||
c.write(dumps(old_config, indent=4))
|
config_file_handler.write(dumps(old_config, indent=4))
|
||||||
if self.config.load_from_file()==1:
|
if self.config.load_from_file()==1:
|
||||||
self.config.reset_to_default()
|
self.config.reset_to_default()
|
||||||
else:
|
else:
|
||||||
|
|
@ -1545,8 +1545,8 @@ class trader:
|
||||||
#If there is an old_long file, also copy it
|
#If there is an old_long file, also copy it
|
||||||
if self.config.get_is_short() and self.status.get_old_long()!={}:
|
if self.config.get_is_short() and self.status.get_old_long()!={}:
|
||||||
try:
|
try:
|
||||||
with open(f"status/{self.base}{self.quote}.oldlong","w") as c:
|
with open(f"status/{self.base}{self.quote}.oldlong","w") as old_long_file_handler:
|
||||||
c.write(dumps(self.status.get_old_long(), indent=4))
|
old_long_file_handler.write(dumps(self.status.get_old_long(), indent=4))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.broker.logger.log_this(f"Exception while writing new old_long file: {e}",1,self.status.get_pair())
|
self.broker.logger.log_this(f"Exception while writing new old_long file: {e}",1,self.status.get_pair())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,8 @@ import calendar
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
from collections import deque
|
|
||||||
from typing import Iterable, List, Tuple
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from flask import Flask, jsonify, request, Response
|
from flask import Flask, jsonify, request
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue