Wertpapieranzeige
Der Artikel "Wertpapieranzeige" beschreibt das Vorgehen zur Erzeugung einer komfortablen Anzeige verschiedener Wertpapier in einer Liste auf Basis des Modules 98_STOCKQUOTES.pm
Stockquotes
Die Einrichtung eines Depots mit dem Modul 98 STOCKQUOTES wird (Wo?) beschrieben. Für das folgende nehmen wir an, dass in dem Depot verschiedene Teildepots mit unterschiedlichen Währungen vorhanden sind, z.B. Depot_EUR für Euro, Depot_CAD für kanadische Dollar. == readingsGroup [code]define Depot_Detail readingsgroup < >,<Symbol>,<Stock>,<Value>,<Change_Rel>,<Change_Abs>,<Trend>,<Rate>,<Count>,<Cur> Depot_EUR:depot_cur_value_total,depot_p_change_total,depot_value_diff_total,depot_buy_value_total:t Depot_EUR:@2,<#1>,(.*)_name,#1_d_cur_value_total,#1_d_p_change_total,#1_d_value_diff_total,#1_close,#1_last,#1_d_stockcount, Depot_USD:depot_cur_value_total,depot_p_change_total,depot_value_diff_total,depot_buy_value_total:t Depot_USD:@2,<#1>,(.*)_name,#1_d_cur_value_total,#1_d_p_change_total,#1_d_value_diff_total,#1_close,#1_last,#1_d_stockcount,#1_currency Depot_CAD:depot_cur_value_total,depot_p_change_total,depot_value_diff_total,depot_buy_value_total:t Depot_CAD:@2,<#1>,(.*)_name,#1_d_cur_value_total,#1_d_p_change_total,#1_d_value_diff_total,#1_close,#1_last,#1_d_stockcount,#1_currency Depot_NOK:depot_cur_value_total,depot_p_change_total,depot_value_diff_total,depot_buy_value_total:t Depot_NOK:@2,<#1>,(.*)_name,#1_d_cur_value_total,#1_d_p_change_total,#1_d_value_diff_total,#1_close,#1_last,#1_d_stockcount,#1_currency Depot_GBP:depot_cur_value_total,depot_p_change_total,depot_value_diff_total,depot_buy_value_total:t Depot_GBP:@2,<#1>,(.*)_name,#1_d_cur_value_total,#1_d_p_change_total,#1_d_value_diff_total,#1_close,#1_last,#1_d_stockcount,#1_currency Depot_R:depot_cur_value_total,depot_p_change_total,depot_value_diff_total,depot_buy_value_total:t Depot_R:@2,<#1>,(.*)_name,#1_last,#1_close,#1_d_stockcount,#1_d_cur_value_total,#1_d_p_change_total,#1_d_value_diff_total,#1_currency
attr Depot_Detail valueColumns { 'depot_cur_value_total' => 'colspan="2"','depot_buy_value_total' => 'colspan="4"'}
attr Depot_Detail valueFormat {if($READING =~ /.*name/){$VALUE=~/.*\((.*)\).*/;;$VALUE=$1}
elsif($READING =~ /.*((cur_value_total)|(value_diff_total))/ && $DEVICE eq "Depot_EUR"){$VALUE.="€"} elsif($READING =~ /.*((cur_value_total)|(value_diff_total))/ && $DEVICE eq "Depot_R"){$VALUE.="€"} elsif($READING =~ /.*((cur_value_total)|(value_diff_total))/ && $DEVICE =~ /Depot_(.*)/ ){$VALUE=(int($VALUE/ReadingsVal("EUR_".$1,"rate",1)*100)/100)."€"} elsif($READING =~ /.*p_change_total/){$VALUE=(int($VALUE*10)/10)."%"} elsif($READING =~ /(.*)_close/ && $DEVICE eq "Depot_GBP" && $1 !~ /VEV.*/){my $tr=(100*ReadingsVal("$DEVICE",$1."_last",1)/ReadingsVal("$DEVICE",$1."_close",1)-1);(int(1000*$tr)/10)."%% ".(($tr>0.01)?"🢁":(($tr>0.001)?"🢅":(($tr>-0.001)?"🢂":(($tr>-0.01)?"🢆":"🢃")))) } elsif($READING =~ /(.*)_close/){my $tr=(ReadingsVal("$DEVICE",$1."_last",1)/ReadingsVal("$DEVICE",$1."_close",1)-1);(int(1000*$tr)/10)."%% ".(($tr>0.01)?"🢁":(($tr>0.001)?"🢅":(($tr>-0.001)?"🢂":(($tr>-0.01)?"🢆":"🢃")))) }}
attr Depot_Detail valueStyle {if($READING =~ /depot.*/ ){'style="background-color:#aaaaff;font-weight:bold;text-align:right"'}
elsif($READING =~ /.*cur_value_total/){'style="text-align:right"'} elsif($READING =~ /.*((p_change_total)|(d_value_diff_total))/ && $VALUE<0){'style="color:red;text-align:right"'} elsif($READING =~ /.*((p_change_total)|(d_value_diff_total))/ && $VALUE>0){'style="color:green;text-align:right"'} elsif($READING =~ /(.*)_close/ && $DEVICE eq "Depot_GBP" && $1 !~ /VEV.*/){my $tr=(100*ReadingsVal("$DEVICE",$1."_last",1)/ReadingsVal("$DEVICE",$1."_close",1)-1);'style="text-align:right;color:'.(($tr>0.01)?'green"':(($tr>0.001)?'#aaff44"':(($tr>-0.001)?'black"':(($tr>-0.01)?'#ffdd88"':'red"')))) } elsif($READING =~ /(.*)_close/){my $tr=(ReadingsVal("$DEVICE",$1."_last",1)/ReadingsVal("$DEVICE",$1."_close",1)-1);'style="text-align:right;color:'.(($tr>0.01)?'green"':(($tr>0.001)?'#aaff44"':(($tr>-0.001)?'black"':(($tr>-0.01)?'#ffdd88"':'red"')))) }}