<commit_before>
import json
import urllib.request
import time

walletBitcoin = 100.0
walletDollar = 100000.0
firstrun = True
transection = 0.002

print ('Starting simulator...')
def getMidPrice():
    with urllib.request.urlopen('https://api.bitfinex.com/v1/pubticker/btcusd') as response:
        html = response.read()
    return float(json.loads(html)['mid'])
oldPrice = currentPrice = initPrice = getMidPrice()


def getTransectionfee():
    return transection * currentPrice


def getTotalNetWorth():
    return walletDollar + (walletBitcoin * currentPrice)

def showTotalNetWorth():
    print ('Total bitcoin:', walletBitcoin, 'walletDollar', walletDollar)
    print ('Total networth:', getTotalNetWorth(), 'profit', getTotalNetWorth() - totalNetWorthStart )

totalNetWorthStart = getTotalNetWorth()

while True:
    currentPrice = getMidPrice()
    print ('old;',oldPrice,'currentPrice;',currentPrice)
    if currentPrice > oldPrice:
        print ("sell")
        walletBitcoin = walletBitcoin - 1
        walletDollar = walletDollar + currentPrice - getTransectionfee()
        
    elif currentPrice < oldPrice:
        print ("buy")
        walletBitcoin = walletBitcoin + 1<commit_msg>get sell price and init start without bitcoin<commit_after>
import json
import urllib.request
import time

walletBitcoin = 0.0
walletDollar = 100000.0
firstrun = True
transection = 0.002

print ('Starting simulator...')
def getMidPrice():
    with urllib.request.urlopen('https://api.bitfinex.com/v1/pubticker/btcusd') as response:
        html = response.read()
    return float(json.loads(html)['mid'])

def getSellPrice():
    with urllib.request.urlopen('https://api.bitfinex.com/v1/pubticker/btcusd') as response:
        html = response.read()
    return float(json.loads(html)['last_price'])

oldPrice = currentPrice = initPrice = getSellPrice()


def getTransectionfee():
    return transection * currentPrice


def getTotalNetWorth():
    return walletDollar + (walletBitcoin * currentPrice)

def showTotalNetWorth():
    print ('Total bitcoin:', walletBitcoin, 'walletDollar', walletDollar)
    print ('Total networth:', getTotalNetWorth(), 'profit', getTotalNetWorth() - totalNetWorthStart )

totalNetWorthStart = getTotalNetWorth()

while True:
    currentPrice = getSellPrice()
    print ('old;',oldPrice,'currentPrice;',currentPrice)
    if currentPrice > oldPrice and walletBitcoin > 0:
        print ("sell")
        walletBitcoin = walletBitcoin - 1
        walletDollar = walletDollar + currentPrice - getTransectionfee()
    elif currentPrice < oldPrice:
        print ("buy")
        walletBitcoin = walletBitcoin + 1
{'fraction_non_alphanumeric': 0.11237661351556567, 'fraction_numerical': 0.01366742596810934, 'mean_word_length': 4.116504854368932, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1297506', 'n_tokens_mistral': 851, 'n_tokens_neox': 813, 'n_words': 191}