-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Placing A Basic Order #13
Comments
Here is my example on how I do a buy (both market and limit orders): func NewContract(symbol string) ib.Contract {
return ib.Contract{
Symbol: symbol,
SecurityType: "STK",
Exchange: "SMART",
Currency: "USD",
}
}
func doBuy(engine *ib.Engine, symbol string, quantity uint64, market bool, price float64) {
request := ib.PlaceOrder{
Contract: NewContract(symbol),
}
request.Order, _ = ib.NewOrder()
request.Order.Action = "BUY"
request.Order.TotalQty = int64(quantity)
if market {
request.Order.OrderType = "MKT"
} else {
request.Order.OrderType = "LMT"
request.Order.LimitPrice = price
}
request.SetID(NextOrderID())
engine.Send(&request)
} Function I've got a functional command line programming using readline that I use for my current trading. If anyone is interesting I will work on making it a separate repository under my account. |
@dsouzae It would be great to see that code open sourced. Even if I wouldn't use it myself, seeing an example of all this together would be really helpful. |
I would also like to see the code. More examples are necessary, especially for getting started. It was your example @dsouzae in a ticket, that helped me getting started with gofinance/ib. |
I have created repository for my current version. It needs some clean up and proper documentation. But It should be relatively easy to read. |
I am trying to figure out how to place an order. Is this currently possible?
I found the
PlaceOrder
type, but am unclear on how to actually place the order. I found the.write
method on it, but it doesn't seem to be used anywhere and is private.The text was updated successfully, but these errors were encountered: