Beispiel #1
0
def Main(msg):
    """
    获取微信消息,进行处理指令、关键词监听、撤回消息监听的动作
    :param msg: 微信消息
    :return: 无
    """
    # 三大功能之一:处理指令
    itchat.get_friends(update=True)
    if msg['ToUserName'] == "filehelper" and msg['Type'] == "Text":
        try:
            exec_command = Execution()
            exec_command.Execution(msg)
        except BaseException as e:
            mylog.WriteLog(e)

    # 三大功能之二:撤回消息部分
    try:
        rmsg = Revocation()
        rmsg.SaveMsg(msg)
        rmsg.Revocation(msg)
        rmsg.ClearTimeOutMsg()
    except BaseException as e:
        mylog.WriteLog(e)

    # 三大功能之三:关键词监听
    if msg['Type'] in ['Text', 'Sharing', 'Map', 'Card']:
        try:
            listener = KeywordListener()
            listener.Listener(msg)
        except BaseException as e:
            mylog.WriteLog(e)
Beispiel #2
0
 def testTestDetailsWithExecution(self):
     t0 = Test(1, "Test 0", "1111")
     t0.description = "This is my test"
     t0.add_parameter("tparam0", "tvalue1")
     t0.add_parameter("tparam1", "tvalue2")
     t0.add_property("tprop0", "tvalue0")
     t0.add_property("tprop1", "tvalue1")
     
     
     
     t1 = Test(2, "Test 2", "2222")
     t1.set_status("error")
     t2 = Test(3, "Test 3", "3333")
     t2.set_status("failure")
     
     s0 = Scenario("Scenario 0")
     s0.add_scenario_property("foo0", "bar0")
     s0.add_scenario_property("foo1", "bar1")
     s0.add_child(t0)
     s0.add_child(t1)
     s0.add_child(t2)
     
     m0 = Machine("Itai's desktop") 
     m0.add_child(s0)
     
     e = Execution()
     e.add_machine(m0)
     print(json.dumps(e.dict()))
Beispiel #3
0
def check_donaways_eod(date_i):
    while done_away_orders.has_order():
        o = done_away_orders.pop_order()
        day_return.add_transaction(o.qty, o.price)
        e = Execution(o.qty, o.symbol, o.price, date_i)
        executions.append(e)
        trades.add_execution(e)
Beispiel #4
0
 def testSimpleModel(self):
     expected = {'machines': [{'status': 'success', 'type': 'machine', 'name': "Itai's desktop", 'children': [{'status': 'success', 'children': [{'status': 'success', 'index': 1, 'uid': '1111', 'parameters': {'tparam0': 'tvalue1', 'tparam1': 'tvalue2'}, 'timestamp': '', 'name': 'Test 0', 'className': '', 'duration': 0, 'type': 'test', 'properties': {'tprop1': 'tvalue1', 'tprop0': 'tvalue0'}, 'description': 'This is my test'}, {'status': 'error', 'index': 2, 'uid': '2222', 'parameters': {}, 'timestamp': '', 'name': 'Test 2', 'className': '', 'duration': 0, 'type': 'test', 'properties': {}, 'description': ''}, {'status': 'failure', 'index': 3, 'uid': '3333', 'parameters': {}, 'timestamp': '', 'name': 'Test 3', 'className': '', 'duration': 0, 'type': 'test', 'properties': {}, 'description': ''}], 'type': 'scenario', 'name': 'Scenario 0', 'scenarioProperties': {'foo0': 'bar0', 'foo1': 'bar1'}}]}]}
     t0 = Test(1, "Test 0", "1111")
     t0.description = "This is my test"
     t0.add_parameter("tparam0", "tvalue1")
     t0.add_parameter("tparam1", "tvalue2")
     t0.add_property("tprop0", "tvalue0")
     t0.add_property("tprop1", "tvalue1")
     t1 = Test(2, "Test 2", "2222")
     t1.set_status("error")
     t2 = Test(3, "Test 3", "3333")
     t2.set_status("failure")
     
     s0 = Scenario("Scenario 0")
     s0.add_scenario_property("foo0", "bar0")
     s0.add_scenario_property("foo1", "bar1")
     s0.add_child(t0)
     s0.add_child(t1)
     s0.add_child(t2)
     
     m0 = Machine("Itai's desktop") 
     m0.add_child(s0)
     
     e = Execution()
     e.add_machine(m0)
     print (e.dict())
     self.assertDictEqual(expected, e.dict())
 def Initialize(self):
     self.SetStartDate(2003, 1, 1)
     self.SetCash(100000)
     
     # Data resolution
     self.UniverseSettings.Resolution = Resolution.Minute
     
     # Universe selection model
     self.securities = []
     self.CustomUniverseSelectionModel = FactorUniverseSelectionModel(self)
     self.AddUniverse(self.CustomUniverseSelectionModel.SelectCoarse, self.CustomUniverseSelectionModel.SelectFine)
     
     # Alpha model
     self.CustomAlphaModel = ValueAlphaModel()
     
     # Portfolio construction model
     self.CustomPortfolioConstructionModel = OptimisationPortfolioConstructionModel()
     
     # Execution model
     self.CustomExecution = Execution()
     
     # Add SPY for trading days data
     self.AddEquity('SPY', Resolution.Daily)
     
     # Schedule rebalancing
     self.Schedule.On(self.DateRules.EveryDay('SPY'), self.TimeRules.At(13, 0), Action(self.RebalancePortfolio))
     
     # Init charting
     InitCharts(self)
     
     # Schedule charting
     self.Schedule.On(self.DateRules.Every(DayOfWeek.Friday), self.TimeRules.BeforeMarketClose('SPY', 0), Action(self.PlotCharts))
