Polish the order surface: numeric OrderFee, flat combo group ids, tag tolerance and notional targeting - #9676
Draft
jhonabreul wants to merge 1 commit into
Draft
Conversation
… tolerance and notional targeting - OrderFee: flat Amount/Currency shortcuts plus arithmetic and comparison operators delegating to Value.Amount, surfaced in Python as __add__/__radd__/__gt__/... via pythonnet's operator mapping - OrderEvent.OrderFeeAmount and OrderEvent.GroupId shortcuts - Order.GroupOrderManagerId shortcut for combo orders - ComboOrderTicket: non-generic List<OrderTicket> returned by the combo order methods with Tickets/GroupOrderManagerId/Filled aggregation - MarketOrder(PyObject, decimal, string): accepts the tag in the third positional slot from Python - Liquidate(string): resolves known tickers, fails pointing to the tag parameter for unknown strings such as a tag slipped into the symbol slot - OrderTargetNotional: targets an absolute notional value including the contract multiplier, rounding to the security lot size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Python algorithms repeatedly crash on the first names they reach for on the order surface. For example:
The change adds the flat shortcuts and operators these calls expect:
OrderFee.Amount/Currencyshortcuts, plus arithmetic and comparison operators delegating toValue.Amount, sofee1 + fee2,sum(fees)andfee > 0work from Python.OrderEvent.OrderFeeAmount,OrderEvent.GroupIdandOrder.GroupOrderManagerIdshortcuts.ComboOrderTicketreturned by the combo order methods: holds the leg tickets and aggregates the group (Tickets,GroupOrderManagerId,Filled). It subclassesList<OrderTicket>, so existing iteration/indexing keeps working in both languages.market_order(symbol, 10, "entry"): Python-only overload accepting the tag in the third positional slot.Liquidate(string): resolves known tickers; unknown strings fail with a prescriptive error (pointing atLiquidate(tag: ...)) instead of a silent no-op or an overload dump.OrderTargetNotional(symbol, targetNotional): market order adjusting holdings to an absolute notional; handles contract multipliers, lot-size rounding, and returnsnullwhen already at target.Deferred: an
OrderStatus.REJECTEDalias forINVALID(duplicate enum values change either the log or the JSON surface), andfloat(order_fee)(needs an interop-layer__float__slot; theAmountshortcut covers it).Related Issue
N/A
Motivation and Context
These are the exact names and operations users try first, and each was a recurring source of failed backtests.
Requires Documentation Change
The new public members are candidates for documentation once merged.
How Has This Been Tested?
OrderSurfaceShortcutsRegressionAlgorithm(C# + Python): asserts every shortcut, the combo ticket aggregation, the positional tag, theLiquidateerror andOrderTargetNotional. Identical statistics in both languages.OrderFeeTests(shortcuts, operators, JSON shape unchanged),ComboOrderTicketTests,OrderEventTests/OrderTestsshortcut cases,AlgorithmTradingTests(LiquidateandOrderTargetNotionalmath incl. futures multiplier).Tests.Common.Orders994,Tests.Algorithm12,719,Tests.Python1,297, combo/liquidate regression algorithms 24 — all passed.Compatibility note: the combo order methods now return
ComboOrderTicket(aList<OrderTicket>subclass — source compatible), andLiquidatewith an unknown ticker now raises instead of warning-and-ignoring.Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>