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
398 stars 107 forks source link

TAKE_PROFIT_ON_FILL_PRICE_PRECISION_EXCEEDED #149

Closed streetgainer closed 4 years ago

streetgainer commented 4 years ago

My OrderCreate data object is:

data={
              "order": {
                "takeProfitOnFill": {
                  "price": round(takeProfit,5)
                },
                "timeInForce": "FOK",
                "instrument": instrument,
                "units": units,
                "type": "MARKET",
                "positionFill": "DEFAULT",
              }
            }

I am continuously getting this error:

failed [400,{"orderRejectTransaction":{"type":"MARKET_ORDER_REJECT","rejectReason":"TAKE_PROFIT_ON_FILL_PRICE_PRECISION_EXCEEDED","instrument":"EUR_USD","units":"80000","timeInForce":"FOK","positionFill":"DEFAULT","takeProfitOnFill":{"price":"1.12247999999999","timeInForce":"GTC"},...... ........."The Take Profit on fill specified contains a price with more precision than is allowed by the Order's instrument","errorCode":"TAKE_PROFIT_ON_FILL_PRICE_PRECISION_EXCEEDED"}]

Can anyone shed some light as to why the padding of the 9's are showing up even though I have a round(takeProfit,5) for the price key in the data object?

hootnot commented 4 years ago

This is a message from the v20 interface of OANDA. The message is pretty clear I would say! Pls do your homework before posting an issue....1.12247999999999 is far too long don' t you think ?

Pls. post usage questions on a site like stackoverfow

I will close this issue

FWIW: you can make use of oandapyV20.types (check the docs!)

>>> import oandapyV20.types as tp
>>> takeProfit = 1.12247999999999
>>> print(tp.PriceValue(takeProfit).value)
1.12248
streetgainer commented 4 years ago

You closed the issue but never read my question towards the bottom of the original post, which was:

Can anyone shed some light as to why the padding of the 9's are showing up even though I have a round(takeProfit,5) for the price key in the data object?

In other words, the 9's are showing up despite the fact that I have the round(takeProfit,5) in the data object.

hootnot commented 4 years ago

You asked question that has nothing to do with the library:

It is up to you to tackle your issues. If you find one and you are pretty sure it is my lib your are welcome to drop the issue.

msarm commented 4 years ago

You closed the issue but never read my question towards the bottom of the original post, which was:

Can anyone shed some light as to why the padding of the 9's are showing up even though I have a round(takeProfit,5) for the price key in the data object?

In other words, the 9's are showing up despite the fact that I have the round(takeProfit,5) in the data object.

I had the same question long time back and finally figured out its not the issue with the library nor the Oanda system. If you see the API blueprint, the price field need to be passed as string instead decimal or float. Alternatively you can make use of tp.PriceValue as part of the library which converts to string.

apatton724 commented 9 months ago

@hootnot is pretty rude. Calm down buddy.

Thanks @msarm - that definitely did the trick.