Skip to content

Commit

Permalink
chore: hides api key on .env
Browse files Browse the repository at this point in the history
  • Loading branch information
Draichi committed Oct 8, 2020
1 parent a7aa9c6 commit a012a39
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Example: CRYPTOCOMPARE_API_KEY='my-key'
CRYPTOCOMPARE_API_KEY=''
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/__pycache__
*.csv
/.vscode
/models
/models
.env
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Deep reinforcement learning multi-agent algorithmic trading framework that learn

## Prerequisites

- [Miniconda](https://conda.io/docs/user-guide/install/index.html) or Anaconda
- [Miniconda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html) or Anaconda

An API Key on [CryptoCompare](https://min-api.cryptocompare.com/)

* * *

Expand All @@ -27,6 +29,8 @@ Deep reinforcement learning multi-agent algorithmic trading framework that learn
### Ubuntu

```sh
# paste your API Key on .env
cp .env.example .env
# make sure you have these installed
sudo apt-get install gcc g++ build-essential python-dev python3-dev -y
# create env
Expand Down
1 change: 1 addition & 0 deletions t-1000.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ dependencies:
- pyrsistent==0.15.4
- pytest==5.1.3
- python-dateutil==2.8.0
- python-dotenv==0.14.0
- pytz==2019.2
- pyyaml==5.1.2
- ray==0.8.0
Expand Down
11 changes: 7 additions & 4 deletions utils/data_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import requests
import pandas as pd
import numpy as np
from dotenv import load_dotenv
from yaspin import yaspin
from prompt_toolkit import HTML, print_formatted_text
from prompt_toolkit.styles import Style
Expand Down Expand Up @@ -41,13 +42,17 @@ def get_datasets(asset, currency, granularity, datapoints, exchange, df_train_si
Returns:
pandas.Dataframe -- The OHLCV and indicators dataframe
"""
load_dotenv()
CRYPTOCOMPARE_API_KEY = os.getenv('CRYPTOCOMPARE_API_KEY')
if not CRYPTOCOMPARE_API_KEY:
raise EnvironmentError('CRYPTOCOMPARE_API_KEY not found on .env')
df_train_path = 'data/bot_train_{}_{}_{}.csv'.format(
asset + currency, datapoints, granularity)
df_rollout_path = 'data/bot_rollout_{}_{}_{}.csv'.format(
asset + currency, datapoints, granularity)
if not os.path.exists(df_rollout_path):
headers = {'User-Agent': 'Mozilla/5.0',
'authorization': 'Apikey 3d7d3e9e6006669ac00584978342451c95c3c78421268ff7aeef69995f9a09ce'}
'authorization': 'Apikey {}'.format(CRYPTOCOMPARE_API_KEY)}

url = 'https://min-api.cryptocompare.com/data/histo{}?fsym={}&tsym={}&limit={}&e={}'.format(
granularity, asset, currency, datapoints, exchange)
Expand All @@ -64,9 +69,7 @@ def get_datasets(asset, currency, granularity, datapoints, exchange, df_train_si
json_response = response.json()
status = json_response['Response']
if status == "Error":
print(colored('=== {} ==='.format(
json_response['Message']), 'red'))
raise AssertionError()
raise AssertionError(colored(json_response['Message'], 'red'))
result = json_response['Data']
df = pd.DataFrame(result)
# print(df.tail())
Expand Down

0 comments on commit a012a39

Please sign in to comment.