Beispiel #6
0
    def init_model(self):
        self.execution = Execution()
        machine = Machine(socket.gethostname())
        machine.planned_tests = self.general_conf.get_int("planned.tests")

        self.execution.add_machine(machine)
        self.uid = str(randint(1000, 9999) + time.time() / 1000).replace(
            ".", "")
        self.index = 0
        self.scenario_stack = []
        self.buffered_elements = []
        self.testDetails = None
Beispiel #7
0
def start():
    global project, tracer, inspector
    try:
        project = Project.from_directory(find_project_directory(os.getcwd()))
        execution = Execution(project)
        inspector = Inspector(execution)
        tracer = Tracer(inspector)
        tracer.btracer.setup()
        sys.settrace(tracer.tracer)
    except PythoscopeDirectoryMissing:
        print "Can't find .pythoscope/ directory for this project. " \
            "Initialize the project with the '--init' option first. " \
            "Pythoscope tracing disabled for this run."
Beispiel #8
0
    def run(self):
        number_of_process = int(os.cpu_count() / 2)

        print(self._path_out)
        print(os.listdir(self._path_out))

        exams_exists = ['{}.mp4'.format(x) for x in os.listdir(self._path_out)]
        if len(self._list_available) > 0:
            list_exams = [
                x for x in self._list_available
                if ('.mp4' in x) and (x not in exams_exists)
            ]
        else:
            list_exams = [
                x for x in os.listdir(self._path_dataset)
                if ('.mp4' in x) and (x not in exams_exists)
            ]

        list_exams = ['benchmark_final.avi']

        process = []
        while len(list_exams) > 0:
            end_list = number_of_process if len(
                list_exams) > number_of_process else len(list_exams)
            list_process = list_exams[0:end_list]
            list_exams = list_exams[end_list:len(list_exams)]

            for exam in list_process:
                title = exam.replace('.avi', '')

                paths = {
                    'path_exam':
                    '{}/{}'.format(self._path_dataset, exam),
                    'path_information':
                    '{}/{}.log'.format(self._path_information, title),
                    'path_out':
                    '{}/{}'.format(self._path_out, title),
                    'path_label':
                    '{}/{}_label.csv'.format(self._path_label, title)
                }

                self._make_path(paths['path_out'])

                execution = Execution()
                thread = Process(target=execution.pupil_process,
                                 args=(paths, ))
                process.append(thread)
                thread.start()

            for thread in process:
                thread.join()
Beispiel #9
0
def check_fills(row):

    while done_away_orders.has_order():
        o = done_away_orders.pop_order()
        day_return.add_transaction(o.qty, o.price)
        e = Execution(o.qty, o.symbol, o.price, row.name)
        executions.append(e)
        trades.add_execution(e)

    orders = open_orders.get_open_orders(row['symbol'])
    if orders is not None:
        for o in orders[:]:
            if is_fill(o, row):
                record_fill(o, row)
                orders.remove(o)
