Pages:
Author

Topic: ncurses based MtGox live monitor and trading-bot-framework - page 3. (Read 33859 times)

hero member
Activity: 938
Merit: 500
https://youengine.io/
So I got something like this:
Did you change the character that is used for the depth bars or is that the way putty displays the ACS_CKBOARD character?

(Also from your screenshot it seems you are still using the socketio server, you should switch to websocket, much better experience, faster connect and no disconnects anymore)
newbie
Activity: 49
Merit: 0
I never liked how depth/tick messages keep flooding the console window. At first I was disabling those. But today I tried to hack it into a separate console window (I am using a large screen and half the console window was unused anyway).

So I got something like this:

At the moment it is rather an ugly hack. And the question is: anyone else interested? Should I clean it up?
legendary
Activity: 1148
Merit: 1001
Radix-The Decentralized Finance Protocol
I hit a problem with my bot and its that the last days the number of trades has increased a lot at mtgox so downloading two days of data everytime I load the bot takes for ever. So Ive been programming a way to save the trades in a database. It obviously saves the trades in the database, but also on load my strategy checks the first received trade and the oldest trade in the database and downloads the trades missing between them so the history is always complete. The idea is to use it for backtesting as well. If anyone is interested I can share the code.

Also, with more datapoints the hourly ema formula gives almost exacts results to bitcoincharts (as suspected) so thats good.
sr. member
Activity: 350
Merit: 250
ahh thx ill look into it
legendary
Activity: 1148
Merit: 1001
Radix-The Decentralized Finance Protocol
can anyone help me with coding a strategy for this tool...

I need to calc the EMAs and want to use the differance in my stratagy...
I have no clue atm how to do this....

Im looking to create a macd stratagy on the dema from mtgox

Pm me pls, as I dont want to derail the thread, thx

MtQuid already showed how to include ta-lib in a strategy. Look early pages in this thread.
sr. member
Activity: 350
Merit: 250
can anyone help me with coding a strategy for this tool...

I need to calc the EMAs and want to use the differance in my stratagy...
I have no clue atm how to do this....

Im looking to create a macd stratagy on the dema from mtgox

Pm me pls, as I dont want to derail the thread, thx
newbie
Activity: 24
Merit: 0
I just want to inform you, guys, that an interesting python open source software for backtesting strategy is available here
http://gbeced.github.io/pyalgotrade/

mixing both goxtool and pyalgotrade could make a good "recipe".

I'm looking for a 1 hour timeframe data history for MtGox BTCUSD

I tried http://bitcoincharts.com/t/trades.csv?symbol=mtgoxUSD&start=1335830400&end=1367366400

as 1335830400 is UNIX Timestamp for Tue, 01 May 2012 00:00:00 GMT
and 1367366400 for Wed, 01 May 2013 00:00:00 GMT

but Bitcoincharts only reply with data from 1367249267 (Mon, 29 Apr 2013 15:27:47 GMT)

Cool.
Have a look here http://www.reddit.com/r/Bitcoin/comments/11iz5b/the_history_of_gox_mountain/
I just downloaded the torrent and this is the head
Code:
http://data.mtgox.com/api/2/BTCUSD/money/trades/fetch?since=0
insert into trades values ("USD", "1279408157", "Y", "BTC", "limit", "1", "2000000000", "20", "4951", "", "0.04951")
insert into trades values ("USD", "1279424586", "Y", "BTC", "limit", "2", "5001000000", "50.01", "5941", "", "0.05941")
insert into trades values ("USD", "1279475336", "Y", "BTC", "limit", "3", "500000000", "5", "8080", "", "0.0808")
insert into trades values ("USD", "1279489451", "Y", "BTC", "limit", "4", "1000000000", "10", "8585", "", "0.08585")
insert into trades values ("USD", "1279490426", "Y", "BTC", "limit", "5", "500000000", "5", "8584", "", "0.08584")
insert into trades values ("USD", "1279490436", "Y", "BTC", "limit", "6", "500000000", "5", "8584", "", "0.08584")
insert into trades values ("USD", "1279511584", "Y", "BTC", "limit", "7", "500000000", "5", "9090", "", "0.0909")
insert into trades values ("USD", "1279556653", "Y", "BTC", "limit", "9", "8000000000", "80", "9307", "", "0.09307")
insert into trades values ("USD", "1279559013", "Y", "BTC", "limit", "10", "10000000000", "100", "8911", "", "0.08911")

