-
Notifications
You must be signed in to change notification settings - Fork 19
/
boll.py
46 lines (40 loc) · 1.2 KB
/
boll.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# coding:utf-8
# 1000元实盘练习程序
# 日线布林带选股
import pandas as pd
import numpy as np
import akshare as ak
import run
import tools
import efinance as ef
import datetime, quandl
import matplotlib.pyplot as plt
import os
from backtest import BackTest
import backtrader as bt
import talib
# 主程序
@run.change_dir
def main(refresh = False):
month = 12
codes = tools.Research(refresh = refresh, month = month, highPrice = 10.0, lowPrice = 5.0, bSelect = True, drop_days = 60)
n = len(codes)
print(n)
chosecodes = []
i = 0
for code in codes:
print("研究进度:", i/n)
i += 1
data = tools.getStockData(code, month = month, refresh = refresh, adjust = "qfq")
upper,middle,lower=talib.BBANDS(data.收盘.values, timeperiod=20, nbdevup=2, nbdevdn=2, matype=1)
data["upper"] = upper
data["middle"] = middle
data["lower"] = lower
# print(data.info(), data.收盘.values[-1], data.lower.values[-1])
if data.收盘.values[-1] < data.lower.values[-1]:
chosecodes.append(code)
return chosecodes
if __name__ == "__main__":
tools.init()
codes = main(refresh = False)
print(codes)