question

Upvotes
Accepted
1 0 0 1

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.

#productpython apivwap
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @mk02 ,

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?

If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,
AHS

@mk02

Hi,

Please be informed that a reply has been verified as correct in answering the question, and marked as such.

Thanks,

AHS

1 Answer

· Write an Answer
Upvotes
Accepted
79.5k 253 52 74

@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.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.