"Time series differentiation example"

haddock
haddock New Altair Community Member
edited November 5 in Community Q&A
I've been playing around with 4.4 and have come across a real gem for time-series miners, here is an example of it at work...
<operator name="Root" class="Process" expanded="yes">
    <operator name="SingleMacroDefinition" class="SingleMacroDefinition">
        <parameter key="macro" value="Symbol"/>
        <parameter key="value" value="&#39;USDJPY&#39;"/>
    </operator>
    <operator name="DatabaseExampleSource" class="DatabaseExampleSource">
        <parameter key="database_system" value="Microsoft SQL Server (Microsoft)"/>
        <parameter key="database_url" value="jdbc:sqlserver://localhost:1433;databaseName=Tradestation"/>
        <parameter key="username" value="sa"/>
        <parameter key="password" value="wL8/6ZO7YrXKa8XgQd4v7g=="/>
        <parameter key="query" value="SELECT [DateTime], FROM [Updates] WHERE Symbol=%{Symbol} and Year(DateTime)&gt;2007&#10;order by [DateTime]"/>
        <parameter key="id_attribute" value="DateTime"/>
    </operator>
    <operator name="CSVExampleSetWriter" class="CSVExampleSetWriter">
        <parameter key="csv_file" value="Close.txt"/>
    </operator>
    <operator name="CSVExampleSource" class="CSVExampleSource">
        <parameter key="filename" value="Close.txt"/>
    </operator>
    <operator name="IteratingOperatorChain" class="IteratingOperatorChain" expanded="yes">
        <parameter key="iterations" value="50"/>
        <operator name="DifferentiateSeries" class="DifferentiateSeries">
            <parameter key="attribute_name" value="C"/>
            <parameter key="change_mode" value="percentage"/>
            <parameter key="lag" value="%{a}"/>
        </operator>
        <operator name="ChangeAttributeNamesReplace" class="ChangeAttributeNamesReplace">
            <parameter key="attributes" value="change.*"/>
            <parameter key="replace_what" value="\(|\)"/>
            <parameter key="replace_by" value="_"/>
            <parameter key="apply_on_special" value="false"/>
        </operator>
        <operator name="AttributeConstruction" class="AttributeConstruction">
            <list key="function_descriptions">
              <parameter key="%{Symbol}_%{a}" value="change_C_"/>
            </list>
            <parameter key="use_standard_constants" value="false"/>
        </operator>
        <operator name="FeatureNameFilter" class="FeatureNameFilter">
            <parameter key="skip_features_with_name" value="change.*"/>
        </operator>
    </operator>
</operator>
You'll need to put the attached 'Close.txt' file in the same directory as the XML process to get it to go. Database gnomes also take note of the SQL query in the disabled database operator. Yes, you can stuff macros into queries  8)

I do rather too much series grinding, and used to do most pre-prep on the server, this by comparison is lightning quick, so I'm one happy bunny this afternoon. Merci beaucoup RM.

[attachment deleted by admin]

Answers

  • IngoRM
    IngoRM New Altair Community Member
    Thanks! Nice to hear that somebody else also like it  ;D

    Cheers,
    Ingo