本文整理汇总了PHP中Utilities::get_min_order_size方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::get_min_order_size方法的具体用法?PHP Utilities::get_min_order_size怎么用?PHP Utilities::get_min_order_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utilities
的用法示例。
在下文中一共展示了Utilities::get_min_order_size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make_min_orders
function make_min_orders($Adapters)
{
foreach ($Adapters as $Adapter) {
echo "*** " . get_class($Adapter) . " ***\n";
//_____get the markets to loop over:
$market_summaries = $Adapter->get_market_summaries();
$num_markets = sizeof($market_summaries);
/*//_____get open orders, sort them by creation date and remove the oldest orders:
$open_orders = $Adapter->get_open_orders();
usort($open_orders, function($a, $b) {
return $b['timestamp_created'] - $a['timestamp_created'];
});
//_____remove oldest orders for each valid market...
$x = 0;
while( $x++ < $num_markets )
if( sizeof( $open_orders ) > 0 )
if( get_class( $Adapter ) == "PoloniexAdapter" )
$output = $Adapter->cancel( $order['id'], array( "market" => $order['market'] ) );
else
$output = $Adapter->cancel( $order['id'] );*/
$bal = [];
shuffle($market_summaries);
foreach ($market_summaries as $market_summary) {
if ($market_summary['frozen']) {
continue;
}
//_____get currencies/balances:
$market = $market_summary['market'];
$curs_bq = explode("-", $market);
$base_cur = $curs_bq[0];
$quote_cur = $curs_bq[1];
$base_bal_arr = $Adapter->get_balance($base_cur, array('type' => 'exchange'));
$base_bal = isset($bal[$base_cur]) ? $bal[$base_cur] : $base_bal_arr['available'];
$quote_bal_arr = $Adapter->get_balance($quote_cur, array('type' => 'exchange'));
$quote_bal = isset($bal[$quote_cur]) ? $bal[$quote_cur] : $quote_bal_arr['available'];
echo " -> " . get_class($Adapter) . " \n";
echo " -> base currency ({$base_cur}) \n";
echo " -> base currency balance ({$base_bal}) \n";
echo " -> quote currency ({$quote_cur}) \n";
echo " -> quote currency balance ({$quote_bal}) \n";
//_____calculate some variables that are rather trivial:
$precision = $market_summary['price_precision'] + 2;
//_____significant digits - example 1: "1.12" has 2 as PP. example 2: "1.23532" has 5 as PP.
$epsilon = 1 / pow(10, $precision);
//_____smallest unit of base currency that exchange recognizes: if PP is 3, then it is 0.001.
$buy_price = $market_summary['bid'];
//_____buy at same price as highest bid.
$sell_price = $market_summary['ask'];
//_____sell at same price as lowest ask.
$spread = $sell_price - $buy_price;
//_____difference between highest bid and lowest ask.
echo " -> precision {$precision} \n";
echo " -> epsilon {$epsilon} \n";
echo " -> buy price: {$buy_price} \n";
echo " -> sell price: {$sell_price} \n";
echo " -> spread: {$spread} \n";
$buy_price = number_format($market_summary['bid'], $precision, '.', '');
$sell_price = number_format($market_summary['ask'], $precision, '.', '');
echo " -> final formatted buy price: {$buy_price} \n";
echo " -> final formatted sell price: {$sell_price} \n";
if (floatval($buy_price) > 0) {
//some currencies have big sell wall at 0.00000001...
$order_size = Utilities::get_min_order_size($market_summary['minimum_order_size_base'], $market_summary['minimum_order_size_quote'], $epsilon, $buy_price, $precision);
echo " -> buying {$order_size} in {$market} for {$buy_price} costing " . $order_size * $buy_price . " with quote balance of {$quote_bal} \n";
if (floatval($order_size * $buy_price) > floatval($quote_bal)) {
echo "\n\n -> quote balance of {$quote_bal} is too low for min buy order size of {$order_size} at buy price of {$buy_price} \n\n";
} else {
$buy = $Adapter->buy($market_summary['market'], $order_size, $buy_price, 'limit', array('market_id' => $market_summary['market_id']));
if (isset($buy['message']) && $buy['message'] != 'MARKET_OFFLINE') {
print_r($buy);
die('test');
} else {
$bal[$quote_cur] = $quote_bal - $order_size * $buy_price;
}
}
}
if (floatval($sell_price) > floatval($buy_price)) {
//just in case...
$order_size = Utilities::get_min_order_size($market_summary['minimum_order_size_base'], $market_summary['minimum_order_size_quote'], $epsilon, $buy_price, $precision);
echo " -> selling {$order_size} in {$market} for {$sell_price} earning " . $order_size * $sell_price . " with base balance of {$base_bal}\n";
if (floatval($order_size) > floatval($base_bal)) {
echo "\n\n -> base balance of {$base_bal} is too low for min sell order size of {$order_size} at sell price of {$sell_price} \n\n";
} else {
$sell = $Adapter->sell($market_summary['market'], $order_size, $sell_price, 'limit', array('market_id' => $market_summary['market_id']));
if (isset($sell['message']) && $sell['message'] != 'MARKET_OFFLINE') {
print_r($sell);
die('test');
} else {
$bal[$base_cur] = $base_bal - $order_size;
}
}
}
echo "\n";
}
}
}
示例2: make_max_orders
function make_max_orders($Adapters)
{
foreach ($Adapters as $Adapter) {
echo "*** " . get_class($Adapter) . " ***\n";
//_____get the markets to loop over:
$market_summaries = $Adapter->get_market_summaries();
$num_markets = sizeof($market_summaries);
$Adapter->cancel_all();
$bal = [];
shuffle($market_summaries);
foreach ($market_summaries as $market_summary) {
if ($market_summary['frozen']) {
continue;
}
//_____get currencies/balances:
$market = $market_summary['market'];
$curs_bq = explode("-", $market);
$base_cur = $curs_bq[0];
$quote_cur = $curs_bq[1];
if ($base_cur == "BTC") {
continue;
}
//if( ! isset( $base_bal ) ) {
$base_bal_arr = $Adapter->get_balance($base_cur, array('type' => 'exchange'));
if (isset($base_bal_arr['ERROR'])) {
continue;
}
$base_bal = isset($bal[$base_cur]) ? $bal[$base_cur] : $base_bal_arr['available'];
//}
if (!isset($quote_bal)) {
$quote_bal_arr = $Adapter->get_balance($quote_cur, array('type' => 'exchange'));
if (isset($quote_bal_arr['ERROR'])) {
continue;
}
$quote_bal = isset($bal[$quote_cur]) ? $bal[$quote_cur] : $quote_bal_arr['available'];
}
echo " -> " . get_class($Adapter) . " \n";
echo " -> base currency ({$base_cur}) \n";
echo " -> base currency balance ({$base_bal}) \n";
echo " -> quote currency ({$quote_cur}) \n";
echo " -> quote currency balance ({$quote_bal}) \n";
//_____calculate some variables that are rather trivial:
$precision = $market_summary['price_precision'] + 2;
//_____significant digits - example 1: "1.12" has 2 as PP. example 2: "1.23532" has 5 as PP.
$epsilon = 1 / pow(10, $precision);
//_____smallest unit of base currency that exchange recognizes: if PP is 3, then it is 0.001.
$buy_price = number_format($market_summary['bid'], $precision, '.', '');
//_____buy at same price as highest bid.
$sell_price = number_format($market_summary['bid'], $precision, '.', '');
//_____sell at same price as lowest ask.
$spread = $sell_price - $buy_price;
//_____difference between highest bid and lowest ask.
echo " -> precision {$precision} \n";
echo " -> epsilon {$epsilon} \n";
echo " -> buy price: {$buy_price} \n";
echo " -> sell price: {$sell_price} \n";
echo " -> spread: {$spread} \n";
echo " -> final formatted buy price: {$buy_price} \n";
echo " -> final formatted sell price: {$sell_price} \n";
/*if( floatval($buy_price) > 0 ) { //some currencies have big sell wall at 0.00000001...
$order_size = Utilities::get_min_order_size( null, $quote_bal / $num_markets, $epsilon, $buy_price, $precision);
echo " -> buying $order_size in $market for $buy_price costing " . $order_size * $buy_price . " with quote balance of $quote_bal \n";
if( floatval($order_size * $buy_price) > floatval($quote_bal) )
echo "\n\n -> quote balance of $quote_bal is too low for min buy order size of $order_size at buy price of $buy_price \n\n";
else {
$buy = $Adapter->buy( $market_summary['market'], $order_size, $buy_price, 'limit', array( 'market_id' => $market_summary['market_id'] ) );
if( isset( $buy['message'] ) && $buy['message'] != 'MARKET_OFFLINE' ) {
print_r( $buy );
//die('test');
} else {
$bal[ $quote_cur ] = $quote_bal - $order_size * $buy_price;
}
}
}*/
//if( floatval($sell_price) > floatval($buy_price) ) { //just in case...
$order_size = $base_bal;
$min_order_size = Utilities::get_min_order_size($market_summary['minimum_order_size_base'], $market_summary['minimum_order_size_quote'], $epsilon, $buy_price, $precision);
if ($order_size > $min_order_size) {
echo " -> selling {$order_size} in {$market} for {$sell_price} earning " . $order_size * $sell_price . " with base balance of {$base_bal}\n";
if (floatval($order_size) > floatval($base_bal)) {
echo "\n\n -> base balance of {$base_bal} is too low for min sell order size of {$order_size} at sell price of {$sell_price} \n\n";
} else {
$sell = $Adapter->sell($market_summary['market'], $order_size, $sell_price, 'limit', array('market_id' => $market_summary['market_id']));
if (isset($sell['message']) && $sell['message'] != 'MARKET_OFFLINE') {
print_r($sell);
//die('test');
} else {
$bal[$base_cur] = $base_bal - $order_size;
}
}
}
//}
echo "\n";
}
}
}
示例3: poloniex_light_show
function poloniex_light_show($Adapter, $market)
{
echo "*** " . get_class($Adapter) . " Light Show ***\n";
//_____get the markets to loop over:
$market_summary = $Adapter->get_market_summary($market);
//_____get currencies/balances:
$market = $market_summary['market'];
$curs_bq = explode("-", $market);
$base_cur = $curs_bq[0];
$quote_cur = $curs_bq[1];
$base_bal_arr = $Adapter->get_balance($base_cur, array('type' => 'exchange'));
$base_bal = isset($bal[$base_cur]) ? $bal[$base_cur] : $base_bal_arr['available'];
$quote_bal_arr = $Adapter->get_balance($quote_cur, array('type' => 'exchange'));
$quote_bal = isset($bal[$quote_cur]) ? $bal[$quote_cur] : $quote_bal_arr['available'];
echo " -> " . get_class($Adapter) . " \n";
echo " -> base currency ({$base_cur}) \n";
echo " -> base currency balance ({$base_bal}) \n";
echo " -> quote currency ({$quote_cur}) \n";
echo " -> quote currency balance ({$quote_bal}) \n";
//_____calculate some variables that are rather trivial:
$precision = $market_summary['price_precision'] + 2;
//_____significant digits - example 1: "1.12" has 2 as PP. example 2: "1.23532" has 5 as PP.
$epsilon = 1 / pow(10, $precision);
//_____smallest unit of base currency that exchange recognizes: if PP is 3, then it is 0.001.
$buy_price = $market_summary['bid'];
//_____buy at same price as highest bid.
$sell_price = $market_summary['ask'];
//_____sell at same price as lowest ask.
$spread = $sell_price - $buy_price;
//_____difference between highest bid and lowest ask.
echo " -> precision {$precision} \n";
echo " -> epsilon {$epsilon} \n";
echo " -> buy price: {$buy_price} \n";
echo " -> sell price: {$sell_price} \n";
echo " -> spread: {$spread} \n";
$buy_price = number_format($market_summary['bid'], $precision, '.', '');
$sell_price = number_format($market_summary['ask'], $precision, '.', '');
echo " -> final formatted buy price: {$buy_price} \n";
echo " -> final formatted sell price: {$sell_price} \n";
$buy = array('message' => null);
$sell = array('message' => null);
//_____make 10 new visible orders:
while ($sell_price - $buy_price > 1.0E-8) {
if (rand() % 88 < 3) {
continue;
}
$buy_size = Utilities::get_min_order_size($market_summary['minimum_order_size_base'], $market_summary['minimum_order_size_quote'], $epsilon, $buy_price, $precision);
$sell_size = Utilities::get_min_order_size($market_summary['minimum_order_size_base'], $market_summary['minimum_order_size_quote'], $epsilon, $sell_price, $precision);
$buy_price = number_format($buy_price, $precision, '.', '');
$sell_price = number_format($sell_price, $precision, '.', '');
if ($buy_price < $sell_price) {
if (!isset($buy['error'])) {
echo " -> buying {$buy_size} of ETH for {$buy_price} costing " . $buy_size * $buy_price . " \n";
$buy = $Adapter->buy($market_summary['market'], $buy_size, $buy_price, 'limit', array('market_id' => $market_summary['market_id']));
echo "buy:\n";
print_r($buy);
}
if (!isset($sell['error'])) {
echo " -> selling {$sell_size} of ETH for {$sell_price} earning " . $sell_size * $sell_price . " \n";
$sell = $Adapter->sell($market_summary['market'], $sell_size, $sell_price, 'limit', array('market_id' => $market_summary['market_id']));
echo "\nsell:\n";
print_r($sell);
}
if (isset($buy['error']) && isset($sell['error'])) {
if (rand() % 88 < 2) {
$eth_open_orders = $Adapter->get_open_orders("ETH-BTC");
usort($eth_open_orders, function ($a, $b) {
return $b['timestamp_created'] - $a['timestamp_created'];
});
//delete the last 44 or so orders every 44 or so buy/sell fails
foreach ($eth_open_orders as $eth_open_order) {
print_r($eth_open_order);
if (rand() % 88 < 2) {
continue;
}
print_r($Adapter->cancel($eth_open_order['id'], array('market' => $eth_open_order['market'])));
}
}
return;
}
}
$buy_price = $buy_price + $epsilon;
$sell_price = $sell_price - $epsilon;
}
echo "\n";
}