@@ -86,10 +86,6 @@ def place_order(
8686 Order:order_confirmation: Dictionary containing the order confirmation data.
8787 """
8888
89- if dry_run :
90- previewOrders = "1"
91- else :
92- previewOrders = ""
9389
9490 if price_type == PriceType .MARKET :
9591 price = ""
@@ -100,8 +96,8 @@ def place_order(
10096 "orderbar_accountid" : "" ,
10197 "notional" : "yes" if notional else "" ,
10298 "stockorderpage" : "yes" ,
103- "submitOrders" : "1 " ,
104- "previewOrders" : previewOrders ,
99+ "submitOrders" : "" ,
100+ "previewOrders" : "1" ,
105101 "lotMethod" : "1" ,
106102 "accountType" : "1" ,
107103 "quoteprice" : "" ,
@@ -125,14 +121,38 @@ def place_order(
125121 "cond_compare_type0_1" : "2" ,
126122 "cond_compare_value0_1" : "" ,
127123 }
128-
124+
129125 order_data = BeautifulSoup (
130126 self .ft_session .post (
131127 url = urls .orderbar (), headers = urls .session_headers (), data = data
132128 ).text ,
133129 "xml" ,
134130 )
135131 order_confirmation = {}
132+ cdata = order_data .find ("actiondata" ).string
133+ cdata_soup = BeautifulSoup (cdata , "html.parser" )
134+ span = (
135+ cdata_soup .find ('div' , class_ = 'msg_bg' )
136+ .find ('div' , class_ = 'yellow box' )
137+ .find ('div' , class_ = 'error_msg' )
138+ .find ('div' , class_ = 'outbox' )
139+ .find ('div' , class_ = 'inbox' )
140+ .find ('span' )
141+ )
142+ if span :
143+ order_warning = span .text .strip ()
144+ order_confirmation ["warning" ] = order_warning
145+ data ["viewederror" ] = "1"
146+ if not dry_run :
147+ data ["previewOrders" ] = ""
148+ data ["submitOrders" ] = "1"
149+ order_data = BeautifulSoup (
150+ self .ft_session .post (
151+ url = urls .orderbar (), headers = urls .session_headers (), data = data
152+ ).text ,
153+ "xml" ,
154+ )
155+
136156 order_success = order_data .find ("success" ).text .strip ()
137157 order_confirmation ["success" ] = order_success
138158 action_data = order_data .find ("actiondata" ).text .strip ()
0 commit comments