本文整理汇总了Python中BasicData.getBasicData方法的典型用法代码示例。如果您正苦于以下问题:Python BasicData.getBasicData方法的具体用法?Python BasicData.getBasicData怎么用?Python BasicData.getBasicData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasicData
的用法示例。
在下文中一共展示了BasicData.getBasicData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calcROC
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicData [as 别名]
def calcROC(stock_code, date, period):
pday = bd.getStockDate(stock_code, date, period)
BX = bd.getBasicData("CLOSE_TODAY", stock_code, pday)
close_today = bd.getBasicData("CLOSE_TODAY", stock_code, date)
AX = close_today - BX
ROC = AX / BX * 100
return round(ROC, 3)
示例2: analyze
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicData [as 别名]
def analyze(stock_code, date, period1, period2):
signal = ""
score = 0.0
recent_high_price = bd.getHighPriceInPeriod("CLOSE_TODAY", stock_code, date, period1)
recent_low_price = bd.getLowPriceInPeriod("CLOSE_TODAY", stock_code, date, period1)
close_today = bd.getBasicData("CLOSE_TODAY", stock_code, date)
BBI = getBBI(stock_code, date)
if (abs(close_today - recent_high_price) / recent_high_price <= HIGH_OFFSET / 100) and (BBI > close_today):
score = score - 1
signal = signal + "[-1]股价在高价区以收市价跌破多空线为卖出信号;"
if (abs(close_today - recent_low_price) / recent_low_price <= LOW_OFFSET / 100) and (BBI < close_today):
score = score + 1
signal = signal + "[1]股价在低价区以收市价突破多空线为买入信号;"
BBIs = getBBIs(stock_code, date, period2)
K = mu.getPoly(BBIs, 1)[0]
if (K > 0) and (BBI > close_today):
score += 1
signal += "[1]多空指数由下向上递增,股价在多空线上方,表明多头势强,可以继续持股;"
if (K < 0) and (BBI < close_today):
score -= 1
signal += "[-1]多空指数由上向下递减,股价在多空线下方,表明空头势强,一般不宜买入;"
print score
print signal.decode("utf-8").encode("gbk")
bd.updateAnalysisData("BBI", str(score) + ";" + signal, stock_code, date)
return [score, signal]
示例3: calcOBV
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicData [as 别名]
def calcOBV(stock_code, date, period):
global ITERATOR_COUNT
close_today = bd.getBasicData("CLOSE_TODAY", stock_code, date)
close_pervious_day = bd.getBasicData("CLOSE_PERVIOUS_DAY", stock_code, date)
volumn = bd.getBasicData("VOLUMN", stock_code, date)
today_volumn = 0.0
if close_today > close_pervious_day:
today_volumn = volumn
if close_today < close_pervious_day:
today_volumn = today_volumn*-1
if ITERATOR_COUNT >= MAX_ITERATOR:
return today_volumn
else:
ITERATOR_COUNT = ITERATOR_COUNT + 1
pday = bd.getStockDate(stock_code, date, 1)
OBV = today_volumn + calcOBV(stock_code, pday, period)
return round(OBV, 3)
示例4: calcCCI
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicData [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)
示例5: calcEMA
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicData [as 别名]
def calcEMA(stock_code, date, period):
if ITERATOR_COUNT >= MAX_ITERATOR:
EXPMA = MA.calcMA(stock_code, date, period)
# print "MIN Date: " +date+ " MA:"+ str(EXPMA)
return EXPMA
else:
global ITERATOR_COUNT
ITERATOR_COUNT = ITERATOR_COUNT + 1
close_today = bd.getBasicData("CLOSE_TODAY", stock_code, date)
pday = du.convertDateToString(bd.getStockDate(stock_code, date, 1), "%Y-%m-%d")
EXPMA_pday = calcEMA(stock_code, pday, period)
EXPMA = 2 * (close_today - EXPMA_pday) / (period + 1) + EXPMA_pday
# print date + ": EXPMA: "+str(EXPMA_PDAY)+" CLOSE: " + str(CLOSE_TODAY) + " EXPMA = " +str(EXPMA)
return round(EXPMA, 3)
示例6: calcAverageLoss
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicData [as 别名]
def calcAverageLoss(stock_code, date, period):
global iterator_count
price_changed = bd.getBasicData("PRICE_CHANGED", stock_code, date)
current_loss = 0.0
if price_changed < 0:
current_loss = price_changed
if iterator_count >= max_iterator:
return calcFirstAverageLoss(stock_code, date, period)
else:
iterator_count += 1
average_loss = (calcAverageLoss(stock_code, bd.getStockDate(stock_code, date, 1), period) * (
period - 1) + abs(current_loss)) / period
# print date + " " + str(average_loss) + " Current Loss: " + str(current_loss)
return round(average_loss, 3)
示例7: calcAverageGain
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicData [as 别名]
def calcAverageGain(stock_code, date, period):
global iterator_count
price_changed = bd.getBasicData("PRICE_CHANGED", stock_code, date)
current_gain = 0.0
if price_changed > 0:
current_gain = price_changed
if iterator_count >= max_iterator:
return calcFirstAverageGain(stock_code, date, period)
else:
iterator_count += 1
average_gain = (calcAverageGain(stock_code, bd.getStockDate(stock_code, date, 1), period) * (
period - 1) + abs(current_gain)) / period
# print date + " Average Gain: " + str(average_gain) + " Current Gain: " + str(current_gain)
return round(average_gain, 3)
示例8: calcWR
# 需要导入模块: import BasicData [as 别名]
# 或者: from BasicData import getBasicData [as 别名]
def calcWR(stock_code, date, period):
close_today = bd.getBasicData("CLOSE_TODAY", stock_code, date)
high_today = bd.getHighPriceInPeriod("HIGH_TODAY", stock_code, date, period)
low_today = bd.getLowPriceInPeriod("LOW_TODAY", stock_code, date, period)
WR = 100 - (close_today - low_today) / (high_today - low_today) * 100
return round(WR, 3)