Skip to content

Commit

Permalink
adding the function to check max unfilled open orders
Browse files Browse the repository at this point in the history
  • Loading branch information
ffahimi authored and Chocksy committed Aug 13, 2024
1 parent d306cef commit d4c2359
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Alpha/Utils/Scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ def hasReachedMaxActivePositions(self) -> bool:

# Do not open any new positions if we have reached the maximum for this strategy
return (len(openPositionsByStrategy) + len(workingOrdersByStrategy)) >= self.base.maxActivePositions

def hasReachedMaxOpenPositions(self) -> bool:
# Filter openPositions and workingOrders by strategyTag
workingOrdersByStrategy = {tag: order for tag, order in self.context.workingOrders.items() if order.strategyTag == self.base.nameTag}

# Do not open any new positions if we have reached the maximum for this strategy
return (len(workingOrdersByStrategy)) >= self.base.maxOpenPositions

def syncExpiryList(self, chain):
# The list of expiry dates will change once a day (at most). See if we have already processed this list for the current date
Expand Down Expand Up @@ -249,4 +256,3 @@ def filterByExpiry(self, chain, expiry=None, computeGreeks=False):

# Return the filtered contracts
return filteredChain

0 comments on commit d4c2359

Please sign in to comment.