Oswald Market Prediction

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Market Prediction as a Task for AGI Agents

James T. Oswald[0000−0003−1195−4793]

RAIR Lab, Rensselaer Polytechnic Institute, Troy NY, USA


James.Oswald.111@gmail.com

Abstract. We argue that market prediction is a worthwhile incremen-


tal challenge for AGI due to its dual logical and statistical nature. We
formally define a modified version of a market prediction task for AGI
and ways in which an instance of a normal market prediction problem
may be converted to our version. We perform an empirical study on an
instance of our problem and benchmark a NARS agent against statisti-
cal and connectionist agents to see if it can competitively forecast the
direction of the S&P 500 from qualitative technical market data.

1 Introduction
When talking about tasks for AGI agents to solve, it is common to think about
human-level tasks including the Turing test and alternatives such as the coffee
test and the robot college student test [8]. These tests will be definitive proof,
that upon solving, we can point to and claim that an agent is generally intelligent.
However, in order to get to that point at which these human-level tasks can be
accomplished, we take the position it is important to make incremental steps on
tasks that are more easily measured. Various proposals have been made for tasks
that might allow us to measure incremental progress toward an AGI, including
Bringsjord’s Psychometric AI [3] and Goertzel’s AGI preschool suite [4]. Both of
these tasks are well defined but have various entry-level bottlenecks to particular
classes of AGI agents. Psychometric AI is a very good task for logicist agents
but would be harder for connectionist agents. The full suite of tasks proposed in
AGI Preschool are beyond the scope of what we can reasonably benchmark any
existing logical agents on. We seek to define a task that is simple enough from a
mathematical standpoint that it may serve as a benchmark for both logicist and
connectionist agents, measuring purely their reasoning ability and statistical-
pattern-finding ability, independent of architecture, which is a task that may be
approached both statistically and logically.
When designing tasks for AGI agents to solve, it is important to take into
account a working definition of intelligence and how it may be measured. Legg
and Hutter’s popular definition of intelligence as ”the capacity for an agent to
achieve goals in a wide range of environments” [13] and Wang’s intelligence as
”the ability for an information processing system to adapt to its environment
with insufficient knowledge and resources” [27] are good starting points. Wang’s
definition better lends itself to the empirical nature of our goal to quantita-
tively measure incremental improvements of AGI agents [25]. However, Legg
2 J. Oswald

and Hutter’s definition is important to take into consideration for its emphasis
on performance in a wide range of environments. Our working definition of in-
telligence in designing this task is then one which takes into account the ability
to perform well in both a wide range of environments and under the constraints
of insufficient knowledge and resources.
With this working definition of intelligence in mind, we assert that market
prediction (also referred to throughout as market forecasting) is a robust task
that serves as a good indicator of intelligence. The task requires an agent to rea-
son about the future from the currently available data, thus hitting check boxes
for reasoning under insufficient knowledge. Rather than empirically testing an
agent in many environments, we argue that the market prediction task itself is so
robust that depending on the provided features, reasoning on individual classes
of features constitutes reasoning on entirely separate environments; for exam-
ple, the analysis of technical market data (raw asset price information and other
daily quantitative indicators) is completely distinct from analysis of fundamental
market data (earnings reports, social media sentiment on assets). The agent can
go about this reasoning on each individual factor in many ways, including look-
ing at statistical trends to analyzing human sentiments and performing logical
reasoning.
In this work, we present the classic market prediction task for AI and discuss
its shortcomings with respect to AGI agents. We then present our modified
market prediction task for AGI and discuss its merits. In the second half of
this work we perform an empirical study comparing a NARS Agent against
various statistical methods on our modified market prediction task. We begin
by presenting our data set and discussing a technique for qualifying it in such
a way that it is usable on our modified task. We finish by briefly discussing the
agents we use and their performance on the task.

2 Related Work

Traditional AI for market prediction

Multiple surveys have been done on the effectiveness of various computational


techniques for market prediction over a wide range of global markets [11, 14].
Kumar’s survey [11] breaks down market forecasting models into three funda-
mental components, of which many hybrid models exist making use of one or
more of these components:

1. Artificial Neural Network (ANN) Based Approaches: classified as anything