Beispiel #10
0
def record_fill(o, row):
    fill_price = 0.0
    if o.price == 0:
        fill_price = float(row['open'])
    else:
        if o.qty > 0:

            fill_price = min(o.price, row['open'])
        elif o.qty < 0:

            fill_price = max(o.price, row['open'])

    day_return.add_transaction(o.qty, fill_price)
    e = Execution(o.qty, o.symbol, fill_price, row.name)
    executions.append(e)
    trades.add_execution(e)
Beispiel #11
0
def build_workout_sample():
    workout1 = Workout()
    workout1.date = '2018-02-19'
    execution1 = Execution()
    execution1.exercise = build_exercise_sample()
    set1, set2, set3 = Set(), Set(), Set()
    set1.start_time = '2018-02-19T16:10:35Z'
    set1.repetitions = 10
    set1.weight = 40
    set2.start_time = '2018-02-19T16:12:35Z'
    set2.repetitions = 9
    set2.weight = 42
    set3.start_time = '2018-02-19T16:14:35Z'
    set3.repetitions = 8
    set3.weight = 42
    execution1.sets = [set1, set2, set3]
    workout1.executions = [execution1]
    return workout1
Beispiel #12
0
    def Initialize(self):
        self.SetStartDate(2017, 1, 1)  # Set Start Date
        self.SetEndDate(2020, 5, 20)
        self.SetCash(100000)  # Set Strategy Cash

        # Weighting style - normalise or alpha_max (alpha maximisation w/ optimisation)
        self.weighting_style = 'normalise'

        # Market neutral
        self.mkt_neutral = True

        # Audio feature to use
        self.audio_feature = 'valence'

        # Get data
        self.data, self.etf_list, self.etf_country = self.DataSetup()

        # Add ETFs
        for etf in self.etf_list:
            self.AddEquity(etf, Resolution.Minute)

        # Portfolio construction model
        self.CustomPortfolioConstructionModel = OptimisationPortfolioConstructionModel(
            turnover=1,
            max_wt=0.2,
            longshort=True,
            mkt_neutral=self.mkt_neutral)

        # Execution model
        self.CustomExecution = Execution(liq_tol=0.005)

        # Schedule rebalancing
        self.Schedule.On(self.DateRules.Every(DayOfWeek.Wednesday),
                         self.TimeRules.BeforeMarketClose('IVV', 210),
                         Action(self.RebalancePortfolio))

        # Init charting
        InitCharts(self)

        # Schedule charting
        self.Schedule.On(self.DateRules.Every(DayOfWeek.Wednesday),
                         self.TimeRules.BeforeMarketClose('IVV', 5),
                         Action(self.PlotCharts))
Beispiel #13
0
    def initialize(self,
                   initial_capital: float,
                   mq_ip: str,
                   hook_ip: str,
                   trading_environment: str,
                   trading_universe: list,
                   datatypes: list,
                   txn_cost: float = 30,
                   cache_rows: int = 3000,
                   test_mq_con=True,
                   hook_name: str = 'FUTU',
                   prefill_period='1Y',
                   **kwargs):
        assert trading_environment in (
            'BACKTEST', 'SIMULATE',
            'REAL'), f'Invalid trading environment {trading_environment}'
        assert initial_capital > 0, 'Initial Capital cannot be 0'
        assert cache_rows > 1, 'No of cached data must be > 0 rows'

        self._account = Account(logger=self._logger,
                                initial_capital=initial_capital,
                                txn_cost=txn_cost)
        self._data = Data(mq_ip=mq_ip,
                          logger=self._logger,
                          hook_ip=hook_ip,
                          trading_universe=trading_universe,
                          datatypes=datatypes,
                          cache_rows=cache_rows,
                          test_mq_con=test_mq_con,
                          hook_name=hook_name,
                          prefill_period=prefill_period,
                          add_pos_func=self._account.add_new_position)
        self._execution = Execution(account=self._account,
                                    data=self._data,
                                    trading_environment=trading_environment,
                                    logger=self._logger)
        self._webapp = AlgoApp(algo=self)

        self._initialized_date = datetime.datetime.today()
        self._running = False
        self._logger.debug('Initialized sucessfully.')
        self._initialized = True
