  Traditional approaches to financial asset allocation start with returns
forecasting followed by an optimization stage that decides the optimal asset
weights. Any errors made during the forecasting step reduce the accuracy of the
asset weightings, and hence the profitability of the overall portfolio. The
Portfolio Transformer (PT) network, introduced here, circumvents the need to
predict asset returns and instead directly optimizes the Sharpe ratio, a
risk-adjusted performance metric widely used in practice. The PT is a novel
end-to-end portfolio optimization framework, inspired by the numerous successes
of attention mechanisms in natural language processing. With its full
encoder-decoder architecture, specialized time encoding layers, and gating
components, the PT has a high capacity to learn long-term dependencies among
portfolio assets and hence can adapt more quickly to changing market conditions
such as the COVID-19 pandemic. To demonstrate its robustness, the PT is
compared against other algorithms, including the current LSTM-based state of
the art, on three different datasets, with results showing that it offers the
best risk-adjusted performance.
