Comments (4)
Turns out if you specify the response format as json it doesn't work, switching it back to xml makes it work; how do I obtain the xml response as it doesn't appear on the terminal?
from pyetrade.
@JhnAshlnd sorry for the late response to this. I am only now finding some open time to continue work on this project. I am going to refactor the orders API to be more like the market, account and alert API in regards to how the resp_format
is set and change the xml parsing lib over to xmltodict
. A lot of the etrade v1 APIs only work with xml
but there is no documentation around what supports json
and what will not. Because of this I am going to make all methods default to xml but the return will give a dict
just the same as if it was a json response. This is the behavior of interfaces that have been refactored. The refactor on orders is currently in motion but I do not have an eta on that.
Now with the current order implementation if you set resp_format=None
it should return a parsed dict of the xml response. If you set it to xml
it should just give you the raw string of the response from the API and you can use whatever parser you want. I understand this is odd and not very intuitive behavior that I will address in the refactor.
from pyetrade.
-
For JSON, the application type has to be json
"Content-Type": "application/json", "consumerKey": {'CONSUMER_KEY'}
-
All values passed in the json payload have to be in quotes including numbers.
-
Before submitting the order, the order has to be previewed. And all the fields of the previewd order have to be included in the PlaceOrderRequest Payload
"PreviewOrderRequestPayload": {
"PreviewOrderRequest": {
"orderType": "$orderType",
"clientOrderId": "$clientOrderId",
"Order": [{
"allOrNone": "false",
"priceType": "LIMIT",
"limitPrice": "$limitPrice",
"stopPrice": "0",
"orderTerm": "GOOD_FOR_DAY",
"marketSession": "REGULAR",
"Instrument": [{
"Product": {
"symbol": "$symbol",
"securityType": "$securityType",
"callPut": "$callPut",
"expiryYear": "$expiryYear",
"expiryMonth": "$expiryMonth",
"expiryDay": "$expiryDay",
"strikePrice": "$strikePrice"
},
"orderAction": "$orderAction",
"orderedQuantity": "$orderedQuantity",
"quantity": "$quantity"
}
]
}
]
}
},
"PlaceOrderRequestPayload": {
"PlaceOrderRequest": {
"orderType": "$orderType",
"clientOrderId": "$clientOrderId",
"PreviewIds": [{
"previewId": "$previewId"
}
],
"Order": [{
"allOrNone": "false",
"priceType": "LIMIT",
"limitPrice": "$limitPrice",
"stopPrice": "0",
"orderTerm": "GOOD_FOR_DAY",
"marketSession": "REGULAR",
"Instrument": [{
"Product": {
"symbol": "$symbol",
"securityType": "$securityType",
"callPut": "$callPut",
"expiryYear": "$expiryYear",
"expiryMonth": "$expiryMonth",
"expiryDay": "$expiryDay",
"strikePrice": "$strikePrice"
},
"orderAction": "$orderAction",
"orderedQuantity": "$orderedQuantity",
"quantity": "$quantity"
}
]
}
]
}
},
from pyetrade.
3. Before submitting the order, the order has to be previewed
It does? The API docs claim that preview is unnecessary and that you can submit orders directly. Preview is stupid anyway for algorithmic trading.
from pyetrade.
Related Issues (20)
- Are contingent orders actually supported? HOT 1
- oauth problems HOT 1
- oauth issue HOT 6
- [Warning!] ETrade API *sever* bug: Stop Price and Trailing Stop Parameter are swapped! HOT 3
- Preview order working but place order responding with same error again and again. HOT 1
- Verification code HOT 2
- Automatic Authentication HOT 2
- 401 Client Error: Unauthorized for URL in prod HOT 1
- auth server down on 2022-06-29
- 401 Client Error: Unauthorized for url HOT 2
- HTTPError: 401 Client Error: Unauthorized for url HOT 1
- oauth no longer working HOT 8
- Keep getting requests.exceptions.HTTPError: 400 Client Error: Bad Request for url when trying to place options order. HOT 8
- Exception: 500 Server Error: Internal Server Error for url When using preview_equity_order function
- Question about Etrade API HOT 2
- get_quote for an option call returns the put HOT 1
- Q: anyone saw this error: Token request failed with code 500 HOT 2
- SSL errors with Python 3.11 HOT 14
- urllib3 version needs to be 1.xx.xx HOT 2
- Cannot grab optionchain data with ETrade API in Python HOT 2
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 pyetrade.