view release on metacpan or search on metacpan
lib/App/financeta/gui.pm view on Meta::CPAN
ylabel => ['Price', textcolor => 'rgb "yellow"'],
xdata => 'time',
xtics => {format => '%Y-%m-%d', rotate => -90, textcolor => 'orange', },
ytics => {textcolor => 'orange'},
label => [1, $self->brand, textcolor => 'rgb "cyan"', at => "graph 0.90,0.03"],
%addon_gen,
},
{
with => 'financebars',
linecolor => 'white',
legend => 'Price',
},
$data(,(0)), $data(,(1)), $data(,(2)), $data(,(3)), $data(,(4)),
@general_plot,
);
if (@addon_plot) {
$pwin->plot({
%binmode,
object => '1',
title => '',
key => ['on', 'outside', textcolor => 'rgb "yellow"'],
lib/App/financeta/gui.pm view on Meta::CPAN
ytics => {textcolor => 'orange'},
bmargin => 0,
lmargin => 9,
rmargin => 2,
%addon_gen,
label => [1, $self->brand, textcolor => 'rgb "cyan"', at => "graph 0.90,0.03"],
},
{
with => 'financebars',
linecolor => 'white',
legend => 'Price',
},
$data(,(0)), $data(,(1)), $data(,(2)), $data(,(3)), $data(,(4)),
@general_plot,
);
if (@addon_plot) {
$pwin->plot({
%binmode,
object => '1',
title => '',
key => ['on', 'outside', textcolor => 'rgb "yellow"'],
lib/App/financeta/gui.pm view on Meta::CPAN
ytics => {textcolor => 'orange'},
bmargin => 0,
tmargin => 0,
lmargin => 9,
rmargin => 2,
%addon_vol,
label => [1, "", at => "graph 0.90,0.03"],
},
{
with => 'impulses',
legend => 'Volume',
linecolor => 'cyan',
},
$data(,(0)), $data(,(5)) / 1e6,
@volume_plot,
);
} elsif ($type eq 'CANDLE') {
my %addon_gen = ();
if (@addon_plot) {
$addon_gen{size} = ["1, 0.7"];
$addon_gen{origin} = [0, 0.3];
lib/App/financeta/gui.pm view on Meta::CPAN
ylabel => ['Price', textcolor => 'rgb "yellow"'],
ytics => {textcolor => 'orange'},
xdata => 'time',
xtics => {format => '%Y-%m-%d', rotate => -90, textcolor => 'orange', },
label => [1, $self->brand, textcolor => 'rgb "cyan"', at => "graph 0.90,0.03"],
%addon_gen,
},
{
with => 'candlesticks',
linecolor => 'white',
legend => 'Price',
},
$data(,(0)), $data(,(1)), $data(,(2)), $data(,(3)), $data(,(4)),
@general_plot,
@candle_plot,
);
if (@addon_plot) {
$pwin->plot({
%binmode,
object => '1',
title => '',
lib/App/financeta/gui.pm view on Meta::CPAN
tmargin => '',
bmargin => 0,
lmargin => 9,
rmargin => 2,
%addon_gen,
label => [1, $self->brand, textcolor => 'rgb "cyan"', at => "graph 0.90,0.03"],
},
{
with => 'candlesticks',
linecolor => 'white',
legend => 'Price',
},
$data(,(0)), $data(,(1)), $data(,(2)), $data(,(3)), $data(,(4)),
@general_plot,
@candle_plot,
);
if (@addon_plot) {
$pwin->plot({
%binmode,
object => '1',
title => '',
lib/App/financeta/gui.pm view on Meta::CPAN
ytics => {textcolor => 'orange'},
bmargin => 0,
tmargin => 0,
lmargin => 9,
rmargin => 2,
%addon_vol,
label => [1, "", at => "graph 0.90,0.03"],
},
{
with => 'impulses',
legend => 'Volume',
linecolor => 'cyan',
},
$data(,(0)), $data(,(5)) / 1e6,
@volume_plot,
);
} elsif ($type eq 'CLOSEV') {
my %addon_gen = ();
my %addon_vol = ();
if (@addon_plot) {
$addon_gen{size} = ["1, 0.6"]; #bug in P:G:G
lib/App/financeta/gui.pm view on Meta::CPAN
ytics => {textcolor => 'orange'},
bmargin => 0,
lmargin => 9,
rmargin => 2,
%addon_gen,
label => [1, $self->brand, textcolor => 'rgb "cyan"', at => "graph 0.90,0.03"],
},
{
with => 'lines',
linecolor => 'white',
legend => 'Close Price',
},
$data(,(0)), $data(,(4)),
@general_plot,
);
if (@addon_plot) {
$pwin->plot({
%binmode,
object => '1',
title => '',
key => ['on', 'outside', textcolor => 'rgb "yellow"'],
lib/App/financeta/gui.pm view on Meta::CPAN
ytics => {textcolor => 'orange'},
bmargin => 0,
tmargin => 0,
lmargin => 9,
rmargin => 2,
%addon_vol,
label => [1, "", at => "graph 0.90,0.03"],
},
{
with => 'impulses',
legend => 'Volume',
linecolor => 'cyan',
},
$data(,(0)), $data(,(5)) / 1e6,
@volume_plot,
);
} else {
$type = 'CLOSE';
my %addon_gen = ();
if (@addon_plot) {
$addon_gen{size} = ["1, 0.7"];
lib/App/financeta/gui.pm view on Meta::CPAN
ylabel => ['Close Price', textcolor => 'rgb "yellow"'],
xdata => 'time',
xtics => {format => '%Y-%m-%d', rotate => -90, textcolor => 'orange', },
ytics => {textcolor => 'orange'},
label => [1, $self->brand, textcolor => 'rgb "cyan"', at => "graph 0.90,0.03"],
%addon_gen,
},
{
with => 'lines',
linecolor => 'white',
legend => 'Close Price',
},
$data(,(0)), $data(,(4)),
@general_plot,
);
if (@addon_plot) {
$pwin->plot({
%binmode,
object => '1',
title => '',
key => ['on', 'outside', textcolor => 'rgb "yellow"'],
lib/App/financeta/indicators.pm view on Meta::CPAN
$self->color_idx($idx + 1); # update
return $colors->[$idx];
}
sub _plot_gnuplot_general {
my ($self, $xdata, $output, $scale) = @_;
# output is the same as the return value of the code-ref above
my @plotinfo = ();
foreach (@$output) {
my $p = (defined $scale) ? $_->[1] / $scale : $_->[1];
my %legend = (legend => $_->[0]) if length $_->[0];
my $args = $_->[2] || {};
$log->debug("Plot args: ", dumper($args));
push @plotinfo, {
with => 'lines',
axes => 'x1y1',
linecolor => $self->next_color,
%legend,
%$args,
}, $xdata, $p;
}
return wantarray ? @plotinfo : \@plotinfo;
}
sub _plot_highcharts_general {
my ($self, $xdata, $output, $scale) = @_;
my @plotinfo = ();
foreach my $o (@$output) {
## this is an array
#[0] => legend title
#[1] => PDL data
#[2] => gnuplot args or undef
#[3] => variable name for execution rules
## let's create a x-y pdl data
## highcharts requires timestamp in milliseconds;
my $xypdl = pdl($xdata * 1000, (defined $scale) ? $o->[1] / $scale : $o->[1])->transpose->setbadtoval(0);
my $xyidx = $xypdl((1))->which;
my $xypdlclean = $xypdl->dice_axis(1, $xyidx);
$log->debug($o->[0], $xypdlclean);
push @plotinfo, {
lib/App/financeta/indicators.pm view on Meta::CPAN
## not required
return undef;
}
sub _plot_gnuplot_candlestick {
my ($self, $xdata, $output) = @_;
my @plotinfo = ();
foreach (@$output) {
my $p = $_->[1];
my %legend = (legend => $_->[0]) if length $_->[0];
my $args = $_->[2] || {};
$log->debug("Plot args: ", dumper($args));
push @plotinfo, {
with => 'impulses',
axes => 'x1y2',
linecolor => $self->next_color,
%legend,
%$args,
}, $xdata, $p;
}
return { candle => \@plotinfo };
}
sub _plot_gnuplot_compare {
my ($self, $xdata, $output) = @_;
if (scalar @$output >= 2) {
# we don't want to change the output variable itself
lib/App/financeta/indicators.pm view on Meta::CPAN
my @a = $self->_plot_gnuplot_general($xdata, $output);
return { additional => \@a };
}
}
sub _plot_highcharts_candlestick {
my ($self, $xdata, $output) = @_;
my @plotinfo = ();
foreach my $o (@$output) {
## this is an array
#[0] => legend title
#[1] => PDL data
#[2] => gnuplot args or undef
#[3] => variable name for execution rules
## let's create a x-y pdl data
## highcharts requires timestamp in milliseconds;
my $xypdl = pdl($xdata * 1000, $o->[1])->transpose->setbadtoval(0);
my $xyidx = $xypdl((1))->which;
my $xypdlclean = $xypdl->dice_axis(1, $xyidx);
$log->debug($o->[0], $xypdlclean);
push @plotinfo, {
share/testpdl.pl view on Meta::CPAN
xlabel => ['Date', textcolor => 'rgb "yellow"'],
ylabel => ['Price', textcolor => 'rgb "yellow"'],
xdata => 'time',
xtics => {format => '%Y-%m-%d', rotate => -90, textcolor => 'orange', },
ytics => {textcolor => 'orange'},
label => [1, $symbol, textcolor => 'rgb "cyan"', at => "graph 0.90,0.03"],
},
{
with => 'financebars',
linecolor => 'white',
legend => 'Price',
},
$timestamp,
$open_px,
$high_px,
$low_px,
$close_px,
### Bollinger Bands plot
{
with => 'lines',
axes => 'x1y1',
linecolor => 'dark-green',
legend => 'Bollinger Band - Upper'
},
$timestamp,
$bb_upper, #upper band
{
with => 'lines',
axes => 'x1y1',
linecolor => 'dark-magenta',
legend => 'Bollinger Band - Lower'
},
$timestamp,
$bb_lower, #lower band
{
with => 'lines',
axes => 'x1y1',
linecolor => 'orange',
legend => 'Bollinger Band - Middle'
},
$timestamp,
$bb_middle, #middle band
{
with => 'points',
pointtype => 5, #triangle
linecolor => 'green',
legend => 'Buys',
},
$timestamp,
$buys,
{
with => 'points',
pointtype => 7, #inverted triangle
linecolor => 'red',
legend => 'Sells',
},
$timestamp,
$sells,
);
$pwin->end_multi;
$pwin->pause_until_close;