Commit 91111062 authored by Dr.李's avatar Dr.李

Merge branch 'dxhb' of https://github.com/alpha-miner/alpha-mind into dxhb

parents 1a7fd765 fe22bde5
Pipeline #281 canceled with stages
......@@ -7,7 +7,25 @@ RUN apt-get update && apt-get install git cmake build-essential gfortran -y
COPY ./alphamind /alphamind
COPY ./notebooks /notebooks
RUN cd /alphamind/pfopt
WORKDIR /alphamind/pfopt
RUN export BUILD_TEST=OFF
RUN export REDIRECT=$1
RUN bash build_linux.sh
\ No newline at end of file
RUN bash ./build_linux.sh
WORKDIR /
COPY ./requirements.txt /requirements.txt
RUN pip install numpy==1.19.1 -i https://pypi.douban.com/simple
RUN pip install -r /requirements.txt -i https://pypi.douban.com/simple
RUN pip install finance-python==0.8.1 -i https://pypi.douban.com/simple
COPY ./setup.py /setup.py
COPY ./setup.cfg /setup.cfg
RUN python setup.py build_ext --inplace
EXPOSE 8080
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
WORKDIR /notebooks
ENTRYPOINT ["/entrypoint.sh"]
CMD []
\ No newline at end of file
......@@ -107,7 +107,7 @@ alpha - mind 提供了多因子研究中常用的工具链,包括:
安装需要直接clone或者下载源代码安装,具体流程为:
1. 克隆项目到本地
克隆项目到本地
```
git clone https://github.com/alpha-miner/alpha-mind.git
cd alpha-mind
......@@ -119,16 +119,23 @@ git submodule update
cd ../..
```
2. 参照上节内容,编译好依赖的子项目。
### SOURCE
3. 确保环境变量'VS90COMNTOOLS'的值为安装的VS的Comntools下的地址,如'\vs2015\Common7\Tools\'
1. 参照上节内容,编译好依赖的子项目。
4. 回到项目的根目录下运行:
2. 回到项目的根目录下运行:
```python
python setup.py install
```
### Docker
1. `docker build -t alpha-mind:latest -f Dockerfile .`
2. `docker run -it -p 8080:8080 --name alpha-mind alpha-mind`
* *注意事项*:
1. 在Linux系统上,请确保gcc版本大于4.8;
2. 在libs下面提供了依赖的一些库的二进制文件。linux版本的是在一台具有两个intel cpu的docker虚机上面编译完成的。如果需要实现最佳的性能,建议用户在目标机器上编译相关依赖的库。依赖的库源码地址:[portfolio-optimizer](https://github.com/alpha-miner/portfolio-optimizer)
......
......@@ -12,65 +12,6 @@ Base = declarative_base()
metadata = Base.metadata
class FundHolding(Base):
__tablename__ = 'fund_holding'
fund_code = Column(String(15), primary_key=True, nullable=False)
ticker = Column(String(15), nullable=False)
short_name = Column(String(30), nullable=False)
reportDate = Column(DateTime, primary_key=True, nullable=False)
holdingsecType = Column(String(5), nullable=False)
holdingSecID = Column(String(15), primary_key=True, nullable=False)
holdingTicker = Column(String(15), nullable=False)
holdingExchangeCd = Column(String(5))
holdingsecShortName = Column(String(30))
holdVolume = Column(Float(53))
marketValue = Column(Float(53))
ratioInNa = Column(Float(53))
publishDate = Column(DateTime, nullable=False)
currencyCd = Column(String(5))
class FundMaster(Base):
__tablename__ = 'fund_master'
fund_code = Column(String(15), primary_key=True)
ticker = Column(String(15), nullable=False)
short_name = Column(String(30), nullable=False)
tradeAbbrName = Column(String(20))
category = Column(String(5), nullable=False)
operationMode = Column(String(5))
indexFund = Column(String(5))
etfLof = Column(String(5))
isQdii = Column(Integer, nullable=False)
isFof = Column(Integer, nullable=False)
isGuarFund = Column(Integer, nullable=False)
guarPeriod = Column(Float(53))
guarRatio = Column(Float(53))
exchangeCd = Column(String(4))
listStatusCd = Column(String(4))
managerName = Column(String(50))
status = Column(String(5))
establishDate = Column(DateTime)
listDate = Column(DateTime)
delistDate = Column(DateTime)
expireDate = Column(DateTime)
managementCompany = Column(BigInteger)
managementFullName = Column(String(50))
custodian = Column(BigInteger)
custodianFullName = Column(String(50))
investField = Column(Text)
investTarget = Column(Text)
perfBenchmark = Column(Text)
circulationShares = Column(Float(53))
isClass = Column(Integer)
idxID = Column(String(15))
idxTicker = Column(String(15))
idxShortName = Column(String(30))
managementShortName = Column(String(30))
custodianShortName = Column(String(30))
class Categories(Base):
__tablename__ = 'categories'
__table_args__ = (
......
......@@ -21,8 +21,6 @@ from sqlalchemy.sql import func
from PyFin.api import advanceDateByCalendar
from alphamind.data.dbmodel.models import FactorMaster
from alphamind.data.dbmodel.models import FundHolding
from alphamind.data.dbmodel.models import FundMaster
from alphamind.data.dbmodel.models import IndexComponent
from alphamind.data.dbmodel.models import IndexMarket
from alphamind.data.dbmodel.models import Industry
......@@ -114,25 +112,6 @@ class SqlEngine(object):
db_session = orm.sessionmaker(bind=self.engine)
return db_session()
def fetch_fund_meta(self) -> pd.DataFrame:
query = self.session.query(FundMaster)
return pd.read_sql(query.statement, query.session.bind)
def fetch_fund_holding(self,
fund_codes,
start_date: str = None,
end_date: str = None,
dates: Iterable[str] = None) -> pd.DataFrame:
query = select([FundHolding]).where(
and_(
FundHolding.fund_code.in_(fund_codes),
FundHolding.reportDate.in_(dates) if dates else FundHolding.reportDate.between(
start_date, end_date)
)
)
return pd.read_sql(query, self.session.bind)
def fetch_factors_meta(self) -> pd.DataFrame:
query = self.session.query(FactorMaster)
return pd.read_sql(query.statement, query.session.bind)
......
#!/bin/sh
export PYTHONPATH=$PYTHONPATH:/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/alphamind/pfopt/lib
export DB_URI="postgresql+psycopg2://alpha:alpha@localhost:5432/alpha"
jupyter lab --ip="0.0.0.0" --port=8080 --allow-root --NotebookApp.token='' --NotebookApp.password=''
\ No newline at end of file
arrow >= 0.10.0
cython >= 0.25.2
cvxpy >= 1.0.3
deprecated >= 1.1.0
ecos >= 2.0.4
finance-python >= 0.5.7
numba >= 0.33.0
numpy >= 1.12.1
pandas >= 0.19.2
psycopg2 >= 2.7.1
scikit-learn >= 0.18.1
scipy >= 0.19.0
simpleutils >= 0.1.2
sqlalchemy >= 1.1.14
xgboost >= 0.90.0
\ No newline at end of file
arrow == 0.16.0
cython == 0.29.21
cvxpy == 1.1.5
cvxopt == 1.2.5
deprecated == 1.2.10
ecos == 2.0.7.post1
jupyter == 1.0.0
jupyterlab == 2.2.6
matplotlib == 3.3.1
numba == 0.51.1
numpy == 1.19.1
pandas == 1.1.1
psycopg2-binary == 2.8.5
scikit-learn ==0.23.2
scipy == 1.5.2
simpleutils == 0.2.6
sqlalchemy == 1.3.19
xgboost == 1.2.0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment