ig-python / trading-ig

A lightweight Python wrapper for the IG Markets API
https://trading-ig.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
308 stars 196 forks source link

timeInForce for create_open_position() and close_open_position() #303

Closed zansibal closed 9 months ago

zansibal commented 9 months ago

The create_open_position() and close_open_position() do not have the timeInForce parameter implemented. I need it, and I would like to create a PR for it.

https://labs.ig.com/rest-trading-api-reference/service-detail?id=678

Should I make the parameter positional (same as for other parameters) requiring the user to choose either "EXECUTE_AND_ELIMINATE" or "FILL_OR_KILL"? This would not be backwards compatible. The other option would be to give it a default value None, and assume (and possibly verify) the same behaviour as today. Both have pros and cons.

I believe the current implementation, by not sending the parameter at all, defaults to "FILL_OR_KILL" on IG.

Any thoughts?

bug-or-feature commented 9 months ago

hey @zansibal - best to keep it backwards compatible I think. We don't want to break anyone's code if they update to latest. Make it a named param with default of None, and only add it to the params dict if it is not None. Like in update_open_position()

zansibal commented 9 months ago

Feature implemented

bug-or-feature commented 9 months ago

thanks for contributing

zansibal commented 9 months ago

You should have the thanks, for maintaining 👍