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.

447

sentiment").

This sample file forms the basis of the sentiment data utilised within the three separate

simulations carried out in this chapter.

30.2 The Trading Strategy

The complexity of this implementation comes mainly from adjustments to QSTrader, rather than

the strategy itself, which is quite straightforward once the sentiment signal has been generated.

The strategy has been deliberately kept simple and there is plenty of scope for modification and

optimisation.

The strategy is long-only in this implementation but is easily modified to include short positions.

Entry and exit thresholds are determined, which are then used to generate long positions

and close them out, respectively.

There are three strategies presented that are all identical with the exception of the selection

of stocks they operate on. The list of stocks are as follows:

• Tech - MSFT, AMZN, GOOG, IBM, AAPL

• Energy - XOM, CVX, SLB, OXY, COP

• Defence - BA, GD, NOC, LMT, RTN

The rules of the strategy are as follows:

• Long a ticker if its sentiment value reaches +6

• Close the ticker position if its sentiment value reaches -1

There is no percentage allocation to each stock, instead a fixed quantity of shares is used for

each throughout the strategy. This fixed quantity is modified for each of the above three sectors,

however.

One obvious modification would be to create a dollar-weighted investment that dynamically

adjusts allocation based on account size. However, in this chapter the position-sizing is kept

simple for ease of understanding the core sentiment event generation.

30.3 Data

In order to carry out this strategy it is necessary to have daily OHLCV pricing data for the

equities in the period covered by these backtests. There are three separate simulations carried

out in this chapter, each containing a group of five stocks from the S&P500. The first group

consists of technology/consumer staple stocks and can be found in the first table below:

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

Saved successfully!

Ooh no, something went wrong!