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

Order Conditions not working #33

Open
superhedge22 opened this issue Dec 28, 2021 · 3 comments
Open

Order Conditions not working #33

superhedge22 opened this issue Dec 28, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@superhedge22
Copy link

superhedge22 commented Dec 28, 2021

Hi,

It seems there's a problem with InitOrderCondition, the condition is not being passed upon OrderCondition, so the value is always 0. I tried initializing it with a TimeCondition and a margin condition, but this always crashes the ib client. I also tried to assert it to time condition, but both the asserted and original OrderConditioner doesn't seem to be carrying conType forward and since this variable isn't exported, it's not possible to set it from an outside package.

I did a workaround and created a factory function to solve my problem, but of course, this is not optimal.

func NewTimeCondition(time string, isMore bool, isConj bool) TimeCondition {
	oc := OrderCondition{
		conditionType:           3,
		IsConjunctionConnection: isConj,
	}
	tc := TimeCondition{
		OperatorCondition: OperatorCondition{oc, isMore},
		Time:              time,
	}
	return tc
}

I'm using golang 1.17/MacOS 12.0.1

@superhedge22
Copy link
Author

Investigating further, I discovered that price conditions also doesn't work. I will investigate and test further and suggest a pull request/patch

@hadrianl hadrianl added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Dec 31, 2021
@hadrianl
Copy link
Owner

OK! Thanks!

@pchavanne
Copy link
Contributor

The problem comes from the OrderCondition setter that doesn't have a pointer receiver.

func (oc OrderCondition) setCondType(condType int64) { oc.conditionType = condType }

So cond.setCondType(1) in InitOrderCondition has no effect.

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

No branches or pull requests

3 participants