Ccxt: How to implement this script on cli base php for indodax?

Created on 8 Apr 2018  ·  40Comments  ·  Source: ccxt/ccxt

Can u explain to me how to implement this script on cli base php,

frist setup api->connection to api->check balance->if null return error else load market->load market

make proceess buy sell and close order

because this part of your example and i doesn understand the step how to make like a trading in console.

Thank You.

question

Most helpful comment

Please update this doc

Docs updated, thank you very much for pointing that out! )

All 40 comments

https://github.com/ccxt/ccxt/blob/master/examples/php/indodax-fetch-balance-create-order-cancel-order.php

<?php

$root = dirname (dirname (dirname (__FILE__)));

include $root . '/ccxt.php';

date_default_timezone_set ('UTC');

$exchange = new \ccxt\indodax (array (
    'apiKey' => 'YOUR_API_KEY', // ←------------ replace with your keys
    'secret' => 'YOUR_SECRET',
    'enableRateLimit' => true,
));

//-----------------------------------------------------------------------------
// querying balance

$balance = $exchange->fetch_balance ();

print_r ($balance);

// do whatever you need here with your balance...

//-----------------------------------------------------------------------------
// placing and canceling orders

$symbol = 'BTC/IDR'; // bitcoin contract according to bitmex futures coding
$type = 'limit';
$side = 'sell'; // or 'buy'
$amount = 1.0;
$price = 6500.0; // or None

// extra params and overrides if necessary
$params = array (
    // ...
);

// buying

$buy_order1 = $exchange->create_limit_buy_order ($symbol, $amount, $price, $params);
echo "Buy order 1:\n";
print_r(buy_order1);

$buy_order2 = $exchange->create_order ($symbol, $type, 'buy', $amount, $price, $params);
//                             order side hardcoded here ↑ for example
echo "Buy order 2:\n";
print_r(buy_order2);

// selling

$sell_order1 = $exchange->create_limit_sell_order ($symbol, $amount, $price, $params);
echo "Sell order 1:\n";
print_r(buy_order1);

$sell_order2 = $exchange->create_order ($symbol, $type, $side, $amount, $price, $params);
//                         order side from a variable here ↑ for example
echo "Sell order 2:\n";
print_r(sell_order2);

// canceling

$exchange->cancel_order($buy_order1['id'], $symbol);
$exchange->cancel_order($buy_order2['id'], $symbol);
$exchange->cancel_order($sell_order1['id'], $symbol);
$exchange->cancel_order($sell_order2['id'], $symbol);

Hope it answers your question.

Thank you i will try :D

Pada tanggal Sen, 9 Apr 2018 19:02, Igor Kroitor notifications@github.com
menulis:

>

https://github.com/ccxt/ccxt/blob/master/examples/php/indodax-fetch-balance-create-order-cancel-order.php

fetch_balance ();print_r ($balance);// do whatever you need here with your balance...//-----------------------------------------------------------------------------// placing and canceling orders$symbol = 'BTC/IDR'; // bitcoin contract according to bitmex futures coding$type = 'limit';$side = 'sell'; // or 'buy'$amount = 1.0;$price = 6500.0; // or None// extra params and overrides if necessary$params = array ( // ...);// buying$buy_order1 = $exchange->create_limit_buy_order ($symbol, $amount, $price, $params);echo "Buy order 1:n";print_r(buy_order1);$buy_order2 = $exchange->create_order ($symbol, $type, 'buy', $amount, $price, $params);// order side hardcoded here ↑ for exampleecho "Buy order 2:n";print_r(buy_order2);// selling$sell_order1 = $exchange->create_limit_sell_order ($symbol, $amount, $price, $params);echo "Sell order 1:n";print_r(buy_order1);$sell_order2 = $exchange->create_order ($symbol, $type, $side, $amount, $price, $params);// order side from a variable here ↑ for exampleecho "Sell order 2:n";print_r(sell_order2);// canceling$exchange->cancel_order($buy_order1['id'], $symbol);$exchange->cancel_order($buy_order2['id'], $symbol);$exchange->cancel_order($sell_order1['id'], $symbol);$exchange->cancel_order($sell_order2['id'], $symbol);

