NAME

cexio - perl module interface to cex.io/ghash.io's API

SYNOPSIS

use cexio;
use Data::Dumper;

# public functions do not require any options
my $cexio_object = new cexio();

print Dumper( $cexio_object->ticker("GHS", "BTC" ) ) ."\n";
print Dumper( $cexio_object->order_book("GHS", "BTC", "100") ) ."\n";
print Dumper( $cexio_object->trade_history("GHS", "BTC", "1184696000") ) ."\n";

# private functions require username, key, and secret to be set
my $cexio_object = new cexio( { username => "sample-user", key => "this-is-not-a-real-key", secret => "this-is-not-a-real-secret" } );

print Dumper( $cexio_object->open_orders("GHS","BTC") ) ."\n";
print Dumper( $cexio_object->cancel_order("1") ) ."\n";
print Dumper( $cexio_object->place_order("GHS", "BTC", "buy", "1", "0.007") ) ."\n";
print Dumper( $cexio_object->hashrate() ) ."\n";
print Dumper( $cexio_object->workers() ) ."\n";

DESCRIPTION

Implements the cex.io API described at https://cex.io/api as a perl module

my $cexio_object = new cexio( \%options );

The only time you need to pass options to new() is when you are using a private function.

The only options you need to pass are 'username', 'key', and 'secret'.

Public functions

my $ticker = $cexio_object->ticker( $primary, $secondary );

Returns the current ticker for orders of $primary for $secondary.

my $order_book = $cexio_object->order_book( $primary, $secondary, $depth );

Returns the current list of bids and asks for price and amount of $primary for $secondary

Setting $depth is optional, and will limit the amount of orders returned.

my $trade_history = $cexio_object->trade_history( $primary, $secondary, $since );

Returns the current trade history of $primary for $secondary since $since trade id.

Setting $since is optional, and will limit the number of trades returned.

Private functions

my $open_orders = $cexio_object->open_orders( $primary, $secondary );

Returns an array of open orders of $primary for $secondary that includes: id - order id time - timestamp type - buy or sell price - price amount - amount pending - pending amount (if partially executed)

my $cancel_order = $cexio_object->cancel_order( $order_id );

Returns 'true' if $order_id has been found and cancelled.

my $place_order = $cexio_object->place_order( $primary, $secondary, "buy" | "sell", $quantity, $price );

Places an order of $primary for $secondary that is either "buy" or "sell" of $quantity at $price.

Returns an associative array representing the order placed: id - order id time - timestamp type - buy or sell price - price amount - amount pending - pending amount (if partially executed)

GHash.io-specific private functions

my $hashrate = $cexio_object->hashrate();

Takes no options. Returns an associative array of general mining hashrate statistics for the past day in MH/s.

my $workers = $cexio_object->workers();

Takes no options. Returns an associative array of mining hashrate statistics broken down by workers in MH/s.

CHANGELOG

Changes to POD to fix formatting

TODO

Add comprehensive unit tests to module distribution =item Add server-side error handling =item Fix any bugs that anybody reports =item Write better documentation. Always write better documentation

SEE ALSO

See https://cex.io/api for the most updated API docs and more details on each of the functions listed here.

VERSION

$Id: cexio.pm,v 0.2.1 2014/05/30 17:30:00 CRYPTOGRA Exp $

AUTHOR

Michael W. Renz, <cryptographrix+cpan at gmail.com>

BUGS

Please report any bugs or feature requests to bug-cexio at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=cexio. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc cexio

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2014 Michael W. Renz.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.