<?php
/*
Vircurex API Auto trader - functions.php
Written by: Frozennova
Version 1.1
Date: 23/12/2013
*/
date_default_timezone_set("UTC");
function balance($cur,$user_name,$secret_word) {
$t = date("Y-m-d\TH:i:s", time());
$year = date("Y", time());
$trx_id = hash("sha256", $t."-".rand()); //
$tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";get_balance;" . $cur);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/get_balance.json?account=$user_name&id=$trx_id&token=$tok×tamp=$t¤cy=" .$cur);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$resp = curl_exec($ch);
$resp = json_decode($resp,true);
if (!isset($resp['availablebalance'])) {
$resp['availablebalance'] = "0.00";
}
return $resp['availablebalance'];
}
function get_sell_price($cur,$user_name,$secret_word) {
$t = date("Y-m-d\TH:i:s", time());
$year = date("Y", time());
$trx_id = hash("sha256", $t."-".rand()); //
$tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";get_balance;" . $cur);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/get_highest_bid.json?base=" . $cur . "&alt=BTC");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$resp = curl_exec($ch);
$resp = json_decode($resp,true);
return $resp['value'];
}
function get_buy_price($cur,$user_name,$secret_word) {
$t = date("Y-m-d\TH:i:s", time());
$year = date("Y", time());
$trx_id = hash("sha256", $t."-".rand()); //
$tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";get_balance;" . $cur);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/get_lowest_ask.json?base=" . $cur . "&alt=BTC");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$resp = curl_exec($ch);
$resp = json_decode($resp,true);
return $resp['value'];
}
function buy_coin($cur,$qty,$price,$user_name,$secret_word) {
$t = date("Y-m-d\TH:i:s", time());
$year = date("Y", time());
$trx_id = hash("sha256", $t."-".rand()); //
$tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";create_order;buy;$qty;$cur;$price;btc");
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/create_order.json?account=$user_name&id=$trx_id&token=$tok×tamp=$t&ordertype=buy&amount=$qty¤cy1=$cur&unitprice=$price¤cy2=btc");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$resp = curl_exec($ch);
return $resp;
}
function sell_coin($cur,$price,$qty,$user_name,$secret_word) {
$t = date("Y-m-d\TH:i:s", time());
$year = date("Y", time());
$trx_id = hash("sha256", $t."-".rand()); //
$tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";create_order;sell;$qty;$cur;$price;btc");
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/create_order.json?account=$user_name&id=$trx_id&token=$tok×tamp=$t&ordertype=sell&amount=$qty¤cy1=$cur&unitprice=$price¤cy2=btc");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$resp = curl_exec($ch);
return $resp;
}
function get_orders($user_name,$secret_word) {
$t = date("Y-m-d\TH:i:s", time());
$year = date("Y", time());
$trx_id = hash("sha256", $t."-".rand()); //
$tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";read_orders");
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/read_orders.json?account=$user_name&id=$trx_id&token=$tok×tamp=$t&otype=0");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$resp = curl_exec($ch);
$resp = json_decode($resp,true);
$i = 0;
if (isset($resp)) {
foreach($resp as $val) {
if (isset($val['orderid'])) {
$unreleased_orders[$i] = $val['orderid'];
$i++;
}
}
}
if(isset($unreleased_orders)){
return $unreleased_orders;
}
}
function release_order($orderid,$user_name,$secret_word) {
$t = date("Y-m-d\TH:i:s", time());
$year = date("Y", time());
$trx_id = hash("sha256", $t."-".rand()); //
$tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";release_order;$orderid");
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/release_order.json?account=$user_name&id=$trx_id&token=$tok×tamp=$t&orderid=$orderid");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$resp = curl_exec($ch);
$resp = json_decode($resp,true);
return $resp;
}
function read_order($orderid,$user_name,$secret_word) {
$t = date("Y-m-d\TH:i:s", time());
$year = date("Y", time());
$trx_id = hash("sha256", $t."-".rand()); //
$tok = hash("sha256", $secret_word.";".$user_name.";".$t.";".$trx_id.";read_order;$orderid");
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.vircurex.com/api/read_order.json?account=$user_name&id=$trx_id&token=$tok×tamp=$t&otype=0&orderid=$orderid");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$resp = curl_exec($ch);
$resp = json_decode($resp,true);
return $resp['order'];
}
?>
preferences:
33.48 ms | 402 KiB | 5 Q