Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.

Code & Readme Improvements #11

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f12195f
Create Pipfile
Mar 23, 2019
8a6d71f
Create README_Pipenv.md
Mar 23, 2019
33c8f43
Update README_Pipenv.md
Mar 23, 2019
173e678
Update README_Pipenv.md
Mar 23, 2019
1396190
Update evolution-strategy-bayesian-agent.ipynb
Mar 23, 2019
ea15da5
Update evolution-strategy-bayesian-agent.ipynb
Mar 23, 2019
d5990e2
Update evolution-strategy-bayesian-agent.ipynb
Mar 23, 2019
70f51f7
Merge pull request #2 from AlconDivino/master
Mar 24, 2019
63cad53
Update README_Pipenv.md
Mar 24, 2019
e76c4d1
Fixed typo in Pipfile
Mar 24, 2019
229c53e
Create downloader_crypto.py
Mar 24, 2019
d103127
Update downloader_crypto.py
Mar 24, 2019
bef77ee
Create btcusd.csv
Mar 24, 2019
df246b0
Add files via upload
Mar 24, 2019
74e0c56
Add files via upload
Mar 24, 2019
7f10d36
Update README.md
Mar 24, 2019
bc4e077
Move bayesian 1.0 files to new dir for Pipenv
Mar 24, 2019
9c87ccc
Create Pipfile
Mar 24, 2019
bd6928c
Added automatic OHLCV fetcher for crypto exchanges
AlconDivino Mar 24, 2019
7ec53b8
Merge branch 'master' of https://github.com/AlconDivino/Stock-Predict…
Mar 25, 2019
cdf52af
Merge branch 'AlconDivino-master'
Mar 25, 2019
6e1ee76
Update Evolution_Bayesian.py
Mar 25, 2019
5cd2315
Rename README_Pipenv.md to README.md
Mar 25, 2019
ca11ecc
Rename agent/crypto_data_loader.py to dataset/crypto_data_loader.py
Mar 25, 2019
15db05a
Create __init__.py
Mar 25, 2019
34fae2b
Update Evolution_Bayesian.py
Mar 25, 2019
ada4ad2
Update Pipfile
Mar 25, 2019
4e7ed6c
Update README.md
Mar 26, 2019
8db7b7e
Update README.md
Mar 26, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@

### Data Explorations

0. Downloader usage: `python downloader_crypto.py bitmex BTC/USD 2015-01-01T00:00:00Z 1d btc.csv`
1. stock market study on TESLA stock, [tesla-study.ipynb](misc/tesla-study.ipynb)
2. fashion trending prediction with cross-validation, [fashion-forecasting.ipynb](misc/fashion-forecasting.ipynb)
3. Bitcoin analysis with LSTM prediction, [bitcoin-analysis-lstm.ipynb](misc/bitcoin-analysis-lstm.ipynb)
Expand Down
50 changes: 34 additions & 16 deletions agent/Evolution_Bayesian.py → agent-new/Evolution_Bayesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
import seaborn as sns
import random
from bayes_opt import BayesianOptimization
import os, sys
sys.path.insert(1, os.path.join(sys.path[0], '../dataset'))
from crypto_data_loader import get_candles
sns.set()

use_csv = False


def get_state(data, t, n):
d = t - n + 1
block = data[d : t + 1] if d >= 0 else -d * [data[0]] + data[0 : t + 1]
Expand All @@ -15,15 +21,6 @@ def get_state(data, t, n):
res.append(block[i + 1] - block[i])
return np.array([res])

df = pd.read_csv('../dataset/GOOG-year.csv')
print(df.tail())

close = df.Close.values.tolist()
window_size = 30
skip = 5
l = len(close) - 1


class Deep_Evolution_Strategy:

inputs = None
Expand Down Expand Up @@ -291,20 +288,41 @@ def find_best_agent(
if investment > accbest:
costbest = investment
return investment
##--------------------------------------------------
##Settings (Later as argv)
exchange = 'bitmex'
symbol = 'BTC/USD'
start_date = '2018-01-01T00:00:00Z'
timeframe = '1d'

#---------------------------------------------------
##Get Data
if use_csv:
df = pd.read_csv('../dataset/btcusd.csv')
else:
df = get_candles(exchange , 3 , symbol ,timeframe , start_date ,25) #df = pd.read_csv('../dataset/GOOG-year.csv')
print(df)

close = df.Close.values.tolist()
window_size = 30
skip = 5
l = len(close) - 1

##----------------------------------------------------
## Bayesian Stuff
accbest = 0.0
NN_BAYESIAN = BayesianOptimization(
find_best_agent,
{
'window_size': (2, 50),#2,50
'skip': (1, 15), #1,15
'population_size': (1, 50),#1,50
'window_size': (2, 50),#standard: 2,50
'skip': (1, 15), #standard: 1,15
'population_size': (1, 50),#standard: 1,50
'sigma': (0.01, 0.99),
'learning_rate': (0.000001, 0.49),#0.000001 , 0.49
'size_network': (10, 1000),#10,1000
'learning_rate': (0.000001, 0.49),#standard: 0.000001 , 0.49
'size_network': (10, 1000),#standard: 10,1000
},
)
NN_BAYESIAN.maximize(init_points = 50, n_iter = 200, acq = 'ei', xi = 0.0)#n_iter=50 init_points=30
NN_BAYESIAN.maximize(init_points = 50, n_iter = 80, acq = 'ei', xi = 0.0)#standard: init_points=30 n_iter=50


print('----------------------------------------------')
Expand All @@ -321,6 +339,6 @@ def find_best_agent(
model = Model(int(params['window_size']) , int(params['size_network']) ,3)
agent = Agent(int(params['population_size']) , params['sigma'] , params['learning_rate'] , model , 10000 , 5 , 5, int(params['skip']),int(params['window_size']))

agent.fit(500, 100)
agent.fit(500, 50)

agent.buy()
18 changes: 18 additions & 0 deletions agent-new/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
pprint = "*"
numpy = "*"
pandas = "*"
seaborn = "*"
bayesian-optimization = "*"
matplotlib = "*"
ccxt = "*"

[requires]
python_version = "3.7"
13 changes: 13 additions & 0 deletions agent/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
ccxt = "*"
pprint = "*"

[requires]
python_version = "3.7"
22 changes: 22 additions & 0 deletions agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Using Pipenv with the Pipfile I included in this directory will get you the proper bayesian_optimization package (For the original version of the /agent scripts) as well as jupyter notebook kernel to work with it. The post-1.0 version of bayesian_optimization requires different code. All to be upgrdaed. This is just to run the original code. Commands to get started:

**pipenv --python 3.7.2**

**pipenv shell**

**pipenv install ipykernel**

**pipenv sync**

**python -m ipykernel install --user --name=my-virtualenv-name**


Replace "my-virtualenv-name" with the name of your pipenv environment. You can see it in the path of the command:

**which python**

Then you can:

**jupyter notebook --ip=127.0.0.1**

Don't forget to switch to the custom agent kernel once the notebook opens.
Loading