using a neural network, including deep learning based approaches and RNN
based approaches with LSTMs for time series prediction [17].
2. Fuzzy Logic Based Approaches: Incorporate any kind of fuzzy logic or fuzzy
logic derivative/alternative into their forecasting model.
3. Genetic Algorithm Based Approaches: Make use of genetic algorithms for
training their forecasting models.
Market Prediction as a Task for AGI Agents 3

Of particular note in this space is [22] which compares a simple ANN network
with an SVN and a Multiple Linear Regression model, finding that SVM yields
the best forecasting performance on the American S&P 500 using technical fac-
tors. We will be using the three methods in this work as our baseline as it
provides a good example of machine learning and statistical techniques using
technical factors that we can compare against, as well as modifying to allow for
the use of converted qualitative factors.
Despite success in predicting the S&P 500, [14] shows that ML for single
stock prediction still falls flat on meaningful day-to-day prediction, particularly
in the case of longer-term investments. This shortcoming of having ML only
useful for speculation is a large drawback for ML based methods as a whole.

AGI for market prediction

The idea of using AGI for market prediction tasks is not a novel concept. Previous
work such as Raheman, Kolonin, and Ansari’s Adaptive Multi-Strategy Market
Making Agent [20] in their own words exploits Goertzel’s definition of AGI in [7]
as ”having the ability to reach complex goals in complex environments” to justify
why their market prediction architecture falls into the realm of AGI. We claim,
however, that the task of market prediction is a far more robust measure of
intelligence than previously let on, and is a good fit as a more general task for
AGI agents.

3 Task

Traditionally, market prediction is modeled as a quantitative sequence prediction


task, where we want to use some numeric features, f1 , ..., fn ∈ R, that we have
available to us at some time, t ∈ N, to predict the price of some asset, p ∈ R,
at some time in the future, t + i ∈ N. Note that the selection of features can
be anything, be that technical market data or fundamental market data. In the
context of market prediction for AGI, the selection of features influences the
”environments” the AGI agent gets to reason on. It is common that the current
price of the asset we desire to predict the price of pt is included within our list of
features [22, 16]. The objective of this quantitative prediction task is to create a
model A that takes our features and maps them as closely as possible to the true
price of the asset at some time in the future. For market prediction tasks, the
time step is typically measured in days and the price in the future we’re trying
to predict is one day ahead of our current features t + 1 [22, 16].

pt+1 = A(pt , f1,t , ..., fn,t ) (1)

The quantitative market prediction task is well formulated, but it can be


difficult for logic-based agents to be measured on, as it requires them to have
an ability to reason over arbitrary continuous price data and return continuous
price results. In order to open the field, we propose a qualitative variant of the
4 J. Oswald

market prediction task that is easier to play for agents where the ability to reason
over arbitrary continuous price data is not a given. Our variant makes discrete
the continuous price data of our features by looking at the relative change of
features from time step to time step. We then convert each feature into two
new qualitative features: a direction, f d ∈ {Up, Down}, and magnitude of change
f m ∈ {Small, Medium, Large}. Note that the set of magnitudes we give here are
just an example and an arbitrary number of magnitudes can be added depending
on how much information we want the agent to have. The computation of these
new magnitudes from quantitative feature data is up to the implementation,
essentially the value of each feature at time t is compared against the value of
the feature at time t − 1 and a decision is made on what magnitude the change
is. For the direction it is assumed the ft ̸= ft−1 . If ft > ft−1 then ftd = Up,
otherwise ftd = Down. We make the goal of our modified task to predict not the
price of our original asset, p, but the direction it moves in pd at the future time
step t + 1. Hence the goal of our new task is the creation of an agent A who can
correctly use magnitude and direction of features to predict the direction of an
asset.
pdt+1 = A(pdt , pm d m d m
t , f1,t , f1,t ..., fn,t , fn,t ) (2)
One of the main merits of this modified task beyond working for logical agents
is that since our set of possible magnitudes is implicitly well ordered, it is fully
possible to convert our qualitative data back to quantitative data for agents that
prefer to use statistical methods internally on numerical data. Hence this task
can be used to benchmark logical, statistical, and connectionist agents.
Our particular instance of this task that we empirically test in this paper sets
our p to be the daily price of the S&P 500 index on market close. The choice of the
S&P 500 index, rather than that of an individual asset like a stock, is deliberate.
The S&P 500 is more predictable and less volatile than individual assets, hence
it is a preferred and popular target for computational and AI market forecasting
tasks [18, 22, 16]. For our data set we have 32 features derived from 29 technical
market factors, including the S&P 500 price. The quantitative features are then
qualified with a Z-Score bucketing approach into 6 magnitude levels.

