git ssb

0+

cel / ledger-scripts



Commit 801dca93854462d939817da96acd4439fb300da6

Use Poloniex API for altcoins

Charles Lehner committed on 8/19/2015, 4:38:11 PM
Parent: ea82bbba9fb249a99d6191087f0a11f2393816cd

Files changed

README.mdchanged
getquotechanged
README.mdView
@@ -95,9 +95,9 @@
9595 Get quotes for various stocks, currencies, and commodities.
9696
9797 Covers:
9898
99-BTC, altcoins, gold, silver, Havelock Investments, CryptoTrade, CryptoStocks,
99+BTC, altcoins, gold, silver, Havelock Investments, CryptoStocks,
100100 and NASDAQ.
101101
102102 #### gethistoric
103103
getquoteView
@@ -60,30 +60,19 @@
6060 return '$' . $ticker->{last};
6161 }
6262 }
6363
64- if ($symbol eq 'ETH') {
65- if (my $ticker = json_req('https://poloniex.com/public?command=returnTicker')) {
66- return '$' . $ticker->{USDT_ETH}->{last};
67- }
68- }
69-
7064 my %coinabul_markets = (
7165 AU => 'Gold',
7266 AG => 'Silver',
7367 );
7468
75- my %cryptotrade_markets = (
76- CTB => 'BTC',
77- CTL => 'LTC',
78- ESB => 'BTC',
79- ESL => 'LTC',
80- GGB => 'BTC',
69+ my %poloniex_markets = (
70+ ETH => 'USDT',
8171 PPC => 'BTC',
82- LTC => 'BTC',
72+ LTC => 'USDT',
73+ XPM => 'BTC',
8374 NMC => 'BTC',
84- XPM => 'BTC',
85- FTC => 'BTC',
8675 );
8776
8877 my %cryptostocks_markets = (
8978 BTCINVEST => 1,
@@ -104,25 +93,22 @@
10493 '€' => 'EUR',
10594 EUR => 1
10695 );
10796
97+ if (my $base = $poloniex_markets{$symbol}) {
98+ my $ticker = $base . '_' . $symbol;
99+ if (my $market = json_req('https://poloniex.com/public?command=returnTicker')) {
100+ my $amount = $market->{$ticker}->{last};
101+ return $base eq 'USDT' ? '$' . $amount : $amount . ' ' . $base;
102+ }
103+ }
104+
108105 if (my $marketid = $coinabul_markets{$symbol}) {
109106 if (my $market = json_req('http://coinabul.com/api.php')) {
110107 return '$' . $market->{$marketid}->{USD};
111108 }
112109 }
113110
114- if (my $currency = $cryptotrade_markets{$symbol}) {
115- my $ticker = lc($symbol . '_' . $currency);
116- my $resp = json_req('https://crypto-trade.com/api/1/ticker/' . $ticker);
117- if ($resp and $resp->{status} eq 'success') {
118- my $data = $resp->{data};
119- my $price = $data->{last} ||
120- ($data->{min_ask} + $data->{max_bid}) / 2;
121- return $price . ' ' . $currency;
122- }
123- }
124-
125111 if ($cryptostocks_markets{$symbol}) {
126112 if (my $info = json_req('https://cryptostocks.com/api/get_security_info.json?ticker=' . $symbol)) {
127113 if ($info and $info->{return_code} == 0) {
128114 return $info->{last_price} . ' ' . $info->{currency};

Built with git-ssb-web