基本上完成了高低点的识别
This commit is contained in:
+2
-1
@@ -42,7 +42,7 @@ class ChanKLC():
|
|||||||
self.strength = klu.strength
|
self.strength = klu.strength
|
||||||
self.last_top_klc = None
|
self.last_top_klc = None
|
||||||
self.last_bottom_klc = None
|
self.last_bottom_klc = None
|
||||||
self.bb_out = False
|
self.bb_out = True
|
||||||
self.macd = 0
|
self.macd = 0
|
||||||
self.signal = 0
|
self.signal = 0
|
||||||
self.state = Chan_MACD_STATE.UNKNOWN
|
self.state = Chan_MACD_STATE.UNKNOWN
|
||||||
@@ -69,6 +69,7 @@ class ChanKLC():
|
|||||||
if self.pre:
|
if self.pre:
|
||||||
self.pre.cal_bb_out()
|
self.pre.cal_bb_out()
|
||||||
def cal_bb_out(self):
|
def cal_bb_out(self):
|
||||||
|
return
|
||||||
for klu in self.klus:
|
for klu in self.klus:
|
||||||
if klu.macd_state != Chan_MACD_STATE.UNKNOWN:
|
if klu.macd_state != Chan_MACD_STATE.UNKNOWN:
|
||||||
self.state = klu.macd_state
|
self.state = klu.macd_state
|
||||||
|
|||||||
+27
-64
@@ -20,6 +20,7 @@ import numpy as np
|
|||||||
from ChanMACD import ChanMACD
|
from ChanMACD import ChanMACD
|
||||||
|
|
||||||
class ChanLun():
|
class ChanLun():
|
||||||
|
time1 = 1
|
||||||
time3 = 3
|
time3 = 3
|
||||||
time5 = 5
|
time5 = 5
|
||||||
time15 = 15
|
time15 = 15
|
||||||
@@ -38,79 +39,40 @@ class ChanLun():
|
|||||||
df = resample_to_interval(dataframe, ticker_indicator*self.times[timeframe])
|
df = resample_to_interval(dataframe, ticker_indicator*self.times[timeframe])
|
||||||
all_data[timeframe] = df
|
all_data[timeframe] = df
|
||||||
return all_data
|
return all_data
|
||||||
def print_zs(self, zs_list):
|
def calculate_bsp(self, dataframe, ticker_indicator):
|
||||||
for zs in zs_list:
|
klu1, klc1, bi1 = self.get_list_by_time(dataframe, self.time1)
|
||||||
if zs.end_klc:
|
klu3, klc3, bi3 = self.get_list_by_time(dataframe, self.time3)
|
||||||
print(zs.start_klc.start_time, zs.end_klc.end_time, zs.sure_time, zs.zg, zs.zd, zs.bi_out_count)
|
klu5, klc5, bi5 = self.get_list_by_time(dataframe, self.time5)
|
||||||
else:
|
klu15, klc15, bi15 = self.get_list_by_time(dataframe, self.time15)
|
||||||
print(zs.start_klc.start_time, zs.zg, zs.zd, zs.bi_out_count)
|
|
||||||
def print_seg(self, seg_list):
|
return dataframe
|
||||||
for seg in seg_list:
|
def get_list_by_time(self, dataframe, ticker_indicator, time):
|
||||||
if seg.is_sure:
|
df = None
|
||||||
print(seg.start_bi.start_time, seg.end_bi.end_time, seg.dir, seg.sure_time, "SEG")
|
if time > 1:
|
||||||
else:
|
df = resample_to_interval(dataframe, ticker_indicator)
|
||||||
print(seg.start_bi.start_time, seg.dir, "SEG")
|
else:
|
||||||
def print_bsp_list(self, bsp_list):
|
df = dataframe
|
||||||
for bsp in bsp_list:
|
klu_list = self.get_klu_list(df)
|
||||||
if bsp.is_sure:
|
klc_list = self.get_klc_list(klc_list)
|
||||||
print(bsp.klc.start_time, bsp.type, bsp.dir, bsp.sure_time, bsp.zs_count, len(bsp.zs.bi_out_list), bsp.dir, bsp.seg.dir, bsp.bi.dir)
|
bi_list = self.cal_bi_list(klc_list)
|
||||||
else:
|
return klu_list, klc_list, bi_list
|
||||||
print(bsp.klc.start_time, bsp.type, bsp.dir, bsp.zs_count, len(bsp.zs.bi_out_list), bsp.dir, bsp.seg.dir, bsp.bi.dir)
|
|
||||||
def print_bi(self, bi_list):
|
|
||||||
for bi in bi_list:
|
|
||||||
if bi.end_klc:
|
|
||||||
if bi.sure_time:
|
|
||||||
print(bi.start_klc.end_time, bi.end_klc.end_time, bi.dir)
|
|
||||||
else:
|
|
||||||
print(bi.start_klc.end_time, bi.end_klc.end_time, bi.dir)
|
|
||||||
else:
|
|
||||||
print(bi.start_klc.end_time, bi.dir, bi.is_sure)
|
|
||||||
def check_fx(self, klc):
|
def check_fx(self, klc):
|
||||||
if klc.pre and klc.next:
|
if klc.pre and klc.next:
|
||||||
if klc.high > klc.pre.high and klc.high > klc.next.high:
|
if klc.high > klc.pre.high and klc.high > klc.next.high:
|
||||||
if klc.pre.pre and klc.high > klc.pre.pre.high and klc.next.next and klc.high > klc.next.next.high:
|
if klc.pre.pre and klc.high > klc.pre.pre.high and klc.next.next and klc.high > klc.next.next.high:
|
||||||
klc.set_fx(Chan_FX_TYPE.TOP)
|
|
||||||
if klc.pre.pre.pre and klc.high > klc.pre.pre.pre.high and klc.next.next.next and klc.high > klc.next.next.next.high:
|
if klc.pre.pre.pre and klc.high > klc.pre.pre.pre.high and klc.next.next.next and klc.high > klc.next.next.next.high:
|
||||||
klc.set_fx(Chan_FX_TYPE.TOP)
|
if klc.macd > 0 and klc.macd > klc.signal and klc.signal > klc.macdhist:
|
||||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "TOP")
|
klc.set_fx(Chan_FX_TYPE.TOP)
|
||||||
return Chan_FX_TYPE.TOP
|
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "TOP")
|
||||||
|
return Chan_FX_TYPE.TOP
|
||||||
elif klc.low < klc.pre.low and klc.low < klc.next.low:
|
elif klc.low < klc.pre.low and klc.low < klc.next.low:
|
||||||
if klc.pre.pre and klc.low < klc.pre.pre.low and klc.next.next and klc.low < klc.next.next.low:
|
if klc.pre.pre and klc.low < klc.pre.pre.low and klc.next.next and klc.low < klc.next.next.low:
|
||||||
klc.set_fx(Chan_FX_TYPE.BOTTOM)
|
|
||||||
if klc.pre.pre.pre and klc.low < klc.pre.pre.pre.low and klc.next.next.next and klc.low < klc.next.next.next.low:
|
if klc.pre.pre.pre and klc.low < klc.pre.pre.pre.low and klc.next.next.next and klc.low < klc.next.next.next.low:
|
||||||
klc.set_fx(Chan_FX_TYPE.BOTTOM)
|
if klc.macd < 0 and klc.macd < klc.signal and klc.signal < klc.macdhist:
|
||||||
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "BOTTOM")
|
klc.set_fx(Chan_FX_TYPE.BOTTOM)
|
||||||
return Chan_FX_TYPE.BOTTOM
|
#print(klc.start_time, klc.end_time,klc.next.start_time, klc.next.end_time,klc.fx, "BOTTOM")
|
||||||
|
return Chan_FX_TYPE.BOTTOM
|
||||||
return Chan_FX_TYPE.UNKNOWN
|
return Chan_FX_TYPE.UNKNOWN
|
||||||
def plot_dataframe(self, dataframe):
|
|
||||||
klc_list = self.get_klc_list(dataframe)
|
|
||||||
bi_list= self.cal_bi_list(klc_list)
|
|
||||||
def get_klu_state_list(self, dataframe):
|
|
||||||
dataframe3 = resample_to_interval(dataframe, self.time3)
|
|
||||||
dataframe5 = resample_to_interval(dataframe, self.time5)
|
|
||||||
dataframe15 = resample_to_interval(dataframe, self.time15)
|
|
||||||
dataframe30 = resample_to_interval(dataframe, self.time30)
|
|
||||||
dataframe60 = resample_to_interval(dataframe, self.time60)
|
|
||||||
dataframe2h = resample_to_interval(dataframe, self.time2h)
|
|
||||||
dataframe6h = resample_to_interval(dataframe, self.time6h)
|
|
||||||
dataframe8h = resample_to_interval(dataframe, self.time8h)
|
|
||||||
dataframe12h = resample_to_interval(dataframe, self.time12h)
|
|
||||||
dataframe4h = resample_to_interval(dataframe, self.time4h)
|
|
||||||
dataframe1d = resample_to_interval(dataframe, self.time1d)
|
|
||||||
dataframe = self.add_indicators(dataframe)
|
|
||||||
dataframe3 = self.add_indicators(dataframe3)
|
|
||||||
dataframe5 = self.add_indicators(dataframe5)
|
|
||||||
dataframe15 = self.add_indicators(dataframe15)
|
|
||||||
dataframe30 = self.add_indicators(dataframe30)
|
|
||||||
dataframe60 = self.add_indicators(dataframe60)
|
|
||||||
dataframe2h = self.add_indicators(dataframe2h)
|
|
||||||
dataframe6h = self.add_indicators(dataframe6h)
|
|
||||||
dataframe8h = self.add_indicators(dataframe8h)
|
|
||||||
dataframe12h = self.add_indicators(dataframe12h)
|
|
||||||
dataframe4h = self.add_indicators(dataframe4h)
|
|
||||||
dataframe1d = self.add_indicators(dataframe1d)
|
|
||||||
|
|
||||||
return state_list
|
|
||||||
def add_indicators(self, df):
|
def add_indicators(self, df):
|
||||||
fast = 12
|
fast = 12
|
||||||
slow = 26
|
slow = 26
|
||||||
@@ -660,6 +622,7 @@ class ChanLun():
|
|||||||
|
|
||||||
# Do nothing
|
# Do nothing
|
||||||
if fx == Chan_FX_TYPE.UNKNOWN:
|
if fx == Chan_FX_TYPE.UNKNOWN:
|
||||||
|
continue
|
||||||
if len(bi_list) > 0 and klc.end_klu:
|
if len(bi_list) > 0 and klc.end_klu:
|
||||||
last_bi = bi_list[-1]
|
last_bi = bi_list[-1]
|
||||||
#print(klc.start_time, last_bi.start_time, last_bi.end_time, last_bi.dir, last_bi.high, last_bi.low, last_bottom.end_time, "last bi")
|
#print(klc.start_time, last_bi.start_time, last_bi.end_time, last_bi.dir, last_bi.high, last_bi.low, last_bottom.end_time, "last bi")
|
||||||
|
|||||||
+3
-3
@@ -257,9 +257,9 @@ def get_a_stock_kl_data(symbol, timeframe, limit=1000, start_time=None, end_time
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def add_indicators(df):
|
def add_indicators(df):
|
||||||
fast = 12
|
fast = 12*1
|
||||||
slow = 26
|
slow = 26*1
|
||||||
period = 9
|
period = 9*1
|
||||||
macd = ta.MACD(df, fastperiod=fast, slowperiod=slow, signalperiod=period)
|
macd = ta.MACD(df, fastperiod=fast, slowperiod=slow, signalperiod=period)
|
||||||
|
|
||||||
df['macd'] = macd['macd']
|
df['macd'] = macd['macd']
|
||||||
|
|||||||
@@ -2411,11 +2411,15 @@
|
|||||||
signalLineSeries: null,
|
signalLineSeries: null,
|
||||||
histogramSeries: null,
|
histogramSeries: null,
|
||||||
mainBiSeries: [],
|
mainBiSeries: [],
|
||||||
|
mainUncompletedBiSeries: [],
|
||||||
mainSegSeries: [],
|
mainSegSeries: [],
|
||||||
|
mainUncompletedSegSeries: [],
|
||||||
mainZsSeries: [],
|
mainZsSeries: [],
|
||||||
mainUncompletedZsSeries: [],
|
mainUncompletedZsSeries: [],
|
||||||
elementBiSeries: [],
|
elementBiSeries: [],
|
||||||
|
elementUncompletedBiSeries: [],
|
||||||
elementSegSeries: [],
|
elementSegSeries: [],
|
||||||
|
elementUncompletedSegSeries: [],
|
||||||
elementZsSeries: [],
|
elementZsSeries: [],
|
||||||
elementUncompletedZsSeries: [],
|
elementUncompletedZsSeries: [],
|
||||||
tradePointSeries: [],
|
tradePointSeries: [],
|
||||||
@@ -5331,7 +5335,7 @@
|
|||||||
if (fx.fx_strength < 1.0){ // 调整小周期阈值
|
if (fx.fx_strength < 1.0){ // 调整小周期阈值
|
||||||
displayText = fx.fx_strength >= 0.6 ? '' : '' // 0.6以上显示点
|
displayText = fx.fx_strength >= 0.6 ? '' : '' // 0.6以上显示点
|
||||||
}
|
}
|
||||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", "");
|
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", "");
|
||||||
// 小周期分型标记配置
|
// 小周期分型标记配置
|
||||||
const markerConfig = {
|
const markerConfig = {
|
||||||
time: timestamp,
|
time: timestamp,
|
||||||
@@ -5387,7 +5391,7 @@
|
|||||||
if (fx.fx_strength < 2.0){ // 调整小周期阈值
|
if (fx.fx_strength < 2.0){ // 调整小周期阈值
|
||||||
displayText = fx.fx_strength >= 1.5 ? '' : '' // 0.6以上显示点
|
displayText = fx.fx_strength >= 1.5 ? '' : '' // 0.6以上显示点
|
||||||
}
|
}
|
||||||
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("1", "").replace("2", "").replace("3", "").replace("41", "").replace("51", "");
|
displayText = fx.fx_type.replace("TOP", "").replace("BOTTOM", "").replace("11", "").replace("21", "").replace("31", "").replace("41", "").replace("51", "");
|
||||||
// 小周期KLU分型标记配置
|
// 小周期KLU分型标记配置
|
||||||
const markerConfig = {
|
const markerConfig = {
|
||||||
time: timestamp,
|
time: timestamp,
|
||||||
|
|||||||
Reference in New Issue
Block a user