Beispiel #14
0
    def __init__(self,
                 challenger,
                 champion,
                 placementRule,
                 placementOption,
                 existRule,
                 existOption,
                 actionRule,
                 actionOption,
                 endingRule,
                 endingOption,
                 objectCount,
                 gameBoard,
                 dataBoard,
                 scriptPath=None,
                 problemIndex='scriptTemplate'):
        if type(challenger) is not UserProgram and type(
                champion) is not UserProgram:
            raise TypeError

        if scriptPath:
            sys.path.insert(0, scriptPath)
        exec 'from {0} import UserRule'.format(problemIndex)

        # parameter setting
        self.challenger = challenger
        self.champion = champion

        self.data = GameData(objectCount, placementRule, placementOption,
                             existRule, existOption, actionRule, actionOption,
                             endingRule, endingOption, gameBoard, dataBoard)

        self.limitTime = 2000

        self.positionData = ''
        self.boardData = ''

        # make rule and execution object
        self.rules = UserRule()
        self.execution = Execution()

        self.changePlayerNBoard(True, '  ')
Beispiel #15
0
    def Initialize(self):
        self.SetStartDate(2019, 1, 1)
        self.SetEndDate(2020, 1, 1)
        self.SetCash(100000)

        # Data resolution
        # By default, assets selected by universe selection are requested with minute resolution data.
        # https://www.quantconnect.com/docs/algorithm-reference/universes
        self.UniverseSettings.Resolution = Resolution.Minute
        self.UniverseSettings.Leverage = 1

        # Universe selection model
        self.securities = []
        self.CustomUniverseSelectionModel = FactorUniverseSelectionModel(self)
        self.AddUniverse(self.CustomUniverseSelectionModel.SelectCoarse,
                         self.CustomUniverseSelectionModel.SelectFine)

        # Alpha model
        self.CustomAlphaModel = ValueAlphaModel()

        # Portfolio construction model
        self.CustomPortfolioConstructionModel = OptimisationPortfolioConstructionModel(
            turnover=0.05, max_wt=0.05, longshort=True)

        # Execution model
        self.CustomExecution = Execution(liq_tol=0.005)

        # Add SPY for trading days data
        self.AddEquity('SPY', Resolution.Daily)

        # Schedule rebalancing
        self.Schedule.On(self.DateRules.EveryDay('SPY'),
                         self.TimeRules.At(13, 0),
                         Action(self.RebalancePortfolio))

        # Init charting
        InitCharts(self)

        # Schedule charting
        self.Schedule.On(self.DateRules.Every(DayOfWeek.Friday),
                         self.TimeRules.BeforeMarketClose('SPY', 0),
                         Action(self.PlotCharts))
Beispiel #16
0
def newInteration(lines, learnFactor, logger):
  execution = Execution(learnFactor, logger);

  linesTraining, linesTeste = execution.separateTrainingTestesLines(lines);


  execution.training(linesTraining);
  results = execution.testing(linesTeste);
  print(results);

  tableResults = Measures.getTableResults(results);
  
  accuracy = Measures.accuracy(tableResults)
  precision = Measures.precision(tableResults)
  recall = Measures.recall(tableResults)
  f1_score = Measures.f1_score(precision, recall)
  
  print('\naccuracy: ' + str(accuracy) + '% ' + 'precision: ' + str(precision) 
        + '% ' + 'recall: ' + str(recall) + '% ' + 'f1_score: ' + str(f1_score) + '%');
  
  return accuracy, precision, recall, f1_score;
Beispiel #17
0
    def Initialize(self):
        self.SetStartDate(2020, 1, 1)
        self.SetEndDate(datetime.now() - timedelta(10))
        self.SetCash(100000)

        # *Data Resolution
        self.UniverseSettings.Resolution = Resolution.Minute

        # *Universe selection model; runs with the above data resolution
        # custom universe selection model class created -- from universe_selection -->UniverseSelectionModel()
        self.securities = []
        self.CustomUniverseSelectionModel = FactorUniverseSelectionModel(self)
        self.AddUniverse(self.CustomUniverseSelectionModel.SelectCoarse,
                         self.CustomUniverseSelectionModel.SelectFine)

        # *Alpha model; A
        self.CustomAlphaModel = ValueAlphaModel()

        # *Portfolio construction model; B
        self.CustomPortfolioConstructionModel = OptimisationPortfolioConstructionModel(
            turnover=0.05, max_wt=0.05, longshort=True)

        #Eexecution model; C
        self.CustomExecution = Execution(liq_tol=0.005)

        # *Add SPY for trading days data; a
        self.AddEquity('SPY', Resolution.Daily)

        # *Scheduling rebalancing; b ; we take the a daily resloution and at 2 oclock we execute a rebalance
        self.Schedule.On(self.DateRules.EveryDay('SPY'),
                         self.TimeRules.At(13, 0),
                         Action(self.RebalancePortfolio))

        # Init charting
        InitCharts(self)

        # Schedule charting
        self.Schedule.On(self.DateRules.Every(DayOfWeek.Friday),
                         self.TimeRules.BeforeMarketClose('SPY', 0),
                         Action(self.PlotCharts))
