Skip to content
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

No support for creating orders with IOC TimeInForce #149

Closed
kaladinlight opened this issue Apr 7, 2021 · 0 comments
Closed

No support for creating orders with IOC TimeInForce #149

kaladinlight opened this issue Apr 7, 2021 · 0 comments

Comments

@kaladinlight
Copy link

client.CreateOrder does not have a function parameter to allow setting TimeInForce resulting in using the default GTE value every time. The only thought I had was to make use of the Option functions to manually overwrite the message as follows:

	// gymnastics to be able to set TimeInForce value to IOC (Immediate or Cancel)
	// https://docs.binance.org/trading-spec.html
	m := msg.CreateOrderMsg{
		Sender:      addr,
		ID:          "",
		Symbol:      sym,
		OrderType:   msg.OrderType.LIMIT,
		Side:        s,
		Price:       price,
		Quantity:    quantity,
		TimeInForce: msg.TimeInForce.IOC,
	}
	withMsg := func(txMsg *tx.StdSignMsg) *tx.StdSignMsg {
		txMsg.Msgs = []msg.Msg{m}
		return txMsg
	}

	createOrderResult, err := client.CreateOrder(base, quote, s, price, quantity, true, withMsg)
	if err != nil {
                panic(err)
	}

However, after looking more closely, the msg is overwritten with the order message created by CreateOrder regardless at: https://github.com/binance-chain/go-sdk/blob/8f0e838a5402c99cc08057a04eaece6dfd99181f/client/transaction/transaction.go#L101 resulting in no possibility to use the IOC TimeInForce as far as I can tell.

It would be a bit difficult to add without breaking the CreateOrder API as it stands. Can you think of any reasonable way to go about adding this functionality? Or please let me know if I am overlooking something and there is another way to accomplish this. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants