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.

462

events_queue = queue.Queue()

csv_dir = config.CSV_DATA_DIR

initial_equity = PriceParser.parse(500000.00)

# Use Yahoo Daily Price Handler

start_date = datetime.datetime(2012, 10, 15)

end_date = datetime.datetime(2016, 2, 2)

price_handler = YahooDailyCsvBarPriceHandler(

csv_dir, events_queue, tickers,

start_date=start_date, end_date=end_date

)

# Use the Sentdex Sentiment trading strategy

sentiment_handler = SentdexSentimentHandler(

config.CSV_DATA_DIR, "sentdex_sample.csv",

events_queue, tickers=tickers,

start_date=start_date, end_date=end_date

)

base_quantity = 2000

sent_buy = 6

sent_sell = -1

strategy = SentdexSentimentStrategy(

tickers, events_queue,

sent_buy, sent_sell, base_quantity

)

strategy = Strategies(strategy, DisplayStrategy())

# Use the Naive Position Sizer

# where suggested quantities are followed

position_sizer = NaivePositionSizer()

# Use an example Risk Manager

risk_manager = ExampleRiskManager()

# Use the default Portfolio Handler

portfolio_handler = PortfolioHandler(

initial_equity, events_queue, price_handler,

position_sizer, risk_manager

)

# Use the ExampleCompliance component

compliance = ExampleCompliance(config)

# Use a simulated IB Execution Handler

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

Saved successfully!

Ooh no, something went wrong!