Beispiel #18
0
    # Trade GBP/USD
    instrument = "GBP_USD"

    # Create the OANDA market price streaming class
    # making sure to provide authentication commands
    prices = StreamingForexPrices(STREAM_DOMAIN, ACCESS_TOKEN, ACCOUNT_ID,
                                  instrument, events)

    # Create the strategy/signal generator, passing the
    # instrument and the events queue
    strategy = TestStrategy(instrument, events)

    # Create the portfolio object that will be used to
    # compare the OANDA positions with the local, to
    # ensure backtesting integrity.
    portfolio = Portfolio(prices, events, equity=100000.0)

    # Create the execution handler making sure to
    # provide authentication commands
    execution = Execution(API_DOMAIN, ACCESS_TOKEN, ACCOUNT_ID)

    # Create two separate threads: One for the trading loop
    # and another for the market price streaming class
    trade_thread = threading.Thread(target=trade,
                                    args=(events, strategy, portfolio,
                                          execution))
    price_thread = threading.Thread(target=prices.stream_to_queue, args=[])

    # Start both threads
    trade_thread.start()
    price_thread.start()
Beispiel #19
0
 def execute(self):
     execution = Execution(self)
     execution.run()
     return execution
Beispiel #20
0
    RESTaccess.socketIO = SocketIO(RESTaccess.TRADING_API_URL, RESTaccess.WEBSOCKET_PORT, params={'access_token': RESTaccess.ACCESS_TOKEN})
    RESTaccess.socketIO.on('connect', RESTaccess.on_connect)
    RESTaccess.socketIO.on('disconnect', RESTaccess.on_close)
    RESTaccess.bearer_access_token = RESTaccess.create_bearer_token(RESTaccess.ACCESS_TOKEN, RESTaccess.socketIO._engineIO_session.id)
    # Create the FXCM market price streaming class
    # making sure to provide authentication commands
    prices = StreamingForexPrices(RESTaccess, instrument, events)

    # Create the portfolio object that will be used to
    # compare the OANDA positions with the local, to
    # ensure backtesting integrity.
    portfolio = Portfolio(prices, events, backtest = False, equity=1000000.0)

    # Create the execution handler making sure to
    # provide authentication commands
    execution = Execution(RESTaccess)

    # Create the strategy/signal generator, passing the
    # instrument, quantity of units and the events queue
    #strategy = TestRandomStrategy(instrument, events)
    strategy = MovingAverageCrossStrategy(instrument,events)
    #strategy = NewsDrivenStrategy(instrument,events)

    # Create two separate threads: One for the trading loop
    # and another for the market price streaming class
    trade_thread = threading.Thread(target=trade, args=(events, strategy, portfolio, execution, heartbeat))
    price_thread = threading.Thread(target=prices.stream_to_queue, args=[])
    # Start both threads
    logger.info("Starting trading thread")
    trade_thread.start()
    logger.info("Starting price streaming thread")
Beispiel #21
0
import os
import sys
import time
import traceback
from threading import Thread

import itchat

from autoreply import MsgAutoReply
from execution import Execution
from keeponline import KeepOnline
from keywordlistener import KeywordListener
from revocation import Revocation
from signin import SignInMPS

exec_command = Execution()
rmsg = Revocation()
listener = KeywordListener()
signfunc = SignInMPS()
keeponline = KeepOnline()
reply = MsgAutoReply()

visitors = 4
visitor_wait = False
msglist = list()


