NAME
Finance::MtGox - trade Bitcoin with the MtGox API
VERSION
Version 0.03
SYNOPSIS
use Finance::MtGox;
my $mtgox = Finance::MtGox->new({
user => 'username',
password => 'secret',
});
# 'key' and 'secret' authentication works too
# unauthenticated API calls
my $depth = $mtgox->call('getDepth');
# authenticated API calls
my $funds = $mtgox->call_auth('getFunds');
# convenience methods built on the core API
my ( $btcs, $usds ) = $mtgox->balances;
my $rate = $mtgox->clearing_rate( 'asks', 200, 'BTC' );
$rate = $mtgox->clearing_rate( 'bids', 42, 'USD' );
BASIC METHODS
new
Create a new Finance::MtGox
object with your MtGox credentials provided in the user
and password
arguments.
You can also provide credentials with key
and secret
arguments. This allows access to MtGox's newer API which has more methods.
call($name)
Run the API call named $name
. Returns a Perl data structure representing the JSON returned from MtGox.
call_auth( $name, $args )
Run the API call named $name
with arguments provided by the hashref $args
. Returns a Perl data structure representing the JSON returned from MtGox
CONVENIENCE METHODS
balances
Returns a list with current BTC and USD account balances, respectively.
clearing_rate( $side, $amount, $currency )
Traverse the current "asks" or "bids" ($side
) on the order book until the given amount of currency has been consumed. Returns the resulting market clearing rate. This method is useful when trying to determine how much you'd have to pay to purchase $40 worth of BTC:
my $rate = $mtgox->clearing_rate( 'asks', 40, 'USD' );
Similar code for determining the rate to sell 40 BTC:
my $rate = $mtgox->clearing_rate( 'bids', 40, 'BTC' );
Dark pool orders are not considered since they're not visible on the order book.
market_price
Returns a volume-weighted USD price per BTC based on MtGox trades within the last 24 hours. Returns undef
if there have been no trades in the last 24 hours.
version
Returns a string indicating which version of the MtGox API is being used. One of 'legacy' or 'v0' (depending on which authentication was provided to "new").
AUTHOR
Michael Hendricks, <michael@ndrix.org>
BUGS
Please report any bugs or feature requests through the web interface at https://github.com/mndrix/Finance-MtGox/issues.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Finance::MtGox
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2011 Michael Hendricks.
This program is distributed under the MIT (X11) License: http://www.opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.