Giter Club home page Giter Club logo

personae's People

Contributors

ceruleanacg avatar yd8534976 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

personae's Issues

Add Forex data and continuous LIVE training , validation and trading piece

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

It seems that the RL algorithms under default parameters didn't learn anything.

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:

  • x - close price at time t, which is newly added and from real data;
  • real - close price at time t+1, which is from real data;
  • predict - close price at time t+1, which is predicted and to be validated.

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).

  1. NaiveLSTM
    image
  2. Whole plot of Attention (In which the detail is hard to distinct)
    image
  3. A local figure of Attention
    3

Thanks very much!

error in run with docker

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.

code 'sh' for index?

Has anyone had success importing this to db using spider? What is the symbol? Thanks

In the RL algorithms, why label in training set is at t+2 while which in validate set is at time t+1 ?

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 :)

Why DoubleDQN output action always be 9

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:

algorithm1

algorithm2

How to run this program in anaconda3?

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

ImportError: /usr/lib/x86_64-linux-gnu/libcuda.so.1: file too short

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?

potential bug and a question

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.

About the action space

I think the action space should be 3 ** self.codes_count rather than self.codes_count * 3 ?

New complementary Tool

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.

Pytorch implementation

hey ceruleanacg,

Thanks for this great repo, I am wondering is there a roadmap to conduct Pytorch implemetation?

Have a good day

Implement about Attention Based Model

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!

a problem about config

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.

help with set up.

[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

errors about mongo

docker run -t -v $PWD:/app/Personae --network=mynet ceruleanwang/personae spider/stock_spider.py

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

Question about the mix_index_state

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!

About sequence data in RL Algorithm

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.