<?xml version="1.0" encoding="utf-8"?>

<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_WithATick" uiRep="TT With A Tick" version="15.114.13" providerID="TT" entryFile="algo.so">

    <HideFromUIComponents>
        <UIComponent>Dashboard</UIComponent>
    </HideFromUIComponents>

    <Parameter name="__instr_id" xsi:type="String_t" refValue="OrderInstrumentID" required="true" dir="In" updateable="false"/>

    <Parameter name="__order_quantity" xsi:type="Qty_t" refValue="OrderQty" required="true" dir="In" updateable="true"/>

    <Parameter name="__price" xsi:type="Price_t" refValue="OrderPrice"  required="true" dir="In" updateable="true"/>

    <Parameter name="__side" xsi:type="Int_t" refValue="OrderSide"  required="true" dir="In" updateable="false"/>

    <Parameter name="__account" xsi:type="String_t" refValue="OrderAccount"  required="true" dir="In" updateable="false"/>

    <!-- For now, hardcode parent to GTC -->
    <Parameter name="__tif" xsi:type="Int_t" constValue="2" required="true" dir="In" updateable="false"/>

    <Parameter name="ChildTIF" xsi:type="Int_t" refValue="OrderTif" required="true" dir="In" updateable="false" orderEntryFixtag="16903"/>

    <!-- Order type -->
    <Parameter name="__type" xsi:type="Int_t" initValue="eLimit" required="true" dir="In" updateable="false">
        <EnumPair enumID="eLimit" wireValue="2"/>
    </Parameter>

    <Parameter name="LimitTicksAway" xsi:type="Int_t" minValue="-999" maxValue="999" initValue="1" required="false" dir="In" updateable="true"  orderEntryFixtag="16912"/>

    <Parameter name="LimitPriceType" xsi:type="Int_t" initValue="eLtp" required="false" dir="In" updateable="false"  orderEntryFixtag="16911">
        <EnumPair enumID="eLtp" wireValue="3"/>
        <EnumPair enumID="eBid" wireValue="1"/>
        <EnumPair enumID="eAsk" wireValue="2"/>
        <EnumPair enumID="eSameSide" wireValue="6"/>
        <EnumPair enumID="eOppositeSide" wireValue="7"/>
    </Parameter>

    <!-- With a Tick -->
    <Parameter name="WithATickType" xsi:type="Int_t" initValue="eQty" required="false" dir="In" updateable="false" orderEntryFixtag="16921">
        <EnumPair enumID="eQty" wireValue="1"/>
        <EnumPair enumID="ePercent" wireValue="2"/>
    </Parameter>

    <Parameter name="WithATick" xsi:type="Qty_t" minValue="0.00000001" initValue="1" required="false" dir="In" updateable="true" orderEntryFixtag="16922"/>
    <Parameter name="AutoResubExpiredGTD" xsi:type="Boolean_t" initValue="false"  required="false" dir="In" updateable="false" orderEntryFixtag="16949"/>

    <lay:StrategyLayout>
        <lay:StrategyPanel orientation="VERTICAL">
            <lay:StrategyPanel name="WithATickPanel" orientation="HORIZONTAL">
                <lay:Control ID="WithATick_ctrl" label="With a Tick" parameterRef="WithATick"
                    xsi:type="lay:SingleSpinner_t"> </lay:Control>
                <lay:Control ID="WithATickType_ctrl" parameterRef="WithATickType"
                    xsi:type="lay:DropDownList_t" initValue="eQty">
                    <lay:ListItem enumID="eQty" uiRep="Qty"/>
                    <lay:ListItem enumID="ePercent" uiRep="%"/>
                </lay:Control>
            </lay:StrategyPanel>

            <lay:StrategyPanel name="ExchOrderTypePanel" orientation="HORIZONTAL">
                <lay:Control ID="ExchOrderType_ctrl" parameterRef="__type"
                    xsi:type="lay:DropDownList_t" initValue="eLimit" label="Exch order type">
                    <lay:ListItem enumID="eLimit" uiRep="Limit"/>
                </lay:Control>
                <lay:Control ID="Control_1" xsi:type="lay:HiddenField_t"> </lay:Control>
            </lay:StrategyPanel>

            <lay:StrategyPanel name="OffsetPanel" orientation="HORIZONTAL">
                <lay:Control ID="EnableOffset_ctrl" label="Offset (ticks)" initValue="false"
                    xsi:type="lay:CheckBox_t"> </lay:Control>
                <lay:Control ID="PriceOffset_ctrl" parameterRef="LimitTicksAway"
                    xsi:type="lay:SingleSpinner_t">
                    <flow:StateRule visible="true">
                        <val:Edit field="EnableOffset_ctrl" operator="EQ" value="true"/>
                    </flow:StateRule>
                </lay:Control>
                <lay:Control ID="PriceOffsetType_ctrl" parameterRef="LimitPriceType"
                    xsi:type="lay:DropDownList_t">
                    <flow:StateRule visible="true">
                        <val:Edit field="EnableOffset_ctrl" operator="EQ" value="true"/>
                    </flow:StateRule>
                    <lay:ListItem enumID="eLtp" uiRep="LTP"/>
                    <lay:ListItem enumID="eBid" uiRep="Bid"/>
                    <lay:ListItem enumID="eAsk" uiRep="Ask"/>
                    <lay:ListItem enumID="eSameSide" uiRep="Same Side"/>
                    <lay:ListItem enumID="eOppositeSide" uiRep="Opposite Side"/>
                </lay:Control>
            </lay:StrategyPanel>
            <lay:Control ID="AutoResub"
                    label="Auto-Resubmit Upon GTD Expiry"
                    initValue="false"
                    parameterRef="AutoResubExpiredGTD"
                    xsi:type="lay:CheckBox_t" />
        </lay:StrategyPanel>
    </lay:StrategyLayout>

    <val:StrategyEdit errorMessage="Limit Offset must be between -999 and 999">
        <val:Edit logicOperator="OR">
            <val:Edit logicOperator="AND">
                <val:Edit field="__type" operator="NE" value="1"/>
                <val:Edit field="LimitTicksAway" operator="NE" value=""/>
                <val:Edit field="LimitTicksAway" operator="LE" value="999"/>
                <val:Edit field="LimitTicksAway" operator="GE" value="-999"/>
            </val:Edit>
            <val:Edit field="__type" operator="EQ" value="1"/>
            <val:Edit field="LimitTicksAway" operator="EQ" value=""/>
        </val:Edit>
    </val:StrategyEdit>

    <val:StrategyEdit errorMessage="With a Tick quantity must be greater than 0">
        <val:Edit logicOperator="OR">
            <val:Edit field="WithATickType" operator="NE" value="1"/>
            <val:Edit logicOperator="AND">
                <val:Edit field="WithATickType" operator="EQ" value="1"/>
                <val:Edit field="WithATick" operator="NE" value=""/>
                <val:Edit field="WithATick" operator="GT" value="0"/>
            </val:Edit>
        </val:Edit>
    </val:StrategyEdit>

    <val:StrategyEdit errorMessage="With a Tick percentage must be positive">
        <val:Edit logicOperator="OR">
            <val:Edit field="WithATickType" operator="NE" value="2"/>
            <val:Edit logicOperator="AND">
                <val:Edit field="WithATickType" operator="EQ" value="2"/>
                <val:Edit field="WithATick" operator="NE" value=""/>
                <val:Edit field="WithATick" operator="GT" value="0"/>
            </val:Edit>
        </val:Edit>
    </val:StrategyEdit>

</Strategy>
