Back

How to set filter parameter to call self.Transactions.GetOpenOrderTickets( filter = null )

From Documentation:

# Get an enumerable of open QuantConnect.Orders.OrderTicket for the specified
# symbol
self.GetOpenOrderTickets(filter = null):
return List<OrderTicket>

 

My Code:


otFilter = lambda ot: ( ot.Symbol == OrderTicket.Symbol and self.OpenTag in OrderTicket.Tag )
OTList = self.Transactions.GetOpenOrderTickets(otFilter)

 

 

 

Error Message:

Runtime Error: Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the GetOpenOrderTickets method. Please checkout the API documentation. at OnOrderEvent in main.py:line 298 :: OTList = self.Transactions.GetOpenOrderTickets(otFilter) TypeError : No method matches given arguments for GetOpenOrderTickets

 

How do I set and pass correct filter parameter to function all   self.Transactions.GetOpenOrderTickets( filter = null )   ?    Can you point me to any pytho example code? 

 

Thank you in advance.

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hey Shailesh,

The error is being thrown because the filter function you are passing in is not in the correct format.
Specifically, the latter part of your lambda function:

self.OpenTag in OrderTicket.Tag

This part doesn't seem to make sense in the context that you are posting.

Maybe you could try using GetOpenOrderTickets(symbol).

OTList = GetOpenOrderTickets(OrderTicket.Symbol)

#and then filter for tags
#Not sure what you are exactly filtering for in your code
#But here's an example

filteredOTList = [ot for ot in OTList if ot.Tag is in self.openTags]

If you attach a backtest to your post, we might be able to more precisely debug your issue.

Hope that helped!

Best
Rahul

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Thank You..

I understand that your solution gets the whole list and then filter it further..  OpenTag is a string "open" and I want to select all the orderTickets for which Order.Tag contains the word string "open".

If you could provide me any sample call to  GetOpenOrderTickets() with filter function with more than one test conditions will be great.   

Thanks

Shailesh.

0

Hey Shailesh,

Here's an example of a filter function with more than one test condition using the parameters from your code:
 

class UncoupledCalibratedInterceptor(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 12, 13) # Set Start Date
self.SetEndDate(2019, 12, 18) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.AddEquity("SPY", Resolution.Hour)
self.OpenTag = "open"
def OnData(self, data):
#Some Trial Trades
self.MarketOrder("SPY", 1)
OrderTicket = self.LimitOrder("SPY", -1, self.Securities["SPY"].Close * 1.002)
#We must check whether "open" is in our ot.Tag
otFilter = lambda ot: ( ot.Symbol == OrderTicker.Symbol and self.OpenTag in ot.Tag )
#We then pass our filter function to the GetOpenOrderTickets method
OTList = self.Transactions.GetOpenOrderTickets(filter = otFilter)

Best
Rahul

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Thank You Rahul. 

Though I was developer some 25 years ago, I am new to QC and new to python.  

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed