ltnguyen14 / quant_stock Goto Github PK
View Code? Open in Web Editor NEWStock analysis/prediction model using machine learning
License: MIT License
Stock analysis/prediction model using machine learning
License: MIT License
I have successfully ran the trainer. / when I go to backtest - it fails.
Actually on closer inspection - I can see a bug. saving doesn't recognize tensor shape.
Tensor("output:0", shape=(?, 1), dtype=float32)
which version of tensorflow are you using?
python driver.py -t feedforward
2017-10-30 15:01:45.434854: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-10-30 15:01:45.435181: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-10-30 15:01:45.435203: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-10-30 15:01:45.435214: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. Lag 0 epoch 0 loss: 59128972527.1 Lag 0 epoch 1 loss: 46587011848.4 Lag 0 epoch 2 loss: 26121063660.8 Lag 0 epoch 3 loss: 29749124009.9 Lag 0 epoch 4 loss: 14901238999.3 The best lag is: 0 Epoch 0 completed out of 5 loss: 418341134612.0 Epoch 1 completed out of 5 loss: 49366656580.6 Epoch 2 completed out of 5 loss: 25395777597.4 Epoch 3 completed out of 5 loss: 17968284636.1 Epoch 4 completed out of 5 loss: 24333348789.0 Accuracy: 0.009250693802035153 Model saved in file: data/model/feedforward.ckpt Tensor("output:0", **shape=(?,** 1), dtype=float32)
python driver.py -b feedforward
Value before transactions: 100000
Loading pre-trained model...
2017-10-30 15:15:29.298250: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-30 15:15:29.298280: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-10-30 15:15:29.298295: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-30 15:15:29.298299: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Model loaded...
Traceback (most recent call last):
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call
return fn(*args)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1306, in _run_fn
status, run_metadata)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/contextlib.py", line 66, in __exit__
next(self.gen)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'input_1' with dtype float
[[Node: input_1 = Placeholder[dtype=DT_FLOAT, shape=<unknown>, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "driver.py", line 8, in <module>
main()
File "driver.py", line 5, in main
inputHandler(inputs)
File "/Users/jpope/Documents/cryptoWorkspace/Quant_stock/misc/arg_handler.py", line 31, in __init__
self.run(FeedforwardStrategy)
File "/Users/jpope/Documents/cryptoWorkspace/Quant_stock/misc/arg_handler.py", line 35, in run
backtest_obj.run(plot=False)
File "/Users/jpope/Documents/cryptoWorkspace/Quant_stock/pipeline/backtest.py", line 110, in run
self.cerebro.run()
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/backtrader/cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/backtrader/cerebro.py", line 1214, in runstrategies
strat = stratcls(*sargs, **skwargs)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/backtrader/metabase.py", line 88, in __call__
_obj, args, kwargs = cls.doinit(_obj, *args, **kwargs)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/backtrader/metabase.py", line 78, in doinit
_obj.__init__(*args, **kwargs)
File "/Users/jpope/Documents/cryptoWorkspace/Quant_stock/pipeline/strategies/ff_strat.py", line 30, in __init__
print(self.sess.run(prediction, feed_dict={x: [[10.0]]}))
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 895, in run
run_metadata_ptr)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1124, in _run
feed_dict_tensor, options, run_metadata)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run
options, run_metadata)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'input_1' with dtype float
[[Node: input_1 = Placeholder[dtype=DT_FLOAT, shape=<unknown>, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
Caused by op 'input_1', defined at:
File "driver.py", line 8, in <module>
main()
File "driver.py", line 5, in main
inputHandler(inputs)
File "/Users/jpope/Documents/cryptoWorkspace/Quant_stock/misc/arg_handler.py", line 31, in __init__
self.run(FeedforwardStrategy)
File "/Users/jpope/Documents/cryptoWorkspace/Quant_stock/misc/arg_handler.py", line 35, in run
backtest_obj.run(plot=False)
File "/Users/jpope/Documents/cryptoWorkspace/Quant_stock/pipeline/backtest.py", line 110, in run
self.cerebro.run()
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/backtrader/cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/backtrader/cerebro.py", line 1214, in runstrategies
strat = stratcls(*sargs, **skwargs)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/backtrader/metabase.py", line 88, in __call__
_obj, args, kwargs = cls.doinit(_obj, *args, **kwargs)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/backtrader/metabase.py", line 78, in doinit
_obj.__init__(*args, **kwargs)
File "/Users/jpope/Documents/cryptoWorkspace/Quant_stock/pipeline/strategies/ff_strat.py", line 23, in __init__
self.saver = tf.train.import_meta_graph("data/model/feedforward.ckpt.meta")
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1698, in import_meta_graph
**kwargs)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/meta_graph.py", line 656, in import_scoped_meta_graph
producer_op_list=producer_op_list)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 313, in import_graph_def
op_def=op_def)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2630, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1204, in __init__
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'input_1' with dtype float
[[Node: input_1 = Placeholder[dtype=DT_FLOAT, shape=<unknown>, _device="/job:localhost/replica:0/task:0/cpu:0"](
Hi,
Nice code, just to be sure. Did you implemented a strategy for each Neural Net? Or just for feedfoward?
class InputHandler: def __init__(self, inputs): self.inputs = inputs if self.inputs.train: self.train(self.inputs.train) if self.inputs.btest: if self.inputs.btest == "test": self.run(TestStrategy) elif self.inputs.btest == "feedfoward": self.run(FeedforwardStrategy)
Willian
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.