<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<Strategy xmlns="http://www.fixprotocol.org/FIXatdl-1-1/Core"
          xmlns:val="http://www.fixprotocol.org/FIXatdl-1-1/Validation"
          xmlns:lay="http://www.fixprotocol.org/FIXatdl-1-1/Layout"
          xmlns:flow="http://www.fixprotocol.org/FIXatdl-1-1/Flow"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.fixprotocol.org/FIXatdl-1-1/Core tt-fixatdl-core-1-1.xsd"
          name="TT_VWAP+"
          uiRep="TT VWAP+"
          providerID="RCM"
          subtypeList="RCM,RCM2,RCM-LN,RCM-FF,RCM-SG"
          version="1.8">

    <Description>Seeks to minimize slippage vs VWAP benchmark by determining a trade schedule based on historical intraday volume patterns for the instrument.</Description>
    
    <Parameter xsi:type="String_t" name="strategyIdentifierTag" fixTag="9100" constValue="VWAP" definedByFIX="true" use="required" revertOnCxlRpl="true" mutableOnCxlRpl="false" />

    <!-- Order type -->
    <Parameter name="__type" xsi:type="Int_t" initValue="eMarket" required="true" dir="In" updateable="false">
        <EnumPair enumID="eMarket" wireValue="1"/>
        <EnumPair enumID="eLimit" wireValue="2"/>
        <EnumPair enumID="eStop" wireValue="3"/>
        <EnumPair enumID="eStopLimit" wireValue="4"/>
    </Parameter>

    <Parameter name="StopPrice" xsi:type="Price_t" minValue="0" fixTag="99" use="optional"/>

    <Parameter name="MaxParticipation" uiRep="Participation Rate" xsi:type="Float_t" fixTag="9103" use="optional" mutableOnCxlRpl="true" updateable="true" minValue="0.01" maxValue="99.99" orderEntryFixtag="9103"/>
    <Parameter name="Aggression" uiRep="Aggression" fixTag="9111" orderEntryFixtag="9111" use="optional" mutableOnCxlRpl="true" updateable="true" xsi:type="Int_t">
        <EnumPair enumID="null" wireValue="{NULL}" />
        <EnumPair enumID="zero" wireValue="0" />
        <EnumPair enumID="one" wireValue="1" />
        <EnumPair enumID="two" wireValue="2" />
        <EnumPair enumID="three" wireValue="3" />
        <EnumPair enumID="four" wireValue="4" />
        <EnumPair enumID="five" wireValue="5" />
        <EnumPair enumID="six" wireValue="6" />
        <EnumPair enumID="seven" wireValue="7" />
        <EnumPair enumID="eight" wireValue="8" />
        <EnumPair enumID="nine" wireValue="9" />
        <EnumPair enumID="ten" wireValue="10" />
    </Parameter>

    <!-- Strategy Parameters -->
    <Parameter name="IWouldPx" uiRep="I Would Price" xsi:type="Price_t" fixTag="9106" orderEntryFixtag="9106" use="optional" mutableOnCxlRpl="true" updateable="true" minValue="0"/>
    <Parameter name="StartTime" uiRep="Start Time" xsi:type="UTCTimestamp_t" fixTag="9101" use="optional" orderEntryFixtag="168"/>
    <Parameter name="EndTime" uiRep="End Time" xsi:type="UTCTimestamp_t" fixTag="9102" use="optional" orderEntryFixtag="126"/>
    <Parameter name="Duration" xsi:type="Int_t" fixTag="9202" orderEntryFixtag="9202" use="optional" updateable="true"/>

    <Parameter name="TriggerPrice" xsi:type="Price_t" minValue="0" fixTag="9190" orderEntryFixtag="9190" use="optional"/>
    <Parameter name="PostTriggerDuration" xsi:type="Int_t" fixTag="9191" orderEntryFixtag="9191" use="optional"/>

    <!-- GUI Layout -->
    <lay:StrategyLayout>

        <!-- Order Details -->
        <lay:StrategyPanel title="ParametersPanel" orientation="VERTICAL" class="main-panel">
            <lay:Control ID="Parameters_label" xsi:type="lay:Label_t" label="Order Details" class="atdl-panel-title"/>
            <lay:StrategyPanel orientation="VERTICAL" class="gradient-block">

                <!-- Order type -->
                <lay:StrategyPanel  orientation="HORIZONTAL">
                    <lay:Control ID="OrderTypeTogglePriceDropdown" parameterRef="__type" xsi:type="lay:DropDownList_t" initValue="eMarket" label="Order Type">
                        <lay:ListItem enumID="eMarket" uiRep="Market order"/>
                        <lay:ListItem enumID="eLimit" uiRep="Limit order"/>
                        <lay:ListItem enumID="eStop" uiRep="Stop order"/>
                        <lay:ListItem enumID="eStopLimit" uiRep="Stop Limit order"/>
                    </lay:Control>
                </lay:StrategyPanel>

                <lay:StrategyPanel name="StopPricePanel" orientation="HORIZONTAL">
                    <flow:StateRule visible="true">
                        <val:Edit logicOperator="OR">
                            <val:Edit field="OrderTypeTogglePriceDropdown" operator="EQ" value="eStop"/>
                            <val:Edit field="OrderTypeTogglePriceDropdown" operator="EQ" value="eStopLimit"/>
                        </val:Edit>
                    </flow:StateRule>
                    <lay:Control ID="StopPrice_ctrl" parameterRef="StopPrice" xsi:type="lay:SingleSpinner_t" initValue="0" label="Stop Price">
                    </lay:Control>
                </lay:StrategyPanel>

                <lay:StrategyPanel orientation="HORIZONTAL">
                    <lay:Control ID="MaxParticipationField" xsi:type="lay:SingleSpinner_t" label="Participation Rate" parameterRef="MaxParticipation" increment="0.01"/>
                </lay:StrategyPanel>

                <lay:StrategyPanel orientation="HORIZONTAL">
                    <lay:Control ID="control_1" xsi:type="lay:HiddenField_t"> </lay:Control>
                    <lay:Control ID="MaxParticipationFieldTooltip" xsi:type="lay:Label_t" label="(0.01 - 99.99)"> </lay:Control>
                </lay:StrategyPanel>

                <lay:StrategyPanel orientation="HORIZONTAL">
                    <lay:Control ID="AggressionField" xsi:type="lay:DropDownList_t" label="Aggression" parameterRef="Aggression"
                        tooltip="Influences how tightly to follow the schedule.">
                        <lay:ListItem enumID="null" uiRep="Default"/>
                        <lay:ListItem enumID="zero" uiRep="0"/>
                        <lay:ListItem enumID="one" uiRep="1"/>
                        <lay:ListItem enumID="two" uiRep="2"/>
                        <lay:ListItem enumID="three" uiRep="3"/>
                        <lay:ListItem enumID="four" uiRep="4"/>
                        <lay:ListItem enumID="five" uiRep="5"/>
                        <lay:ListItem enumID="six" uiRep="6"/>
                        <lay:ListItem enumID="seven" uiRep="7"/>
                        <lay:ListItem enumID="eight" uiRep="8"/>
                        <lay:ListItem enumID="nine" uiRep="9"/>
                        <lay:ListItem enumID="ten" uiRep="10"/>
                    </lay:Control>
                </lay:StrategyPanel>

                <lay:StrategyPanel orientation="HORIZONTAL">
                    <lay:Control ID="IWouldPxFieldAllowed" label="I Would Price" xsi:type="lay:CheckBox_t" initValue="false"/>
                    <lay:Control ID="IWouldPxField" xsi:type="lay:SingleSpinner_t" parameterRef="IWouldPx" increment="1"
                        tooltip="Order aggressively tries to fill if instrument reaches this price, irrespective of volume based tracking objectives.">
                        <flow:StateRule visible="true">
                            <val:Edit field="IWouldPxFieldAllowed" operator="EQ" value="true" />
                        </flow:StateRule>
                    </lay:Control>
                </lay:StrategyPanel>

            </lay:StrategyPanel>
        </lay:StrategyPanel>

        <!-- Precondition Details -->
        <lay:StrategyPanel name="PreconditionDetailsPanel" orientation="VERTICAL" class="main-panel">
            <lay:Control ID="PreconditionDetails_label" xsi:type="lay:Label_t" label="Precondition Details" class="atdl-panel-title"/>
            <lay:StrategyPanel orientation="VERTICAL" class="gradient-block">

                <!-- TT Custom Time Layout Section -->
                <lay:Control ID="Start" xsi:type="lay:DropDownList_t" initValue="eNow" label="Start Time">
                    <lay:ListItem enumID="eNow" uiRep="Now"/>
                    <lay:ListItem enumID="eTime" uiRep="Time"/>
                </lay:Control>

                <lay:StrategyPanel name="StartTimeControlPanel" orientation="HORIZONTAL">
                    <flow:StateRule visible="true">
                        <val:Edit field="Start" operator="EQ" value="eTime"/>
                    </flow:StateRule>
                    <lay:Control ID="c_dummy_1" xsi:type="lay:HiddenField_t"> </lay:Control>
                    <lay:Control ID="StartTimeClock" parameterRef="StartTime" xsi:type="lay:Clock_t" initValueMode="1" value="{now}"/>
                </lay:StrategyPanel>

                <lay:StrategyPanel orientation="HORIZONTAL" >
                    <lay:Control ID="End" xsi:type="lay:DropDownList_t" initValue="eDuration" label="End Time">
                        <lay:ListItem enumID="eDuration" uiRep="Duration"/>
                        <lay:ListItem enumID="eTime" uiRep="Time"/>
                    </lay:Control>
                </lay:StrategyPanel>

                <lay:StrategyPanel name="EndDurationControlPanel" orientation="HORIZONTAL" indent="true">
                    <flow:StateRule visible="true">
                        <val:Edit field="End" operator="EQ" value="eDuration"/>
                    </flow:StateRule>
                    <lay:Control ID="control_1" xsi:type="lay:HiddenField_t"/>
                    <lay:Control ID="Duration_ctrl" parameterRef="Duration" xsi:type="lay:TextField_t" initValue=""/> 
                    <lay:Control ID="MinutesLabel" xsi:type="lay:Label_t" label="minutes"/>
                </lay:StrategyPanel>

                <lay:StrategyPanel name="EndTimeControlPanel" orientation="HORIZONTAL">
                    <flow:StateRule visible="true">
                        <val:Edit field="End" operator="EQ" value="eTime"/>
                    </flow:StateRule>
                    <lay:Control ID="control_1" xsi:type="lay:HiddenField_t"> </lay:Control>
                    <lay:Control ID="ExpireTime_ctrl" parameterRef="EndTime" xsi:type="lay:Clock_t" initValueMode="1" initValue="{now}"/>
                </lay:StrategyPanel>  

                <lay:StrategyPanel orientation="HORIZONTAL">
                    <lay:Control ID="TriggerPriceField" xsi:type="lay:SingleSpinner_t" parameterRef="TriggerPrice" label="Trigger Price" increment="1"
                        tooltip="If set, BUY(SELL) order activates once LastTradePx less(greater) than or equal to Trigger Price."/>
                </lay:StrategyPanel>

                <lay:StrategyPanel orientation="HORIZONTAL">
                    <lay:Control ID="PostTriggerDuration" xsi:type="lay:TextField_t" label="Post Trigger Dur" parameterRef="PostTriggerDuration" initValue=""
                    tooltip="If set to positive value, max minutes to work order after StopPrice or TriggerPrice reached."/>
                    <lay:Control ID="MinutesLabel" xsi:type="lay:Label_t" label="minutes"/>
                </lay:StrategyPanel>

            </lay:StrategyPanel>
        </lay:StrategyPanel>

    </lay:StrategyLayout>

    <!-- TT Clock Input Validation -->
    <val:StrategyEdit errorMessage="End Time should be later than Start Time">
        <val:Edit logicOperator="OR">
            <val:Edit field="StartTime" operator="NX"/>
            <val:Edit field="EndTime" operator="NX"/>
            <val:Edit field="EndTime" operator="GT" field2="StartTime"/>
        </val:Edit>
    </val:StrategyEdit>

    <val:StrategyEdit errorMessage="Use of Duration and End Time not allowed">
        <val:Edit logicOperator="OR">
            <val:Edit field="Duration" operator="NX"/>
            <val:Edit field="EndTime" operator="NX"/>
        </val:Edit>
    </val:StrategyEdit>

</Strategy>
