Post
Topic
Board Trading Discussion
Re: ncurses based MtGox live monitor and trading-bot-framework
by
prof7bit
on 01/05/2013, 16:21:15 UTC
Code:
   def slot_keypress(self, gox, (key)):
if key == ord("b"):
    self.debug("canceling all rebalancing orders")
do you mean that self.debug.. is under the "e" of key and above it was under the "y" of key?

the entire two last lines don't seem to belong into the slot_keypress method because the if line needs to be intended further than the def line to be considered inside the method and the line after the if needs to be intended even further than the if to be considered inside the if block.

Also be careful with mixing tabs and spaces, you dont see them, everything looks right but isnt. In python it has been established that everybody use 4 spaces and no tabs to have a consistent coding style everywhere and I am trying to follow the styleguides as close as possible myself. So set your editor to

(depending on what editor you use, every editor has similar options somewhere in its config)
indentation 4 spaces
no tabs
convert tabs to spaces

Do this once and from then on everything becomes much easier.

You should also make it a habit to run your code through pylint, I'm doing this everytime I save the code in the editor, before I even attempt to run it, Its a great help, it forces you to adhere to the established standards and coding style and it also finds a lot of problems and errors (my favorite are misspelled variable names, missing function arguments, missing self argument in methods) that could otherwise only be detected at runtime and maybe even not immediately after program start but only after a few hours when its attempting to do its first trade.