Bitcoin Forum

Bitcoin => Project Development => Topic started by: ahihi on June 17, 2011, 11:01:55 AM



Title: goxsh — command-line frontend to Mt. Gox
Post by: ahihi on June 17, 2011, 11:01:55 AM
goxsh (https://github.com/ahihi/goxsh) is a "Mt. Gox shell" that I've been writing mainly for personal use, but I'm posting it here in the hopes that it could be useful to others too. :)

https://i.imgur.com/jJPjL.png

Features

  • Buy and sell bitcoins
  • Specify buy/sell amounts in BTC or USD
  • List and cancel orders
  • Withdraw bitcoins
  • Interactive authentication with no-echo password prompt — no need to store your credentials on disk
  • Display account balance
  • Display ticker
  • Calculate profitable short/long prices from an initial price
  • Tab completion of commands
  • Sequence multiple commands using semicolons
  • Abort commands with SIGINT (ctrl-c on *nix) without exiting, if Mt. Gox is being slow
  • Insert comments (# blah) e.g. for quick notes

Requirements

Python 2.6 or a newer 2.* release.

Usage

Run the script in a terminal window and type "help" to see the list of available commands.

License

Public domain. :)

----

Bug reports and ideas are welcome, but I can't promise anything!


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: nakedman on June 17, 2011, 11:20:59 AM
Looks pretty sweet. Thanks for sharing!


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: weex on June 18, 2011, 10:48:44 PM
Nice job on the use of Decimal. I just extended mtgox-trader to work with exchb.com so this might be cool to extend that way as well.


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: ahihi on June 19, 2011, 05:59:22 AM
Nice job on the use of Decimal. I just extended mtgox-trader to work with exchb.com so this might be cool to extend that way as well.

I've been thinking of supporting other exchanges than Mt. Gox, but I haven't decided on a nice way to switch between them. And it's a low-priority task since I don't really use any others on a regular basis myself. :P


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: N12 on June 19, 2011, 06:54:05 AM
After entering a username:
Code:
Traceback (most recent call last):
  File "C:\Users\Monolith\gox.py", line 145, in prompt
    proc(*args)
  File "C:\Users\Monolith\gox.py", line 302, in __cmd_login__
    readline.remove_history_item(readline.get_current_history_length() - 1)
AttributeError: 'module' object has no attribute 'remove_history_item'
Am I doing something wrong?


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: ahihi on June 19, 2011, 07:02:47 AM
After entering a username:
Code:
Traceback (most recent call last):
  File "C:\Users\Monolith\gox.py", line 145, in prompt
    proc(*args)
  File "C:\Users\Monolith\gox.py", line 302, in __cmd_login__
    readline.remove_history_item(readline.get_current_history_length() - 1)
AttributeError: 'module' object has no attribute 'remove_history_item'
Am I doing something wrong?

Hmm, it looks like the readline module on your system doesn't support history item removal, which I use to delete the lone username line from the command history. I'm currently working on some changes to command parsing, but as soon as that's done I'll put in a check for this and push it to github. Thanks for the report! :)

For the time being, you should be able to work around this by giving the username directly to the login command ($ login your_username_here).


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: ahihi on June 19, 2011, 08:19:13 AM
Just pushed a new version that fixes the remove_history_item bug, adds support for sequencing multiple commands (blah1; blah2) and allows comments (# blah)!

----

Thanks, works for me now. This is a neat tool for trading, I particularly like the profit price command.

Sent a small donation along your way. :)

Thank you! :)


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: weex on June 19, 2011, 10:13:27 AM
Great development pace...if you keep it up everyone's going to want to trade via CLI.  ;D


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: dserrano5 on June 20, 2011, 06:21:50 PM
I use a quickie shell that I wrote in a couple of minutes in Perl. Yours is more advanced than mine but it doesn't seem to have a feature I have coded in mine:

> buy 500$ 17.50
> buy 15% 17.50

ie. "Buy as many bitcoins as needed with 500 USD", "buy as many bitcoins as needed with 15% of my USDs". My python-fu doesn't reach a level high enough to make a patch, so I can only contribute my Perl (error checking removed to make the code clearer):