Hope it answers your question.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/ccxt/ccxt/issues/2504#issuecomment-379929690, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AiBPfiMWA3hzacckUUdMNNDUoh2MFp9sks5tm_YwgaJpZM4TLdNl
.

$params = array (
// ...
);

can u explain the list of params?

Thank you

$amount = 1.0;
$price = 6500.0; // or None

// extra params and overrides if necessary
$params = array (
// ...
);

// buying

$buy_order1 = $exchange->create_limit_buy_order ($symbol, $amount, $price, $params);
echo "Buy order 1:n";
print_r ($buy_order1);

what is different of $amount and $price? is not same?

Can u tell me how to get average currency from OHLCV Candlestick Charts ? i'm used 'BTC/IDR' currency.

Thank you

Can u tell me how to get average currency from OHLCV Candlestick Charts ?

You should be very precise and specific with financial terms. There's no such thing as "average currency" in OHLCV. An OHLCV candlestick shows the statistical data for a market symbol (which is a pair of two currencies). So, I don't really get what kind of data you want, could you clarify this?

sorry that i'm mean, average on Price Ticker.

{
'symbol': string symbol of the market ('BTC/USD', 'ETH/BTC', ...)
'info': { the original non-modified unparsed reply from exchange API },
'timestamp': int (64-bit Unix Timestamp in milliseconds since Epoch 1 Jan 1970)
'datetime': ISO8601 datetime string with milliseconds
'high': float, // highest price
'low': float, // lowest price
'bid': float, // current best bid (buy) price
'bidVolume': float, // current best bid (buy) amount (may be missing or undefined)
'ask': float, // current best ask (sell) price
'askVolume': float, // current best ask (sell) amount (may be missing or undefined)
'vwap': float, // volume weighed average price
'open': float, // opening price
'close': float, // price of last trade (closing price for current period)
'last': float, // same as close, duplicated for convenience
'previousClose': float, // closing price for the previous period
'change': float, // absolute change, last - open
'percentage': float, // relative change, (change/open) * 100
'average': float, // average price, (last + open) / 2
'baseVolume': float, // volume of base currency
'quoteVolume': float, // volume of quote currency
}

can u explain me to some function in bold text,

what is the mean opening price, btc currncy or IDR currency?

in case i will make some function :

`$ticker = $inboxno->fetch_ticker('BTC/IDR');

print "====== IMPORTAN TRADING TICKER INFORMATION ===== rn";
print "Trading Crypto : " . $ticker['symbol'] . "rn";
print "Time Stamp : " . $ticker['timestamp'] . "rn";
print "Date Time : " . $ticker['datetime']. "rn";
print "High : " . $ticker['high'] . "rn";
print "Low : " . $ticker['low'] . "rn";
print "Bid : " . $ticker['bid'] . "rn";
print "Bid Volume : " . $ticker['bidVolume'] . "rn";
print "Ask : " . $ticker['ask'] . "rn";
print "Ask Volume : " . $ticker['askVolume'] . "rn";
print "Vwap : " . $ticker['vwap'] . "rn";
print "Open : " . $ticker['open'] . "rn";
$open = '10000';
print "Close : " . $ticker['close'] . "rn";
print "Last : " . $ticker['last'] . "rn";
print "Previous Close : " . $ticker['previousClose'] . "rn";
$change = $ticker['last'] - $open;
print "Change : " . $change . "rn";
$percentage = ($change / $open) * 100;
print "Percentage : " . $percentage . "rn";
$average = ($ticker['last'] + $open) / 2;
print "Average : " . $average . "rn";
print "Volume BTC: " . $ticker['baseVolume'] . "rn";
print "Volume IDR : " . $ticker['quoteVolume'] . "rn";
print "Server Time : " . $ticker['info']['server_time'] . "rn";
print "====== IMPORTAN TRADING TICKER CLOSE ===== rnrn";

$buy = $ticker['bid'] - $average;

if($buy > 2){
frist -> get last and save as temp.
second -> function sleep 7m.
thrithy -> check the last after 7m sleep and save as temp.
four -> checking if temp last after 7m sleep 50% less than last before 7m. make some buy function.
}

$sell = $average - $ticker['ask'];

if($sell > 2){
frist -> get last and save as temp.
second -> function sleep 7m.
thrithy -> check the last after 7m sleep and save as temp.
four -> checking if temp last after 7m sleep 30% bigger than last before 7m. make some sell function.
}`

