App-idxdb

 view release on metacpan or  search on metacpan

script/idxdb  view on Meta::CPAN

#!perl

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2021-06-21'; # DATE
our $DIST = 'App-idxdb'; # DIST
our $VERSION = '0.008'; # VERSION

use 5.010001;
use strict;
use warnings;

use Perinci::CmdLine::Any;

our %SPEC;

my $prefix = '/App/idxdb/';

Perinci::CmdLine::Any->new(
    url => $prefix,
    subcommands => {
        'update'     => {url => "${prefix}update"},
        'ownership'  => {url => "${prefix}ownership"},
        'daily'      => {url => "${prefix}daily"},
        #'stocks-by-ownership' => {url => "${prefix}stock_by_ownership"},
        'stocks-by-foreign-ownership' => {url => "${prefix}stocks_by_foreign_ownership"},
    },
    log => 1,
)->run;

# ABSTRACT: Import data for stocks on the IDX (Indonesian Stock Exchange) and perform queries on them
# PODNAME: idxdb

__END__

=pod

=encoding UTF-8

=head1 NAME

idxdb - Import data for stocks on the IDX (Indonesian Stock Exchange) and perform queries on them

=head1 VERSION

This document describes version 0.008 of idxdb (from Perl distribution App-idxdb), released on 2021-06-21.

=head1 SYNOPSIS

To update data:

 % idxdb update

To see the legends for ownership field names (e.g. ForeignIB = foreign bank):

 % idxdb ownership --legend

To see ownership (e.g. % foreign/local) of some stock through time:

 % idxdb ownership BBRI
 % idxdb ownership --fields-all BBRI --date-start 2020-01-01 --date-end 2020-09-30
 % idxdb ownership --fields-foreign-total --6month --graph BBNI

To graph ownership composition (% foreign bank, foreign total, local bank, etc)
of some stock:

 % idxdb ownership BBRI --graph

To see a table of daily trading summary of some stock:

 % idxdb daily BBRI

To graph closing price and accumulated foreign net buy of some stock in the last 2 year:

 % idxdb daily --field Close --field AccumForeignNetBuy --2year BBRI

=head1 DESCRIPTION

B<NOTE: EARLY RELEASE, ONLY A FEW SUBCOMMANDS HAVE BEEN IMPLEMENTED.>

This utility lets you load some data like IDX's daily trading summary (stock
summary), list of stocks, and KSEI's monthly ownership into a SQLite database
and perform some SQL queries against it.

Keywords: stock trading, Indonesian Stock Exchange, securities analysis.

=head1 SUBCOMMANDS

=head2 B<daily>

Show data from daily stock/trading summary.

=head2 B<ownership>

Show ownership of some stock through time.

=head2 B<stocks-by-foreign-ownership>

Rank stocks from highest foreign ownership.

=head2 B<update>

Update data.

Currently this routine imports from text files in the C<gudangdata> repository on
the local filesystem. Functionality to import from server directly using
L<Finance::SE::IDX> and L<Finance::ID::KSEI> will be added in the future.

=head1 OPTIONS

C<*> marks required options.

=head2 Common options

=over

script/idxdb  view on Meta::CPAN

See C<--date-start>.

=item B<--6month>

Alias for --date-start.

See C<--date-start>.

=item B<--date-end>=I<s>

Default value:

 1624208400

=item B<--date-start>=I<s>

Default value:

 1621616400

=item B<--field>=I<s@>

Default value:

 ["LocalTotal","ForeignTotal"]

Can be specified multiple times.

=item B<--fields-all>

Alias for --field.

See C<--field>.

=item B<--fields-foreign>

Alias for --field.

See C<--field>.

=item B<--fields-foreign-total>

Alias for --field.

See C<--field>.

=item B<--fields-json>=I<s>

See C<--field>.

=item B<--fields-local>

Alias for --field.

See C<--field>.

=item B<--graph>, B<-g>

Show graph instead of table.

=item B<--legend>

Show legend of ownership instead (e.g. ForeignIB = foreign bank, etc).

=item B<--month>

Alias for --date-start.

See C<--date-start>.

=item B<--stock>=I<s>*

Can also be specified as the 1st command-line argument.

=item B<--week>

Alias for --date-start.

See C<--date-start>.

=item B<--year>

Alias for --date-start.

See C<--date-start>.

=item B<--ytd>

Alias for --date-start.

See C<--date-start>.

=back

=head2 Options for subcommand update

=over

=item B<--gudangdata-path>=I<s>*

=back

=head1 COMPLETION

This script has shell tab completion capability with support for several
shells.

=head2 bash

To activate bash completion for this script, put:

 complete -C idxdb idxdb

in your bash startup (e.g. F<~/.bashrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is recommended, however, that you install modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.

=head2 tcsh

To activate tcsh completion for this script, put:

script/idxdb  view on Meta::CPAN

=head2 other shells

For fish and zsh, install L<shcompgen> as described above.

=head1 CONFIGURATION FILE

This script can read configuration files. Configuration files are in the format of L<IOD>, which is basically INI with some extra features.

By default, these names are searched for configuration filenames (can be changed using C<--config-path>): F<~/.config/idxdb.conf>, F<~/idxdb.conf>, or F</etc/idxdb.conf>.

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

To put configuration for a certain subcommand only, use a section name like C<[subcommand=NAME]> or C<[SOMESECTION subcommand=NAME]>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]> or C<[subcommand=SUBCOMMAND_NAME profile=SOMENAME]> or C<[SOMESECTION subcommand=SUBCOMMAND_NAME profile=SOMENAME]>....

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

=head2 Common for all subcommands

 format (see --format)
 log_level (see --log-level)
 naked_res (see --naked-res)

=head2 Configuration for subcommand daily

 date_end (see --date-end)
 date_start (see --date-start)
 fields (see --field)
 graph (see --graph)
 stocks (see --stock)
 total (see --total)

=head2 Configuration for subcommand ownership

 date_end (see --date-end)
 date_start (see --date-start)
 fields (see --field)
 graph (see --graph)
 legend (see --legend)
 stock (see --stock)

=head2 Configuration for subcommand stocks-by-foreign-ownership


=head2 Configuration for subcommand update

 gudangdata_path (see --gudangdata-path)

=head1 ENVIRONMENT

=head2 IDXDB_OPT => str

Specify additional command-line options.

=head1 FILES

F<~/.config/idxdb.conf>

F<~/idxdb.conf>

F</etc/idxdb.conf>

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-idxdb>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-idxdb>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-idxdb>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=head1 SEE ALSO

L<Finance::SE::IDX>

L<Finance::ID::KSEI>

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2021 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 0.953 second using v1.01-cache-2.11-cpan-ceb78f64989 )