-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from TheCyberHead/docker
Docker Integration
- Loading branch information
Showing
12 changed files
with
118 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ env/* | |
build/* | ||
cyberhead.egg-info/* | ||
dist/* | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM ubuntu:latest | ||
|
||
WORKDIR /app | ||
ADD ./cyberhead /app | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y python3 python3-pip telnet curl make g++ libssl-dev git | ||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | ||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | ||
RUN apt-get update | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get install -y yarn | ||
RUN pip3 install -r ./requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
version: '3' | ||
|
||
services: | ||
cyberhead-mysql: | ||
container_name: cyberhead-mysql | ||
image: mysql | ||
environment: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: cyberhead | ||
ports: | ||
- "3306:3306" | ||
restart: unless-stopped | ||
cyberhead-rmq: | ||
container_name: cyberhead-rmq | ||
image: 'rabbitmq:3.6-management-alpine' | ||
ports: | ||
- '5672:5672' | ||
- '15672:15672' | ||
restart: unless-stopped | ||
cyberhead: | ||
container_name: cyberhead | ||
environment: | ||
CH_DB_NAME: cyberhead | ||
CH_DB_HOST: database | ||
CH_DB_USER: root | ||
CH_DB_PASSWORD: root | ||
build: | ||
context: ./ | ||
dockerfile: ./Dockerfile | ||
command: sh -c "tail -f /dev/null" | ||
volumes: | ||
- .:/app | ||
depends_on: | ||
- cyberhead-mysql | ||
- cyberhead-rmq | ||
ports: | ||
- 5000:5000 | ||
- 3000:3000 | ||
restart: always | ||
links: | ||
- "cyberhead-rmq:rabbit" | ||
- "cyberhead-mysql:database" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
python3 ./cyberhead/database.py | ||
python3 ./startup.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from cyberhead.database import DataSet | ||
from cyberhead.modules.datasets import yahoo | ||
from sqlalchemy import create_engine | ||
import numpy as np | ||
import pandas | ||
import os | ||
|
||
engine = create_engine(f"mysql+pymysql://{os.getenv('CH_DB_USER')}:{os.getenv('CH_DB_PASSWORD')}@{os.getenv('CH_DB_HOST')}:3306/{os.getenv('CH_DB_NAME')}").connect() | ||
|
||
def allTimeFetch(ticker: str, period: str, interval: str, dataset_id: int): | ||
data = yahoo.download_historical(ticker, period, interval) | ||
data.to_csv('cyberhead/tmp/{}.csv'.format(ticker)) | ||
read_export = pandas.read_csv('cyberhead/tmp/{}.csv'.format(ticker)) | ||
read_export.drop('Adj Close',axis=1, inplace=True) | ||
read_export.columns = ['datetime', 'open_price', 'high_price', 'low_price', 'closing_price', 'volume'] | ||
read_export['dataset_id'] = dataset_id | ||
read_export.to_sql('history', con=engine, if_exists='append', index = False) | ||
return ticker | ||
|
||
|
||
timeseries_ohlc = [ | ||
{ | ||
"identifier": "Google 1D", | ||
"reference_symbol":"GOOG1D", | ||
"ticker": "GOOG", | ||
"source": "Yahoo", | ||
"frecuency":"1D" | ||
}, | ||
{ | ||
"identifier": "Apple 1D", | ||
"reference_symbol":"AAPL1D", | ||
"ticker": "AAPL", | ||
"source": "Yahoo", | ||
"frecuency":"1D" | ||
} | ||
] | ||
|
||
for data in timeseries_ohlc: | ||
data_set = DataSet.create(identifier=data["identifier"], | ||
reference_symbol=data["reference_symbol"], | ||
symbol=data["ticker"], | ||
source=data["source"], | ||
frecuency=data["frecuency"]) | ||
allTimeFetch(data["ticker"],"max", "1d",data_set.id) | ||
print(f'{data["reference_symbol"]} loaded.') |