4 Data Set

Our initial data set for consideration consists of 29 technical market indicators.
We group these factors into 5 broad classes based on the type of indicator they
are and what units they are recorded in. Our data-points are recorded daily over
the course of 10 years from January 1st 2012 to March 24th 2022; data from
non-subsequent market closes is thrown out. The selection of these indicators
was heavily influenced by the list of technical indicators for market prediction
that Sheta et al. use in their 2015 work [22] as well as those used in [16]. We
have had to update many of these factors to include more recent market data as
well as change the stocks in our data set to better reflect those currently used
to calculate the S&P 500 at the time this work is being done.
Market Prediction as a Task for AGI Agents 5

Indicator Classes
– Market Indexes (Index): Indexes are broad predictors of market perfor-
mance based on a variety of underlying assets from which the index price is
calculated. All of the market indexes we use in our data set are international
exchange indexes which give our agent a good overview of the state of global
markets, which have been shown to influence each other [6]. For our data set
we use the closing price of the index as its daily data-point.
– Commodities (Commodity): Commodities are real assets traded on com-
modity exchanges. The link between commodity prices and stock prices, on
the whole, is an area under active research [1, 10], however, results seem to
be positive, particularly for stocks of companies whose underlying products
are commodities; such as oil and mining companies [2, 15].
– Stock Prices (Stock): Stock prices are the market values of shares in a
company on a stock exchange. We consider the prices of the top five stocks
on the S&P 500 in 2022, the top 5 stocks on the S&P 500 from 2015, as well
as a few other significant stocks in terms of market capitalization. For our
data set, we use the closing price of the stock as its daily data point.
– Foreign Exchange Rates (Currency): A foreign exchange rate is the
amount of US Dollars a unit of a given foreign currency is worth. Foreign
exchange rates are considered to be strong indicators of market performance
and have observable ties to index prices [12, 6]. All foreign exchange rates in
our data set are obtained from the US Federal Reserve H10’s reported daily
exchange rate.
– Bond Yields (Bond): Bond yields are the interest rate agreed to be paid
when a bond is issued. Our data set includes two classes of bonds: corpo-
rate bonds, and US treasury bonds. We include treasury bonds with various
maturities and source our treasury bond data from the US Federal Reserve
H15’s reported daily yields. For corporate bonds, we use Moody’s Corpo-
rate bond yield indexes, which function as an indicator of all corporate bond
yields within a risk class. The relationship between bond prices and market
performance is widely acknowledged to be quite strong [21, 23].

