Does pyramiding up to full position size improve performance?

August 31, 2019
Update September 25, 2019

We hypothesize that we can use a pyramiding technique for our trade position sizing. Instead of placing a trade with maximum risk on (full size), perhaps incrementally adding size on the trade as it moves in our favor will help keep losses small while still giving us a chance to fully capture upside movement. In this research, we use one model that places trades with full size, and the other that places trades using the pyramiding technique. We collect data from both models and compare the results below.

In [1]:
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import preprocessing
from bokeh.plotting import figure, show, output_notebook
import warnings
warnings.filterwarnings('ignore')
In [2]:
# retrieve data
adf = pd.read_csv('Test_3A_Medium_Trend_Trader/history.csv')
pyrdf = pd.read_csv('Test_3B_Pyramiding/history.csv')
In [3]:
# chop it up - only look at data over the same time period
adf = adf[151:]

# take a look
plt.plot(adf.accountBalance)
plt.plot(pyrdf.accountBalance)
plt.show()
In [4]:
# normalize the return streams so different account values don't matter
min_max_scaler = preprocessing.MinMaxScaler(feature_range=(-1,1))
adf_sc = min_max_scaler.fit_transform(adf.accountBalance.reshape(-1,1))
pyrdf_sc = min_max_scaler.fit_transform(pyrdf.accountBalance.reshape(-1,1))

plt.plot(adf_sc)
plt.plot(pyrdf_sc)
plt.show()
In [5]:
# put them back in dataframe to align with dates values for plotting later
adf['scaled'] = adf_sc
pyrdf['scaled'] = pyrdf_sc

# simple preprocessing: convert to datetime
adf['time'] = pd.to_datetime(adf['time'])
pyrdf['time'] = pd.to_datetime(pyrdf['time'])
In [6]:
# generate the target plot
p = figure(title='Equity Curves: Full Sizing vs Pyramiding In',
               x_axis_type='datetime',
               plot_width=900,
               plot_height=400)

p.line(x=adf.time, y=adf.scaled, color='blue', legend='Full Size')
p.line(x=pyrdf.time, y=pyrdf.scaled, color='orange', legend='Pyramiding')
p.xaxis.axis_label = 'time'
p.yaxis.axis_label = 'PL'
output_notebook()
show(p)
Loading BokehJS ...

We can observe that over the test period, the pyramiding strategy does not seem to significantly improve performance by reducing downside volatility. While it does reduce the size of trading losses, these small losses happen more frequently when size is added and the trades still do not work out. By implementing a pyramiding technique there exists a tradeoff between reducing large losses and missing out on the gains that would have been captured by the full position size. So far, it seems that the timeframe under study does not seem to generate large trends frequently enough to justify missing out on those intermediary small wins captured with the full position size.

to be continued...