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

Rename OrderDuration to TimeInForce #1911

Merged

Conversation

StefanoRaggi
Copy link
Contributor

Description

This PR renames the following items:

  • OrderDuration enum -> TimeInForce
  • Order.Duration property -> Order.TimeInForce

Related Issue

QuantConnect/Lean.Brokerages.InteractiveBrokers#27

Motivation and Context

"Time In Force" is the standard term used in trading platforms and APIs:
https://www.investopedia.com/terms/t/timeinforce.asp

Requires Documentation Change

No.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/ect)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description or feature-<issue#>-<description>

"Time In Force" is the standard term used in trading platforms and APIs.
Copy link
Contributor

@mchandschuh mchandschuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few changes, I think especially the aliases will be nice for users.

/// </summary>
GTC,
GoodTilCancelled,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can alias these, such that, GTC = GoodTilCancelled -- support both the abbreviations as well as the full names.

Also, normally I would recommend that we 'phase out' the OrderDuration type name and associated values, but i practice it's never really used and not well documented either, so I think these changes are safe.

@@ -192,7 +192,7 @@ public void WorksWithJsonConvert()
'Time':'2010-03-04T14:31:00Z',
'Quantity':999,
'Status':3,
'Duration':0,
'TimeInForce':0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to update OrderJsonConverter to check for a Duration property in case TimeInForce does not exist?

@@ -654,7 +655,7 @@ private Order ConvertOrder(JToken order)
var gtdTime = order["gtdTime"];
if (gtdTime != null)
{
qcOrder.Duration = OrderDuration.Custom;
qcOrder.TimeInForce = TimeInForce.Custom;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to remember to come back here and properly set this to GTD when it gets added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, Custom will be renamed to GoodTilDate in the GTD PR

@@ -770,7 +770,7 @@ private Order ConvertOrder(RestV1.DataType.Order order)
qcOrder.Id = orderByBrokerageId.Id;
}

qcOrder.Duration = OrderDuration.Custom;
qcOrder.TimeInForce = TimeInForce.Custom;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will also become GTD when it gets added.

if (timeInForce == TimeInForceFactory.DAY)
return (OrderDuration)1; //.Day;
return (TimeInForce)1; //.Day;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will also need to remember this and the equivalent in the tradier brokerage when we add day time in force.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on the TimeInForce.Day PR now :)

Both Duration (old) and TimeInForce (new) JSON keys are deserialized into the Order.TimeInForce property.
Copy link
Contributor

@mchandschuh mchandschuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @StefanoRaggi! Changes look great!

@mchandschuh mchandschuh merged commit c272d11 into QuantConnect:master Apr 25, 2018
@StefanoRaggi StefanoRaggi deleted the feature-1093-time-in-force branch April 25, 2018 21:28
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

Successfully merging this pull request may close these issues.

2 participants