Skip to content

Commit

Permalink
const → let #330
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Oct 18, 2017
1 parent cc91a5f commit c00f123
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 40 deletions.
139 changes: 127 additions & 12 deletions build/ccxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ public function fetch_trades ($symbol, $params = array ()) {
), $params));
// looks like they switched this endpoint off
// it returns 503 Service Temporarily Unavailable always
// return $this->parse_trades (reponse, $market);
// return $this->parse_trades ($response, $market);
return $response;
}

Expand Down Expand Up @@ -15686,17 +15686,8 @@ public function fetch_balance ($params = array ()) {
$balance = $balances[$i];
$uppercase = strtoupper ($balance['currency']);
$currency = $this->common_currency_code ($uppercase);
$account = null;
if (array_key_exists ($currency, $result)) {
$account = $result[$currency];
} else {
$account = $this->account ();
}
if ($balance['type'] == 'trade') {
$account['free'] = floatval ($balance['balance']);
} else if ($balance['type'] == 'frozen') {
$account['used'] = floatval ($balance['balance']);
}
$account = $this->account ();
$account['free'] = floatval ($balance['balance']);
$account['total'] = $this->sum ($account['free'], $account['used']);
$result[$currency] = $account;
}
Expand Down Expand Up @@ -17110,6 +17101,130 @@ public function request ($path, $api = 'public', $method = 'GET', $params = arra

// -----------------------------------------------------------------------------

class kuna extends acx {

public function __construct ($options = array ()) {
parent::__construct (array_merge(array (
'id' => 'kuna',
'name' => 'KUNA.IO',
'countries' => 'UA',
'rateLimit' => 1000,
'version' => 'v2',
'hasCORS' => false,
'hasFetchTickers' => false,
'hasFetchOHLCV' => false,
'urls' => array (
'logo' => 'https://user-images.githubusercontent.com/1294454/31697638-912824fa-b3c1-11e7-8c36-cf9606eb94ac.jpg',
'api' => 'https://kuna.io',
'www' => 'https://kuna.io',
'doc' => 'https://kuna.io/documents/api',
),
'api' => array (
'public' => array (
'get' => array (
'tickers/{market}',
'order_book',
'order_book/{market}',
'trades',
'trades/{market}',
'timestamp',
),
),
'private' => array (
'get' => array (
'members/me',
'orders',
'trades/my',
),
'post' => array (
'orders',
'order/delete',
),
),
),
'markets' => array (
'BTC/UAH' => array ( 'id' => 'btcuah', 'symbol' => 'BTC/UAH', 'base' => 'BTC', 'quote' => 'UAH' ),
'ETH/UAH' => array ( 'id' => 'btcuah', 'symbol' => 'ETH/UAH', 'base' => 'ETH', 'quote' => 'UAH' ),
'GBG/UAH' => array ( 'id' => 'gbguah', 'symbol' => 'GBG/UAH', 'base' => 'GBG', 'quote' => 'UAH' ), // Golos Gold (GBG != not GOLOS)
'KUN/BTC' => array ( 'id' => 'kunuah', 'symbol' => 'KUN/BTC', 'base' => 'KUN', 'quote' => 'BTC' ),
'BCH/BTC' => array ( 'id' => 'bchbtc', 'symbol' => 'BCH/UAH', 'base' => 'BCH', 'quote' => 'BTC' ),
'WAVES/UAH' => array ( 'id' => 'wavesuah', 'symbol' => 'WAVES/UAH', 'base' => 'WAVES', 'quote' => 'UAH' ),
),
'precision' => array (
'amount' => 8,
'price' => 0,
),
), $options));
}

public function fetch_order_book ($symbol, $params) {
const market = $this->market ($symbol);
$orderBook = $this->publicGetOrderBook (array_merge (array (
'market' => market['id'],
), $params));
return $this->parse_order_book ($orderBook, null, 'bids', 'asks', 'price', 'volume');
}

public function parse_order ($order, $market = null) {
const dateString = $order['created_at'];
const timestamp = Date.parse (dateString);
return array (
'id' => $order['id'],
'timestamp' => timestamp,
'datetime' => $this->iso8601 (timestamp),
'status' => 'open',
'symbol' => 'BTC/UAH',
'type' => $order['ord_type'],
'side' => $order['side'],
'price' => floatval ($order['price']),
'amount' => floatval ($order['volume']),
'filled' => floatval ($order['executed_volume']),
'remaining' => floatval ($order['remaining_volume']),
'trades' => null,
'fee' => null,
'info' => $order,
);
}

public function fetch_open_orders ($symbol, $params = array ()) {
const market = $this->market ($symbol);
$orders = $this->privateGetOrders (array_merge (array (
'market' => market['id'],
), $params));
$result = array ();
for ($i = 0; $i < count ($orders); $i++) {
$result[] = $this->parse_order ($orders[$i]);
}
return $result;
}

public function parse_trade ($trade, $market = null) {
const dateString = $trade['created_at'];
const timestamp = Date.parse (dateString);
return array (
'id' => $trade['id'],
'timestamp' => timestamp,
'datetime' => $this->iso8601 (timestamp),
'symbol' => $market['symbol'],
'type' => null,
'side' => null,
'price' => floatval ($trade['price']),
'amount' => floatval ($trade['volume']),
'info' => $trade,
);
}

public function fetch_trades ($symbol, $params = array ()) {
const market = $this->market ($symbol);
const response = $this->publicGetTrades (array_merge (array (
'market' => market['id'],
), $params));
return $this->parse_trades (response, market);
}
}

// -----------------------------------------------------------------------------

class lakebtc extends Exchange {

public function __construct ($options = array ()) {
Expand Down
16 changes: 8 additions & 8 deletions ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -16717,16 +16717,16 @@ var kuna = extend (acx, {
},

async fetchOrderBook (symbol, params) {
const market = this.market (symbol);
let market = this.market (symbol);
let orderBook = await this.publicGetOrderBook (this.extend ({
'market': market['id'],
}, params));
return this.parseOrderBook (orderBook, undefined, 'bids', 'asks', 'price', 'volume');
},

parseOrder (order, market = undefined) {
const dateString = order['created_at'];
const timestamp = Date.parse (dateString);
let dateString = order['created_at'];
let timestamp = Date.parse (dateString);
return {
'id': order['id'],
'timestamp': timestamp,
Expand All @@ -16746,7 +16746,7 @@ var kuna = extend (acx, {
},

async fetchOpenOrders (symbol, params = {}) {
const market = this.market (symbol);
let market = this.market (symbol);
let orders = await this.privateGetOrders (this.extend ({
'market': market['id'],
}, params));
Expand All @@ -16758,8 +16758,8 @@ var kuna = extend (acx, {
},

parseTrade (trade, market = undefined) {
const dateString = trade['created_at'];
const timestamp = Date.parse (dateString);
let dateString = trade['created_at'];
let timestamp = Date.parse (dateString);
return {
'id': trade['id'],
'timestamp': timestamp,
Expand All @@ -16774,8 +16774,8 @@ var kuna = extend (acx, {
},

async fetchTrades (symbol, params = {}) {
const market = this.market (symbol);
const response = await this.publicGetTrades (this.extend ({
let market = this.market (symbol);
let response = await this.publicGetTrades (this.extend ({
'market': market['id'],
}, params));
return this.parseTrades (response, market);
Expand Down
132 changes: 122 additions & 10 deletions ccxt/async/exchanges.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c00f123

Please sign in to comment.