Help me explain my function :)

Thank You.

but if i'm used same as doc

'average': float, // average price, (last + open) / 2

$average = ($ticker['last'] + $open) / 2;

$sell = $average - $ticker['ask'];

result $sell always negative.

explain it

Thank You brother :D :D

untitled

what is the mean opening price, btc currncy or IDR currency?

In CCXT library:

  • price is always in quote currency
  • amount in tickers is designated as baseVolume (base currency, BTC), and quoteVolume (quote currency, IDR)

From the Manual: https://github.com/ccxt/ccxt/wiki/Manual#consistency-of-base-and-quote-currencies

base currency ↓
             BTC / USDT
             ETH / BTC
            DASH / ETH
             BTC / IDR
                    ↑ quote currency

So, all prices in BTC/IDR ticker are in IDR.

Does this answer your question?

Please update this doc

if ($exchange->has['fetchOHLCV']) foreach ($exchange->markets as $symbol => $market) { usleep ($exchange.rateLimit * 1000); // usleep wants microseconds var_dump ($exchange->fetch_ohlcv ($symbol, '1M')); // one month }

when use usleep($exchange.rateLimit * 100); //usleep wants microseconds it will be getting an error like this : Warning: Use of undefined constant rateLimit - assumed 'rateLimit' (this will throw an Error in a future version of PHP)

update to : 'if ($exchange->has['fetchOHLCV'])
foreach ($exchange->markets as $symbol => $market) {
usleep ($exchange->rateLimit * 1000); // usleep wants microseconds
var_dump ($exchange->fetch_ohlcv ($symbol, '1M')); // one month
}'

Thank you.

and try review again the class has[fetchOHLCV] / fetch_ohlcv , i got unidentified output like this :
float(3.465E-5)

Thank you

i got unidentified output like this : float(3.465E-5)

What do you mean exactly by "unidentified" ? Which output, which exchange?

Please update this doc

Docs updated, thank you very much for pointing that out! )

untitled

like this

Please check $exchange.withdraw (currency, amount, address, tag = undefined, params = {})
change to $exchange->withdraw (currency, amount, address, tag = undefined, params = {})

@juragandotid that is answered here: https://github.com/ccxt/ccxt/issues/2529#issuecomment-379923894 . You call it "unidentified" because you need at least basic Python skills to treat that correctly – that's how float point numbers are printed out in Python print() and pprint() by default, and it's up to you to choose the way you want them. You should read more about Python basics and on working with variable types, especially float number, scientific notation s and formatting (docs linked above).

Documentation Withdraw for indodax

withdrawCoin(base parameter indodax)

This method is for withdrawing assets (except IDR).
To be able to use this method you need to enable withdraw permission when you generate the API
Key. Otherwise you will get “No permission” error.
You also need to prepare a Callback URL. Callback URL is a URL that our system will call to
verify your withdrawal requests. Various parameters will be sent to Callback URL, make sure to
check this information on your server side. If all the data is correct, print out a string “ok” (without
quotes). We will continue the request if only we receive “ok” (without quotes) response, otherwise
the request will be failed.
Callback call will be sent through a POST request, with 5 seconds connection timeout.

Request Parameter :

Parameter Required? Description value

currency yes Currency to withdraw btc, ltc, doge,eth,etc

withdraw_address yes Receiver address a valid address

withdraw_amount yes Amount to send numerical

withdraw_memo optional / no Memo to be sent to the receiver memo

request_id yes Custom string you need to provide to alphanumeric,
max length 255
identify each withdrawal request. request_id
will be passed to callback call so your
system can identify the request.

Response :

{ "success": 1, "status": "approved", "withdraw_currency": "xrp", "withdraw_address": "rwWr7KUZ3ZFwzgaDGjKBysADByzxvohQ3C", "withdraw_amount": "10000.00000000", "fee": "2.00000000", "amount_after_fee": "9998.00000000", "submit_time": "1509469200", "withdraw_id": "xrp-12345", "txid": "", "withdraw_memo": "123123" }

