Comments (3)
So I changed some code... I'm not very knowledgeable about GIT pulls and such, so I'll include my changes here if it helps.
From the Oanda docs, it appears that the gtdTime field was missing from the limit orders when a GTD order is used. So I made the following changes to the init function of the LimitOrderRequest class in requests/limitorder.py (I'm removing the big comment block for clarity.)
class LimitOrderRequest(BaseRequest):
"""create a LimitOrderRequest.
LimitOrderRequest is used to build the body for a LimitOrder.
The body can be used to pass to the OrderCreate endpoint.
"""
def __init__(self,
instrument,
units,
price,
positionFill=OrderPositionFill.DEFAULT,
clientExtensions=None,
takeProfitOnFill=None,
timeInForce=TimeInForce.GTC,
gtdTime = None, # inserting missing field for GTD trades
stopLossOnFill=None,
trailingStopLossOnFill=None,
tradeClientExtensions=None):
super(LimitOrderRequest, self).__init__()
# by default for a LIMIT order
self._data.update({"type": OrderType.LIMIT})
self._data.update({"timeInForce": timeInForce})
# required
self._data.update({"instrument": instrument})
self._data.update({"units": Units(units).value})
self._data.update({"price": PriceValue(price).value})
# Only if GTD
if timeInForce == 'GTD':
self._data.update({"gtdTime": gtdTime})
# optional
self._data.update({"positionFill": positionFill})
self._data.update({"clientExtensions": clientExtensions})
self._data.update({"takeProfitOnFill": takeProfitOnFill})
self._data.update({"stopLossOnFill": stopLossOnFill})
self._data.update({"trailingStopLossOnFill": trailingStopLossOnFill})
self._data.update({"tradeClientExtensions": tradeClientExtensions})
Also, the time value provided to gtdDate needs to be UTC. I used the following code:
from oandapyV20.types import DateTime
gtdTime = DateTime(datetime.utcnow() + timedelta(seconds = 30*60)).value
Hope this helps! Your stuff is great!
from oanda-api-v20.
Hi, I'm a bit limited available (holiday) , but it seems you found a missing parameter, gtdTime. Will come back to it.
from oanda-api-v20.
@mullenba fixed this one. Thanks!
from oanda-api-v20.
Related Issues (20)
- PositionClose HOT 2
- Streaming OHLC data? HOT 3
- `InstrumentsCandles` Returns Candles from a few days ago HOT 1
- Unit not accepting less than 1 HOT 2
- Expiry time on Stop order not correct HOT 1
- Allow floats as unit size instead of integers HOT 3
- Proxy uses HTTP and not HTTPS HOT 1
- daily candles seem to be shifted one day HOT 1
- ContentDecodingError with InstrumentsCandles HOT 3
- API Connection keeps closing HOT 2
- Wrong implementation of units - "rejectReason":"UNITS_INVALID" HOT 1
- Client Access Not working for Instruments call or any data call HOT 1
- question for Feite HOT 1
- question for hootnot 2 HOT 1
- Keep on getting `The provided request was forbidden` error. HOT 4
- question for feit HOT 1
- asyncio support?
- Extend the pricing endpoints
- Add asyncio support
- Wrong bar values?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oanda-api-v20.