A script to automate the marketplace choiceadv is very difficult unless you have ALL of the hobo glyphs, since handling for all possibilities must be present in the event that you find you've gone a wrong direction. For now, use the script Grotfang linked above, it's quite handy. (Note that mafia auto-stops when you get a hobo code, unless you have other goals set. This makes getting glyphs quite easy, except for the very annoying glyph in the Greater-Than Sign.)
Then, if you are using Best Between Battle, you can type this in the CLI to get to the marketplace with 1000 nickels:
maximize items; conditions add 1000 hobo nickel; adv * town square"; equip hobo binder; adv * town square
Note that your CCS needs to be capable of killing hobos. Also, you will still have to navigate the marketplace yourself, but that's pretty close to full automation.