Thank You.

how do i get the last price if using this class fetch_ohlcv

Thank you.

how do i get the last price if using this class fetch_ohlcv

First of, that is not a class. If you want to be understood, you should not really use the words that you're not familiar with yet ) That is called a function or a method or class method, not a class ) If you want an advice: better learn the common terminology and stick to it )

OHLCV stands for:

  • Open (opening price in quote currency for that candle/period)
  • High (highest price in quote currency for that candle/period)
  • Low (lowest price in quote currency for that candle/period)
  • Close (closing price in quote currency for that candle/period)
  • Volume (in base currency)

↑ as you can see, the OHLCV data does not contain the "last" price, however, you can get the last price from fetchTicker or from fetchTrades – that will be the price of the last trade, if you want the current last price. Historical OHLCV data does not contain that info.

can u explain how to sleep in mircrosecond?

if ($exchange->has['fetchOHLCV']) foreach ($exchange->markets as $symbol => $market) { **usleep ($exchange->rateLimit * 1000); // usleep wants microseconds** var_dump ($exchange->fetch_ohlcv ($symbol, '1M')); // one month }

this is my code
usleep($exchange->rateLimit * 180000000);

igot an error :

Warning: usleep() expects parameter 1 to be integer

thank you

The rateLimit is milliseconds, one millisecond = 1000 microseconds

$rateLimitInMicroseconds = $exchange->rateLimit * 1000;
usleep($exchange-rateLimit);

I'd recommend to use the built-in rate-limiter instead.

UPD. Corrected the above answer.

when i use usleep in 1 minute what can i do?

why cannot get respon from this
$symbol = 'BTC/IDR'; // bitcoin contract according to bitmex futures coding $type = 'limit'; $side = 'buy'; // or 'buy' $amount = 0.00022; $simpan = 94000000; $buyOrder = $this->inboxno->create_order($symbol, $type, $side, $amount, $simpan); print_r($buyOrder);

how to add Exception in php, because i wanna check whats misstack in response

I think this trobel on indodax source, please check again any mistack or typo or api change.Because i have try no response and no error show.

Thank your.

please check indodax.php at public function describe()

'BTC/IDR' => array ( 'id' => 'btc_idr', 'symbol' => 'BTC/IDR', 'base' => 'BTC', 'quote' => 'IDR', 'baseId' => 'btc', 'quoteId' => 'idr', 'precision' => array ( 'amount' => 8, 'price' => 0 ), 'limits' => array ( 'amount' => array ( 'min' => 0.0001, 'max' => null ))),

on array('min' => 0.0001, 'max' => null)

indodax now minimum open order or buy is 50000 IDR

thank you.

And now indodax private api has change to https://indodax.com/trade_api.

Please check again any api change or partmeter change.

Thank You.

apiprtmeter

api

And once again , i think indodax now has change method authentication api.

Public api = https://indodax.com/api
Private api = https://indodax.com/trade_api

and authenticate api using hmac, and post on https://indodax.com/trade_api.

auth

@juragandotid you'd better start reading around if you want to save your time:

Make sure that you have the most recent version of ccxt, this is also written in the docs.
Current CCXT implementation of INDODAX is up to date.

Mybe the indodax doc typo send request to https://indodax.com/tapi because in doc private api has change to https://indodax.com/trade_api. or there has use https://indodax.com/tapi to authenticate whit api key and sign in with hmac. and https://indodax.com/trade_api for private api supported list partmeter in doc update 2018 and http://indodax.com/api for public api supported list partmeter in doc.

This is my review, and please chek again mybe i'm false review and thingking.

Thank you.

This: https://indodax.com/trade_api is their website page for creating API keys, it requires a user to sign in.

This: https://indodax.com/tapi is their API base URL for integrating with other code, and this is what we are using, as documented in their Manual. If you change it to https://indodax.com/trade_api it just stops working, obviously, as expected.

mybe i'm false review and thingking.

Yep.

How to include api key private on indodax.php ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbn920 picture rbn920  ·  64Comments

marinsokol5 picture marinsokol5  ·  60Comments

barthr picture barthr  ·  37Comments

kroitor picture kroitor  ·  72Comments

janeCMD picture janeCMD  ·  43Comments