and the tail
Code:
insert into trades values ("USD", "1367047706", "Y", "BTC", "limit", "1367047706332857", "9980000", "0.0998", "13683040", "ask", "136.8304")
insert into trades values ("USD", "1367047791", "Y", "BTC", "limit", "1367047791768232", "25712723", "0.25712723", "13688009", "bid", "136.88009")
insert into trades values ("USD", "1367047804", "Y", "BTC", "market", "1367047804704062", "80186290", "0.8018629", "13682010", "ask", "136.8201")
insert into trades values ("USD", "1367047805", "Y", "BTC", "limit", "1367047805062520", "79726342", "0.79726342", "13688009", "bid", "136.88009")
insert into trades values ("USD", "1367047825", "Y", "BTC", "limit", "1367047825872682", "497020000", "4.9702", "13682020", "ask", "136.8202")
insert into trades values ("USD", "1367047826", "Y", "BTC", "limit", "1367047826181247", "500000000", "5", "13682000", "ask", "136.82")
insert into trades values ("USD", "1367047853", "Y", "BTC", "limit", "1367047853175671", "502980000", "5.0298", "13682000", "bid", "136.82")
insert into trades values ("USD", "1367047879", "Y", "BTC", "market", "1367047879486765", "800000000", "8", "13686000", "bid", "136.86")
insert into trades values ("USD", "1367047879", "Y", "BTC", "market", "1367047879775307", "600000000", "6", "13688000", "bid", "136.88")
insert into trades values ("USD", "1367047879", "Y", "BTC", "market", "1367047879824265", "122345236", "1.22345236", "13688009", "bid", "136.88009")

Would be cool to link up with pyalgotrade.
member
Activity: 69
Merit: 10
Excellent work prof7bit!!! Keep it up the good job!  Wink

Just made some changes to the stop loss bot and posted it in the stop loss bot thread (I added the start gain feature and full wallet amount autofill).

Donating 0.1 for this amazing tool. See transaction dd9dc2b56c328d7a1bb57d07381c789d2312249ee84dd79b578d75e49b4b854b

-DonBit
member
Activity: 105
Merit: 10
I just want to inform you, guys, that an interesting python open source software for backtesting strategy is available here
http://gbeced.github.io/pyalgotrade/

mixing both goxtool and pyalgotrade could make a good "recipe".

I'm looking for a 1 hour timeframe data history for MtGox BTCUSD

I tried http://bitcoincharts.com/t/trades.csv?symbol=mtgoxUSD&start=1335830400&end=1367366400

as 1335830400 is UNIX Timestamp for Tue, 01 May 2012 00:00:00 GMT
and 1367366400 for Wed, 01 May 2013 00:00:00 GMT

but Bitcoincharts only reply with data from 1367249267 (Mon, 29 Apr 2013 15:27:47 GMT)
sr. member
Activity: 288
Merit: 250
ManualMiner
Smiley
thx, i use your code as leraning object; isnt that a good motivation - as soon as it works it brings btc
hero member
Activity: 938
Merit: 500
https://youengine.io/
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.
hero member
Activity: 560
Merit: 500
I am the one who knocks
You REALLY want to listen to prof7bit.  Especially because we don't have backtesting so you are effectively PAYING to test your bot on the live system.
hero member
Activity: 938
Merit: 500
https://youengine.io/
AAAAAAHHHHH, its the variables in the braces of the class-functions, right?
i.e.
def slot_history_changed(self, history, _dummy):
history is found in goxapi - class History(BaseObject)
so goxapi "fills" its classes and strategy.py is defining other classes filled with goxapi results?
I think i start to understand
lol, yes, almost. Although your usage of the above terms indicates that you are only at the beginning of your journey, learning Python. You should really try to work through some tutorials, write your own simple programs from scratch, first start with simple functon calls, understand what function arguments are, global and local variables, then much later maybe learn what classes are and methods and how these are related, inheritance, virtual methods and all that stuff. And then beneath all that there also exist an entire universe of hidden Python-specific black magic that can also be used. This is not learned and understood in one single day, it needs some time.
sr. member
Activity: 288
Merit: 250
ManualMiner
Sad i am blind as a fish, cant see it..

i posted:

hy
i started to look into goxbot and i must admit, i dont get anything, but anyway i will reach the goal of my own little bot. Wink plz help!

in my strategy module i got (copied most of it of the 50/50-balance boot)

Code:
import strategy
import goxapi


class Strategy(strategy.Strategy):

    """a protfolio rebalancing bot"""
    def __init__(self, gox):
        strategy.Strategy.__init__(self, gox)
        self.temp_halt = False


    def slot_before_unload(self, _sender, _data):
        pass

    def slot_keypress(self, gox, (key)):
if key == ord("b"):
    self.debug("canceling all rebalancing orders")






If key "b" is pressed goxtool displays: someone pressed key b,
But it doesnt display "canceling all rebalancing orders".
so, how to write messages to the log output?


btw: is there an easy way to get rid of the Winconsole output in the main window? I am running tail on the log in a second window, so its just superfluid for me?



what i run now is (snipplet):

