示例#1
0
def printBuysAndSellsCounts(query={}):
    for bot in db_bots.find(query):
        buy, sell = 0, 0
        ops = bot['history']['operations']
        for op in ops:
            if op[1] > 0:
                buy += 1
            else:
                sell += 1
        print(bot['id'], bot['name'], '  :  ', buy, 'buys and', sell, 'sells')
示例#2
0
def countBuysAndSells(query={}):
    buy, sell = 0, 0
    for bot in db_bots.find(query):
        ops = bot['history']['operations']
        for op in ops:
            if op[1] > 0:
                buy += 1
            else:
                sell += 1
    return buy, sell
示例#3
0
def filterByEvalutaion(bar=100000, query={}):
    res = []
    for bot in db_bots.find(query):
        hist = bot['history']['evaluation']
        if (len(hist) < 2):
            pass
        else:
            lastHist = hist[-1][1]
            if lastHist > bar:
                res.append(bot)
    return res
示例#4
0
def printGoodAndBad(query={}):
    good, bad, better = 0, 0, 0
    for bot in db_bots.find(query):
        hist = bot['history']['evaluation']
        if (len(hist) < 2):
            pass
        else:
            lastHist = hist[-1][1]
            secLastHist = hist[-2][1]
            good += 1 if lastHist > 100000 else 0
            bad += 1 if lastHist < 100000 else 0
            better += 1 if lastHist > secLastHist else 0
    print("among 2000 robots,", good, 'are winning,', bad, 'are losing',
          better, 'are improving')
示例#5
0
'''
This module is a high-level interface of the system.
'''

from crawlbot import downloadData
from time import sleep
# downloadData(8,way='db')

print("Download complete. Now starting to train.")
sleep(0.5)

from tradebot import Bot
from config import db_bots, forestSize

# Fill up the forest with new bots
while db_bots.count_documents({}) < forestSize:
    bot = Bot()
    bot.save()

allBots = db_bots.find()
sleep(0.5)
for epoch in db_bots.find():
    bot = Bot(epoch)
    bot.operate(way='db')
    bot.eliminate(way='db', bar=98000)