Asking for the best architecture for price predicting problem | Coursera Community
Coursera Header
Answered

Asking for the best architecture for price predicting problem


Badge +1

I have dataset of EURUSD prices per minute. I want to predict the price of the next minute. I am trying to program this using a deep neural network. Is this the best method, or are their any other methods for this type of problem. Highly appreciate the input of community.

 

Thank you.

icon

Best answer by Frissian V. 28 July 2020, 21:23

Hello friend,

I know that LSTM networks are quite popular for predicting time series data, so that's where you may want to start out. That being said, predicting asset prices is a very complex practice, especially if you want to get down to the minute precision. Unfortunately, no matter how good your model is or the algorithm you use, the is a randomness factor that cannot be predicted with high accuracy. I'm not saying it's impossible, it's just very hard. Another thing you may want to check is incorporating more variables to the equation other than history prices alone. Real world models are usually multivariate in order to produce better predictions. Cheers!

View original

6 replies

Badge

Hello friend,

I know that LSTM networks are quite popular for predicting time series data, so that's where you may want to start out. That being said, predicting asset prices is a very complex practice, especially if you want to get down to the minute precision. Unfortunately, no matter how good your model is or the algorithm you use, the is a randomness factor that cannot be predicted with high accuracy. I'm not saying it's impossible, it's just very hard. Another thing you may want to check is incorporating more variables to the equation other than history prices alone. Real world models are usually multivariate in order to produce better predictions. Cheers!

Badge

Hi Kav,

I would suggest using some RNN for this type of prediction problem. And, according to Mr. Ng and several advisers: act fast, start small and improve with wisdom and knowledge. Luck. ;-)

Hen

Badge +1

If you need something like this https://www.dailyfx.com/eur-usd  I recommend you to build an RNN.

Badge +1

Thank you all for your great input. I think I have to move RNN/LSTM approach.

 

I used a DNN for this problem. For example, the input of DNN is the data of the past 100 minutes and output is the price at 101st minute. 

 

What is the reason not to use DNN for this problem?

 

In the DNN I developed, I am always getting the zero as cost.

Badge +1
class TrainNetwork:
def __init__(self, input_size, layer1_size, layer2_size, layer3_size, layer4_size, output_layer_size, iterations,
learning_rate, input_data, output_data, number_of_inputs):
self.input_size = input_size
self.layer1_size = layer1_size
self.layer2_size = layer2_size
self.layer3_size = layer3_size
self.layer4_size = layer4_size
self.output_layer_size = output_layer_size
self.iterations = iterations
self.learning_rate = learning_rate
self.input_data = input_data
self.output_data = output_data
self.number_of_inputs = number_of_inputs

def train_network(self):
tf.reset_default_graph()
# Initialize placeholders
# Number of rows are not defined
# Number of columns = 3
x = tf.placeholder(dtype=tf.float32, shape=[None, self.input_size], name="x")
# Number of columns = None
y = tf.placeholder(dtype=tf.float32, shape=[None, self.output_layer_size], name="y")

layer1 = tf.contrib.layers.fully_connected(x, 5, tf.nn.relu)

layer2 = tf.contrib.layers.fully_connected(layer1, self.layer2_size, tf.nn.relu)

layer3 = tf.contrib.layers.fully_connected(layer2, self.layer3_size, tf.nn.relu)

layer4 = tf.contrib.layers.fully_connected(layer3, self.layer4_size, tf.nn.relu)
# Output layer
output = tf.contrib.layers.fully_connected(layer4, self.output_layer_size)

# Define loss
loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(logits=output, labels=y))

# Define an optimizer
train_op = tf.train.AdamOptimizer(learning_rate=self.learning_rate).minimize(loss)

# Save the costs to plot them
costs = []
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
# tf.add_to_collection("optimizer", train_op)
for i in range(self.iterations):
avg_cost = 0
for j in range(self.number_of_inputs):
_, c = sess.run([train_op, loss], feed_dict={
x: np.array(self.input_data[j]).reshape(np.shape(self.input_data[j])[0], 1).T,
y: np.array(self.output_data[j]).reshape(1,1)})
avg_cost += c
# print("loss", l)
# print("y", y)
# print("output", c)
costs.append(avg_cost / self.number_of_inputs)
print("avg_cost", avg_cost)
return costs


if __name__ == "__main__":
data_path = '../resources/EURUSD1.csv'
input_size = 100

raw_data = np.genfromtxt(data_path, delimiter=',')
length = len(raw_data)
start_point = 7500000
position = 2

input_data_list = []
for i in range(start_point, length - input_size):
input_data_list.append(raw_data[i:i + input_size, position])

input_data = np.array(input_data_list)
output_data = raw_data[start_point + input_size:length, position]

nn = TrainNetwork(input_size, 120, 150, 100, 80, 1, 100, 0.001, input_data, output_data, len(input_data))
costs = nn.train_network()

This is my code for DNN.

Userlevel 2
Badge +2

I have dataset of EURUSD prices per minute. I want to predict the price of the next minute. I am trying to program this using a deep neural network. Is this the best method, or are their any other methods for this type of problem. Highly appreciate the input of community.

 

Thank you.

I certainly believe that for this kind of regression problem, you should use either “Ridge Regression” or “Step-wise regression” where the independent data-points are highly corelated.

Reply