Code:
class Strategy(strategy.Strategy):
    """a protfolio rebalancing bot"""
    def __init__(self, gox):
        strategy.Strategy.__init__(self, gox)
        self.temp_halt = False

    def slot_before_unload(self, _sender, _data):
        pass

    def slot_keypress(self, gox, (key)):
        """a key has been pressed"""

        if key == ord("c"):
            # cancel existing rebalancing orders and suspend trading
            self.debug("canceling all rebalancing orders")
            self.temp_halt = True
            #self.cancel_orders()

do you mean that self.debug.. is under the "e" of key and above it was under the "y" of key?
sr. member
Activity: 288
Merit: 250
ManualMiner
AAAAAAHHHHH, its the variables in the braces of the class-functions, right?

i.e.

def slot_history_changed(self, history, _dummy):

history is found in goxapi - class History(BaseObject)

so goxapi "fills" its classes and strategy.py is defining other classes filled with goxapi results?

I think i start to understand
hero member
Activity: 938
Merit: 500
https://youengine.io/
i know about indentation (just a beginner yet), what i ment was, that i didnt see which indentation was messed up

The last two lines in your other posting, the if statement was outside the slot_keypress method, it was even outside the entire class. MtQuid intuitively corrected it and fixed the indentation without asking further questions when he tested it (because he understood what was probably your intention) but the Python interpreter cannot guess what you might have wanted to do, it will interpret it such that the block belonging to the slot_keypress method ends as soon as the indentation level changes.
sr. member
Activity: 288
Merit: 250
ManualMiner
i know about indentation (just a beginner yet), what i ment was, that i didnt see which indentation was messed up, but maybe due to the fact that since 6 hours i am studying your code and its the first time i actually try to cope with classes..
hero member
Activity: 938
Merit: 500
https://youengine.io/
thx again, i re-pasted the rebalancing bot and now it works, still i cant see what the error in the above code was

Because you messed up the indentations. This totally changes the program.

In Python whitespace has a syntactical meaning to get rid of the ugly and redundant and hard to reach (on a german keyboard) curly braces. The absence of curly braces and the clean and readable syntax are one of the main reasons I prefer python over all other scripting languages and Pascal over C++.
sr. member
Activity: 288
Merit: 250
ManualMiner
thx again, i re-pasted the rebalancing bot and now it works, still i cant see what the error in the above code was, anyway it prints out now.
I got this code now:

Code:
"""
The portfolio rebalancing bot will buy and sell to maintain a
constant asset allocation ratio of exactly 50/50 = fiat/BTC
"""

import strategy
import goxapi

DISTANCE    = 7     # percent price distance of next rebalancing orders
MARKER      = 7     # lowest digit of price to identify bot's own orders
COIN        = 1E8   # number of satoshi per coin, this is a constant.

def add_marker(price, marker):
    """encode a marker in the price value to find bot's own orders"""
    return price / 10 * 10 + marker

def has_marker(price, marker):
    """return true if the price value has the marker"""
    return (price % 10) == marker

def mark_own(price):
    """return the price with our own marker embedded"""
    return add_marker(price, MARKER)

def is_own(price):
    """return true if this price has our own marker"""
    return has_marker(price, MARKER)



class Strategy(strategy.Strategy):
    """a protfolio rebalancing bot"""
    def __init__(self, gox):
        strategy.Strategy.__init__(self, gox)
        self.temp_halt = False

    def slot_before_unload(self, _sender, _data):
        pass

    def slot_keypress(self, gox, (key)):
        """a key has been pressed"""

        if key == ord("c"):
            # cancel existing rebalancing orders and suspend trading
            self.debug("canceling all rebalancing orders")
            self.temp_halt = True
            #self.cancel_orders()


could you please point me in the right direction, so i can do some reading, about the "virtual slots"- i suppose the functions in the Strategy Class are those slots, i.e.
"slot_history_changed" - one is supposed to use this function to put some code in, when it is "fired"  - what i dont get is, the def is only fount in the strategy.py file - how does the goxtool and goxapi fire something into it?? thx!
hero member
Activity: 938
Merit: 500
https://youengine.io/
Tarzan's bots are not autoritative. Also he wrote some comments that indicate he did not really understand goxtool yet at the time he attempted to write these bots.

One can either make a copy of the existing strategy.py and use it directy or one can (more elegant and recommended) just derive a new class from it and override only the virtual slot methods that are needed for the bot and leave away the ones that are not needed (in Python all methods are always virtual and defining a method that exists in the inherited class will automatically override it)

Also please paste your code as it is (it was clearly not formatted properly in your previous posting, and you know (because you followed my advice to learn Python) that in Python indentation is a critical part of the syntax. Also post *all* relevant log output)
Pages:
Jump to: