Bitcoin Forum
April 25, 2024, 01:58:42 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: goxsh — command-line frontend to Mt. Gox  (Read 5073 times)
ahihi (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0



View Profile
June 17, 2011, 11:01:55 AM
Last edit: June 19, 2011, 08:14:06 AM by ahihi
 #1

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. Smiley

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. Smiley

----

Bug reports and ideas are welcome, but I can't promise anything!
1714053522
Hero Member
*
Offline Offline

Posts: 1714053522

View Profile Personal Message (Offline)

Ignore
1714053522
Reply with quote  #2

1714053522
Report to moderator
The Bitcoin software, network, and concept is called "Bitcoin" with a capitalized "B". Bitcoin currency units are called "bitcoins" with a lowercase "b" -- this is often abbreviated BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714053522
Hero Member
*
Offline Offline

Posts: 1714053522

View Profile Personal Message (Offline)

Ignore
1714053522
Reply with quote  #2

1714053522
Report to moderator
1714053522
Hero Member
*
Offline Offline

Posts: 1714053522

View Profile Personal Message (Offline)

Ignore
1714053522
Reply with quote  #2

1714053522
Report to moderator
1714053522
Hero Member
*
Offline Offline

Posts: 1714053522

View Profile Personal Message (Offline)

Ignore
1714053522
Reply with quote  #2

1714053522
Report to moderator
nakedman
Newbie
*
Offline Offline

Activity: 27
Merit: 0


View Profile
June 17, 2011, 11:20:59 AM
 #2

Looks pretty sweet. Thanks for sharing!
weex
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
June 18, 2011, 10:48:44 PM
 #3

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.
ahihi (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0



View Profile
June 19, 2011, 05:59:22 AM
 #4

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. Tongue
N12
Donator
Legendary
*
Offline Offline

Activity: 1610
Merit: 1010



View Profile
June 19, 2011, 06:54:05 AM
 #5

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?
ahihi (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0



View Profile
June 19, 2011, 07:02:47 AM
 #6

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! Smiley

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).
ahihi (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0



View Profile
June 19, 2011, 08:19:13 AM
 #7

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. Smiley

Thank you! Smiley
weex
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
June 19, 2011, 10:13:27 AM
 #8

Great development pace...if you keep it up everyone's going to want to trade via CLI.  Grin
dserrano5
Legendary
*
Offline Offline

Activity: 1974
Merit: 1029



View Profile
June 20, 2011, 06:21:50 PM
 #9

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!
Ssoele
Full Member
***
Offline Offline

Activity: 134
Merit: 100


There's no place like 127.0.0.1


View Profile
July 30, 2011, 03:18:36 PM
 #10

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

Did my words move you? Or did they bring you to enlightenment? Feel free to give some ฿ to me: 1DKMAfeDswYf9MFjWxjPCfjEVkgmXvnizo
Want to play some Minefield?
Optonic
Newbie
*
Offline Offline

Activity: 31
Merit: 0


View Profile WWW
July 30, 2011, 09:28:38 PM
 #11

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

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.
Optonic
Newbie
*
Offline Offline

Activity: 31
Merit: 0


View Profile WWW
July 31, 2011, 06:28:45 PM
 #12

Talking of feature requests: Just added FeatureRequests to the 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) and I will update FeatureRequests for you.
Optonic
Newbie
*
Offline Offline

Activity: 31
Merit: 0


View Profile WWW
August 10, 2011, 05:02:49 PM
 #13

goxsh 0.21 released. See New goxsh fork#msg446216.
infested999
Hero Member
*****
Offline Offline

Activity: 854
Merit: 500



View Profile
August 16, 2011, 10:01:51 AM
 #14

Can someone explain what the "profit" command does? I looked it up on the help page but it's not very descriptive.

              ▄███▄   ▄███▄
              █████   █████
      ▄███▄    ▀▀▀     ▀▀▀    ▄███▄
      █████     ▄██▄ ▄██▄     █████
       ▀▀▀ ▄██▄ ▀██▀ ▀██▀ ▄██▄ ▀▀▀
 ▄███▄     ▀██▀           ▀██▀     ▄███▄
 █████ ▄██▄                   ▄██▄ █████
  ▀▀▀  ▀██▀                   ▀██▀  ▀▀▀
                       ▄█
▄███▄ ▄██▄            ███ ███  ▄██▄ ▄███▄
█████ ▀██▀  ████      █████    ▀██▀ █████
 ▀▀▀         ▀███▄    ████           ▀▀▀
       ▄██▄    ████   ███     ▄██▄
 ▄███▄ ▀██▀     ▀███  ███     ▀██▀ ▄███▄
 █████            ███▄██           █████
  ▀▀▀              ▀████            ▀▀▀
                     ███
                     ███
                     ██
                   ███

████    ██
  ████    ██
    ████    ██
      ████    ██
        ████    ██
          ████    ██
          ████    ██
        ████    ██
      ████    ██
    ████    ██
  ████    ██
████    ██










White Paper
Yellow Paper
Pitch Deck
Telegram
LinkedIn
Twitter
holorga
Sr. Member
****
Offline Offline

Activity: 354
Merit: 250



View Profile WWW
August 16, 2011, 10:11:28 AM
 #15

awesome

infested999
Hero Member
*****
Offline Offline

Activity: 854
Merit: 500



View Profile
August 16, 2011, 10:35:12 AM
 #16

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!

              ▄███▄   ▄███▄
              █████   █████
      ▄███▄    ▀▀▀     ▀▀▀    ▄███▄
      █████     ▄██▄ ▄██▄     █████
       ▀▀▀ ▄██▄ ▀██▀ ▀██▀ ▄██▄ ▀▀▀
 ▄███▄     ▀██▀           ▀██▀     ▄███▄
 █████ ▄██▄                   ▄██▄ █████
  ▀▀▀  ▀██▀                   ▀██▀  ▀▀▀
                       ▄█
▄███▄ ▄██▄            ███ ███  ▄██▄ ▄███▄
█████ ▀██▀  ████      █████    ▀██▀ █████
 ▀▀▀         ▀███▄    ████           ▀▀▀
       ▄██▄    ████   ███     ▄██▄
 ▄███▄ ▀██▀     ▀███  ███     ▀██▀ ▄███▄
 █████            ███▄██           █████
  ▀▀▀              ▀████            ▀▀▀
                     ███
                     ███
                     ██
                   ███

████    ██
  ████    ██
    ████    ██
      ████    ██
        ████    ██
          ████    ██
          ████    ██
        ████    ██
      ████    ██
    ████    ██
  ████    ██
████    ██










White Paper
Yellow Paper
Pitch Deck
Telegram
LinkedIn
Twitter
neofutur
Full Member
***
Offline Offline

Activity: 146
Merit: 100



View Profile
August 16, 2011, 07:28:08 PM
 #17

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
Optonic
Newbie
*
Offline Offline

Activity: 31
Merit: 0


View Profile WWW
August 16, 2011, 09:18:16 PM
Last edit: August 18, 2011, 12:53:29 PM by Optonic
 #18

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.
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!