# 解析消息,构造{id:xxx, msg:{}, visit:xxx}类型的消息,加入消息队列
@itchat.msg_register([
    itchat.content.TEXT,
    itchat.content.PICTURE,
Beispiel #22
0
from task import Tasks
import matplotlib.pyplot as plt
import sys



if len(sys.argv) != 5:
    print("Usage : main.py start_pi_value end_pi_value start_φi_value end_φi_value")
    sys.exit(4)

startPi = int(sys.argv[1])
endPi = int(sys.argv[2])
startφi = int(sys.argv[3])
endφi = int(sys.argv[4])

exe = Execution()

exe.create_Task(startPi,endPi,startφi,endφi)
exe.sort_pi()
exe.doc.write("start value of task pi: "+str(startPi)+", end value of task pi: "+str(endPi)+'\n')
exe.doc.write("start value of task φi: "+str(startφi)+", end value of task φi: "+str(endφi)+'\n')
exe.doc.write("--------------------------------------------------------------------------------------------------"+'\n')
  
task = Tasks()

exe.display_task()
exe.display_sortedTask()
exe.display_intervalle()


Beispiel #23
0
import json
import falcon
from execution import Execution
from termination import Termination
from propagation import Propagation
from addition import Addition
from deletion import Deletion
from getting_list import GettingList
import os

with open('dejima_config.json') as f:
    dejima_config_dict = json.load(f)
peer_name = os.environ['PEER_NAME']
db_conn_dict={} # key: xid, value: database connection for each xid transaction.
child_peer_dict = {} # key: xid, value: set of child peers for each xid transaction.

app = falcon.API()
app.add_route("/post_transaction", Execution(peer_name, db_conn_dict, child_peer_dict, dejima_config_dict))
app.add_route("/add_student", Addition(peer_name, db_conn_dict, child_peer_dict, dejima_config_dict))
app.add_route("/delete_student", Deletion(peer_name, db_conn_dict, child_peer_dict, dejima_config_dict))
app.add_route("/get_student_list", GettingList(peer_name, db_conn_dict, child_peer_dict, dejima_config_dict))
app.add_route("/_propagate", Propagation(peer_name, db_conn_dict, child_peer_dict, dejima_config_dict))
app.add_route("/_terminate_transaction", Termination(db_conn_dict, child_peer_dict, dejima_config_dict))

if __name__ == "__main__":
    from wsgiref import simple_server
    httpd = simple_server.make_server("0.0.0.0", 8000, app)
    httpd.serve_forever()
 def __init__(self, *args, **kwargs):
     unittest.TestCase.__init__(self, *args, **kwargs)
     self.pkg_dir = os.path.join('..')
     self.execution = Execution(self.pkg_dir)
     self.img_size = 160
Beispiel #25
0
import numpy as np
import tensorflow as tf
from execution import Execution

execution = Execution()
execution.detect_vehicles('imgs/12697433.jpg')
Beispiel #26
0
 def __init__(self, pkg_dir):
     self.pkg_dir = pkg_dir
     self.execution = Execution(self.pkg_dir)
Beispiel #27
0
from execution import Execution
obj = Execution()
obj.show_menu()
obj.cart()
obj.show_cart()
obj.billing()
Beispiel #28
0
if __name__ == '__main__':
    heartbeat = 0.5 # Half second
    events = Queue.Queue()

    # Trade 10000 units of EUR/USD
    instrument = 'EUR_USD'
    units = 10000

    # Create the OANDA market price streaming class
    # making sure to provide authentication commands
    prices = StreamingForexPrices(
        STREAM_DOMAIN, ACCESS_TOKEN, ACCOUNT_ID,
        instrument, events
    )

    # Create the execution handler making sure to
    # provide authentication commands
    execution = Execution(STREAM_DOMAIN, ACCESS_TOKEN, ACCOUNT_ID)

    # Create the strategy/signal generator, passing the
    # instrument, quantity of units and the events queue
    strategy = TestRandomStrategy(instrument, units, events)

    # Create two separate threads: One for the trading loop
    # and another for the market price streaming class
    trade_thread = threading.Thread(target=trade, args=(events, strategy, execution))
    price_thread = threading.Thread(target=prices.stream_to_queue, args=[])

    # Start both threads
    trade_thread.start()
    price_thread.start()
Beispiel #29
0
    if config.is_backTest == True:
        try:
            os.remove('bookKeepingstore.h5')
        except:
            pass

#
#    # Create the strategy/signal generator, passing the
#    # instrument, quantity of units and the events queue
    strategy = TestStrategy(events)

    bookKeep = bookKeeping(events, config)

    #    # Create the execution handler making sure to
    #    # provide authentication commands
    execution = Execution(config)
    #
    ##    # Create two separate threads: One for the trading loop
    ##    # and another for the market price streaming class
    ##    trade_thread = threading.Thread(target=trade, args=(events, strategy, execution))
    trade_thread = threading.Thread(target=trade,
                                    args=(events, strategy, execution,
                                          instruments, data, bookKeep))
    #    price_thread = threading.Thread(target=prices[0].stream_to_queue, args=[])

    # Start both threads
    trade_thread.start()
#    price_thread.start()

#kwargs={}
#x=None