Do not clean up other platforms' trades
This commit is contained in:
parent
6bf3daee4c
commit
d3b4d3ea21
|
@ -677,6 +677,11 @@ class Transactions(util.Base):
|
|||
return False
|
||||
return tx_data
|
||||
|
||||
def get_subclass(self, reference):
|
||||
obj = r.hget(f"trade.{reference}", "subclass")
|
||||
subclass = util.convert(obj)
|
||||
return subclass
|
||||
|
||||
def del_ref(self, reference):
|
||||
"""
|
||||
Delete a given reference from the Redis database.
|
||||
|
@ -687,7 +692,7 @@ class Transactions(util.Base):
|
|||
r.delete(f"trade.{reference}")
|
||||
r.delete(f"trade.{tx}.reference")
|
||||
|
||||
def cleanup(self, references):
|
||||
def cleanup(self, subclass, references):
|
||||
"""
|
||||
Reconcile the internal reference database with a given list of references.
|
||||
Delete all internal references not present in the list and clean up artifacts.
|
||||
|
@ -696,6 +701,7 @@ class Transactions(util.Base):
|
|||
"""
|
||||
for tx, reference in self.get_ref_map().items():
|
||||
if reference not in references:
|
||||
if self.get_subclass(reference) == subclass:
|
||||
self.log.info(f"Archiving trade reference: {reference} / TX: {tx}")
|
||||
r.rename(f"trade.{tx}.reference", f"archive.trade.{tx}.reference")
|
||||
r.rename(f"trade.{reference}", f"archive.trade.{reference}")
|
||||
|
@ -712,6 +718,7 @@ class Transactions(util.Base):
|
|||
for reference in refs:
|
||||
ref_data = util.convert(r.hgetall(f"trade.{reference}"))
|
||||
if not ref_data:
|
||||
print("NOT REF DATA")
|
||||
continue
|
||||
if ref_data["id"] == tx:
|
||||
return reference
|
||||
|
|
Loading…
Reference in New Issue