GithubHelp home page GithubHelp logo

Comments (4)

JhnAshlnd avatar JhnAshlnd commented on June 6, 2024 1

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.

jessecooper avatar jessecooper commented on June 6, 2024

@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.

chotaGit avatar chotaGit commented on June 6, 2024
  1. For JSON, the application type has to be json

         "Content-Type": "application/json", "consumerKey": {'CONSUMER_KEY'}
    
  2. All values passed in the json payload have to be in quotes including numbers.

  3. 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.

bitbugprime avatar bitbugprime commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.