Ejemplo n.º 1
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()