Stock Market On Mint 18.2 Bash & Perl Example
Page 1 of 1
Re: Stock Market On Mint 18.2 Bash & Perl Example
First Install:
If above fails you can use:
finance-quote.sourceforge.net/download.html
stocks2.csv
Perl_stock.pl
Run.sh
Run3.sh
- Code:
sudo apt-get install -y libfinance-quote-perl
If above fails you can use:
finance-quote.sourceforge.net/download.html
stocks2.csv
- Code:
TWTR,NYSE
TGT,NYSE
DAL,NYSE
DVN,NYSE
DOW,NYSE
TWX,NYSE
FOXA,NYSE
TSLA,NASDAQ
Perl_stock.pl
- Code:
#!/usr/bin/perl
# (c) J~Net 2016
#ALL RIGHTS RESERVED!
#
# sudo apt-get install -y libfinance-quote-perl
# Usage ./perl_stock.pl stocks.csv > output.txt
# cat output.txt
#
# Original https://linuxconfig.org/fetch-stock-quotes-with-perl-finance-quote-module
#
use Finance::Quote;
my $q = Finance::Quote->new();
open (FIN, $ARGV[0]) || die ("Could not open $ARGV[0]");
while ($line = <FIN>) {
($field1,$field2) = split ',', $line;
my %hash = (
$field1 => $field2 );
chomp(%hash);
foreach my $i (keys %hash) {
my %data = $q->fetch( $hash{$i}, $i);
print $hash{$i} . " " . $i . " Price " . $data{$i, 'price'} . "\n";
}
}
close (FIN);
# write output to file
use strict;
use warnings;
# gedit output.txt
Run.sh
- Code:
#!/bin/bash
# Usage: ./Run.sh
#
#echo -en "\e[92m\c"
if [ -e final.txt ]
then
mv final.txt old_final.txt
fi
# sh Run.sh &&
sh run3.sh > final.txt
cat final.txt
if [ -e old_final.txt ]
then
echo "Now For The Differences... "
diff old_final.txt final.txt
echo "> Means ^ & < Means Down!"
fi
echo "Finished."
Run3.sh
- Code:
#!/bin/bash
# Usage ./Run.sh
if [ -e output2.txt ]
then
mv output2.txt old_output.txt
fi
./perl_stock.pl stocks2.csv > output2.txt
if [ -e old_output.txt ]
then
echo "Now For The Differences... "
diff old_output.txt output.txt
echo "> Means ^ & < Means Down!"
fi
cat output2.txt
Last edited by jamied_uk on 20th November 2017, 23:21; edited 1 time in total
Re: Stock Market On Mint 18.2 Bash & Perl Example
For more info
Original https://linuxconfig.org/fetch-stock-quotes-with-perl-finance-quote-module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The unreliable bash side
./stock_full.sh tickers.txt
use perl to get stock prices
perlmaven.com/writing-to-files-with-perl
perlmonks.org/?node_id=960
marketwatch.com/tools/quotes/lookup.asp?siteID=mktw&Lookup=t&Country=all&Type=All
perlmaven.com/subroutines-and-functions-in-perl
stackoverflow.com/questions/10682087/how-to-redirect-console-output-to-a-text-file
askubuntu.com/questions/515900/how-to-compare-two-files
encrypted.google.com/search?q=read+file+in+linux+bash+compare+2+files+
Original https://linuxconfig.org/fetch-stock-quotes-with-perl-finance-quote-module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The unreliable bash side
./stock_full.sh tickers.txt
use perl to get stock prices
perlmaven.com/writing-to-files-with-perl
perlmonks.org/?node_id=960
marketwatch.com/tools/quotes/lookup.asp?siteID=mktw&Lookup=t&Country=all&Type=All
perlmaven.com/subroutines-and-functions-in-perl
stackoverflow.com/questions/10682087/how-to-redirect-console-output-to-a-text-file
askubuntu.com/questions/515900/how-to-compare-two-files
encrypted.google.com/search?q=read+file+in+linux+bash+compare+2+files+
Similar topics
» Getting Stocks Using Perl On Linux
» BASH AND PERL ENCRYPTION AND DECRYPTION
» Linux Mint 18.1 Bash Script For Web Devs
» Linux Mint Bash Password & Security Plus SHC & Compiling
» Basic Spelling Game With Bash & Aspell On Linux Mint Example
» BASH AND PERL ENCRYPTION AND DECRYPTION
» Linux Mint 18.1 Bash Script For Web Devs
» Linux Mint Bash Password & Security Plus SHC & Compiling
» Basic Spelling Game With Bash & Aspell On Linux Mint Example
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum