hootnot / oanda-api-v20

OANDA REST-V20 API wrapper. Easy access to OANDA's REST v20 API with oandapyV20 package. Checkout the Jupyter notebooks!
MIT License
402 stars 107 forks source link

Expiry time on Stop order not correct #184

Closed sword134 closed 3 years ago

sword134 commented 3 years ago

Hello,

I am trying to add an expiry time to a stoporder by taking the current time and adding 5 minutes. However on the Oanda trader platform it shows the expiry as tomorrow at a completely different timestamp.

I am using the following code

Cancel_Time = datetime.now() + timedelta(minutes=5)
mktOrder_DAX_Long = StopOrderRequest(instrument="DE30_EUR", units=1, price=highest_high, gtdTime=str(Cancel_Time), timeInForce="GTD")
hootnot commented 3 years ago

please read the documentation: https://developer.oanda.com/rest-live-v20/primitives-df/#DateTime

That means you should use datetime.utcnow() instead of datetime.now()