Custom VWAP Order using python for REDI API

Hi, I'm accessing the REDI API using python on Windows 11. I'm trying to send a VWAP order and I want to include custom algo specifications including Start Time, End Time, and Exec Style. These fields are documented in the REDI API Specifications in section 3.1.6 Algorithm Order Entry, but I don't know how to implement them in python. Please provide any advice.

Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @mk02

    Thanks for reaching out to us.

    The code looks like this:

    import pythoncom
    import win32com.client
    from time import sleep 


    o = win32com.client.Dispatch("REDI.ORDER")#,clsctx=pythoncom.CLSCTX_LOCAL_SERVER,userName="DEMO")


    def sendOrder1():  
        side = 'Buy'
        price = '43.33'
        quantity = '100'
        o.Side = side
        o.symbol = 'IBM'
        o.Exchange = 'DEMO algo'
        o.Quantity = quantity
        o.PriceType = 'VWAP DEMO'   
        o.Price = price
        o.TIF = 'Day'
        o.Account = 'EQUITY-TR'
        o.Ticket = 'Bypass'
        o.SetNewVariable("(MB) Start Time", "155500")
        o.SetNewVariable("(MB) End Time", "160000")
    o.SetNewVariable("(MB) Exec Style", "Aggressive")

        # Prepare a variable which can handle returned values from submit method of the order
        print('send')
        msg = win32com.client.VARIANT(win32com.client.pythoncom.VT_BYREF | win32com.client.pythoncom.VT_VARIANT, None)
        # Send an options order
        result = o.Submit(msg)
        print(result) 
        print(msg)
       
     
    sendOrder1()

    I hope that this information is of help.