13.08.2022 Views

advanced-algorithmic-trading

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

https://sanet.cd/blogs/polatebooks/

463

execution_handler = IBSimulatedExecutionHandler(

)

events_queue, price_handler, compliance

# Use the Tearsheet Statistics

title = ["Sentiment Sentdex Strategy"]

statistics = TearsheetStatistics(

config, portfolio_handler, title,

benchmark="SPY"

)

# Set up the backtest

backtest = Backtest(

price_handler, strategy,

portfolio_handler, execution_handler,

position_sizer, risk_manager,

statistics, initial_equity,

sentiment_handler=sentiment_handler

)

results = backtest.simulate_trading(testing=testing)

statistics.save(filename)

return results

@click.command()

@click.option(

’--config’,

default=settings.DEFAULT_CONFIG_FILENAME,

help=’Config filename’

)

@click.option(

’--testing/--no-testing’,

default=False,

help=’Enable testing mode’

)

@click.option(

’--tickers’,

default=’SPY’,

help=’Tickers (use comma)’

)

@click.option(

’--filename’,

default=’’,

help=’Pickle (.pkl) statistics filename’

)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!