Skip to content

Commit

Permalink
break fetching fills if identical
Browse files Browse the repository at this point in the history
  • Loading branch information
enarjord committed Oct 15, 2024
1 parent f17db69 commit c0cec29
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/exchanges/bybit.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ async def fetch_fills(self, start_time, end_time, limit=None):
if end_time is None:
end_time = int(self.get_exchange_time() + 1000 * 60 * 60 * 4)
all_fetched_fills = []
prev_hash = ""
for _ in range(100):
fills = await self.cca.fetch_my_trades(
limit=limit, params={"paginate": True, "endTime": int(end_time)}
Expand All @@ -394,6 +395,10 @@ async def fetch_fills(self, start_time, end_time, limit=None):
all_fetched_fills += fills
if fills[0]["timestamp"] <= start_time:
break
new_hash = calc_hash([x["id"] for x in fills])
if new_hash == prev_hash:
break
prev_hash = new_hash
logging.info(
f"fetched fills from {fills[0]['datetime']} to {fills[-1]['datetime']} n fills: {len(fills)}"
)
Expand Down

0 comments on commit c0cec29

Please sign in to comment.