NAME
Finance::Bitcoin::Feed - Collect bitcoin real-time price from many sites' streaming data source
SYNOPSIS
use Finance::Bitcoin::Feed;
#default output is to print to the stdout
Finance::Bitcoin::Feed->new->run();
# will print output to the stdout:
# COINSETTER BTCUSD 123.00
#or custom your stdout
my $feed = Finance::Bitcoin::Feed->new;
#first unsubscribe the event 'output'
$feed->unsubscribe('output');
#then listen on 'output' by your callback
open my $fh, ">out.txt";
$fh->autoflush();
$feed->on('output', sub{
my ($self, $site, $currency, $price) = @_;
print $fh "the price currency $currency on site $site is $price\n";
});
# let's go!
$feed->run();
DESCRIPTION
Finance::Bitcoin::Feed is a bitcoin realtime data source which collect real time data source from these sites:
The default output format to the stdout by this format:
site_name TIMESTAMP CURRENCY price
For example:
COINSETTER 1418173081724 BTCUSD 123.00
The unit of timestamp is ms.
You can custom your output by listen on the event output and modify the data it received.
METHODS
This class inherits all methods from Mojo::EventEmitter
EVENTS
This class inherits all events from Mojo::EventEmitter and add the following new ones:
output
#output to the stdout, the default action:
$feed->on('output', sub { shift; say join " ", @_ } );
#or you can clear this default action and add yours:
$feed->unsubscribe('output');
open my $fh, ">out.txt";
$feed->on('output', sub{
my ($self, $site, $currency, $price) = @_;
say $fh "the price of $site of currency $currency is $price"
});
DEBUGGING
You can set the FINANCE_BITCOIN_FEED_DEBUG environment variable to get some advanced diagnostics information printed to STDERR. And these modules use Mojo::UserAgent, you can also open the MOJO_USERAGENT_DEBUG environment variable:
FINANCE_BITCOIN_FEED_DEBUG=1
MOJO_USERAGENT_DEBUG=1
SEE ALSO
Finance::Bitcoin::Feed::Site::Hitbtc
Finance::Bitcoin::Feed::Site::BtcChina
Finance::Bitcoin::Feed::Site::CoinSetter
AUTHOR
Chylli <chylli@binary.com>
COPYRIGHT
Copyright 2014- Binary.com