Features We select our initial 29 quantitative features at each time step from
the set of technical data outlined in Table 1. We add an additional three features,
derived by offsetting the price of the S&P 500 by 1, 2, and 3 days into the past
respectively, giving our agent S&P 500 closing prices of the past 4 days on one
single time step. Now with all features f present, we convert each feature f into
two new discretized features, a direction f d and magnitude f m . We take the
features from the previous day and compute the direction as Up if the feature
value is higher than the previous day, otherwise it is marked Down.
(
d Up ft−1 < ft
ft = (3)
Down ft−1 ≥ ft

Obtaining the magnitude is a more difficult process, as we want to ensure that


magnitude is fairly assigned no matter the distribution of changes in a feature.
6 J. Oswald

Table 1: Indicators used in our dataset (YF = Yahoo Finance, FR = Federal


Reserve, WSJ = Wall Street Journal)
Name Class Description Source
SPX Index S&P 500, indicator of the US stock market NASDAQ
HSI Index Hang Seng Index, indicator of the Hong Kong YF
stock market
FCHI Index CAC 40, indicator of the French stock market YF
FTSE Index FTSE 100, indicator of the British stock market WSJ
GDAXI Index DAX Index, indicator of the German stock market YF
DJIA Index Dow Jones Industrial Average WSJ
OIL Commodity Price of crude oil (West Texas Intermediate) EIA
GOLD Commodity Price of gold NASDAQ
AAPL Stock Stock price of Apple Inc. YF
MSFT Stock Stock price of Microsoft Corporation YF
AMZN Stock Stock price of Amazon Inc. YF
GOOGL Stock Stock price of Alphabet Inc. class A shares YF
GOOG Stock Stock price of Alphabet Inc. class C shares YF
XOM Stock Stock price of Exxon Mobil Corporation YF
GE Stock Stock price of General Electric YF
PG Stock Stock price of Procter & Gamble YF
JNJ Stock Stock price of Johnson & Johnson YF
BRKA Stock Stock price of Berkshire Hathaway Inc. class A YF
shares
GBP Currency British Pound to US Dollar exchange rate FR H10
CAD Currency Canadian Dollars to US Dollar exchange rate FR H10
CNY Currency Chinese Renminbi to US Dollar exchange rate FR H10
JPY Currency Japanese Yen to US Dollar exchange rate FR H10
DAAA Bond Moody’s Seasoned AAA Corporate Bond Yield FRED
DBAA Bond Moody’s Seasoned BAA Corporate Bond Yield FRED
TB3M Bond Yield on 3-month Treasury Securities FR H15
TB6M Bond Yield on 6-month Treasury Securities FR H15
TB1Y Bond Yield on 1-year Treasury Securities FR H15
TB5Y Bond Yield on 5-year Treasury Securities FR H15
TB10Y Bond Yield on 10-year Treasury Securities FR H15

Figure 1 shows the distribution in our data set of daily percent change in a stock;
Apple Inc. (AAPL) as well as a foreign exchange rate, that between Canadian
Dollars (CAD) and US Dollars. The issue is that a 1% change in the AAPL
feature is not a significant movement and hence should not be assigned a high
magnitude, whereas a 1% change in CAD is very significant and should be as-
signed a high magnitude. This issue plays out across all features in our data
set. Hence we must construct a means of assigning magnitude based on the
distributions of individual features so that magnitudes are fairly assigned.
Market Prediction as a Task for AGI Agents 7

Fig. 1: Distribution of daily percent change of Apple Stock Price vs. Distribution
of Canadian Dollar to USD Foreign Exchange Rates

The solution we have come up with for this problem is a Z-Score bucketing
method based on the daily percent change of a feature. The daily percent change
of a feature, ct , is computed by finding the percent an asset’s value has changed
since the day before.
ft − ft−1
ct = (4)
ft−1
We refer to the daily percent change of a feature as a feature movement. The Z-
Score of a feature movement represents how many standard deviations, σ, away
the movement is from the mean, µ, (average least significant) movement of that
feature. Therefore the Z-score of a movement provides us a way to qualify the
magnitude of a movement in relation to other movements on a per feature basis,
even when these features have very different underlying normal distributions.
Hence for quantitative feature ft and T set of time steps (before t), we compute
our Z-score for the movement zt as:

ct − |T1 | u∈T cu
P
ct − µ
zt = =r (5)
σ 1
P 
1
P 2
|T | v∈T cv − |T | u∈T cu

Finally, we qualify our Z-Scores by bucketing them, each bucket acts as an enu-
meration for a qualitative label. If k is the number of buckets and n is the number
of buckets per standard deviation, we compute our magnitude bucket as:

ftm = min (⌊n |zt |⌋ , k − 1) (6)

In our instance of the problem, we use 2 buckets per standard deviation and use
6 buckets total. We split our 2314 data points into 162 points of test data and
2152 points of train data, and we shuffle our data to ensure our test data has
the same distribution as our training data.
8 J. Oswald

5 Methods
We investigate the performance of five different agents on the task. Three of
these agents are statistical in nature (MLR, MLogR, SVC), one is connectionist
(ANN), and one is an AGI method (NARS). All underlying statistical agents,
unless otherwise stated, are implemented as sci-kit learn classifiers with default
parameters [19].
Multiple Linear Regression Agent (MLR) The MLR agent makes use
of the statistical technique known as Multiple Linear Regression to help it deter-
mine the market direction. We convert our qualitative features into quantitative
features for this task by interpreting Up and Down as 1 and -1 respectively, com-
puting our input features as the product ftd ftm for each feature. As the output
of a linear regression agent is continuous, we map it to the closest feature bucket
for evaluation.
Multiple Logistic Regression Agent (MLogR) Identical to MLR except
we instead use multiple logistic regression rather than multiple linear regression.
Multiple logistic regression, at least in the quantitative case, has been shown as
a good predictor of the S&P 500 [24]. The input formatting and output rounding
are the same as those used for our MLR agent.
Support Vector Machine Agent (SVM) Our SVM agent uses raw qual-
itative features as input to train a support vector classifier [5] which tries to
classify feature lists either up or down. SVM maps data points to a high dimen-
sional space so that they may be more accurately classified.
Artificial Neural Network Agent (ANN) For our agent we use a multi-
layer perceptron classifier with ReLu activation function. The network has a
hidden layer with 100 neurons. We train the agent on the qualified data using
values as classes.
Limited NARS Agent (NARS) Uses a NARS [26] agent under the hood.
Due to spacial limitations in our ability to create arbitrary length term products
in NAL (for further explanation, observe Theorem 8.4 in [26]) we impose restric-
tions on our input and use linear regression to compute the five most important
discretized features (from both direction and movement features), f1∗ , ..., f5∗ , as
our modified agent input. Training data is passed in Narseese as products of
∗ ∗ ∗
qualified features implying market direction. (f1,t × f2,t × ... × f5,t ) ⇒ pdt+1 . We
use default frequency and confidence for all of our inputs of training data and
give the agent 10,000 cycles between training and testing. For our implemen-
tation of NARS we create the agent using OpenNARS for applications [9]. For
∗ ∗ ∗
testing the agent we query (f1,t × f2,t × ... × f5,t ) ⇒?, for query responses that
are not either Up or Down, we mark the prediction as incorrect.

6 Results
Our performance metric is accuracy, the number of times the agent was correctly
able to predict the direction of the S&P 500 in the testing set. We find in Table
Market Prediction as a Task for AGI Agents 9

2 the accuracies from our agents on trained vs unseen test data. While not
performing quite as well as the statistical agents, we observe that the limited
NARS agent is at least able to predict the market direction well beyond the
random baseline.
Table 2: Results of all of our agents
Method Train Test
Random Baseline 55.23% 49.3%
MLR 65.03% 64.81%
MLogR 65.17% 63.58%
SVC 55.09% 51.23%
ANN 65.45% 64.19%
NARS 62.76% 60.49%

7 Conclusion
In this work, we discussed the merits of using market prediction as a task for
AGI agents based on its robust ability to emulate different environments in a sin-
gle task. We have proposed a novel version of the market prediction task that is
adaptable to logical, connectionist, and statistical agents. In our empirical study,
we presented a comprehensive data set for market prediction and discussed in
detail a means of converting quantitative technical market features into quali-
tative market features via a Z-Score bucketing approach based on the absolute
daily percent change of a feature. We empirically tested five agents on the new
task and found that, while not able to out-perform them, the NARS agent is
able to perform around the same level as other narrow AI agents tested.

References
1. Black, A.J., Klinkowska, O., McMillan, D.G., McMillan, F.J.: Forecasting stock
returns: do commodity prices help? Journal of Forecasting 33(8), 627–639 (2014)
2. Boyer, M.M., Filion, D.: Common and fundamental factors in stock returns of
canadian oil and gas companies. Energy economics 29(3), 428–453 (2007)
3. Bringsjord, S., Schimanski, B.: What is artificial intelligence? psychometric ai as
an answer. In: IJCAI (2003)
4. Bugaj, V., Goertzel, B.: Agi preschool: A framework for evaluating early-stage
human-like agis. In: Proceedings of the 2nd Conference on Artificiel General Intel-
ligence (2009)
5. Cortes, C., Vapnik, V.N.: Support-vector networks. Machine Learning 20, 273–297
(2004)
6. Garefalakis, A., Dimitras, A., Koemtzopoulos, D., Spinthiropoulos, K.: Determi-
nant factors of hong kong stock market. Available at SSRN 1762162 (2011)
7. Goertzel, B.: Artificial general intelligence: Concept, state of the art, and future
prospects. Journal of Artificial General Intelligence 5, 1 – 48 (2014)
8. Goertzel, B., Iklé, M., Wigmore, J.: The architecture of human-like general intel-
ligence. In: Theoretical Foundations of Artificial General Intelligence. p. 123–144
(2012)
10 J. Oswald

9. Hammer, P., Lofthouse, T.: ‘opennars for applications’: Architecture and con-
trol. In: International Conference on Artificial General Intelligence. pp. 193–204.
Springer (2020)
10. Hu, C., Xiong, W.: Are commodity futures prices barometers of the global econ-
omy? Working Paper 19706, National Bureau of Economic Research (December
2013). https://doi.org/10.3386/w19706, http://www.nber.org/papers/w19706
11. Kumar, G., Jain, S., Singh, U.P.: Stock market forecasting using computational
intelligence: A survey. Archives of Computational Methods in Engineering pp. 1–33
(2020)
12. Lee, Y.M., Wang, K.M.: Dynamic heterogeneous panel analysis of the correla-
tion between stock prices and exchange rates. Economic research-Ekonomska is-
traživanja 28(1), 749–772 (2015)
13. Legg, S., Hutter, M.: A collection of definitions of intelligence. In: AGI (2006)
14. Mokhtari, S., Yen, K.K., Liu, J.: Effectiveness of artificial intelligence in stock mar-
ket prediction based on machine learning. In: International Journal of Computer
Application (2021)
15. Nangolo, C., Musingwini, C.: Empirical correlation of mineral commodity prices
with exchange-traded mining stock prices. Journal of the Southern African Insti-
tute of Mining and Metallurgy 111(7), 459–468 (2011)
16. Niaki, S., Hoseinzade, S.: Forecasting s&p 500 index using artificial neural networks
and design of experiments. Journal of Industrial Engineering International 9, 1–9
(02 2015)
17. Pang, X.W., Zhou, Y., Wang, P., Lin, W., Chang, V.: An innovative neural network
approach for stock market prediction. The Journal of Supercomputing 76, 2098–
2118 (2018)
18. Patel, J., Shah, S.R., Thakkar, P., Kotecha, K.: Predicting stock and stock price
index movement using trend deterministic data preparation and machine learning
techniques. Expert Syst. Appl. 42, 259–268 (2015)
19. Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O.,
Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., Vanderplas, J., Passos, A.,
Cournapeau, D., Brucher, M., Perrot, M., Duchesnay, E.: Scikit-learn: Machine
learning in Python. Journal of Machine Learning Research 12, 2825–2830 (2011)
20. Raheman, A., Kolonin, A., Ansari, I.: Adaptive multi-strategy market making
agent. In: AGI (2021)
21. Rankin, E., Idil, M.S.: A century of stock-bond correlations. Bulletin of The Re-
serve Bank of Australia (2014)
22. Sheta, A.F., Ahmed, S.E.M., Faris, H.: A comparison between regression, artificial
neural networks and support vector machines for predicting stock market index.
International Journal of Advanced Research in Artificial Intelligence 4 (2015)
23. Shiller, R.J., Beltratti, A.E.: Stock prices and bond yields: Can their comovements
be explained in terms of present value models? Journal of monetary economics
30(1), 25–46 (1992)
24. Smita, M.: Logistic regression model for predicting performance of s&p bse30 com-
pany using ibm spss. International Journal of Mathematics Trends and Technology
(2021)
25. Wang, P.: The evaluation of agi systems. In: AGI 2010 (2010)
26. Wang, P.: Non-Axiomatic Logic. WORLD SCIENTIFIC (2013).
https://doi.org/10.1142/8665, https://www.worldscientific.com/doi/abs/10.1142/8665
27. Wang, P., Goertzel, B.: Introduction: Aspects of artificial general intelligence. In:
AGI (2006)

You might also like