shenyichen105 / Deep-Reinforcement-Learning-in-Stock-Trading

Using deep actor-critic model to learn best strategies in pair trading
309 stars 127 forks source link

i think util.py file is missing. #1

Open doncat99 opened 7 years ago

4575759ww commented 7 years ago

The same question, can't find util.py

doncat99 commented 7 years ago

I simply reconstruct the only export function "get_data" in util.py file as below:

def get_data(symbols, dates_range, update):
    import os
    cwd = os.getcwd()
    dir = cwd + "/data/"
    df = pd.DataFrame()
    symbols.append('spy')
    for symbol in symbols:
        print("symbol", symbol)
        filename = dir + symbol + '.csv'
        data = pd.read_csv(filename, index_col=["Date"], parse_dates=['Date'])
        if df.empty:
            if 'Close' in data:
                df[symbol] = data['Close']
            else:
                df[symbol] = data['Rate']
        else:
            if 'Close' in data:
                df[symbol] = data['Close']
            else:
                df[symbol] = data['Rate']
    return df[df.index.isin(dates_range)].sort_index()

I used all the default setting (dates, stocks selected), and the result seems promising. With 100,000 initial cash to start,


190044.204471


@4575759ww

magick93 commented 7 years ago

@doncat99

I added a file called util.pyand added your function.

Now when I try to run, I get further, but I now get:

python RLMDP/runner.py
Traceback (most recent call last):
  File "RLMDP/runner.py", line 2, in <module>
    from agent import PolicyGradientAgent, CriticsAgent
  File "/home/anton/git/priceinsight/Deep-Reinforcement-Learning-in-Stock-Trading/RLMDP/agent.py", line 4, in <module>
    import lasagne
  File "/usr/local/lib/python2.7/dist-packages/lasagne/__init__.py", line 19, in <module>
    from . import layers
  File "/usr/local/lib/python2.7/dist-packages/lasagne/layers/__init__.py", line 7, in <module>
    from .pool import *
  File "/usr/local/lib/python2.7/dist-packages/lasagne/layers/pool.py", line 6, in <module>
    from theano.tensor.signal import downsample
ImportError: cannot import name downs

Any idea what I might be doing wrong?

LymengLM commented 6 years ago

@magick93 Since downsample has been moved, try configure this file "/usr/local/lib/python2.7/dist-packages/lasagne/layers/pool.py"

from theano.tensor.signal import downsample ... pooled_out = downsample.max_pool_2d( ... )

to

from theano.tensor.signal import pool ... pooled_out = pool.pool_2d( ... )

lorrp1 commented 6 years ago

i got: 190044.2044709011 which is good but it should be 461000

@doncat99 @LymengLM @shenyichen105 @4575759ww

zhoujinhai commented 5 years ago

the code just 5 interactions, I run need long time on CPU! How to improve the running speed?

silviumatei commented 5 years ago

the code just 5 interactions, I run need long time on CPU! How to improve the running speed?

Did you try running it on Kaggle? Usually their server is faster than my laptop, particularly if the script allows activating the GPU option.