Skip to content

Commit

Permalink
#update
Browse files Browse the repository at this point in the history
  • Loading branch information
yutiansut committed Aug 28, 2018
1 parent e5cb986 commit 8bb3aa6
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 33 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding:utf-8

from QUANTAXIS.QABacktest.QABacktest import QA_Backtest
from QUANTAXIS.QAApplication.QABacktest import QA_Backtest

"""
日内t0的回测框架
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion QUANTAXIS/QACmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import subprocess
import requests

from QUANTAXIS.QABacktest.QAAnalysis import QA_backtest_analysis_backtest
from QUANTAXIS.QAApplication.QAAnalysis import QA_backtest_analysis_backtest
from QUANTAXIS.QAUtil import QA_util_log_info, QA_Setting, QA_util_mongo_initial
from QUANTAXIS.QASU.main import (QA_SU_save_stock_list, QA_SU_save_stock_min, QA_SU_save_stock_xdxr,
QA_SU_save_stock_block, QA_SU_save_stock_info,QA_SU_save_stock_info_tushare,
Expand Down
53 changes: 44 additions & 9 deletions QUANTAXIS/QAFetch/QATushare.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,52 @@
import pandas as pd
import tushare as ts

from QUANTAXIS.QAUtil import (QA_util_date_int2str, QA_util_date_stamp,
from QUANTAXIS.QAUtil import (QA_util_date_int2str, QA_util_date_stamp, QASETTING,
QA_util_log_info, QA_util_to_json_from_pandas)

# try:
# pro = ts.pro_api()
# except Exception as e:
# if isinstance(e, NameError):
# print('请设置tushare pro的token凭证码')
# else:
# print('请升级tushare 至最新版本 pip install tushare -U')
# print(e)

def set_token(token=None):
try:
if token is None:
token = QASETTING.get_config('TSPRO', 'token', None)
else:
QASETTING.set_config('TSPRO', 'token', token)
ts.set_token(token)
except:
print('请升级tushare 至最新版本 pip install tushare -U')


def get_pro():
try:
set_token()
pro = ts.pro_api()
except Exception as e:
if isinstance(e, NameError):
print('请设置tushare pro的token凭证码')
else:
print('请升级tushare 至最新版本 pip install tushare -U')
print(e)
pro = None
return pro


def QA_fetch_get_stock_adj(code, end=''):
"""获取股票的复权因子
Arguments:
code {[type]} -- [description]
Keyword Arguments:
end {str} -- [description] (default: {''})
Returns:
[type] -- [description]
"""


pro = get_pro()
adj = pro.adj_factor(ts_code=code, trade_date=end)
return adj


def QA_fetch_get_stock_day(name, start='', end='', if_fq='01', type_='pd'):
Expand Down
6 changes: 3 additions & 3 deletions QUANTAXIS/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@
from QUANTAXIS.QAARP.QAUser import QA_User
from QUANTAXIS.QAARP.QAStrategy import QA_Strategy
# Backtest
from QUANTAXIS.QABacktest.QABacktest import QA_Backtest
from QUANTAXIS.QAApplication.QABacktest import QA_Backtest

from QUANTAXIS.QABacktest.QAAnalysis import QA_backtest_analysis_backtest
from QUANTAXIS.QABacktest.QAResult import backtest_result_analyzer
from QUANTAXIS.QAApplication.QAAnalysis import QA_backtest_analysis_backtest
from QUANTAXIS.QAApplication.QAResult import backtest_result_analyzer

# ENGINE
from QUANTAXIS.QAEngine import QA_Thread, QA_Event, QA_Worker, QA_Task, QA_Engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from QUANTAXIS.QAARP.QARisk import QA_Performance, QA_Risk
from QUANTAXIS.QAARP.QAStrategy import QA_Strategy
from QUANTAXIS.QAARP.QAUser import QA_User
from QUANTAXIS.QABacktest.QABacktest import QA_Backtest
from QUANTAXIS.QAApplication.QABacktest import QA_Backtest
from QUANTAXIS.QAFetch import QAQuery_Advance
from QUANTAXIS.QAIndicator import QA_indicator_BOLL
from QUANTAXIS.QAUtil.QADate_trade import (QA_util_get_last_day,
Expand Down
2 changes: 1 addition & 1 deletion QUANTAXIS_Test/QABacktest_Test/QABacktest_Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from QUANTAXIS.QAARP.QARisk import QA_Performance, QA_Risk
from QUANTAXIS.QAARP.QAStrategy import QA_Strategy
from QUANTAXIS.QAARP.QAUser import QA_User
from QUANTAXIS.QABacktest.QABacktest import QA_Backtest
from QUANTAXIS.QAApplication.QABacktest import QA_Backtest
from QUANTAXIS.QAFetch.QAQuery import QA_fetch_stock_day
from QUANTAXIS.QAIndicator import QA_indicator_MA
from QUANTAXIS.QAUtil.QADate import QA_util_datetime_to_strdate
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def read(fname):
"""
名字,一般放你包的名字即可
"""
PACKAGES = ["QUANTAXIS", "QUANTAXIS.QAFetch", "QUANTAXIS.QACmd", "QUANTAXIS.QAMarket", 'QUANTAXIS.QAWeb', 'QUANTAXIS.QATrade', 'QUANTAXIS.QASetting',
"QUANTAXIS.QABacktest", "QUANTAXIS.QAEngine", "QUANTAXIS.QAData", 'QUANTAXIS.QAData.proto', "QUANTAXIS.QAAnalysis", 'QUANTAXIS.QASelector',
PACKAGES = ["QUANTAXIS", "QUANTAXIS.QAFetch", "QUANTAXIS.QACmd", "QUANTAXIS.QAMarket", 'QUANTAXIS.QAWeb', 'QUANTAXIS.QASetting',
"QUANTAXIS.QAApplication", "QUANTAXIS.QAEngine", "QUANTAXIS.QAData", 'QUANTAXIS.QAData.proto', "QUANTAXIS.QAAnalysis", 'QUANTAXIS.QASelector',
"QUANTAXIS.QASU", "QUANTAXIS.QAUtil", "QUANTAXIS.QAARP", "QUANTAXIS.QAIndicator", "QUANTAXIS_CRAWLY", "QUANTAXIS.QAView"]
"""
包含的包,可以多个,这是一个列表
Expand Down
20 changes: 10 additions & 10 deletions source/QUANTAXIS.QABacktest.rst
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
QUANTAXIS.QABacktest package
QUANTAXIS.QAApplication package
============================

