App-financeta

 view release on metacpan or  search on metacpan

lib/App/financeta/data/gemini.pm  view on Meta::CPAN

        } else {
            $granularity = '1day';
        }
        $log->debug("Granularity selected is $granularity");
        my $url = sprintf ('https://api.gemini.com/v2/candles/%s/%s', lc($symbol), $granularity);
        $log->debug("Performing GET request to $url");
        my $lwp = LWP::UserAgent->new(timeout => 60);
        $lwp->env_proxy;
        my $res = $lwp->get($url);
        if ($res->is_success) {
            my $content = $res->decoded_content;
            if (defined $content and length($content)) {
                my $jquotes = decode_json($content);
                if (ref $jquotes eq 'ARRAY' and scalar(@$jquotes)) {
                    ## sort quotes by timestamp
                    my @sorted = sort { $a->[0] <=> $b->[0] } @$jquotes;
                    $log->info("No. of rows downloaded: " . scalar(@sorted));
                    foreach my $q (@sorted) {
                        $q->[0] /= 1000;#remove millisecond scale
                        #push @quotes, pdl(@$q);
                    }

share/testpdl.pl  view on Meta::CPAN

    my $qdata;
    my $url = sprintf("https://api.gemini.com/v2/candles/%s/%s", lc $symbol, '1day');
    if (-e $filename) {
        print "Found $filename, loading data from that\n";
        $content = path($filename)->slurp;
    } else {
        my $lwp = LWP::UserAgent->new(timeout => 60);
        $lwp->env_proxy;
        my $resp = $lwp->get($url);
        if ($resp->is_success) {
            $content = $resp->decoded_content;
            path($filename)->spew($content);
        } else {
            warn "Error from request to $url: " . $resp->status_line;
            return undef;
        }
    }
    if (defined $content and length($content)) {
        my $jquotes = decode_json $content;
        if (ref $jquotes eq 'ARRAY' and scalar(@$jquotes)) {
            ## sort quotes by timestamp

share/testpdljs.pl  view on Meta::CPAN

    my $qdata;
    my $url = sprintf("https://api.gemini.com/v2/candles/%s/%s", lc $symbol, '1day');
    if (-e $filename) {
        print "Found $filename, loading data from that\n";
        $content = path($filename)->slurp;
    } else {
        my $lwp = LWP::UserAgent->new(timeout => 60);
        $lwp->env_proxy;
        my $resp = $lwp->get($url);
        if ($resp->is_success) {
            $content = $resp->decoded_content;
            path($filename)->spew($content);
        } else {
            warn "Error from request to $url: " . $resp->status_line;
            return undef;
        }
    }
    if (defined $content and length($content)) {
        my $jquotes = decode_json $content;
        if (ref $jquotes eq 'ARRAY' and scalar(@$jquotes)) {
            ## sort quotes by timestamp



( run in 0.340 second using v1.01-cache-2.11-cpan-26ccb49234f )