本文整理匯總了Python中mpl_finance.volume_overlay方法的典型用法代碼示例。如果您正苦於以下問題:Python mpl_finance.volume_overlay方法的具體用法?Python mpl_finance.volume_overlay怎麽用?Python mpl_finance.volume_overlay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mpl_finance
的用法示例。
在下文中一共展示了mpl_finance.volume_overlay方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _plotNetCapitalFlow
# 需要導入模塊: import mpl_finance [as 別名]
# 或者: from mpl_finance import volume_overlay [as 別名]
def _plotNetCapitalFlow(self, df, ax, code):
try:
mf = df['mf_amt'].values
close = df['close'].values.copy()
open = df['open'].values.copy()
close[mf>0] = 1; open[mf>0] = 0
close[mf<=0] = 0; open[mf<=0] = 1
volume_overlay(ax, open, close, abs(mf)/10**7, colorup='r', colordown='g', width=.5, alpha=1)
except KeyError:
# !!!剛上市新股的前幾個交易日,有時萬得沒有資金淨流入和成交量淨流入的日線數據
#self._info.print('[{0}: {1}]沒有日線[資金淨流入]數據'.format(code, self._daysEngine.stockAllCodesFunds[code]), DyLogData.warning)
pass
示例2: _plotKamaCandleStick
# 需要導入模塊: import mpl_finance [as 別名]
# 或者: from mpl_finance import volume_overlay [as 別名]
def _plotKamaCandleStick(self, code, periods, left=None, right=None, top=None, bottom=None):
def _dateFormatter(x, pos):
if not (0 <= int(x) < df.shape[0]):
return None
return df.index[int(x)].strftime("%y-%m-%d")
# get DataFrame
df = self._daysEngine.getDataFrame(code)
#maDf = DyStockDataUtility.getKamas(df, [5, 10], False)
maDf = DyStockDataUtility.getDealMas(df, [5, 10, 20, 30, 60], False)
# 數據對齊
df = df.ix[periods]
maDf = maDf.ix[periods]
if df.shape[0] == 0 or maDf.shape[0] == 0:
return
# create grid spec
gs = GridSpec(4, 1)
gs.update(left=left, right=right, top=top, bottom=bottom, hspace=0)
# subplot for price candle stick
axPrice = plt.subplot(gs[:-1, :])
axPrice.set_title('{0}({1}),考夫曼指標'.format(self._daysEngine.stockAllCodesFunds[code], code))
axPrice.grid(True)
# set x ticks
x = [x for x in range(df.shape[0])]
xspace = max((len(x)+9)//10, 1)
axPrice.xaxis.set_major_locator(FixedLocator(x[:-xspace-1: xspace] + x[-1:]))
axPrice.xaxis.set_major_formatter(FuncFormatter(_dateFormatter))
# plot K-chart
candlestick2_ohlc(axPrice, df['open'].values, df['high'].values, df['low'].values, df['close'].values, width=.9, colorup='r', colordown='g', alpha =1)
# plot MAs
for ma in maDf.columns:
axPrice.plot(x, maDf[ma].values, label=ma)
# plot volume
axVolume = plt.subplot(gs[-1, :], sharex=axPrice)
axVolume.grid(True)
volume_overlay(axVolume, df['open'].values, df['close'].values, df['volume'].values/10**6, colorup='r', colordown='g', width=.9, alpha=1)
axPrice.legend(loc='upper left', frameon=False)
示例3: ohlc2cs
# 需要導入模塊: import mpl_finance [as 別名]
# 或者: from mpl_finance import volume_overlay [as 別名]
def ohlc2cs(fname, dimension):
# python preprocess.py -m ohlc2cs -l 20 -i stockdatas/EWT_testing.csv -t testing
print("Converting olhc to candlestick")
inout = fname
df = pd.read_csv(fname, parse_dates=True, index_col=0)
df.fillna(0)
plt.style.use('dark_background')
df.reset_index(inplace=True)
df['Date'] = df['Date'].map(mdates.date2num)
my_dpi = 96
fig = plt.figure(figsize=(dimension / my_dpi,
dimension / my_dpi), dpi=my_dpi)
ax1 = fig.add_subplot(1, 1, 1)
candlestick2_ochl(ax1, df['Open'], df['Close'], df['High'],
df['Low'], width=1,
colorup='#77d879', colordown='#db3f3f')
ax1.grid(False)
ax1.set_xticklabels([])
ax1.set_yticklabels([])
ax1.xaxis.set_visible(False)
ax1.yaxis.set_visible(False)
ax1.axis('off')
# create the second axis for the volume bar-plot
# Add a seconds axis for the volume overlay
ax2 = ax1.twinx()
# Plot the volume overlay
bc = volume_overlay(ax2, df['Open'], df['Close'], df['Volume'],
colorup='#77d879', colordown='#db3f3f', alpha=0.5, width=1)
ax2.add_collection(bc)
ax2.grid(False)
ax2.set_xticklabels([])
ax2.set_yticklabels([])
ax2.xaxis.set_visible(False)
ax2.yaxis.set_visible(False)
ax2.axis('off')
pngfile = "temp_class/{}.png".format(inout)
fig.savefig(pngfile, pad_inches=0, transparent=False)
plt.close(fig)
# normal length - end
params = []
params += ["-alpha", "off"]
subprocess.check_call(["convert", pngfile] + params + [pngfile])
print("Converting olhc to candlestik finished.")
開發者ID:jason887,項目名稱:Using-Deep-Learning-Neural-Networks-and-Candlestick-Chart-Representation-to-Predict-Stock-Market,代碼行數:47,代碼來源:predictme.py
示例4: ohlc2cs
# 需要導入模塊: import mpl_finance [as 別名]
# 或者: from mpl_finance import volume_overlay [as 別名]
def ohlc2cs(fname, seq_len, dataset_type, dimension):
print("Converting olhc to candlestick")
symbol = fname.split('_')[0]
symbol = symbol.split('/')[1]
print(symbol)
path = "{}".format(os.getcwd())
# print(path)
if not os.path.exists("{}/dataset/{}_{}/{}/{}".format(path, seq_len, dimension, symbol, dataset_type)):
os.makedirs("{}/dataset/{}_{}/{}/{}".format(path,
seq_len, dimension, symbol, dataset_type))
df = pd.read_csv(fname, parse_dates=True, index_col=0)
df.fillna(0)
plt.style.use('dark_background')
df.reset_index(inplace=True)
df['Date'] = df['Date'].map(mdates.date2num)
for i in range(0, len(df)):
# normal length - begin
# candlestick ohlc normal
c = df.ix[i:i + int(seq_len) - 1, :]
# ohlc+volume
useVolume = True
if len(c) == int(seq_len):
my_dpi = 96
fig = plt.figure(figsize=(dimension / my_dpi,
dimension / my_dpi), dpi=my_dpi)
ax1 = fig.add_subplot(1, 1, 1)
candlestick2_ochl(ax1, c['Open'], c['Close'], c['High'],
c['Low'], width=1,
colorup='#77d879', colordown='#db3f3f')
ax1.grid(False)
ax1.set_xticklabels([])
ax1.set_yticklabels([])
ax1.xaxis.set_visible(False)
ax1.yaxis.set_visible(False)
ax1.axis('off')
# create the second axis for the volume bar-plot
# Add a seconds axis for the volume overlay
if useVolume:
ax2 = ax1.twinx()
# Plot the volume overlay
bc = volume_overlay(ax2, c['Open'], c['Close'], c['Volume'],
colorup='#77d879', colordown='#db3f3f', alpha=0.5, width=1)
ax2.add_collection(bc)
ax2.grid(False)
ax2.set_xticklabels([])
ax2.set_yticklabels([])
ax2.xaxis.set_visible(False)
ax2.yaxis.set_visible(False)
ax2.axis('off')
pngfile = 'dataset/{}_{}/{}/{}/{}-{}_combination.png'.format(
seq_len, dimension, symbol, dataset_type, fname[11:-4], i)
fig.savefig(pngfile, pad_inches=0, transparent=False)
plt.close(fig)
print("Converting olhc to candlestik finished.")
開發者ID:jason887,項目名稱:Using-Deep-Learning-Neural-Networks-and-Candlestick-Chart-Representation-to-Predict-Stock-Market,代碼行數:59,代碼來源:preproccess_binclass.py
示例5: ohlc2cs
# 需要導入模塊: import mpl_finance [as 別名]
# 或者: from mpl_finance import volume_overlay [as 別名]
def ohlc2cs(fname, seq_len, dataset_type, dimension, use_volume):
# python preprocess.py -m ohlc2cs -l 20 -i stockdatas/EWT_testing.csv -t testing
print("Converting olhc to candlestick")
symbol = fname.split('_')[0]
symbol = symbol.split('/')[1]
print(symbol)
path = "{}".format(os.getcwd())
# print(path)
if not os.path.exists("{}/dataset/{}_{}/{}/{}".format(path, seq_len, dimension, symbol, dataset_type)):
os.makedirs("{}/dataset/{}_{}/{}/{}".format(path,
seq_len, dimension, symbol, dataset_type))
df = pd.read_csv(fname, parse_dates=True, index_col=0)
df.fillna(0)
plt.style.use('dark_background')
df.reset_index(inplace=True)
df['Date'] = df['Date'].map(mdates.date2num)
for i in range(0, len(df)):
# ohlc+volume
c = df.ix[i:i + int(seq_len) - 1, :]
if len(c) == int(seq_len):
my_dpi = 96
fig = plt.figure(figsize=(dimension / my_dpi,
dimension / my_dpi), dpi=my_dpi)
ax1 = fig.add_subplot(1, 1, 1)
candlestick2_ochl(ax1, c['Open'], c['Close'], c['High'],
c['Low'], width=1,
colorup='#77d879', colordown='#db3f3f')
ax1.grid(False)
ax1.set_xticklabels([])
ax1.set_yticklabels([])
ax1.xaxis.set_visible(False)
ax1.yaxis.set_visible(False)
ax1.axis('off')
# create the second axis for the volume bar-plot
# Add a seconds axis for the volume overlay
if use_volume:
ax2 = ax1.twinx()
# Plot the volume overlay
bc = volume_overlay(ax2, c['Open'], c['Close'], c['Volume'],
colorup='#77d879', colordown='#db3f3f', alpha=0.5, width=1)
ax2.add_collection(bc)
ax2.grid(False)
ax2.set_xticklabels([])
ax2.set_yticklabels([])
ax2.xaxis.set_visible(False)
ax2.yaxis.set_visible(False)
ax2.axis('off')
pngfile = 'dataset/{}_{}/{}/{}/{}-{}.png'.format(
seq_len, dimension, symbol, dataset_type, fname[11:-4], i)
fig.savefig(pngfile, pad_inches=0, transparent=False)
plt.close(fig)
# normal length - end
print("Converting olhc to candlestik finished.")
開發者ID:rosdyana,項目名稱:Going-Deeper-with-Convolutional-Neural-Network-for-Stock-Market-Prediction,代碼行數:58,代碼來源:preproccess_binclass.py