Пример #1
0
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
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
0
    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']),
            'low': str(x['low']),