Bitcoin Forum
May 29, 2024, 03:02:17 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: MTGox api/v1 php script, Incomplete need help adding to it.  (Read 799 times)
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
December 17, 2013, 09:22:00 AM
 #1

Got this api script to work for the defined functions

although im trying to set the market buy to an amount in USD, ie buy 5$ worth of btc!

line 88 submit_buy_order_at_market($amount)

problem is the amount is in BTC, I need to set it to USD somehow

https://github.com/daftspunk/php-mtgox-v1/blob/master/mtgox_private_api.php     


Thanks for the help
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
December 17, 2013, 09:56:27 AM
 #2

Found the v2

https://github.com/medoix/php-mtgox-v2/blob/master/mtgox_private_api.php


looks like its built the same way, not sure how to do the market order at USD
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
December 17, 2013, 10:00:24 AM
 #3

Found the v2

https://github.com/medoix/php-mtgox-v2/blob/master/mtgox_private_api.php


looks like its built the same way, not sure how to do the market order at USD

That is still V1

Code:
const uri_account_info = '1/generic/private/info';
    const uri_new_address = '1/generic/bitcoin/address';
    const uri_add_private_key = '1/generic/private/bitcoin/addpriv';
    const uri_add_wallet_dat = '1/generic/bitcoin/wallet_add';
    const uri_withdraw_coins = '1/generic/bitcoin/send_simple';
    const uri_id_key = '1/generic/private/idkey';
    const uri_trade_history = '1/BTC%s/private/trades';
    const uri_wallet_history = '1/generic/private/wallet/history';
    const uri_wallet_history_alt = '1/generic/wallet/history';
    const uri_submit_order = '1/BTC%s/private/order/add';
    const uri_get_orders = '1/generic/private/orders';
    const uri_order_result = '1/generic/private/order/result';
    const uri_cancel_order = '0/cancelOrder.php';

Those are V1 endpoints for the api.

https://github.com/pathaksa/MtGox-PHP-API-V2 and it does not support an order at market price, so just get the current price and set that as the order price.
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
December 17, 2013, 10:28:27 AM
Last edit: December 17, 2013, 10:44:11 AM by BitvoinVender
 #4

hmm, I know on mtgox's website I can set a market buy and just select USD. If i sell at a price isn't it possible it doesn't fill right  away? especially if the price is falling? If I calculated with the current price how much btc to buy, and placed an order priced over it would fill right away. But its possible it would spend more USD than my original target. Id have to go into the order book and make sure the entire trade can complete at a given price.

though it would be easier to tell an api to buy 5$ worth of bitcoin and have it be accurate down to the penny.
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
December 19, 2013, 11:26:07 PM
 #5

ok I need up bump this thread


im programming the follow steps to do this.

//get current price

//get current order book

//get amount (USD available to make purchase)

//calculate order (amount btc to be bought to reach USD target)

//place order for the btc calculated at market that would equate to the dollar amount.

//verify dollar's transaction cost. (assuming order book didn't change while placing.)



....

Is this really the way to do this? why on earth would an API not be able to place a market buy at a USD amount. I can do this on mtgox's website.

.1 btc reward to some one that figures this out.
bitpop
Legendary
*
Offline Offline

Activity: 2912
Merit: 1060



View Profile WWW
December 24, 2013, 07:34:21 AM
 #6

Have you tried setting currency to usd maybe?

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!