Skip to content

Commit

Permalink
Revert "Cash reset (#27)" (#28)
Browse files Browse the repository at this point in the history
This reverts commit c662813.
  • Loading branch information
EtWnn authored May 18, 2021
1 parent c662813 commit a8a9062
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 35 deletions.
3 changes: 0 additions & 3 deletions CryptoPrice/retrievers/MetaRetriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ def get_path_prices(self, asset: str, ref_asset: str, timestamp: int,
:return: Metaprice reflecting the value calculated through a trading path
:rtype: Optional[MetaPrice]
"""
if asset == ref_asset:
yield MetaPrice(1, asset, ref_asset, [], source=set('',))
return
if preferred_assets is None:
preferred_assets = ['BTC', 'ETH']

Expand Down
32 changes: 11 additions & 21 deletions CryptoPrice/storage/DataBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,11 @@ def drop_table(self, table: Union[Table, str]):
:return: None
:rtype: None
"""
self.drop_tables([table])

def drop_tables(self, tables: List[Union[Table, str]]):
"""
Delete a list of tables if they exist
:param tables: list of tables to delete
:type tables: List[Union[Table, str]]
:return: None
:rtype: None
"""
for table in tables:
if isinstance(table, Table):
table = table.name
execution_order = f"DROP TABLE IF EXISTS {table}"
self.db_cursor.execute(execution_order)
self.commit()
if isinstance(table, Table):
table = table.name
execution_order = f"DROP TABLE IF EXISTS {table}"
self.db_cursor.execute(execution_order)
self.db_conn.commit()

def drop_all_tables(self):
"""
Expand All @@ -165,12 +153,14 @@ def drop_all_tables(self):
:return: None
:rtype: None
"""
tables = [t[1] for t in self.get_tables_descriptions()]
self.drop_tables(tables)
tables_desc = self.get_all_tables()
for table_desc in tables_desc:
self.drop_table(table_desc[1])
self.commit()

def get_tables_descriptions(self) -> List[Tuple]:
def get_all_tables(self) -> List[Tuple]:
"""
return the descriptions of all the tables existing in the database
return all the tables existing in the database
:return: tables descriptions
:rtype: List[Tuple]
Expand Down
11 changes: 0 additions & 11 deletions CryptoPrice/storage/KlineDataBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,3 @@ def add_cache_closest(self, asset: str, ref_asset: str, timeframe: TIMEFRAME, ti
row = (timestamp, closest_timestamp, window)
self.add_row(table, row, update_if_exists=True)

def drop_cache_tables(self):
"""
Delete all the cache tables stored in the database
:return: None
:rtype: None
"""
tables = [t[1] for t in self.get_tables_descriptions()]
tables = [table for table in tables if table.endswith('_cache')]
self.drop_tables(tables)

0 comments on commit a8a9062

Please sign in to comment.