Skip to content

Commit

Permalink
Merge pull request #49 from nkaz001/fix_order_sequence
Browse files Browse the repository at this point in the history
Fix order sequence error due to delays
  • Loading branch information
nkaz001 authored Oct 25, 2023
2 parents 7f81263 + 4a4207f commit 92f1d64
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hftbacktest/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ def __init__(self):
def append(self, order, timestamp):
timestamp = int(timestamp)

# Prevents the order sequence from being out of order.
if len(self.order_list) > 0:
_, latest_timestamp = self.order_list[-1]
if timestamp < latest_timestamp:
timestamp = latest_timestamp

self.order_list.append((order, timestamp))

if order.order_id in self.orders:
Expand Down

0 comments on commit 92f1d64

Please sign in to comment.