ceruleanacg / personae Goto Github PK
View Code? Open in Web Editor NEWπ Personae is a repo of implements and environment of Deep Reinforcement Learning & Supervised Learning for Quantitative Trading.
License: MIT License
π Personae is a repo of implements and environment of Deep Reinforcement Learning & Supervised Learning for Quantitative Trading.
License: MIT License
Why assume that everyone is going to use your docker image ? What is the actual launch script ?
Of the Market initial function parameters, the mix_index_state mean that whether the index code 'sh' is included into market's code. I want to know that whether the code 'sh' is a stock/future index data and if yes, how can i get it and why you use it? Hope you can give me response, thank you very much!
Traceback (most recent call last):
File "spider/stock_spider.py", line 34, in
main(stock_spider_parser.parse_args())
File "spider/stock_spider.py", line 30, in main
StockSpider(_code, args.start, args.end).crawl()
File "spider/stock_spider.py", line 22, in crawl
stock.save_if_need()
File "/app/Personae/base/model/document.py", line 52, in save_if_need
return self.save() if len(self.class.objects(code=self.code, date=self.date)) < 1 else None
File "/usr/local/lib/python3.5/dist-packages/mongoengine/queryset/manager.py", line 37, in get
queryset = queryset_class(owner, owner._get_collection())
File "/usr/local/lib/python3.5/dist-packages/mongoengine/document.py", line 198, in _get_collection
cls.ensure_indexes()
File "/usr/local/lib/python3.5/dist-packages/mongoengine/document.py", line 878, in ensure_indexes
collection.create_index(fields, background=background, **opts)
File "/usr/local/lib/python3.5/dist-packages/pymongo/collection.py", line 1754, in create_index
self.__create_index(keys, kwargs, session, **cmd_options)
File "/usr/local/lib/python3.5/dist-packages/pymongo/collection.py", line 1642, in __create_index
with self._socket_for_writes() as sock_info:
File "/usr/local/lib/python3.5/dist-packages/pymongo/collection.py", line 194, in _socket_for_writes
return self.__database.client._socket_for_writes()
File "/usr/local/lib/python3.5/dist-packages/pymongo/mongo_client.py", line 968, in _socket_for_writes
server = self._get_topology().select_server(writable_server_selector)
File "/usr/local/lib/python3.5/dist-packages/pymongo/topology.py", line 224, in select_server
address))
File "/usr/local/lib/python3.5/dist-packages/pymongo/topology.py", line 183, in select_servers
selector, server_timeout, address)
File "/usr/local/lib/python3.5/dist-packages/pymongo/topology.py", line 199, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: mongo:27017: [Errno -2] Name or service not known
Another question(It can be found in my mail, too) is as shown in the title. I am puzzled whether I had misunderstanded. Please help me to realize it...
I ran 3 alogrithms of NaiveLSTM, TreNet and Attention. After training, the predictions were plotted. While I made a tiny change on the plotting method - I added the close price at time t in x, to compare it with real and predict. Then in the figure, there were now 3 lines:
What puzzled me is the predict line approximated much more with x instead of with real in the result of all the three algorithms. In my former experiments, I used some form of simple functions such as sin(x) as a sequence, and plotted x, real, and predict. On these simple sequences the predict lines approximate the real(y, time t+1) perfectly.
As a result, I have got a question whether the algorithms learned anything. Please give me some help...
Following 3 plots are NaiveLSTM, the whole plot of Attention, and a local figure in the plot of Attention. In all of which, there 3 lines indicating x(just close price at time t, real, and predict).
Thanks very much!
[andrewcz@andrewcz-pc Personae]$ sudo docker run -p 27017:27017 -v /data/db:/data/db -d --network=your_network mongo
040b83a8b3aa269b5290a4234a487265f71b0465e95169997e44d386770f989d
docker: Error response from daemon: network your_network not found.
how do i set up mongodb running a arch linux system.
Amazing repo by the way
BEst,
Andrew
I think the action space should be 3 ** self.codes_count
rather than self.codes_count * 3
?
I want to say,how can you code running?Missing some code!!!
Hi Ceruleanacg:
The DA_RNN project you reproduced is very good. Since I am a beginner, there are a lot of puzzles that seem simple. I hope to get your guidance. The first is that I used the TensorFlow-CPU version (running under Windows 10) to see that you are using mongoengine to get the data in real time. I am not very clear about how to load under anaconda. I would like to ask how to change the program to read the datasets directly and train the model and model evaluation.(I mean I have a dataset for DA-RNN.)
Thank you very much!
Have a good day! (ps:I saw you in the previous issue as Chinese, and my WeChat is: zheng2505199316)
Wendong Zheng
Hello, cerulean, thanks for your great repo!
I found a problem in implement of your Attention Based Model.
I've mailed you about that, please confirm that, thank you!
I test DoubleDQN
algorithm find from 2012-01-01 to 2018-01-01 Model output action always be 9 (Buy 601398). Is it possible 6 years just keep buying one stock??
By the way, I change default stock_codes
list
From
stock_codes = ["600036", "601328", "601998", "601398"]
To
stock_codes = ["600036", "601328", "601398", "601998"]
But the output action still be 9...
Some output:
according to this "self.cnn = self.add_cnn(self.cnn_x, filters=2, kernel_size=[2, 2], pooling_size=[2, 2]) "
after cnn, the shape should be (-1,5,20,2)?
Am i misunderstanding?
As asked in the title, in base/env/market.py, when generating sequences from orignal dataset, the label of training set is at time of t+2(data_index + 1) compared to x(from data_index - seq_len to data_index, a semi-closed interval), while when choosing label for the validate set, it is at t+1 instead.
Note that there is a tiny bug in master in the statement of instruments_y assiginment and I fixed in according to the code in dev branch.
`
if date_index < self.bound_index:
# Get y, y is not at date index, but plus 1. (Training Set)
instruments_y = scaled_frame.iloc[date_index + 1]['close']
else:
# Get y, y is at date index. (Test Set)
instruments_y = scaled_frame.iloc[date_index]['close'] # data_index + 1 --> data_index here
`
Thanks for your answer :)
My name is Luis, I'm a big-data machine-learning developer, I'm a fan of your work, and I usually check your updates.
I was afraid that my savings would be eaten by inflation. I have created a powerful tool that based on past technical patterns (volatility, moving averages, statistics, trends, candlesticks, support and resistance, stock index indicators).
All the ones you know (RSI, MACD, STOCH, Bolinger Bands, SMA, DEMARK, Japanese candlesticks, ichimoku, fibonacci, williansR, balance of power, murrey math, etc) and more than 200 others.
The tool creates prediction models of correct trading points (buy signal and sell signal, every stock is good traded in time and direction).
For this I have used big data tools like pandas python, stock market libraries like: tablib, TAcharts ,pandas_ta... For data collection and calculation.
And powerful machine-learning libraries such as: Sklearn.RandomForest , Sklearn.GradientBoosting, XGBoost, Google TensorFlow and Google TensorFlow LSTM.
With the models trained with the selection of the best technical indicators, the tool is able to predict trading points (where to buy, where to sell) and send real-time alerts to Telegram or Mail. The points are calculated based on the learning of the correct trading points of the last 2 years (including the change to bear market after the rate hike).
I think it could be useful to you, to improve, I would like to give it to you, and if you are interested in improving and collaborating I am also willing, and if not I would like to file it in the drawer.
Has anyone had success importing this to db using spider? What is the symbol? Thanks
hey ceruleanacg,
Thanks for this great repo, I am wondering is there a roadmap to conduct Pytorch implemetation?
Have a good day
Hey, I try to run with docker, but I' m not familiar with it , I also download the Kitematic , and your images . Then I run
docker run -t -v /Users/fanpu/Personae:/app --network=bridge ceruleanwang/haru DoubleDQN.p
python3.5: can't open file 'DoubleDQN.py': [Errno 2] No such file or directory
Could u pls help me solve the error? Thanks.
When I run DoubleDQN or DuelingDQN, the result is nothing(his_profits is always 0). It seems that the algorithm have learned nothing.
I think the input of the RL algorithm have some problems. The input data is just one day's stock data plus the agent's status, but I think one day's data cannot do any effective prediction.
So can I use sequence data in RL Algorithm?
Another question is when I run RL algorithm, it is too slow. Almost 15 seconds 1 episode. What is the main cost? And how many episodes should I set in total to get a good result?
Hello, I tried to run "TreNet.py", but it can not find config in algorithm
from algorithm import config
ImportError: No module named 'algorithm'
I don't know how to find "config" , maybe i should do something first?
How to solve this problem? Could you help me ? Sorry, I'm new here.
Thank you.
Thanks for the code. found it helpful in understanding the complexities of stock price prediction.
line #208 in base.env.market.py
if date_index < self.bound_index:
# Get y, y is not at date index, but plus 1. (Training Set)
instruments_y = scaled_frame.iloc[date_index + 1]['close']
else:
# Get y, y is at date index. (Test Set)
instruments_y = scaled_frame.iloc[date_index + 1]['close']
both the if and else conditions have the same code. should the else statement be
instruments_y = scaled_frame.iloc[date_index]['close']
secondly, i had a question. how do i convert the scaled values back to the normal values after the predict function is called ? I would like to see the predicted price as a non scaled value ?
thanks and appreciate your effort.
Please add forex data and live online feed e.g Interactive Brokers through Backtrader which has inbuilt backtesting with connection for live trading and data feeds ( Forex, Stocks, Futures, CFDs, ETF, Options, Commodities , etc ) from interactive brokers .
Continuous Live Market Data Feed from IB ==> Features generation & data procession on the fly ==>
Personae ==> Continuous RL Prediction or Signal generation ==> Trade long or short through IB ( Timeframes -- 1Min, 5Min, 15Min, 30Min, 1H, 4H, Daily )
You can test using Interactive brokers Demo account
I use Docker to run this project, but meet some problems.
The progress is below:
docker image build -t ppdemo .
docker run --name my_mongo -p 27017:27017 -d mongo
docker run -t --link my_mongo:mongo -v $PWD:/app/Personae ppdemo spider/stock_spider.py
It is fine now. But some errors happened when python import tensorflow.
$ docker run -t --link my_mongo:mongo -v $PWD:/app/Personae ppdemo algorithm/SL/DualAttnRNN.py
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/lib/x86_64-linux-gnu/libcuda.so.1: file too short
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "algorithm/SL/DualAttnRNN.py", line 3, in <module>
import tensorflow as tf
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/lib/x86_64-linux-gnu/libcuda.so.1: file too short
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I am a noob in using docker. May you tell me what's wrong with the progress?
It's hard for me to run it up
I just wanna say "Have u found a job?"
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.