Auto strategy close fix
This commit is contained in:
@ -16,10 +16,12 @@ def startUp():
|
||||
|
||||
if not(os.path.exists('data')):
|
||||
os.mkdir('data')
|
||||
if not(os.path.exists('data/backup')):
|
||||
os.mkdir('data/backup')
|
||||
|
||||
if os.path.exists(filePath):
|
||||
timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
|
||||
backupPath = (f'data/data_backup_{timestamp}.json')
|
||||
backupPath = (f'data/backup/data_backup_{timestamp}.json')
|
||||
shutil.copy(filePath, backupPath)
|
||||
generalLogger.info(f'JSON backup was created: {backupPath}')
|
||||
|
||||
@ -28,7 +30,7 @@ def startUp():
|
||||
generalLogger.info(f'New {filePath} created with empty JSON.')
|
||||
|
||||
|
||||
async def parseParams(params):
|
||||
def parseParams(params):
|
||||
# Returnes dictionary of string params as paramsLines in options
|
||||
paramsList = params.split()
|
||||
paramsDict = {}
|
||||
@ -39,7 +41,7 @@ async def parseParams(params):
|
||||
paramsDict[options.paramsLines[i]] = paramsList[i]
|
||||
return paramsDict
|
||||
|
||||
async def toDictPairParams(pair: str, params):
|
||||
def toDictPairParams(pair: str, params):
|
||||
# Returnes dictionary as pair:internal(params)
|
||||
paramsList = params.split()
|
||||
|
||||
@ -52,7 +54,7 @@ async def toDictPairParams(pair: str, params):
|
||||
return paramsDict
|
||||
|
||||
|
||||
async def checkPair(pair: str):
|
||||
def checkPair(pair: str):
|
||||
# Returnes 1 if pair exists and 0 if not
|
||||
currentData = {}
|
||||
try:
|
||||
@ -66,7 +68,7 @@ async def checkPair(pair: str):
|
||||
else:
|
||||
return 0
|
||||
|
||||
async def deletePair(pair: str):
|
||||
def deletePair(pair: str):
|
||||
# Returnes 0 if deleted successfully and -1 if not
|
||||
currentData = {}
|
||||
try:
|
||||
@ -85,9 +87,9 @@ async def deletePair(pair: str):
|
||||
generalLogger.info(f'Pair {pair} was not found in the data file when trying to delete it.')
|
||||
return -1
|
||||
|
||||
async def savePairParams(pair: str, params):
|
||||
def savePairParams(pair: str, params):
|
||||
# Saves or updates data in JSON
|
||||
newData = await toDictPairParams(pair, params)
|
||||
newData = toDictPairParams(pair, params)
|
||||
|
||||
if newData == -1:
|
||||
return -1
|
||||
@ -110,7 +112,7 @@ async def savePairParams(pair: str, params):
|
||||
return 0
|
||||
|
||||
|
||||
async def loadJson():
|
||||
def loadJson():
|
||||
# Returnes the contents of the JSON file as a dictionary
|
||||
data = {}
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user