<commit_before>import decimal
import logging
import config
import time
import concurrent.futures
from .observer import Observer
from .emailer import send_email
from private_markets import cryptsy
from private_markets import vircurex
from private_markets import bter
from private_markets import coinse


class TraderBot(Observer):
    def __init__(self):
        self.clients = {
            "Cryptsy": cryptsy.PrivateCryptsy(),
            "Vircurex": vircurex.PrivateVircurex(),
            "Bter": bter.PrivateBter(),
            "CoinsE": coinse.PrivateCoinsE()
        }
        self.trade_wait = 120  # in seconds
        self.last_trade = 0
        self.potential_trades = []

    def begin_opportunity_finder(self, depths):
        """Begin with no potential trades and update market balances."""
        self.potential_trades = []
        self.update_balances()

    def end_opportunity_finder(self):
        """Sort potential trades by profit, then execute the most profitable
        one."""
        if self.potential_trades:
            # Sort trades by profit, most profitable first
            self.potential_trades.sort(key=lambda x: x[0], reverse=True)
            # Execute only the best (more profitable)
            self.execute_trade(*self.potential_trades[0][:])

        time.sleep(1)  # Small pause to not flood API requests
        with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
            for market_name, market in self.clients.items():
                executor.submit(market.update_order_status())

    def max_tradable_volume(self, buy_price, kask, kbid):
        # We're buying primary coins from the market with kask at buy_price
        min1 = float(self.clients[kask].s_coin_balance) * (1 - config.balance_margin) / buy_price
        # We're selling primary coins to the market with kbid<commit_msg>Increase sleep time after trading<commit_after>import decimal
import logging
import config
import time
import concurrent.futures
from .observer import Observer
from .emailer import send_email
from private_markets import cryptsy
from private_markets import vircurex
from private_markets import bter
from private_markets import coinse


class TraderBot(Observer):
    def __init__(self):
        self.clients = {
            "Cryptsy": cryptsy.PrivateCryptsy(),
            "Vircurex": vircurex.PrivateVircurex(),
            "Bter": bter.PrivateBter(),
            "CoinsE": coinse.PrivateCoinsE()
        }
        self.trade_wait = 120  # in seconds
        self.last_trade = 0
        self.potential_trades = []

    def begin_opportunity_finder(self, depths):
        """Begin with no potential trades and update market balances."""
        self.potential_trades = []
        self.update_balances()

    def end_opportunity_finder(self):
        """Sort potential trades by profit, then execute the most profitable
        one."""
        if self.potential_trades:
            # Sort trades by profit, most profitable first
            self.potential_trades.sort(key=lambda x: x[0], reverse=True)
            # Execute only the best (more profitable)
            self.execute_trade(*self.potential_trades[0][:])

        time.sleep(5)  # Small pause to not flood API requests
        with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
            for market_name, market in self.clients.items():
                executor.submit(market.update_order_status())

    def max_tradable_volume(self, buy_price, kask, kbid):
        # We're buying primary coins from the market with kask at buy_price
        min1 = float(self.clients[kask].s_coin_balance) * (1 - config.balance_margin) / buy_price
        # We're selling primary coins to the market with kbid
{'fraction_non_alphanumeric': 0.08203753351206435, 'fraction_numerical': 0.005361930294906166, 'mean_word_length': 2.906806282722513, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1860420', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1021, 'n_words': 301}