Submodules
----------

QUANTAXIS.QABacktest.QAAnalysis module
QUANTAXIS.QAApplication.QAAnalysis module
--------------------------------------

.. automodule:: QUANTAXIS.QABacktest.QAAnalysis
.. automodule:: QUANTAXIS.QAApplication.QAAnalysis
:members:
:undoc-members:
:show-inheritance:

QUANTAXIS.QABacktest.QABacktest module
QUANTAXIS.QAApplication.QABacktest module
--------------------------------------

.. automodule:: QUANTAXIS.QABacktest.QABacktest
.. automodule:: QUANTAXIS.QAApplication.QABacktest
:members:
:undoc-members:
:show-inheritance:

QUANTAXIS.QABacktest.QAResult module
QUANTAXIS.QAApplication.QAResult module
------------------------------------

.. automodule:: QUANTAXIS.QABacktest.QAResult
.. automodule:: QUANTAXIS.QAApplication.QAResult
:members:
:undoc-members:
:show-inheritance:

QUANTAXIS.QABacktest.backtest\_setting module
QUANTAXIS.QAApplication.backtest\_setting module
---------------------------------------------

.. automodule:: QUANTAXIS.QABacktest.backtest_setting
.. automodule:: QUANTAXIS.QAApplication.backtest_setting
:members:
:undoc-members:
:show-inheritance:
Expand All @@ -40,7 +40,7 @@ QUANTAXIS.QABacktest.backtest\_setting module
Module contents
---------------

.. automodule:: QUANTAXIS.QABacktest
.. automodule:: QUANTAXIS.QAApplication
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion source/QUANTAXIS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Subpackages

QUANTAXIS.QAARP
QUANTAXIS.QAAnalysis
QUANTAXIS.QABacktest
QUANTAXIS.QAApplication
QUANTAXIS.QACmd
QUANTAXIS.QAData
QUANTAXIS.QAEngine
Expand Down
2 changes: 1 addition & 1 deletion test_backtest/T0backtest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
"\n",
"from QUANTAXIS.QAARP.QARisk import QA_Risk\n",
"from QUANTAXIS.QAARP.QAUser import QA_User\n",
"from QUANTAXIS.QABacktest.QABacktest import QA_Backtest\n",
"from QUANTAXIS.QAApplication.QABacktest import QA_Backtest\n",
"from QUANTAXIS.QAUtil.QALogs import QA_util_log_info\n",
"from QUANTAXIS.QAUtil.QAParameter import FREQUENCE, MARKET_TYPE\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion test_backtest/T0backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def on_bar(self, event):

from QUANTAXIS.QAARP.QARisk import QA_Risk
from QUANTAXIS.QAARP.QAUser import QA_User
from QUANTAXIS.QABacktest.QABacktest import QA_Backtest
from QUANTAXIS.QAApplication.QABacktest import QA_Backtest
from QUANTAXIS.QAUtil.QALogs import QA_util_log_info
from QUANTAXIS.QAUtil.QAParameter import FREQUENCE, MARKET_TYPE

Expand Down
2 changes: 1 addition & 1 deletion test_backtest/backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from QUANTAXIS.QAARP.QARisk import QA_Risk
from QUANTAXIS.QAARP.QAUser import QA_User
from QUANTAXIS.QABacktest.QABacktest import QA_Backtest
from QUANTAXIS.QAApplication.QABacktest import QA_Backtest
from QUANTAXIS.QAUtil.QALogs import QA_util_log_info
from QUANTAXIS.QAUtil.QAParameter import FREQUENCE, MARKET_TYPE
from test_backtest.minstrategy import MAMINStrategy
Expand Down
2 changes: 1 addition & 1 deletion test_backtest/backtest_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from QUANTAXIS.QAARP.QARisk import QA_Risk
from QUANTAXIS.QAARP.QAUser import QA_User
from QUANTAXIS.QABacktest.QABacktest import QA_Backtest
from QUANTAXIS.QAApplication.QABacktest import QA_Backtest
from QUANTAXIS.QAUtil.QALogs import QA_util_log_info
from QUANTAXIS.QAUtil.QAParameter import FREQUENCE, MARKET_TYPE
from test_backtest.minstrategy import MAMINStrategy
Expand Down

0 comments on commit 8bb3aa6

Please sign in to comment.