예제 #1
0
파일: bbCmd.py 프로젝트: phildeutsch/bitbot
    def do_balance(self, arg):    
        krakenAPI = apiKraken.API(keyKraken, secKraken)
        pKraken   = bbClasses.portfolio(1,0)
        mKraken   = bbClasses.marketData('Null', 0, 0)
        b,a = krakenAPI.getDepth(1)
        mKraken.bid = float(b[0][0])
        mKraken.ask = float(a[0][0])
        krakenAPI.getBalance(mKraken, pKraken)

        print('Exchange   EUR         BTC     Value  ')
        print('--------------------------------------')
        sys.stdout.write('{0:<10}'.format('Kraken'))       
        sys.stdout.write('{0:>8.2f}'.format(float(pKraken.EUR)))       
        sys.stdout.write('{0:>10.3f}'.format(float(pKraken.BTC)))
        sys.stdout.write('{0:>10.2f}'.format(pKraken.value))
        print('')       
예제 #2
0
파일: bbCmd.py 프로젝트: phildeutsch/bitbot
    def do_funding(self, arg):
        krakenAPI = apiKraken.API(keyKraken, secKraken)
        pKraken   = bbClasses.portfolio(1,0)
        mKraken   = bbClasses.marketData('Null', 0, 0)
        b,a = krakenAPI.getDepth(1)
        mKraken.bid = float(b[0][0])
        mKraken.ask = float(a[0][0])

        strTime = datetime.datetime.now().isoformat()[0:16]
        flagBTC = input('Enter BTC transaction? ([y]/n): ')
        if flagBTC is 'n':
            amtEUR = input('Enter EUR amount: (<0 if withdrawal): ')
            writeList = ','.join([strTime, str(mKraken.bid), str(mKraken.ask),
                                  '0', str(amtEUR) + '\n'])
        else:
            amtBTC = input('Enter BTC amount: (<0 if withdrawal): ')
            writeList = ','.join([strTime, str(mKraken.bid), str(mKraken.ask),
                                  str(amtBTC), '0\n'])
        with open(bbCfg.fundFileName, 'at') as ff:
            ff.write(writeList)
예제 #3
0
def main(argv=None):
    testFlag, btFlag, quiet = argParser(argv)
    
    # Use data from exchange
    if btFlag == 0:
        API = apiKraken.API(keyKraken, secKraken)
        t = bbClasses.trader(bbCfg.logFileName)
    # Backtest: Use data from logfile
    else:
        API = apiBacktest.API()
        with open(bbCfg.logFileNameBT, 'w') as logBT:
            logBT.write('Time,Bid,Ask,EUR,BTC,Trade,minPrice,maxPrice\n')
        t = bbClasses.trader(bbCfg.logFileNameBT)
    
    p = bbClasses.portfolio(100,0)
    m = bbClasses.marketData('Null', 500, 500)

    if btFlag == 1 and testFlag == 0 and not quiet:
    # Progress bar
        for i in range(bbFunctions.progressBarLength()):
            sys.stdout.write('|')
        sys.stdout.write('\n')
        sys.stdout.flush
    while True:
        mainLoop(m, p, t, API, testFlag, btFlag, quiet)

        if testFlag:
            break
        elif btFlag == 1 and API.line == bbFunctions.file_len(bbCfg.logFileName):
            break
    
        if not btFlag:       
            timeNow = datetime.datetime.now()
            delay = (10 - (timeNow.minute)%10) * 60 - timeNow.second
            time.sleep(delay)
    if not quiet:
        print('\n')      
예제 #4
0
파일: test.py 프로젝트: phildeutsch/bitbot
import sys

sys.path.append('./source')
sys.path.append('./api')

import bbCfg
import bbFunctions
import bbClasses
import bitbot
import apiKraken
import apiBacktest

from bbKeys import *

t = bbClasses.trader(bbCfg.logFileName)
p = bbClasses.portfolio(100,0)
m = bbClasses.marketData('Null', 500, 500)
apiK = apiKraken.API(keyKraken, secKraken)
apiB = apiBacktest.API()

print('\nTesting normal trading')
bitbot.mainLoop(m, p, t, apiK, 0, 0)

print('\nTesting test mode')
bitbot.mainLoop(m, p, t, apiK, 1, 0)

print('\nTesting backtesting')
bitbot.main('-b')

print('\nTesting backtest + test mode')
bitbot.mainLoop(m, p, t, apiB, 1, 1)