-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #841 from yutiansut/master
update
- Loading branch information
Showing
16 changed files
with
178 additions
and
280 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 |
---|---|---|
@@ -1,35 +1,47 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
# 问题反馈 | ||
|
||
--- | ||
当您安装/使用QUANTAXIS的时候如果遇到任何问题, 您可以在这里提出,我们会在24小时内给您答复 | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
## 您使用的QUANTAXIS版本号是什么? | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
``` | ||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
``` | ||
## 您的系统信息(包括系统版本,系统架构(32/64),内存大小等等) | ||
``` | ||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
**Additional context** | ||
Add any other context about the problem here. | ||
``` | ||
|
||
## 您的系统环境是什么? | ||
``` | ||
- monodb | ||
- nodejs(V9以下版本) | ||
- python3.5/3.6 | ||
- docker(有无) | ||
``` | ||
## 您需要反馈的问题 | ||
``` | ||
``` | ||
## 感谢您的反馈 如有意见和建议,请在此说明: | ||
``` | ||
``` | ||
## 您的联系方式(QQ/EMAIL) | ||
``` | ||
``` | ||
|
||
|
||
THANKS | ||
by yutiansut | ||
2017.12 |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
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,103 @@ | ||
# @Hakase | ||
import QUANTAXIS as QA | ||
import numpy as np | ||
import pandas as pd | ||
import datetime | ||
import sys | ||
import random | ||
|
||
class backtest(): | ||
"""依据回测场景的建模 | ||
""" | ||
|
||
def __init__(self, start_time='2015-01-01', end_time='2018-09-24', init_cash=500000, code='RBL8', frequence=QA.FREQUENCE.FIFTEEN_MIN): | ||
self.start_time = start_time | ||
self.end_time = end_time | ||
self.frequence = frequence | ||
self.code = code | ||
self.init_cach = init_cash | ||
self.time_ = None | ||
self.market_data_ = None | ||
self.res= False | ||
|
||
@property | ||
def position(self): | ||
return self.account.sell_available.get(self.code, 0) | ||
|
||
@property | ||
def time(self): | ||
return self.time_ | ||
|
||
@property | ||
def market_data(self): | ||
return self.market_data_ | ||
# 自定义函数------------------------------------------------------------------- | ||
|
||
@property | ||
def hold_judge(self): | ||
"""仓位判断器 | ||
Returns: | ||
[type] -- [description] | ||
""" | ||
|
||
if self.account.cash/self.account.init_cash < 0.3: | ||
return False | ||
else: | ||
return True | ||
|
||
def before_backtest(self): | ||
raise NotImplementedError | ||
|
||
def before(self, *args, **kwargs): | ||
self.before_backtest() | ||
self.data_min = QA.QA_fetch_future_min_adv( | ||
self.code, self.start_time, self.end_time, frequence=self.frequence) | ||
|
||
self.data_day = QA.QA_fetch_future_day_adv( | ||
self.code, self.start_time, self.end_time) | ||
|
||
self.Broker = QA.QA_BacktestBroker() | ||
|
||
def model(self, *arg, **kwargs): | ||
raise NotImplementedError | ||
|
||
def load_strategy(self, *arg, **kwargs): | ||
# self.load_model(func1) | ||
raise NotImplementedError | ||
|
||
def run(self, *arg, **kwargs): | ||
raise NotImplementedError | ||
|
||
def buy(self, pos, towards): | ||
|
||
self.account.receive_simpledeal(code=self.code, | ||
trade_price=self.market_data.open, trade_amount=pos, | ||
trade_towards=towards, trade_time=self.time, | ||
message=towards) | ||
|
||
def sell(self, pos, towards): | ||
self.account.receive_simpledeal(code=self.code, | ||
trade_price=self.market_data.open, trade_amount=pos, | ||
trade_towards=towards, trade_time=self.time, | ||
message=towards) | ||
|
||
def main(self, *arg, **kwargs): | ||
print(vars(self)) | ||
self.identity_code = '_'.join([str(x) for x in list(kwargs.values())]) | ||
|
||
self.backtest_cookie = 'future_{}_{}'.format( | ||
datetime.datetime.now().time().__str__()[:8], self.identity_code) | ||
self.account = QA.QA_Account(allow_sellopen=True, allow_t0=True, account_cookie=self.backtest_cookie, | ||
market_type=QA.MARKET_TYPE.FUTURE_CN, frequence=self.frequence, init_cash=self.init_cash) | ||
|
||
self.gen = self.data_min.reindex( | ||
self.res) if self.res else self.data_min | ||
|
||
for ind, item in self.gen.iterrows: | ||
self.time_ = ind[0] | ||
self.code = ind[1] | ||
|
||
self.market_data_ = item | ||
self.run() |
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
Oops, something went wrong.