Exemple #1
0
        'port': 6379,
        'db': 0,
    }
    redis_conn = StrictRedis(**config)
    engine = create_engine('sqlite://')
    session_factory = sessionmaker(bind=engine)
    Session = scoped_session(session_factory)
    session = Session()

    Base.metadata.create_all(engine)
    usd = Currency(name='Dollar', code='USD')
    nasdaq = Exchange(name='NASDAQ', currency=usd)
    stock_ebay = Stock(symbol='EBAY', exchange=nasdaq, ISIN='US2786421030', description='')

    owner = Owner(name='Lucky')
    broker = Broker(name='Cheap Broker')
    account = Account(owner=owner, broker=broker)
    pesos = Currency(name='Pesos', code='ARG')
    account.deposit(Money(amount=1000, currency=pesos))
    config_file = "backtest_smaPortfolio.ini"
    config = PyConfig(config_file)

    th_tick_feeder = TickFeederThread(config, redis_conn, securities=[stock_ebay])

    start = datetime.now()
    end = datetime.now() - timedelta(days=30)
    th_back_tester=BackTesterThread(config=config, pubsub=redis_conn, session=session, account=account, securities=[stock_ebay])
    th_back_tester.start()
    th_tick_feeder.start()
    Session.remove()
Exemple #2
0
    redis_conn = StrictRedis(**config)
    engine = create_engine('sqlite://')
    session_factory = sessionmaker(bind=engine)
    Session = scoped_session(session_factory)
    session = Session()

    Base.metadata.create_all(engine)
    usd = Currency(name='Dollar', code='USD')
    nasdaq = Exchange(name='NASDAQ', currency=usd)
    stock_ebay = Stock(symbol='EBAY', exchange=nasdaq, ISIN='US2786421030', description='')

    owner = Owner(name='Lucky')
    broker = Broker(name='Cheap Broker')
    account = Account(owner=owner, broker=broker)
    pesos = Currency(name='Pesos', code='ARG')
    account.deposit(Money(amount=1000, currency=pesos))
    config_file = "backtest_smaPortfolio.ini"
    config = PyConfig(config_file)
    strategy = StrategyFactory.create_strategy(config.get(CONF_ULTRAFINANCE_SECTION, CONF_STRATEGY_NAME),
                                               config.getSection(CONF_ULTRAFINANCE_SECTION))

    th_tick_feeder = BackTesterThread(config, redis_conn, securities=[stock_ebay])

    start = datetime.now()
    end = datetime.now() - timedelta(days=30)
    th_trading_engine = TradingEngineThread(redis_conn.pubsub(), securities=[stock_ebay], strategy=strategy)

    th_tick_feeder.start()
    th_trading_engine.start()
    Session.remove()
Exemple #3
0
    nasdaq = Exchange(name='NASDAQ', currency=usd)
    stock_ebay = Stock(symbol='EBAY',
                       exchange=nasdaq,
                       ISIN='US2786421030',
                       description='')

    owner = Owner(name='Lucky')
    broker = Broker(name='Cheap Broker')
    account = Account(owner=owner, broker=broker)
    pesos = Currency(name='Pesos', code='ARG')
    account.deposit(Money(amount=1000, currency=pesos))
    config_file = "backtest_smaPortfolio.ini"
    config = PyConfig(config_file)
    strategy = StrategyFactory.create_strategy(
        config.get(CONF_ULTRAFINANCE_SECTION, CONF_STRATEGY_NAME),
        config.getSection(CONF_ULTRAFINANCE_SECTION))

    th_tick_feeder = BackTesterThread(config,
                                      redis_conn,
                                      securities=[stock_ebay])

    start = datetime.now()
    end = datetime.now() - timedelta(days=30)
    th_trading_engine = TradingEngineThread(redis_conn.pubsub(),
                                            securities=[stock_ebay],
                                            strategy=strategy)

    th_tick_feeder.start()
    th_trading_engine.start()
    Session.remove()