Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @Route("/auto", name="auto")
- */
- public function auto(Request $request){
- $market = $request->query->get('market');
- $total = floatval($request->query->get('total'));
- $book = "https://bittrex.com/api/v1.1/public/getorderbook?market=$market&type=both&depth=50";
- $book = json_decode(file_get_contents($book))->result->sell;
- $sum = 0;
- $price = 0;
- foreach($book as $k=>$v){
- $sum += floatval($v->Quantity)*floatval($v->Rate);
- if($sum >= $total){
- $price = floatval($v->Rate);
- break;
- }
- }
- $quantity = $total/$price;
- echo "Q:$quantity P:$price";
- $buy = "https://bittrex.com/api/v1.1/market/buylimit?apikey=API_KEY&market=$market&quantity=$quantity&rate=$price";
- $apikey='';
- $apisecret='';
- $nonce=time();
- $uri='https://bittrex.com/api/v1.1/'.$command.'?market='.$market.'&apikey='.$apikey.'&nonce='.$nonce."&quantity=$quantity&rate=$price";
- $sign=hash_hmac('sha512',$uri,$apisecret);
- $ch = curl_init($uri);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
- $execResult = curl_exec($ch);
- $obj = json_decode($execResult);
- return new JsonResponse(array());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement