一个python包,用于从coinmarketcap获取加密货币的历史市场数据,并计算和绘制不同的指标。
PriceIndices的Python项目详细描述
安装
PIP
pip install PriceIndics
从源(github)
git克隆https://github.com/dc-aichara/Price-Indices.git
CD价格指数
python3 setup.py安装
用法
fromPriceIndicesimportMarketHistory,Indices
示例
获取市场历史和收盘价
>>>history=MarketHistory()# Get Market History >>>df_history=history.get_history('bitcoin','20130428','20190624')>>>df_history.head()DateOpen*HighLowClose**VolumeMarketCap02019-06-2310696.6911246.1410556.1010855.372099832650219297009035512019-06-2210175.9211157.3510107.0410701.692999520486119021412482422019-06-219525.0710144.569525.0710144.562062400864318029324152832019-06-209273.069594.429232.489527.161784682378416930478479142019-06-199078.739299.629070.409273.5215546809946164780855869# Get closing price>>>price_data=history.get_price('bitcoin','20130428','20190624')>>>price_data.head()dateprice02019-06-2310855.3712019-06-2210701.6922019-06-2110144.5632019-06-209527.1642019-06-199273.52
计算波动率指数
>>>df_bvol=Indices.get_bvol_index(price_data)>>>df_bvol.head()datepriceBVOL_Index02019-06-2210701.690.63648212019-06-2110144.560.63641422019-06-209527.160.61988632019-06-199273.520.60840342019-06-189081.760.604174
绘制波动率指数
>>>Indices.get_bvol_graph(df_bvol)"""This will return a plot of BVOL index against time also save volatility index plot in your working directory as 'bvol_index.png'"""
计算相对强度指数(rsi)
>>>df_rsi=Indices.get_rsi(price_data)>>>print(df_rsi.tail())datepriceprice_changegainlossgain_averageloss_averageRSRSI_1RS_SmoothRSI_222172013-05-02105.217.467.460.001.5321432.5000000.61285737.9982290.56111735.94330622182013-05-01116.9911.7811.780.002.3735712.1757141.09093952.1745960.97531949.37525722192013-04-30139.0022.0122.010.003.9457141.9814291.99134866.5702581.86911065.14598122202013-04-29144.545.545.540.003.8785711.9814291.95746266.1872262.20642268.81259222212013-04-28134.21-10.330.0010.333.8785712.5064291.54744960.7450501.39715858.283931
绘制rsi
>>>Indices.get_rsi_graph(df_rsi)"""This will return a plot of RSI against time and also save RSI plot in your working directory as 'rsi.png'"""
获取bollinger谱带及其绘图
>>>df_bb=Indices.get_bollinger_bands(price_data,20)>>>df_bb.tail()datepriceSMASDpluseminus22432013-05-02105.21115.23456.339257127.913013-115.234522442013-05-01116.99114.94006.097587127.135174-114.940022452013-04-30139.00115.79008.016499131.822998-115.790022462013-04-29144.54116.917510.217936137.353372-116.917522472013-04-28134.21117.453010.842616139.138233-117.4530"""This will also save Bollingers bands plot in your working directory as 'bollinger_bands.png'"""
得到移动平均收敛散度(macd)及其图
>>>df_macd=Indices.get_moving_average_convergence_divergence(price_data)"""This will return a pandas DataFrame and save EMA plot as 'macd.png' in working directory. """">>>df_macd.head()datepriceEMA_12EMA_26MACD192019-06-189081.7610415.97934010886.327599-470.348259202019-06-179320.3510247.42098010770.329259-522.908279212019-06-168994.4910054.66236810638.785610-584.123242222019-06-158838.389867.54200410505.422231-637.880228232019-06-148693.839686.97092610371.230214-684.259288
获得简单移动平均值(SMA)及其曲线图
>>>df_sma=Indices.get_simple_moving_average(price_data,20)"""This will return a pandas DataFrame and save EMA plot as 'sma.png' in working directory. """">>>df_sma.head()datepriceSMA192019-06-189081.7610998.4180202019-06-179320.3510891.8930212019-06-168994.4910781.1900222019-06-158838.3810674.1860232019-06-148693.8310548.1055
得到指数移动平均值(ema)及其曲线
>>>df_ema=Indices.get_exponential_moving_average(price_data,[20,70])"""This will return a pandas DataFrame and save EMA plot as 'ema.png' in working directory. """">>>df_ema.head()datepriceEMA_20EMA_7002019-07-0711450.8511450.85000011450.85000012019-07-0611208.5511427.77381011444.02464822019-07-0510978.4611384.98201811430.91015132019-07-0411215.4411368.83515911424.84056942019-07-0311961.2711425.25752511439.951257
许可证
查看这个价格指数包的webpage。
免责声明:
All content provided here, is for educational purpose and your general information only, procured from third party sources.
I make no warranties of any kind in relation to this content, including but not limited to accuracy
and updatedness. No part of the content that I provide constitutes financial advice, legal advice
or any other form of advice meant for your specific reliance for any purpose. Any use or reliance on
my content is solely at your own risk and discretion. You should conduct your own research, review,
analyse and verify my content before relying on them. Trading is a highly risky activity that can
lead to major losses, please therefore consult your financial advisor before making any decision.
No content on this Site is meant to be a solicitation or offer.