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.

1 Answer

· Write an Answer
Upvotes
Accepted
76.6k 238 52 72

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