예제 #1
0
파일: simulate.py 프로젝트: brinchj/mtgox
def sim(start, end):
    f = "%d/%m-%Y %H:%M"
    start = time.mktime(time.strptime(start, f))
    end = time.mktime(time.strptime(end, f))
    trades = filter(lambda x: x['date'] >= start and x['date'] <= end,
                    history
                    )

    print '%s -- %s:' % \
        (time.ctime(trades[0]['date']), time.ctime(trades[-1]['date'])),

    trades = map(lambda x: {'date': x['date'],
                            'price': Decimal(x['price_int']) / Decimal(10**5),
                            'tid': x['tid']},
                 trades)
    bot = Scalper(Sim(trades), Decimal(1), Decimal(0))
    try:
        bot.start()
    except:
        print bot.btcs, bot.usds
예제 #2
0
파일: bot.py 프로젝트: brinchj/mtgox
import logging

from config import KEY, SEC
from mtgox import MtGox
from scalper import Scalper
from decimal import Decimal

logging.basicConfig(
    filename="bot.log",
    filemode="w",
    format="[%(asctime)s, %(threadName)s, %(name)s, %(levelname)s]\n   %(message)s",
    # format = '%(name)-12s: %(message)s',
    datefmt="%d/%m %H:%M:%S",
)

# logging.getLogger('MtGoxCore').setLevel(logging.DEBUG)
# logging.getLogger('MtGox').setLevel(logging.DEBUG)
logging.getLogger("MtGoxCore").setLevel(logging.NOTSET)
logging.getLogger("MtGox").setLevel(logging.DEBUG)


gox = MtGox(KEY, SEC)
gox.start()
scalper = Scalper(gox, Decimal(14), Decimal(80))
scalper.start()
예제 #3
-1
    filemode = 'w',
    format = '[%(asctime)s, %(threadName)s, %(name)s, %(levelname)s]\n   %(message)s',
    # format = '%(name)-12s: %(message)s',
    datefmt = '%d/%m %H:%M:%S',
    )

# logging.getLogger('MtGoxCore').setLevel(logging.DEBUG)
logging.getLogger('MtGox').setLevel(logging.DEBUG)
logging.getLogger('MtGoxCore').setLevel(logging.NOTSET)
# logging.getLogger('MtGox').setLevel(logging.INFO)

TIMEOUT = 60

_gox = MtGox(KEY, SEC)
_gox.start()
_scalper = Scalper(_gox)
_scalper.start()

def _to_decimal(x):
    return Decimal(str(x))

def stop():
    _gox.stop()
    _scalper.stop()
    quit()

def ticker():
    x = _gox.ticker()
    return {'buy': str(x['buy']),
            'sell': str(x['sell']),
            'high': str(x['high']),