One of an interface success (usability, etc.) is or should be its consistency. This is as much for Graphical User "Interface" or Application Programming "Interface".
Every plane flies, has wings, engine (1 or more), tail and landing gear. The ****pit of a Cessna 172 (small 4-seater) has the same basic instruments as a Boeing 767 and a space shuttle.
Why? Because they all perform the same basic functionality: fly!
The difference comes in extras: engine, size, capabilty (weight, take off speed, landing speed, etc.).
Problem 1.
------------
The order methods in NT6.5 however are by their interface, divided in two groups:
- those that return "void" (SetSopLoss(), SetTarget() ) and
- those that return "IOrder" (Enter...(), EXit..() )
"SetStopLoss()" works great, does all the orders management under the hood:
- Finds its related Open Orders (Entry and StopLoss)
- Does all the required cancellation and placing of new orders.
Until one wants to implement one of the "OnOrder/Position Update()" method, then there is nothing. No information available to the programmer about the orders created and managed by the "SetStopLoss()" method!
In the case of using the "OnOrder/Position Update()" methods, one has to dramatically change his/her code and replace the "SetStopLoss()" method with the "supposed to be equivalent" "ExitLong/ShortStop()" method!!!
In other words, if I want to take off on a Boeing 767 instead of a Cessna 172, the yoke/stick (equivalent of driving wheel) is suddenly on the roof or hidden to the pilot. Even Discovery/Columbia/Endeavour all have the yoke/stick at the expected place of a fixed-wing aircraft.
Problem 2. (related to use of "ExitLong/ShortStop()"
----------------------------------------------------
When implementing the "OnOrder...", "OnPosition..." methods, one has to check the "Token" (ID) of the orders. Meaning that every generated order has an ID, which is great.
However, when one wants to set a StopLoss to an existing open order, one has to store, manage and remember something called an 'fromEntrySignal' (A string Created by the programmer).
"ExitLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal)"
Although this might appear to be harmless, it makes the program more error-prone.
One of OO good practice is re-usability. Why no re-use the Token or ID already generated and is guaranteed to be unique?
Suggestions:
--------------
If ALL order handling methods used the IOrder class, there would be one place and one place only to set and/or retrieve orders info: IOrder.
This will make the API easier to use, consistent and introduce re-usability, which will increase maintainability of our code (and yours in some extent) and productivity of the API users (us).
Direct Benefit for you: Less support (on related items)!
Direct benefit to us: Plenty.
Cheers,
Obi
Comment