coinbase-php icon indicating copy to clipboard operation
coinbase-php copied to clipboard

How to place buy/sell order for Ethereum?

Open eddial opened this issue 9 years ago • 3 comments

Hi,

I was wondering how to place a buy/sell order for Ether. The docs say I can use this:

use Coinbase\Wallet\Resource\Buy;

$buy = new Buy([
    'bitcoinAmount' => 1
]);

$client->createAccountBuy($account, $buy);

What are the parameters I should put into the Buy object to buy Ether? And how can I pass more arguments into the call like in the API docs? https://developers.coinbase.com/api/v2?python#place-buy-order

Hope someone can help me out! :)

eddial avatar Jul 16 '17 17:07 eddial

I think something like that

    $buy = new Buy();
    $buy->setAmount(new Money(0.05, 'ETH'));
    $buy->setPaymentMethod($paymentMethod);

bitcoinAmount is just a shorthand for

public function setBitcoinAmount($amount)
{
    $this->amount = new Money($amount, CurrencyCode::BTC);
}

magicsunday avatar Dec 01 '17 11:12 magicsunday

Then to place the buy: should we still use : $client->createAccountBuy($account, $buy); ? I'm not certain which account needs to be used here, getPrimaryAccount or one of getAccounts? In any case: createAccountBuy is returning null in my code... :/

dreammonkey avatar Jan 10 '18 20:01 dreammonkey

Support for new currencies was added in version 2.6.0. Ensure you're running that version or newer, and if you're still seeing issues feel free to open a new issue. Thanks!

sds avatar Feb 11 '18 07:02 sds