App-financeta
view release on metacpan or search on metacpan
lib/App/financeta/gui.pm view on Meta::CPAN
package App::financeta::gui;
use strict;
use warnings;
use 5.10.0;
our $VERSION = '0.16';
$VERSION = eval $VERSION;
use App::financeta::mo;
use App::financeta::utils qw(dumper log_filter get_icon_path get_file_path);
use Carp ();
use Log::Any '$log', filter => \&App::financeta::utils::log_filter;
use Try::Tiny;
use File::Spec;
use File::HomeDir;
use File::Path ();
use DateTime;
if ($^O !~ /win32/i) {
eval {
require POE;
require POE::Kernel;
POE::Kernel->import({loop => 'Prima'});
require POE::Session;
} or die "Unable to load POE::Loop::Prima";
}
use Prima qw(
Application Buttons MsgBox Calendar ComboBox Notebooks
Widget::ScrollWidget DetailedList Dialog::ColorDialog
Dialog::FileDialog Dialog::FindDialog ScrollBar
Dialog::PrintDialog Dialog::ImageDialog Dialog::FontDialog
sys::GUIException Utils
);
use Prima::Utils ();
use Capture::Tiny ();
use PDL::Lite;
use PDL::IO::Misc;
use PDL::NiceSlice;
use PDL::Graphics::Gnuplot;
use App::financeta::gui::security_wizard;
use App::financeta::gui::progress_bar;
use App::financeta::gui::editor;
use App::financeta::gui::tradereport;
use App::financeta::indicators;
use App::financeta::data;
use Scalar::Util qw(blessed);
use Browser::Open ();
use YAML::Any ();
use JSON::XS qw(encode_json);
use Template;
$PDL::doubleformat = "%0.6lf";
$| = 1;
has debug => 0;
has timezone => 'America/New_York';
has brand => __PACKAGE__;
has main => (builder => '_build_main');
has tmpdir => ( default => sub {
my $dir = $ENV{TEMP} || $ENV{TMP} || $ENV{APPDATA} if $^O =~ /Win32|Cygwin/i;
$dir //= $ENV{TMPDIR} || File::Spec->tmpdir;
$dir //= '/tmp' unless $^O =~ /Win32|Cygwin/i;
$dir = File::Spec->catdir($dir, $ENV{USER} || getlogin(), 'financeta');
File::Path::make_path($dir) unless -d $dir;
return $dir;
});
has datadir => ( default => sub {
my $dir = $ENV{DATADIR} || File::Spec->catfile(File::HomeDir->my_home, '.financeta');
File::Path::make_path($dir) unless -d $dir;
return $dir;
});
has plot_engine => 'highcharts';
has current => {};
has indicator => (builder => '_build_indicator');
has tab_was_closed => 0;
has editors => {};
has tradereports => {};
has list_sources => ['yahoo', 'gemini'];
has list_sources_pretty => ['Yahoo! Finance', 'Gemini Crypto Exchange'];
has list_sources_urls => ['https://finance.yahoo.com', 'https://docs.gemini.com/rest-api/?python#symbols'];
sub _build_indicator {
my $self = shift;
return App::financeta::indicators->new(debug => $self->debug,
plot_engine => $self->plot_engine);
}
sub _build_editor {
my $self = shift;
my $name = shift || '';
$name =~ s/tab_//g if length $name;
return App::financeta::gui::editor->new(debug => $self->debug,
parent => $self, brand => $self->brand . " Rules Editor for $name");
}
sub _build_tradereport {
my $self = shift;
my $name = shift || '';
$name =~ s/tab_//g if length $name;
return App::financeta::gui::tradereport->new(debug => $self->debug,
parent => $self, brand => $self->brand . " Trade Report for $name");
}
sub icon {
my $icon_path = get_icon_path(__PACKAGE__);
return (defined $icon_path) ? Prima::Icon->load($icon_path) : undef;
}
sub _build_main {
my $self = shift;
( run in 1.033 second using v1.01-cache-2.11-cpan-140bd7fdf52 )