question

Upvotes
Accepted
18 0 1 6

Can not send the order via python.

Hi Team, I've 3 accounts to send the order via API of r1XXXX5,r1XXXX7 and r1XXXX8. But only r1XXXX5 is work fine, the result message return "true". how can I do with another two account to send the order via API??

here is my code to run for these 3 account


import pythoncom
import win32com.client
# import pyodbc
from time import sleep

# Equity Order Entry Example
# REDI.ORDER: Used to send equities and futures orders
# REDI.OPTIONORDER: Used to send options orders
# REDI.SPREAD: Used to create spreads (e.g. pairs trading)
# REDI.TICKET: Used to create tickets (i.e. parent orders)
# REDI.QUERY: Used to obtain order information (e.g. order status)
# REDI.DONEAWAY: Doneaways are manual trade notifications (e.g. enter a doneaway to alert REDI of a trade done outside of REDI)
# REDI.TFLIST: Lists, or baskets, represent groups of tickets. These can be sent to brokers in batches, or waves, using the REDI Portfolio Trader.
# REDI.QUERY: Used to obtain order information (e.g. order status)
o = win32com.client.Dispatch("REDI.ORDER")#,clsctx=pythoncom.CLSCTX_LOCAL_SERVER,userName="DEMO")
# print("hello")

def sendOrder1():
    print('begin')
    side = 'Buy'
    # price = '43.33'
    quantity = '5'
    o.Side = side#'Sell'#'SBUX'#
    o.symbol = 'CLZ1' #'LCOZ1'#
    o.Quantity = quantity
    o.PriceType = 'Market'#'DEMOTEST'#'Limit''Limit'#   #'Market' no need to place the Price
    # o.Price = price
    o.TIF = 'Day'
    o.Exchange = 'DEMF DMA'#'DEMF DMA'#'DEMO DMA'#'REDI Eq DMA (DEMO)'#'REDI Fut DMA'#'DEMO SHARES'##'DEMO DMA'#'DEMF'#'BETA DMA'#'REDI Fut DMA (DEMF)'#'DEMO DESK'#'DEMO DMA'#'IFCM'#
    o.Account = 'DEMO'#'TESTACCT'#'r154725'#
    o.Ticket = 'Direct'#'ByPass'#'DEMF SHARE'#
    # 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) # ‘True’ if order submission was successful

sendOrder1()

redi-apiorder-entry
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.

Upvotes
Accepted
45.2k 103 43 60

@alongkot.b

It works when I changed the order of my code. I tested with C#.

            ORDER hOrder = new ORDER();
            object error = null;
            hOrder.Side = "BUY";
            hOrder.Symbol = "CLZ1";
            hOrder.Exchange = "DEMF DMA";
            hOrder.PriceType = "Market";           
            hOrder.Quantity = "100";          
            hOrder.TIF = "Day";           
            hOrder.Account = "EQUITY-TR";
            hOrder.Ticket = "Direct";           

            bool result = hOrder.Submit(ref error);
            if(result == false)
            {
                Console.WriteLine(error);
            }

Did you see an error in the msg variable when the Submit method returned false?

I am unable to verify the accounts. You may contact the REDI support directly via MyRefinitiv or contact your Refinitiv Sales or Account team.


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.

Upvotes
45.2k 103 43 60

@alongkot.b

If it returns false, you can check the error via the msg variable.

result = o.Submit(msg)
...
print(msg)

I tired the attached code and got this error.

Price is required
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.

Upvotes
18 0 1 6

Hi @Jirapongse,

as i test, Price will be used in case of PriceType is not market. anyway this configuration is work very well for account of "r1XXXX5" but not work for the others.

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.

Upvotes
18 0 1 6

Hi @Jirapongse ,

from the API side, I tried the same as you suggest to put the order as "limit" by specify the buy/sell price. it's work good with account of r1XXXX8. while the order of "market" do not work with account of r1XXXX8 but work with account of r1XXXX5


But all of the 3-account work well with GUI side. As i got message from the support team, redi.support@refinitiv.com. they config all 3 account to be the same. Are there any configuration we miss?


Thank you very much,

Petch

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.

Upvotes
45.2k 103 43 60

@alongkot.b

Have you updated the code?

Please try this one below and share the output.

import pythoncom
import win32com.client
# import pyodbc
from time import sleep 

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

def sendOrder1():
    print('begin')
    side = 'Buy'
    # price = '43.33'
    quantity = '5'
    o.Side = side
    o.symbol = 'CLZ1'
    o.Exchange = 'DEMF DMA'
    o.PriceType = 'Market'
    o.Quantity = quantity
    # o.Price = price
    o.TIF = 'Day'
    o.Account = 'Demo'
    o.Ticket = 'Bypass'
    # 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()
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.