Author

Topic: MTGox api/v1 php script, Incomplete need help adding to it. (Read 814 times)

legendary
Activity: 2912
Merit: 1060
Have you tried setting currency to usd maybe?
newbie
Activity: 46
Merit: 0
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.
newbie
Activity: 46
Merit: 0
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.
legendary
Activity: 1498
Merit: 1000
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.
newbie
Activity: 46
Merit: 0
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
newbie
Activity: 46
Merit: 0
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
Jump to: