@@ -206,6 +206,51 @@ same time. You can find the full description here:
206206 }
207207 }))
208208
209+ Order expiration
210+ ^^^^^^^^^^^^^^^^
211+ Order expiration is a trade option that allows you to automatically cancel old pending orders. By default orders have
212+ the expiration type `` ORDER_TIME_GTC `` , which means they won' t be canceled until the user' s request. `` ORDER_TIME_DAY ``
213+ means the order will be canceled at the end of the current trade day; `` ORDER_TIME_SPECIFIED `` means the order will be
214+ canceled at a specified time; `` ORDER_TIME_SPECIFIED_DAY `` means the order will be canceled at the end of the specified
215+ trade day. MetaTrader 4 supports only `` ORDER_TIME_GTC `` and `` ORDER_TIME_SPECIFIED `` .
216+ You can find the full description here:
217+ `https:// metaapi.cloud/ docs/ client/ restApi/ api/ trade/ # pending-order-expiration-settings <https://metaapi.cloud/docs/client/restApi/api/trade/#pending-order-expiration-settings>`_
218+
219+ .. code- block:: python
220+
221+ # without specified options, ORDER_TIME_GTC is applied
222+ print (await connection.create_limit_buy_order(' GBPUSD' , 0.07 , 1.0 , 0.9 , 2.0 ))
223+
224+ # specified expiration time
225+ print (await connection.create_limit_buy_order(
226+ ' GBPUSD' , 0.07 , 1.0 , 0.9 , 2.0 , {
227+ ' expiration' : {
228+ ' type' : ' ORDER_TIME_SPECIFIED' ,
229+ ' time' : datetime.now() + timedelta(days = 1 )
230+ }
231+ }
232+ ))
233+
234+ # specified expiration date
235+ print (await connection.create_limit_buy_order(
236+ ' GBPUSD' , 0.07 , 1.0 , 0.9 , 2.0 , {
237+ ' expiration' : {
238+ ' type' : ' ORDER_TIME_SPECIFIED_DAY' ,
239+ ' time' : datetime.now() + timedelta(days = 1 )
240+ }
241+ }
242+ ))
243+
244+ # expires at the end of the current day
245+ print (await connection.create_limit_buy_order(
246+ ' GBPUSD' , 0.07 , 1.0 , 0.9 , 2.0 , {
247+ ' expiration' : {
248+ ' type' : ' ORDER_TIME_SPECIFIED_DAY' ,
249+ ' time' : datetime.now() + timedelta(days = 1 )
250+ }
251+ }
252+ ))
253+
209254Monitoring account connection health and uptime
210255============================================== =
211256You can monitor account connection health using MetaApiConnection.health_monitor API .
0 commit comments