Key

• This line was added.
• This line was removed.
• Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version next

...

XY
truetrue
truefalse
falsetrue
falsefalse

Transforms:

d-

...

trans
RawWrangle true 'equals' step derive type:single value:(X == Y) ? 'yes' : 'no' as: 'equals' Formula type Single row formula Formula (X == Y) ? 'yes' : 'no' New column name New formula

Results:

Your output looks like the following:

...

GOOG10705.25674.5
FB10084.00101.125
AAPL50125.2597.375
MSFT10038.87545.25

TransformTransformation:

You can perform evaluations of this data using ternary operators to determine if you want to take action.

...

To assist in evaluation, you might first want to create columns that contain the cost (Basis) and the current value (CurrentValue) for each stock:

d-

...

trans
RawWrangle true 'Basis' step derive type:single value:(Qty * BuyPrice) as:'Basis'

...

p01Name Formula type Single row formula Formula (Qty * BuyPrice) New column name New formula

D trans
RawWrangle true 'CurrentValue' step derive type:single value:(Qty * CurrentPrice) as:'CurrentValue' Formula type Single row formula Formula (Qty * CurrentPrice) New column name New formula

Now, you can build some rules based on the spread between Basis and CurrentValue.

The most important action is determining if it is time to sell. The following rule writes a sell notification if the current value is \$1000 or more than the cost. Otherwise, no value is written to the action column.

d-

...

trans
RawWrangle true 'action' step derive type:single value:(CurrentValue - 1000 > Basis) ? 'sell' : '' as:'action' Formula type Single row formula Formula (CurrentValue - 1000 > Basis) ? 'sell' : '' New column name New formula

But what about buying more? The following transform is an edit to the previous one. In this new version, the sell test is performed, and if writes a buy action if the CurrentPrice is within 10% of the BuyPrice

This second evaluation is performed after the first one, as it replaces the else clause, which did nothing in the previous version. In the Recipe panel, click the previous transform and edit it, replacing it with the new version:

d-

...

trans
RawWrangle true 'action' step derive type:single value: ((CurrentValue - 1000) > Basis) ? 'sell' : ((abs(CurrentValue - Basis) <= (Basis * 0.1)) ? 'buy' : 'hold') as: 'action' Formula type Single row formula Formula ((CurrentValue - 1000) > Basis) ? 'sell' : ((abs(CurrentValue - Basis) <= (Basis * 0.1)) ? 'buy' : 'hold') New column name New formula

If neither test evaluates to true, the written action is hold

...

Info

NOTE: The following formatting inserts a dollar sign (\$) in front of the value, which changes the data type to String.

d-

...

trans
RawWrangle true step set col:BuyPrice value: NUMFORMAT(BuyPrice, '\$ ##,###.00') Columns BuyPrice Formula NUMFORMAT(BuyPrice, '\$ ##,###.00') Edit column with formula

Results:

After moving your columns, your dataset should look like the following, if you completed the number formatting steps:

...