本文整理汇总了Python中BasicData.getBasicDataInPeriod方法的典型用法代码示例。如果您正苦于以下问题:Python BasicData.getBasicDataInPeriod方法的具体用法?Python BasicData.getBasicDataInPeriod怎么用?Python BasicData.getBasicDataInPeriod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasicData
的用法示例。
在下文中一共展示了BasicData.getBasicDataInPeriod方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: analyze
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicDataInPeriod [as 别名]
def analyze(stock_code, date, period):
score = 0.0
signal = ""
RSI = getRSI(stock_code, date)
if 90 > RSI > 80:
score -= 1
signal += "[-1]当六日指标上升到达80时,表示股市已有超买现象;"
if RSI > 90:
score -= -1
signal += "[-1]超过90以上时,则表示已到严重超买的警戒区,股价已形成头部,极可能在短期内反转回转;"
if 10 < RSI < 20:
score += 1
signal += "[1]六日强弱指标下降至20时,表示股市有超卖现象;"
if RSI < 10:
score += 1
signal += "[1]一旦继续下降至10以下时则表示已到严重超卖区域,股价极可能有止跌回升的机会;"
close_in_period = bd.getBasicDataInPeriod("CLOSE_TODAY", stock_code, date, period)
RSI_in_period = bd.getTechDataInPeriod("CCI", stock_code, date, period)
close_k = mu.getPoly(close_in_period, 1)[0]
RSI_k = mu.getPoly(RSI_in_period, 1)[0]
if close_k > 0 and RSI_k < 0:
signal += "强弱指标下降而股价反趋上涨,产生的背离现象;"
if close_k < 0 and RSI_k > 0:
signal += "强弱指标上升而股价反而下跌, 产生的背离现象;"
print score
print signal.decode("utf-8").encode("gbk")
bd.updateAnalysisData("RSI", str(score) + ";" + signal, stock_code, date)
return [score, signal]
示例2: calcPSY
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicDataInPeriod [as 别名]
def calcPSY(stock_code, date, period):
result_set = bd.getBasicDataInPeriod("CLOSE_TODAY, CLOSE_PERVIOUS_DAY", stock_code, date, period)
count = 0.0
for each in result_set:
if each[0] > each[1]:
count += 1
PSY = count / period * 100
return round(PSY, 3)
示例3: calcFirstAverageLoss
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicDataInPeriod [as 别名]
def calcFirstAverageLoss(stock_code, date, period):
price_changes_in_period = bd.getBasicDataInPeriod("PRICE_CHANGED", stock_code, date, period)
first_average_loss = 0.0
for each in price_changes_in_period:
if first_average_loss < 0:
first_average_loss += each[0]
first_average_loss = abs(first_average_loss) / period
print "First Average Loss: " + str(first_average_loss)
return round(first_average_loss, 3)
示例4: calcFirstAverageGain
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicDataInPeriod [as 别名]
def calcFirstAverageGain(stock_code, date, period):
price_changes_in_period = bd.getBasicDataInPeriod("PRICE_CHANGED", stock_code, date, period)
first_average_gain = 0.0
for each in price_changes_in_period:
if first_average_gain > 0:
first_average_gain += each[0]
first_average_gain = first_average_gain / period
print "First Average Gain: " + str(first_average_gain)
return round(first_average_gain, 3)
示例5: calcVR
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicDataInPeriod [as 别名]
def calcVR(stock_code, date, period):
result_set = bd.getBasicDataInPeriod("CLOSE_TODAY, CLOSE_PERVIOUS_DAY, VOLUMN", stock_code, date, period)
rise_volumn = 0.0
decline_volumn = 0.0
for each in result_set:
if each[0] > each[1]:
rise_volumn += each[2]
else:
decline_volumn += each[2]
VR = rise_volumn / decline_volumn * 100
return round(VR, 3)
示例6: calcBRAR
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicDataInPeriod [as 别名]
def calcBRAR(stock_code, date, period):
result_set = bd.getBasicDataInPeriod(
"HIGH_TODAY, OPEN_TODAY, LOW_TODAY, CLOSE_PERVIOUS_DAY", stock_code, date, period
)
AR_Nn = AR_Dn = BR_Nn = BR_Dn = 0.0
for each in result_set:
AR_Nn = AR_Nn + each[0] - each[1]
AR_Dn = AR_Dn + each[1] - each[2]
if each[0] > each[3]:
BR_Nn = BR_Nn + each[0] - each[3]
if each[3] > each[2]:
BR_Dn = BR_Dn + each[3] - each[2]
AR = round(AR_Nn / AR_Dn * 100, 3)
BR = round(BR_Nn / BR_Dn * 100, 3)
return [BR, AR]
示例7: calcCCI
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicDataInPeriod [as 别名]
def calcCCI(stock_code, date, period):
high_today = bd.getBasicData("HIGH_TODAY", stock_code, date)
low_today = bd.getBasicData("LOW_TODAY", stock_code, date)
close_today = bd.getBasicData("CLOSE_TODAY", stock_code, date)
MAn = 0.0
price_in_period = bd.getBasicDataInPeriod("CLOSE_TODAY, HIGH_TODAY, LOW_TODAY", stock_code, date, period)
for each in price_in_period:
MAn += (each[0] + each[1] + each[2])/3
MAn = MAn / period
MD = 0.0
TP = (high_today + low_today + close_today) / 3
for each in price_in_period:
MD += abs(MAn - (each[0] + each[1] + each[2])/3)
MD = MD / period
CCI = (TP - MAn) / MD / 0.015
return round(CCI, 3)
示例8: analyze
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicDataInPeriod [as 别名]
def analyze(stock_code, date, period):
score = 0
signal = ""
OBVs = bd.getTechDataInPeriod("OBV", stock_code, date, period)
close_in_period = bd.getBasicDataInPeriod("CLOSE_TODAY", stock_code, date, period)
OBV_K = mu.getPoly(OBVs, 1)[0]
CLOSE_K = mu.getPoly(close_in_period, 1)[0]
# 1.OBV线下降,而此时股价上升,是卖出股票的信号。
if OBV_K < 0 and CLOSE_K > 0:
score -= 1
signal += "[-1]OBV线下降,而此时股价上升,是卖出股票的信号;"
# 2.OBV线上升,而此时股价下跌,是买进股票的信号。
if OBV_K > 0 and CLOSE_K < 0:
score += 1
signal += "[1]OBV线上升,而此时股价下跌,是买进股票的信号;"
# 3.OBV线从正的累积数转为负数时,为下跌趋势,应该卖出持有股票;反之,OBV线从负的累积数转为正数,应该买进股票。
OBV_today = OBVs[0]
OBV_pday = OBVs[1]
if OBV_today > 0 and OBV_pday < 0:
score += 1
signal += "[1]OBV线从负的累积数转为正数,应该买进股票;"
if OBV_today < 0 and OBV_pday > 0:
score -= 1
signal += "[-1]OBV线从正的累积数转为负数时,为下跌趋势,应该卖出持有股票;"
# 4.OBV线呈缓慢上升时,为买进信号,但是若OBV线急速上升,隐含着能量不可能长久维持大成交量,非但不是买进信号,尚是卖出时机。
if OBV_K > 0:
if OBV_K > UP_RATIO_THREHOLD:
score -= 1
signal += "[-1]若OBV线急速上升,隐含着能量不可能长久维持大成交量,非但不是买进信号,尚是卖出时机;"
else:
score += 1
signal += "[1]OBV线呈缓慢上升时,为买进信号;"
print score
print signal.decode("utf-8").encode("gbk")
bd.updateAnalysisData("OBV", str(score) + ";" + signal, stock_code, date)
return [score, signal]
示例9: analyze
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicDataInPeriod [as 别名]
def analyze(stock_code, date, period):
score = 0.0
signal = ""
DMA = getDMA(stock_code, date)
AMA = getAMA(stock_code, date)
DMAs = getDMAs(stock_code, date, period)
AMAs = getAMAs(stock_code, date, period)
DMA_K1 = mu.getPoly(DMAs, 1)[0]
AMA_K1 = mu.getPoly(AMAs, 1)[0]
DMA_K2 = mu.getPoly(DMAs, 2)[0]
AMA_K2 = mu.getPoly(AMAs, 2)[0]
#1. DMA和AMA的值及线的运动方向
if AMA > 0 and DMA > 0 and AMA_K1 > 0 and DMA_K1 > 0:
score += 1
signal += "[1]当DMA和AMA均大于0,并向上移动时,一般表示为股市处于多头行情中,可以买入或持股;"
if AMA < 0 and DMA < 0 and AMA_K1 < 0 and DMA_K1 < 0:
score -= 1
signal += "[-1]当DMA和AMA均小于0, 并向下移动时,一般表示为股市处于空头行情中,可以卖出股票或观望;"
if AMA > 0 and DMA > 0 and AMA_K2 > 0 and DMA_K2 > 0:
score -= 1
signal += "[-1]当DMA和AMA均大于0,但在经过一段比较长时间的向上运动后,如果两者同时从高位向下移动时,一般表示为股票行情处于退潮阶段,股票将下跌,可以卖出股票和观望;"
if AMA < 0 and DMA < 0 and AMA_K1 < 0 and DMA_K1 < 0:
score += 1
signal += "[1]当DMA和AMA均小于0时,但在经过一段比较长时间的的向下运动后,如果两者同时从低位向上移动时,一般表示为短期行情即将启动,股票将上涨,可以短期买进股票或持股待涨;"
close_in_period = bd.getBasicDataInPeriod("CLOSE_TODAY",stock_code, date, period)
volumn_in_period = bd.getBasicDataInPeriod("VOLUMN", stock_code, date, period)
close_K1 = mu.getPoly(close_in_period, 1)[0]
volumn_K1 = mu.getPoly(volumn_in_period, 1)[0]
#2. DMA曲线和股价曲线的配合使用
if AMA < 0 and DMA < 0 and AMA_K1 > 0 and DMA_K1 > 0 and close_in_period > 0:
score += 1
signal += "[1]当DMA曲线与股价曲线从低位同步上升,表明空头力量已经衰弱、多头力量开始积聚,短期内股价有望止跌企稳,投资者应可以开始少量逢低买入;"
if -1 <= AMA <= 1 and -1 <= DMA <= 1 and AMA_K1 > 0 and DMA_K1 > 0 and volumn_K1 > 0:
score += 1
signal += "[1]当DMA曲线与股价曲线从0值附近向上攀升时,表明多头力量开始大于空头力量,股价将在成交量的配合下,走出一波向上扬升的上涨行情。此时,投资者应逢低买入或坚决持股待涨;"
pday = bd.getStockDate(stock_code, date, 1)
DMA_pday = getDMA(stock_code, pday)
AMA_pday = getAMA(stock_code, pday)
#3. DMA线和AMA线的几次交叉情况
if close_K1 < 0 and DMA_pday < AMA_pday and DMA > AMA:
score += 1
signal += "[1]当股价经过一段很长时间的下跌行情后,DMA线开始向上突破AMA线时,表明股市即将转强,股价跌势已经结束,将止跌朝上,可以开始买进股票,进行中长线建仓;"
if close_K1 > 0 and DMA_pday > AMA_pday and DMA < AMA:
score -= 1
signal += "[-1]当股价经过前期一段很长时间的上升行情后,股价涨幅已经很大的情况下,一旦DMA线向下突破AMA时,表明股市即将由强势转为弱势,股价将大跌,这时应卖出大部分股票而不能买股票;"
print DMA
print DMA_pday
print AMA
print AMA_pday
print score
print signal.decode("utf-8").encode("gbk")
bd.updateAnalysisData("DMA", str(score) + ";" + signal, stock_code, date)
return [score, signal]