willmoss / bitstamp-php-api

PHP API for Bitstamp
19 stars 16 forks source link

Can not get API to Buy #8

Closed hoffy closed 7 years ago

hoffy commented 10 years ago

Hello, I can not seem to wrap my mind around getting this to buy. I have the sell operation working fine. Here is the snippet of my buy code. I put the round method into place as I thought maybe the value was throwing things out of whack. This does not seem to be the case. Any help you can provide would be great.

Thanks.


if ($ticker_last < $ticker_previous){ $buy_rate = $ticker_last * $buy_percentage; $buy_value = $ticker_last - $buy_rate;

if ($buy_value <= $ticker_last){

if ($balance_liquid_USD == 0){echo "Not Enough USD To Initiate Buy Order \n";} else { $buy_quantity = $balance_liquid_USD / $buy_value; $buy_quantity_round = round($buy_quantity, 2, PHP_ROUND_HALF_UP); $buy_price = $buy_value; //echo $buy_quantity_round, "\n"; //echo $buy_quantity, "\n"; $bs->buyBTC($buy_quantity_round); //$bs->bitstamp_query("buy", array('amount'=>"$buy_quantity_round",'price'=>"$buy_price")); $ticker_previous = $ticker_last; echo "Buy Action.\n"; } } else {echo "Buy Criteria Does Not Meet Percentage. \nGoal Missed: $buy_value \n";} } else {echo "Buy Criteria Not Met\n";}

hoffy commented 10 years ago

also please note neither of the $bs-> functions of the above code will inititate a buy action.