Code:
    given ($cmd) {
        when ('buy') {
            if ($args[0] =~ /^([0-9.]+)%$/) {
                my $pct = $1;
                my $b = $m->get_balance;   ## $m is an MtGox object
                $args[0] = sprintf '$%.3f', $b->{'usds'} * $pct / 100;
                ## don't continue, fall to the next if
            }
            if ($args[0] =~ /^\$([0-9.]+)$/ or $args[0] =~ /^([0-9.]+)\$$/) {
                my $usds = $1;
                my $t = $m->get_ticker;
                my $sell = $t->{'ticker'}{'sell'};

                $args[0] = $usds / $sell;
                ## don't continue, now the code proceeds to buy
            }
            $m->buy (amount => $args[0], price => $args[1]);

Hope it's useful!


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: Ssoele on July 30, 2011, 03:18:36 PM
A fellow pool member has made a nice fork of goxsh, you can see his thread here http://forum.bitcoin.org/index.php?topic=33017.0 (http://forum.bitcoin.org/index.php?topic=33017.0)


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: Optonic on July 30, 2011, 09:28:38 PM
A fellow pool member has made a nice fork of goxsh, you can see his thread here http://forum.bitcoin.org/index.php?topic=33017.0 (http://forum.bitcoin.org/index.php?topic=33017.0)

Thank you for promoting my fork/thread, Ssoele!

All of you are welcome to discuss this fork or ask for features over at the the thread in the "Newbies" section or within this thread.


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: Optonic on July 31, 2011, 06:28:45 PM
Talking of feature requests: Just added FeatureRequests (https://github.com/Optonic/goxsh/wiki/FeatureRequests) to the goxsh wiki (https://github.com/Optonic/goxsh/wiki). To edit the wiki a github account is required. If you are not a registered user at github and don't want to register you may of course continue to request features within this thread (or at the thread over at the "Newbies" section: New goxsh fork (http://forum.bitcoin.org/index.php?topic=33017.0)) and I will update FeatureRequests (https://github.com/Optonic/goxsh/wiki/FeatureRequests) for you.


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: Optonic on August 10, 2011, 05:02:49 PM
goxsh 0.21 released. See New goxsh fork#msg446216 (https://bitcointalk.org/index.php?topic=33017.msg446216#msg446216).


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: infested999 on August 16, 2011, 10:01:51 AM
Can someone explain what the "profit" command does? I looked it up on the help page but it's not very descriptive.


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: holorga on August 16, 2011, 10:11:28 AM
awesome


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: infested999 on August 16, 2011, 10:35:12 AM
When I withdraw I get this:

Code:
infested999$ withdraw xxxxxxxxxxxxxxxx x.xxxxxxxx
Funds are on their way (bitcoin transaction: edcf5d09cebc54cb87f9b30776dc48201ca19005db56dae6fca2f94f23b8510d)
Updated balance:
Traceback (most recent call last):
  File "goxsh.py", line 211, in prompt
    proc(*args)
  File "goxsh.py", line 429, in __cmd_withdraw__
    self.__print_balance(withdraw_info)
  File "goxsh.py", line 312, in __print_balance
    print u"BTC:", balance[u"btcs"]
KeyError: u'btcs'
BTC: infested999$

It still withdraws the money just fine, but it scared me a bit and I thought my BTC were all gone for a second. You should suppress that error!


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: neofutur on August 16, 2011, 07:28:08 PM
When I withdraw I get this:

Code:
infested999$ withdraw xxxxxxxxxxxxxxxx x.xxxxxxxx
Funds are on their way (bitcoin transaction: edcf5d09cebc54cb87f9b30776dc48201ca19005db56dae6fca2f94f23b8510d)
Updated balance:
Traceback (most recent call last):
  File "goxsh.py", line 211, in prompt
    proc(*args)
  File "goxsh.py", line 429, in __cmd_withdraw__
    self.__print_balance(withdraw_info)
  File "goxsh.py", line 312, in __print_balance
    print u"BTC:", balance[u"btcs"]
KeyError: u'btcs'
BTC: infested999$

It still withdraws the money just fine, but it scared me a bit and I thought my BTC were all gone for a second. You should suppress that error!

 for your information, the most advanced and supported goxsh is now the Optonic fork :

https://github.com/Optonic/goxsh
https://github.com/Optonic/goxsh/network
http://www.goxsh.info/
and channel #goxsh on freenode IRC server


Title: Re: goxsh — command-line frontend to Mt. Gox
Post by: Optonic on August 16, 2011, 09:18:16 PM
Can someone explain what the "profit" command does? I looked it up on the help page but it's not very descriptive.
The profit command calculates from which rate a buy/sell is profitable when bought/sold at a specified rate considering the current commission fee of Mt. Gox. E.g. if you sold 1 BTC at $10.00 you will start making profit (ending up with more BTC) when rebuying at < $9.94008. If you bought 1 BTC at $10.00 you will start making profit (ending up with more $ in your account) when selling at > $10.06028. If you rebuy > $9.94008 or sell < $10.06028 fees will be greater than what you actually gain in the actual trade and you end up with a loss.

When I withdraw I get this:

Code:
infested999$ withdraw xxxxxxxxxxxxxxxx x.xxxxxxxx
Funds are on their way (bitcoin transaction: edcf5d09cebc54cb87f9b30776dc48201ca19005db56dae6fca2f94f23b8510d)
Updated balance:
Traceback (most recent call last):
  File "goxsh.py", line 211, in prompt
    proc(*args)
  File "goxsh.py", line 429, in __cmd_withdraw__
    self.__print_balance(withdraw_info)
  File "goxsh.py", line 312, in __print_balance
    print u"BTC:", balance[u"btcs"]
KeyError: u'btcs'
BTC: infested999$

It still withdraws the money just fine, but it scared me a bit and I thought my BTC were all gone for a second. You should suppress that error!
This is a known bug with the last release of ahihi. Doesn't affect the withdraw–it just fails to print the new balance after the withdrawal. Fixed since 0.20 (https://github.com/Optonic/goxsh/tree/0.20).