Skip to content

Instantly share code, notes, and snippets.

@Slurpgoose
Last active April 23, 2020 03:56
Show Gist options
  • Save Slurpgoose/d5ed03e8aa5399cfcd0b7e6737dcc988 to your computer and use it in GitHub Desktop.
Save Slurpgoose/d5ed03e8aa5399cfcd0b7e6737dcc988 to your computer and use it in GitHub Desktop.
Plot Candle OHLC Data
def _check_and_prepare_data(data):
'''
Check and Prepare the data input:
For now, data must be a Pandas DataFrame with a DatetimeIndex
and columns named 'Open', 'High', 'Low', 'Close', and optionally 'Volume'
Later (if there is demand for it) we may accept all of the following data formats:
1. Pandas DataFrame with DatetimeIndex (as described above)
2. Pandas Series with DatetimeIndex:
Values are close prices, and Series generates a line plot
3. Tuple of Lists, or List of Lists:
The inner Lists are each columns, in the order: DateTime, Open, High, Low, Close, Volume
4. Tuple of Tuples or List of Tuples:
The inner tuples are each row, containing values in the order: DateTime, Open, High, Low, Close, Volume
Return a Tuple of Lists: datetimes, opens, highs, lows, closes, volumes
'''
if not isinstance(data, pd.core.frame.DataFrame):
raise TypeError('Expect data as DataFrame')
if not isinstance(data.index,pd.core.indexes.datetimes.DatetimeIndex):
raise TypeError('Expect data.index as DatetimeIndex')
dates = mdates.date2num(data.index.to_pydatetime())
opens = data['Open'].values
highs = data['High'].values
lows = data['Low'].values
closes = data['Close'].values
if 'Volume' in data.columns:
volumes = data['Volume'].values
else:
volumes = None
return dates, opens, highs, lows, closes, volumes
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3078, in get_loc
return self._engine.get_loc(key)
File "pandas/_libs/index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Open'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "vizualize.py", line 56, in <module>
mpf.plot(df, type='candle')
File "/usr/local/lib/python3.7/site-packages/mplfinance/plotting.py", line 35, in decorator
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/mplfinance/plotting.py", line 154, in plot
dates,opens,highs,lows,closes,volumes = _check_and_prepare_data(data)
File "/usr/local/lib/python3.7/site-packages/mplfinance/_arg_validators.py", line 29, in _check_and_prepare_data
opens = data['Open'].values
File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 2688, in __getitem__
return self._getitem_column(key)
File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 2695, in _getitem_column
return self._get_item_cache(key)
File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 2489, in _get_item_cache
values = self._data.get(item)
File "/usr/local/lib/python3.7/site-packages/pandas/core/internals.py", line 4115, in get
loc = self.items.get_loc(item)
File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3080, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas/_libs/index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Open'
Traceback (most recent call last):
File "vizualize.py", line 53, in <module>
df = structureData(data)
File "vizualize.py", line 38, in structureData
df = df[['date', 'open', 'high', 'low', 'close']]
File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 2682, in __getitem__
return self._getitem_array(key)
File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 2726, in _getitem_array
indexer = self.loc._convert_to_indexer(key, axis=1)
File "/usr/local/lib/python3.7/site-packages/pandas/core/indexing.py", line 1327, in _convert_to_indexer
.format(mask=objarr[mask]))
KeyError: "['date' 'open' 'high' 'low' 'close'] not in index"
[{"exchange":"cbpro","pair":"BTC-USD","t":1587513600,"l":6826,"h":7167.37,"o":6853.67,"c":7124.72,"v":12267.4072768},{"exchange":"cbpro","pair":"BTC-USD","t":1587427200,"l":6776,"h":6959,"o":6837.22,"c":6853.68,"v":14467.84248756},{"exchange":"cbpro","pair":"BTC-USD","t":1587340800,"l":6748.72,"h":7227.11,"o":7130.7,"c":6838.19,"v":18396.60555727},{"exchange":"cbpro","pair":"BTC-USD","t":1587254400,"l":7063.02,"h":7275,"o":7262.04,"c":7130.71,"v":8887.88875146},{"exchange":"cbpro","pair":"BTC-USD","t":1587168000,"l":7021,"h":7308,"o":7036.45,"c":7261.76,"v":11510.52116868},{"exchange":"cbpro","pair":"BTC-USD","t":1587081600,"l":7000,"h":7156.66,"o":7114.76,"c":7037.46,"v":13514.57644149},{"exchange":"cbpro","pair":"BTC-USD","t":1586995200,"l":6456,"h":7217.27,"o":6623.62,"c":7112.64,"v":28117.55707545},{"exchange":"cbpro","pair":"BTC-USD","t":1586908800,"l":6605.89,"h":6940,"o":6876.92,"c":6624.12,"v":14753.81361034},{"exchange":"cbpro","pair":"BTC-USD","t":1586822400,"l":6771.41,"h":6997.38,"o":6860.51,"c":6877.37,"v":12868.6061641},{"exchange":"cbpro","pair":"BTC-USD","t":1586736000,"l":6555,"h":6908.13,"o":6908.12,"c":6861.21,"v":22323.76661709},{"exchange":"cbpro","pair":"BTC-USD","t":1586649600,"l":6787.44,"h":7200,"o":6889.78,"c":6908.13,"v":12733.98839119},{"exchange":"cbpro","pair":"BTC-USD","t":1586563200,"l":6775,"h":6955,"o":6871.83,"c":6889.65,"v":8066.07536876},{"exchange":"cbpro","pair":"BTC-USD","t":1586476800,"l":6750,"h":7305.91,"o":7293.23,"c":6871.91,"v":19671.19020798},{"exchange":"cbpro","pair":"BTC-USD","t":1586390400,"l":7110,"h":7377,"o":7370.38,"c":7293.24,"v":12369.84267516},{"exchange":"cbpro","pair":"BTC-USD","t":1586304000,"l":7154.22,"h":7430,"o":7200.01,"c":7370.11,"v":15429.12191833},{"exchange":"cbpro","pair":"BTC-USD","t":1586217600,"l":7073,"h":7466,"o":7341.55,"c":7200.01,"v":22743.06622044},{"exchange":"cbpro","pair":"BTC-USD","t":1586131200,"l":6773.28,"h":7373.37,"o":6778.64,"c":7341.56,"v":27992.01318781},{"exchange":"cbpro","pair":"BTC-USD","t":1586044800,"l":6681,"h":6925,"o":6874.77,"c":6778.25,"v":8962.91059819},{"exchange":"cbpro","pair":"BTC-USD","t":1585958400,"l":6658.16,"h":7025.53,"o":6741.99,"c":6874.77,"v":10217.67907796},{"exchange":"cbpro","pair":"BTC-USD","t":1585872000,"l":6606.06,"h":7050,"o":6804.24,"c":6741.99,"v":14953.18284928},{"exchange":"cbpro","pair":"BTC-USD","t":1585785600,"l":6570.92,"h":7292.11,"o":6666.11,"c":6804.52,"v":28761.00804113},{"exchange":"cbpro","pair":"BTC-USD","t":1585699200,"l":6160,"h":6744.99,"o":6424.02,"c":6666.11,"v":17900.2508585},{"exchange":"cbpro","pair":"BTC-USD","t":1585612800,"l":6333.91,"h":6524.79,"o":6406.4,"c":6424.35,"v":11939.0253308},{"exchange":"cbpro","pair":"BTC-USD","t":1585526400,"l":5853,"h":6631.23,"o":5878.98,"c":6406.4,"v":23659.80264153},{"exchange":"cbpro","pair":"BTC-USD","t":1585440000,"l":5870.46,"h":6279.96,"o":6251.45,"c":5877.21,"v":16111.23637843},{"exchange":"cbpro","pair":"BTC-USD","t":1585353600,"l":6030,"h":6372.36,"o":6372.36,"c":6251.82,"v":20353.8748456},{"exchange":"cbpro","pair":"BTC-USD","t":1585267200,"l":6260,"h":6880,"o":6760,"c":6372.36,"v":20458.2557729},{"exchange":"cbpro","pair":"BTC-USD","t":1585180800,"l":6520.13,"h":6795,"o":6691.71,"c":6758.18,"v":17456.11705058},{"exchange":"cbpro","pair":"BTC-USD","t":1585094400,"l":6470,"h":6983.31,"o":6766,"c":6690.96,"v":31266.36827545},{"exchange":"cbpro","pair":"BTC-USD","t":1585008000,"l":6403.16,"h":6866.1,"o":6493.58,"c":6766.64,"v":40618.19870698},{"exchange":"cbpro","pair":"BTC-USD","t":1584921600,"l":5678.2,"h":6641.03,"o":5815.24,"c":6490.63,"v":42437.97070062},{"exchange":"cbpro","pair":"BTC-USD","t":1584835200,"l":5738,"h":6420,"o":6198.64,"c":5818.25,"v":28089.48698286},{"exchange":"cbpro","pair":"BTC-USD","t":1584748800,"l":5851,"h":6470,"o":6210.47,"c":6198.78,"v":23514.96653599},{"exchange":"cbpro","pair":"BTC-USD","t":1584662400,"l":5657,"h":6990,"o":6183.82,"c":6206.1,"v":53024.40103701},{"exchange":"cbpro","pair":"BTC-USD","t":1584576000,"l":5261.69,"h":6441.37,"o":5413.88,"c":6186.26,"v":54666.67461085},{"exchange":"cbpro","pair":"BTC-USD","t":1584489600,"l":5001,"h":5452.82,"o":5331.71,"c":5413.64,"v":37513.03523454},{"exchange":"cbpro","pair":"BTC-USD","t":1584403200,"l":4935.6,"h":5569.44,"o":5039.95,"c":5331.71,"v":44347.15487325},{"exchange":"cbpro","pair":"BTC-USD","t":1584316800,"l":4432.3,"h":5350.3,"o":5346.86,"c":5037.61,"v":80184.03685247},{"exchange":"cbpro","pair":"BTC-USD","t":1584230400,"l":5085.91,"h":5985,"o":5161.16,"c":5345.35,"v":43763.76236813},{"exchange":"cbpro","pair":"BTC-USD","t":1584144000,"l":5050,"h":5669,"o":5630.93,"c":5165.25,"v":32760.12278053},{"exchange":"cbpro","pair":"BTC-USD","t":1584057600,"l":3858,"h":5995,"o":4857.1,"c":5637.6,"v":130316.64684438},{"exchange":"cbpro","pair":"BTC-USD","t":1583971200,"l":4644,"h":7969.45,"o":7938.05,"c":4857.1,"v":113902.20332904},{"exchange":"cbpro","pair":"BTC-USD","t":1583884800,"l":7583.27,"h":7987.97,"o":7894.68,"c":7938.05,"v":13647.86513876},{"exchange":"cbpro","pair":"BTC-USD","t":1583798400,"l":7733.56,"h":8158.25,"o":7934.56,"c":7894.68,"v":17172.47130109},{"exchange":"cbpro","pair":"BTC-USD","t":1583712000,"l":7630,"h":8187.03,"o":8037.73,"c":7934.52,"v":25563.61417462},{"exchange":"cbpro","pair":"BTC-USD","t":1583625600,"l":8002.2,"h":8901.37,"o":8901.36,"c":8037.76,"v":16591.91410216},{"exchange":"cbpro","pair":"BTC-USD","t":1583539200,"l":8850.47,"h":9214.67,"o":9158.51,"c":8901.37,"v":6478.25334502},{"exchange":"cbpro","pair":"BTC-USD","t":1583452800,"l":9000.01,"h":9182.08,"o":9070.18,"c":9158.51,"v":6422.12885254},{"exchange":"cbpro","pair":"BTC-USD","t":1583366400,"l":8759.99,"h":9174.24,"o":8759.99,"c":9070.17,"v":10073.31421239},{"exchange":"cbpro","pair":"BTC-USD","t":1583280000,"l":8670.57,"h":8847,"o":8757.83,"c":8760.66,"v":5688.58509691},{"exchange":"cbpro","pair":"BTC-USD","t":1583193600,"l":8635.31,"h":8927.45,"o":8919.21,"c":8757.84,"v":9152.7069265},{"exchange":"cbpro","pair":"BTC-USD","t":1583107200,"l":8487.33,"h":8973.45,"o":8522.3,"c":8915,"v":10216.69254477},{"exchange":"cbpro","pair":"BTC-USD","t":1583020800,"l":8400,"h":8752.34,"o":8523.33,"c":8522.31,"v":7353.13960471},{"exchange":"cbpro","pair":"BTC-USD","t":1582934400,"l":8520.67,"h":8799,"o":8708.61,"c":8525.07,"v":5142.70830477},{"exchange":"cbpro","pair":"BTC-USD","t":1582848000,"l":8428.8,"h":8899.94,"o":8814.9,"c":8708.89,"v":13643.28590301},{"exchange":"cbpro","pair":"BTC-USD","t":1582761600,"l":8520,"h":8972.92,"o":8778.3,"c":8812.49,"v":14781.02020263},{"exchange":"cbpro","pair":"BTC-USD","t":1582675200,"l":8602,"h":9375.36,"o":9304.99,"c":8778.3,"v":21610.46289952},{"exchange":"cbpro","pair":"BTC-USD","t":1582588800,"l":9230,"h":9681.56,"o":9660,"c":9305,"v":9370.80656806},{"exchange":"cbpro","pair":"BTC-USD","t":1582502400,"l":9474.74,"h":10030,"o":9965,"c":9660,"v":11274.83220813},{"exchange":"cbpro","pair":"BTC-USD","t":1582416000,"l":9667.13,"h":10025.66,"o":9668.23,"c":9965.01,"v":5631.93728472},{"exchange":"cbpro","pair":"BTC-USD","t":1582329600,"l":9575.01,"h":9722.97,"o":9695.66,"c":9668.23,"v":3301.24362823},{"exchange":"cbpro","pair":"BTC-USD","t":1582243200,"l":9566.98,"h":9769.66,"o":9610.05,"c":9695.66,"v":7073.36617743},{"exchange":"cbpro","pair":"BTC-USD","t":1582156800,"l":9393.39,"h":9698.1,"o":9593.48,"c":9610.05,"v":12382.01006133},{"exchange":"cbpro","pair":"BTC-USD","t":1582070400,"l":9280.98,"h":10315,"o":10188.04,"c":9600.08,"v":16637.05014888},{"exchange":"cbpro","pair":"BTC-USD","t":1581984000,"l":9610.27,"h":10298.25,"o":9700,"c":10188.04,"v":11606.56132767},{"exchange":"cbpro","pair":"BTC-USD","t":1581897600,"l":9467,"h":9969.38,"o":9920.52,"c":9700,"v":10144.62802455},{"exchange":"cbpro","pair":"BTC-USD","t":1581811200,"l":9612.12,"h":10048.34,"o":9911.22,"c":9921,"v":9430.32887897},{"exchange":"cbpro","pair":"BTC-USD","t":1581724800,"l":9750,"h":10400,"o":10371.33,"c":9911.22,"v":12323.28859704},{"exchange":"cbpro","pair":"BTC-USD","t":1581638400,"l":10102.5,"h":10395.66,"o":10236.49,"c":10371.33,"v":8026.49620683},{"exchange":"cbpro","pair":"BTC-USD","t":1581552000,"l":10083.1,"h":10522.51,"o":10351.13,"c":10236.49,"v":17101.28534969},{"exchange":"cbpro","pair":"BTC-USD","t":1581465600,"l":10250,"h":10483.86,"o":10270.01,"c":10351.13,"v":13740.9848527},{"exchange":"cbpro","pair":"BTC-USD","t":1581379200,"l":9706,"h":10400,"o":9851.78,"c":10270.01,"v":16722.06581913},{"exchange":"cbpro","pair":"BTC-USD","t":1581292800,"l":9736,"h":10199,"o":10168.36,"c":9851.78,"v":13249.58715176},{"exchange":"cbpro","pair":"BTC-USD","t":1581206400,"l":9888.76,"h":10178.91,"o":9905.64,"c":10168.35,"v":9649.74938704},{"exchange":"cbpro","pair":"BTC-USD","t":1581120000,"l":9653.47,"h":9955,"o":9807.92,"c":9905.64,"v":8100.97112281},{"exchange":"cbpro","pair":"BTC-USD","t":1581033600,"l":9713.99,"h":9885,"o":9763.01,"c":9808.05,"v":8516.66510844},{"exchange":"cbpro","pair":"BTC-USD","t":1580947200,"l":9521.47,"h":9857,"o":9613.91,"c":9763.01,"v":12672.14755524},{"exchange":"cbpro","pair":"BTC-USD","t":1580860800,"l":9150,"h":9769.7,"o":9164.33,"c":9613.82,"v":13264.84220779},{"exchange":"cbpro","pair":"BTC-USD","t":1580774400,"l":9078.05,"h":9350,"o":9280.49,"c":9164.33,"v":8190.88648953},{"exchange":"cbpro","pair":"BTC-USD","t":1580688000,"l":9220,"h":9619.95,"o":9325.01,"c":9280.49,"v":11910.28572971},{"exchange":"cbpro","pair":"BTC-USD","t":1580601600,"l":9140,"h":9480,"o":9380.18,"c":9323.5,"v":7307.92291459},{"exchange":"cbpro","pair":"BTC-USD","t":1580515200,"l":9285.01,"h":9458.08,"o":9334.98,"c":9380.18,"v":4387.41986202},{"exchange":"cbpro","pair":"BTC-USD","t":1580428800,"l":9195.49,"h":9522.5,"o":9502.71,"c":9334.98,"v":9719.06131452},{"exchange":"cbpro","pair":"BTC-USD","t":1580342400,"l":9171.11,"h":9574.68,"o":9287.9,"c":9503.08,"v":12948.39766745},{"exchange":"cbpro","pair":"BTC-USD","t":1580256000,"l":9224.75,"h":9439.83,"o":9391.14,"c":9288.44,"v":12233.05063864},{"exchange":"cbpro","pair":"BTC-USD","t":1580169600,"l":8880.87,"h":9418.91,"o":8895.95,"c":9394.5,"v":17578.54006083},{"exchange":"cbpro","pair":"BTC-USD","t":1580083200,"l":8556.6,"h":8985,"o":8595,"c":8895.96,"v":9548.60631978},{"exchange":"cbpro","pair":"BTC-USD","t":1579996800,"l":8278.68,"h":8595,"o":8326.8,"c":8595,"v":5497.32293973},{"exchange":"cbpro","pair":"BTC-USD","t":1579910400,"l":8252.73,"h":8437.76,"o":8427.58,"c":8326.81,"v":3783.20831697},{"exchange":"cbpro","pair":"BTC-USD","t":1579824000,"l":8216.71,"h":8509.99,"o":8385.21,"c":8427.26,"v":8635.12024903},{"exchange":"cbpro","pair":"BTC-USD","t":1579737600,"l":8278,"h":8665,"o":8660.38,"c":8385.22,"v":12206.24491133},{"exchange":"cbpro","pair":"BTC-USD","t":1579651200,"l":8565,"h":8791.76,"o":8722.03,"c":8660.38,"v":5481.65770829},{"exchange":"cbpro","pair":"BTC-USD","t":1579564800,"l":8465,"h":8774.31,"o":8628.89,"c":8722.03,"v":7520.65103045},{"exchange":"cbpro","pair":"BTC-USD","t":1579478400,"l":8504.06,"h":8734.84,"o":8697.53,"c":8628.89,"v":5605.80561385},{"exchange":"cbpro","pair":"BTC-USD","t":1579392000,"l":8465,"h":9194.99,"o":8908.95,"c":8697.53,"v":15218.51476182},{"exchange":"cbpro","pair":"BTC-USD","t":1579305600,"l":8800.1,"h":8980,"o":8899.42,"c":8909.32,"v":5600.21827844},{"exchange":"cbpro","pair":"BTC-USD","t":1579219200,"l":8665.67,"h":9013,"o":8714.77,"c":8899.42,"v":15447.36512517},{"exchange":"cbpro","pair":"BTC-USD","t":1579132800,"l":8580,"h":8850,"o":8808.81,"c":8714.76,"v":9265.76423506},{"exchange":"cbpro","pair":"BTC-USD","t":1579046400,"l":8550,"h":8900,"o":8812.58,"c":8808.81,"v":14977.61979023},{"exchange":"cbpro","pair":"BTC-USD","t":1578960000,"l":8105.23,"h":8893.69,"o":8105.6,"c":8815.69,"v":27075.8082207},{"exchange":"cbpro","pair":"BTC-USD","t":1578873600,"l":8041.95,"h":8195.81,"o":8180.81,"c":8104.5,"v":6678.02840315},{"exchange":"cbpro","pair":"BTC-USD","t":1578787200,"l":7963.25,"h":8185,"o":8017.47,"c":8180.81,"v":3920.74009838},{"exchange":"cbpro","pair":"BTC-USD","t":1578700800,"l":8000.01,"h":8290,"o":8198.09,"c":8020,"v":7557.36879269},{"exchange":"cbpro","pair":"BTC-USD","t":1578614400,"l":7671,"h":8199.77,"o":7813.78,"c":8198.09,"v":13420.61860763},{"exchange":"cbpro","pair":"BTC-USD","t":1578528000,"l":7744.48,"h":8048.67,"o":8047.75,"c":7813.78,"v":9477.70483336},{"exchange":"cbpro","pair":"BTC-USD","t":1578441600,"l":7845,"h":8469.39,"o":8160.01,"c":8045.51,"v":23927.78644113},{"exchange":"cbpro","pair":"BTC-USD","t":1578355200,"l":7723,"h":8216,"o":7764.63,"c":8158.52,"v":19857.53813894},{"exchange":"cbpro","pair":"BTC-USD","t":1578268800,"l":7343.17,"h":7805,"o":7355.4,"c":7764.63,"v":11770.42968139},{"exchange":"cbpro","pair":"BTC-USD","t":1578182400,"l":7312.22,"h":7488.87,"o":7348.63,"c":7355.4,"v":5942.01494574},{"exchange":"cbpro","pair":"BTC-USD","t":1578096000,"l":7263.32,"h":7398,"o":7334.45,"c":7348.63,"v":4742.46620989},{"exchange":"cbpro","pair":"BTC-USD","t":1578009600,"l":6854.67,"h":7401.2,"o":6945.02,"c":7334.45,"v":14056.39238489},{"exchange":"cbpro","pair":"BTC-USD","t":1577923200,"l":6903,"h":7186.18,"o":7174.33,"c":6945.02,"v":8010.92738748},{"exchange":"cbpro","pair":"BTC-USD","t":1577836800,"l":7136.05,"h":7238.14,"o":7165.72,"c":7174.33,"v":3350.63004888},{"exchange":"cbpro","pair":"BTC-USD","t":1577750400,"l":7111,"h":7298.67,"o":7218.01,"c":7165.72,"v":6755.96883486},{"exchange":"cbpro","pair":"BTC-USD","t":1577664000,"l":7200,"h":7386.28,"o":7384.57,"c":7218,"v":7347.22088262},{"exchange":"cbpro","pair":"BTC-USD","t":1577577600,"l":7278.07,"h":7531,"o":7302.67,"c":7384.89,"v":6557.31229484},{"exchange":"cbpro","pair":"BTC-USD","t":1577491200,"l":7232.55,"h":7346,"o":7245.83,"c":7302.67,"v":4621.76136294},{"exchange":"cbpro","pair":"BTC-USD","t":1577404800,"l":7053.32,"h":7254,"o":7194.13,"c":7245.83,"v":8492.97603648},{"exchange":"cbpro","pair":"BTC-USD","t":1577318400,"l":7140,"h":7432.1,"o":7192.12,"c":7194.13,"v":7669.0329008},{"exchange":"cbpro","pair":"BTC-USD","t":1577232000,"l":7115.5,"h":7265.12,"o":7255.01,"c":7192.12,"v":3299.65944044},{"exchange":"cbpro","pair":"BTC-USD","t":1577145600,"l":7151.08,"h":7426.15,"o":7310.79,"c":7255.01,"v":7797.31351736},{"exchange":"cbpro","pair":"BTC-USD","t":1577059200,"l":7259.19,"h":7688.99,"o":7514.74,"c":7310.79,"v":15139.33988185},{"exchange":"cbpro","pair":"BTC-USD","t":1576972800,"l":7125,"h":7521.55,"o":7143.01,"c":7513.06,"v":10202.17603024},{"exchange":"cbpro","pair":"BTC-USD","t":1576886400,"l":7099.57,"h":7190,"o":7190,"c":7143.01,"v":3423.26190789},{"exchange":"cbpro","pair":"BTC-USD","t":1576800000,"l":7073.66,"h":7220,"o":7149.13,"c":7190,"v":6020.22689987},{"exchange":"cbpro","pair":"BTC-USD","t":1576713600,"l":7044.45,"h":7371.7,"o":7288.05,"c":7149.12,"v":10503.10731585},{"exchange":"cbpro","pair":"BTC-USD","t":1576627200,"l":6430,"h":7448.24,"o":6616.62,"c":7285.53,"v":23097.54270516},{"exchange":"cbpro","pair":"BTC-USD","t":1576540800,"l":6556,"h":6933.21,"o":6877.04,"c":6616.62,"v":14047.41226353},{"exchange":"cbpro","pair":"BTC-USD","t":1576454400,"l":6803.24,"h":7137,"o":7111,"c":6877.03,"v":13170.13695005},{"exchange":"cbpro","pair":"BTC-USD","t":1576368000,"l":7006.01,"h":7220.01,"o":7062.92,"c":7111,"v":4905.19442136},{"exchange":"cbpro","pair":"BTC-USD","t":1576281600,"l":7008.03,"h":7264.33,"o":7249.9,"c":7062.91,"v":4334.04050458},{"exchange":"cbpro","pair":"BTC-USD","t":1576195200,"l":7183.29,"h":7299.21,"o":7185.91,"c":7249.9,"v":6119.05346128},{"exchange":"cbpro","pair":"BTC-USD","t":1576108800,"l":7075.01,"h":7298.5,"o":7201.24,"c":7185.91,"v":8578.07225074},{"exchange":"cbpro","pair":"BTC-USD","t":1576022400,"l":7124.45,"h":7263.31,"o":7219.37,"c":7201.23,"v":5951.55939387},{"exchange":"cbpro","pair":"BTC-USD","t":1575936000,"l":7156.03,"h":7398,"o":7337.51,"c":7219.37,"v":7187.10559074},{"exchange":"cbpro","pair":"BTC-USD","t":1575849600,"l":7262.87,"h":7659.38,"o":7520,"c":7337.51,"v":10252.89331517},{"exchange":"cbpro","pair":"BTC-USD","t":1575763200,"l":7387.5,"h":7580.84,"o":7502.2,"c":7520,"v":4243.5281669},{"exchange":"cbpro","pair":"BTC-USD","t":1575676800,"l":7487,"h":7643,"o":7541.76,"c":7502.19,"v":4876.33856339},{"exchange":"cbpro","pair":"BTC-USD","t":1575590400,"l":7305.75,"h":7609.5,"o":7393.55,"c":7540.08,"v":9346.34006931},{"exchange":"cbpro","pair":"BTC-USD","t":1575504000,"l":7152.78,"h":7489.87,"o":7199,"c":7393.54,"v":9248.37658376},{"exchange":"cbpro","pair":"BTC-USD","t":1575417600,"l":7080,"h":7775,"o":7302.94,"c":7198.99,"v":16490.16548626},{"exchange":"cbpro","pair":"BTC-USD","t":1575331200,"l":7237.26,"h":7412.85,"o":7305.01,"c":7302.94,"v":6169.03965176},{"exchange":"cbpro","pair":"BTC-USD","t":1575244800,"l":7157.33,"h":7430,"o":7405.33,"c":7305.01,"v":7029.95625983},{"exchange":"cbpro","pair":"BTC-USD","t":1575158400,"l":7237.16,"h":7555.92,"o":7555.92,"c":7404.27,"v":8692.58780339},{"exchange":"cbpro","pair":"BTC-USD","t":1575072000,"l":7453,"h":7820,"o":7759.99,"c":7555.92,"v":6130.42566398},{"exchange":"cbpro","pair":"BTC-USD","t":1574985600,"l":7411,"h":7870.1,"o":7432.41,"c":7760,"v":10862.78844038},{"exchange":"cbpro","pair":"BTC-USD","t":1574899200,"l":7370.62,"h":7660.82,"o":7524.73,"c":7432.41,"v":8646.63700515},{"exchange":"cbpro","pair":"BTC-USD","t":1574812800,"l":6850,"h":7678.76,"o":7162.67,"c":7523.72,"v":19213.98364601},{"exchange":"cbpro","pair":"BTC-USD","t":1574726400,"l":7021.84,"h":7340.59,"o":7127.01,"c":7162.67,"v":11857.49541903},{"exchange":"cbpro","pair":"BTC-USD","t":1574640000,"l":6526,"h":7379.99,"o":6908.64,"c":7127.01,"v":27124.48255363},{"exchange":"cbpro","pair":"BTC-USD","t":1574553600,"l":6865,"h":7344,"o":7329.29,"c":6908.64,"v":10695.00788503},{"exchange":"cbpro","pair":"BTC-USD","t":1574467200,"l":7102.21,"h":7361.41,"o":7283.19,"c":7329.29,"v":7728.4239895},{"exchange":"cbpro","pair":"BTC-USD","t":1574380800,"l":6775.47,"h":7720,"o":7616.48,"c":7283.03,"v":33676.56392657},{"exchange":"cbpro","pair":"BTC-USD","t":1574294400,"l":7374.5,"h":8114.97,"o":8082.97,"c":7616.46,"v":16947.0184322},{"exchange":"cbpro","pair":"BTC-USD","t":1574208000,"l":8030.05,"h":8222.41,"o":8123.36,"c":8082.96,"v":5296.45566165},{"exchange":"cbpro","pair":"BTC-USD","t":1574121600,"l":7980.07,"h":8197.82,"o":8168.84,"c":8123.36,"v":7360.99550259},{"exchange":"cbpro","pair":"BTC-USD","t":1574035200,"l":8015,"h":8501.01,"o":8501,"c":8168.84,"v":9864.12446203},{"exchange":"cbpro","pair":"BTC-USD","t":1573948800,"l":8371.02,"h":8637.01,"o":8481,"c":8500.01,"v":3754.24485434},{"exchange":"cbpro","pair":"BTC-USD","t":1573862400,"l":8423,"h":8531.03,"o":8457.48,"c":8481,"v":2712.33956982},{"exchange":"cbpro","pair":"BTC-USD","t":1573776000,"l":8361,"h":8773.22,"o":8630.01,"c":8457.48,"v":10940.91541078},{"exchange":"cbpro","pair":"BTC-USD","t":1573689600,"l":8558.01,"h":8784.61,"o":8758.34,"c":8630,"v":5607.47902352},{"exchange":"cbpro","pair":"BTC-USD","t":1573603200,"l":8705,"h":8838.8,"o":8811,"c":8758.34,"v":4486.2787504},{"exchange":"cbpro","pair":"BTC-USD","t":1573516800,"l":8556.56,"h":8870,"o":8721.53,"c":8810,"v":6272.86259557},{"exchange":"cbpro","pair":"BTC-USD","t":1573430400,"l":8590,"h":9067.34,"o":9032.23,"c":8721.54,"v":7049.92853839},{"exchange":"cbpro","pair":"BTC-USD","t":1573344000,"l":8731.43,"h":9150,"o":8807.89,"c":9032.23,"v":6070.46798596},{"exchange":"cbpro","pair":"BTC-USD","t":1573257600,"l":8712.52,"h":8873.48,"o":8763.01,"c":8807.89,"v":4175.00938447},{"exchange":"cbpro","pair":"BTC-USD","t":1573171200,"l":8660,"h":9246,"o":9198.85,"c":8763.01,"v":12876.55531942},{"exchange":"cbpro","pair":"BTC-USD","t":1573084800,"l":9075,"h":9375.16,"o":9341.27,"c":9198.84,"v":5989.36091519},{"exchange":"cbpro","pair":"BTC-USD","t":1572998400,"l":9253.66,"h":9450,"o":9322.09,"c":9341.27,"v":6829.68611819},{"exchange":"cbpro","pair":"BTC-USD","t":1572912000,"l":9169.84,"h":9474.89,"o":9412.63,"c":9322.09,"v":7581.21667266},{"exchange":"cbpro","pair":"BTC-USD","t":1572825600,"l":9127,"h":9600,"o":9206.52,"c":9412.53,"v":8361.9587774},{"exchange":"cbpro","pair":"BTC-USD","t":1572739200,"l":9068.3,"h":9380,"o":9308.52,"c":9206.52,"v":4294.50041401},{"exchange":"cbpro","pair":"BTC-USD","t":1572652800,"l":9210,"h":9393,"o":9253.09,"c":9308.52,"v":4559.26538837},{"exchange":"cbpro","pair":"BTC-USD","t":1572566400,"l":9057.27,"h":9299.99,"o":9159.96,"c":9253.12,"v":7774.27145408},{"exchange":"cbpro","pair":"BTC-USD","t":1572480000,"l":8950,"h":9433,"o":9164.45,"c":9159.48,"v":8326.9619179},{"exchange":"cbpro","pair":"BTC-USD","t":1572393600,"l":8991.33,"h":9431.36,"o":9431.36,"c":9164.44,"v":9862.67699421},{"exchange":"cbpro","pair":"BTC-USD","t":1572307200,"l":9068.19,"h":9575,"o":9225.06,"c":9430.8,"v":12640.19748534},{"exchange":"cbpro","pair":"BTC-USD","t":1572220800,"l":9180.59,"h":9939.69,"o":9555.89,"c":9226.5,"v":16736.97258328},{"exchange":"cbpro","pair":"BTC-USD","t":1572134400,"l":9102.33,"h":9826.72,"o":9259.98,"c":9548.84,"v":19636.4291242},{"exchange":"cbpro","pair":"BTC-USD","t":1572048000,"l":8645.01,"h":10540.49,"o":8668,"c":9259.78,"v":53383.40194086},{"exchange":"cbpro","pair":"BTC-USD","t":1571961600,"l":7389.91,"h":8800.1,"o":7430.87,"c":8668,"v":27140.20895781},{"exchange":"cbpro","pair":"BTC-USD","t":1571875200,"l":7359.48,"h":7509.99,"o":7475.54,"c":7430.87,"v":7972.6408295},{"exchange":"cbpro","pair":"BTC-USD","t":1571788800,"l":7296.44,"h":8049,"o":8024,"c":7474.85,"v":19159.93039884},{"exchange":"cbpro","pair":"BTC-USD","t":1571702400,"l":7998.9,"h":8317.14,"o":8209.92,"c":8024.72,"v":6015.86741941},{"exchange":"cbpro","pair":"BTC-USD","t":1571616000,"l":8156,"h":8349.84,"o":8235.94,"c":8209.92,"v":6137.13312184},{"exchange":"cbpro","pair":"BTC-USD","t":1571529600,"l":7875.01,"h":8309,"o":7965.27,"c":8236.12,"v":6162.04807515},{"exchange":"cbpro","pair":"BTC-USD","t":1571443200,"l":7873.46,"h":8099.98,"o":7954.15,"c":7965.28,"v":4839.48919554},{"exchange":"cbpro","pair":"BTC-USD","t":1571356800,"l":7814.08,"h":8117.77,"o":8076.94,"c":7954.16,"v":7071.36378903},{"exchange":"cbpro","pair":"BTC-USD","t":1571270400,"l":7937.01,"h":8124.42,"o":7995.81,"c":8076.2,"v":4909.27039643},{"exchange":"cbpro","pair":"BTC-USD","t":1571184000,"l":7908.86,"h":8171.59,"o":8162.44,"c":7993.54,"v":8489.99546525},{"exchange":"cbpro","pair":"BTC-USD","t":1571097600,"l":8085.65,"h":8420,"o":8355,"c":8162.44,"v":8558.56827956},{"exchange":"cbpro","pair":"BTC-USD","t":1571011200,"l":8215.66,"h":8409,"o":8282.96,"c":8355,"v":4462.50438875},{"exchange":"cbpro","pair":"BTC-USD","t":1570924800,"l":8146.47,"h":8469.02,"o":8309.03,"c":8282.97,"v":5858.03981575},{"exchange":"cbpro","pair":"BTC-USD","t":1570838400,"l":8261.46,"h":8425,"o":8263.02,"c":8309.03,"v":3046.40450951},{"exchange":"cbpro","pair":"BTC-USD","t":1570752000,"l":8226,"h":8826,"o":8587.49,"c":8267.33,"v":12446.84471206},{"exchange":"cbpro","pair":"BTC-USD","t":1570665600,"l":8452.5,"h":8660,"o":8590.01,"c":8587.5,"v":7908.66988763},{"exchange":"cbpro","pair":"BTC-USD","t":1570579200,"l":8121,"h":8712.45,"o":8180,"c":8590,"v":14459.7776891},{"exchange":"cbpro","pair":"BTC-USD","t":1570492800,"l":8107.26,"h":8342.97,"o":8208.99,"c":8180,"v":5857.54021433},{"exchange":"cbpro","pair":"BTC-USD","t":1570406400,"l":7762.35,"h":8310.57,"o":7859.79,"c":8209,"v":10012.00725014},{"exchange":"cbpro","pair":"BTC-USD","t":1570320000,"l":7780.85,"h":8176.18,"o":8147.63,"c":7859.79,"v":8697.93975986},{"exchange":"cbpro","pair":"BTC-USD","t":1570233600,"l":8020.2,"h":8200,"o":8156.68,"c":8147.63,"v":3826.82870697},{"exchange":"cbpro","pair":"BTC-USD","t":1570147200,"l":8002.21,"h":8241.35,"o":8241.27,"c":8156.67,"v":7715.28010237},{"exchange":"cbpro","pair":"BTC-USD","t":1570060800,"l":8059.22,"h":8419.95,"o":8381.72,"c":8240.41,"v":7778.11842343},{"exchange":"cbpro","pair":"BTC-USD","t":1569974400,"l":8168.85,"h":8391,"o":8321.87,"c":8381.72,"v":7040.87668343},{"exchange":"cbpro","pair":"BTC-USD","t":1569888000,"l":8200,"h":8535,"o":8304.95,"c":8321.52,"v":12266.35796784},{"exchange":"cbpro","pair":"BTC-USD","t":1569801600,"l":7701,"h":8393.23,"o":8054.09,"c":8304.96,"v":15142.61949966},{"exchange":"cbpro","pair":"BTC-USD","t":1569715200,"l":7902.96,"h":8246.87,"o":8217.47,"c":8052.4,"v":7142.36916333},{"exchange":"cbpro","pair":"BTC-USD","t":1569628800,"l":8015.25,"h":8343,"o":8193.99,"c":8217.47,"v":9039.55200543},{"exchange":"cbpro","pair":"BTC-USD","t":1569542400,"l":7861.02,"h":8290,"o":8060,"c":8193.99,"v":15914.66412076},{"exchange":"cbpro","pair":"BTC-USD","t":1569456000,"l":7712.45,"h":8464.08,"o":8438.35,"c":8060,"v":27664.78945578},{"exchange":"cbpro","pair":"BTC-USD","t":1569369600,"l":8222.01,"h":8743.86,"o":8530.01,"c":8438.35,"v":23524.43263014},{"exchange":"cbpro","pair":"BTC-USD","t":1569283200,"l":8159.35,"h":9777.16,"o":9693.74,"c":8530.01,"v":38736.2261491},{"exchange":"cbpro","pair":"BTC-USD","t":1569196800,"l":9609.37,"h":10051.15,"o":10026.79,"c":9693.74,"v":11355.88878537},{"exchange":"cbpro","pair":"BTC-USD","t":1569110400,"l":9848.37,"h":10097,"o":9973.99,"c":10026.8,"v":5276.95241027},{"exchange":"cbpro","pair":"BTC-USD","t":1569024000,"l":9917.34,"h":10170.15,"o":10168.85,"c":9973.99,"v":5043.0795144},{"exchange":"cbpro","pair":"BTC-USD","t":1568937600,"l":10056.3,"h":10309.84,"o":10275.01,"c":10168.85,"v":6183.91792313},{"exchange":"cbpro","pair":"BTC-USD","t":1568851200,"l":9585.86,"h":10379.15,"o":10156.22,"c":10275.01,"v":15625.02434239},{"exchange":"cbpro","pair":"BTC-USD","t":1568764800,"l":10074.08,"h":10258,"o":10185.42,"c":10155.26,"v":5627.58140023},{"exchange":"cbpro","pair":"BTC-USD","t":1568678400,"l":10135.44,"h":10276.18,"o":10262.54,"c":10185.39,"v":5716.17663911},{"exchange":"cbpro","pair":"BTC-USD","t":1568592000,"l":10068.42,"h":10379.98,"o":10303.66,"c":10262.54,"v":7785.7271484},{"exchange":"cbpro","pair":"BTC-USD","t":1568505600,"l":10263.39,"h":10380,"o":10360.01,"c":10304.46,"v":2745.26528355},{"exchange":"cbpro","pair":"BTC-USD","t":1568419200,"l":10223.36,"h":10439,"o":10365.94,"c":10360.25,"v":4470.31545378},{"exchange":"cbpro","pair":"BTC-USD","t":1568332800,"l":10157,"h":10452.5,"o":10423.85,"c":10365.93,"v":6909.03483326},{"exchange":"cbpro","pair":"BTC-USD","t":1568246400,"l":10040,"h":10460,"o":10158.81,"c":10423.72,"v":7625.24967791},{"exchange":"cbpro","pair":"BTC-USD","t":1568160000,"l":9851.97,"h":10297.12,"o":10093,"c":10160.2,"v":8374.04003496},{"exchange":"cbpro","pair":"BTC-USD","t":1568073600,"l":9916,"h":10389.26,"o":10310.01,"c":10093.01,"v":8098.57574372},{"exchange":"cbpro","pair":"BTC-USD","t":1567987200,"l":10059.99,"h":10541.75,"o":10401.13,"c":10310,"v":9745.07271844},{"exchange":"cbpro","pair":"BTC-USD","t":1567900800,"l":10231.13,"h":10595,"o":10484.37,"c":10398.97,"v":4915.56585169},{"exchange":"cbpro","pair":"BTC-USD","t":1567814400,"l":10304.52,"h":10580,"o":10308.9,"c":10484.37,"v":4381.36082048},{"exchange":"cbpro","pair":"BTC-USD","t":1567728000,"l":10182,"h":10939.34,"o":10574.28,"c":10308.92,"v":15732.60470722},{"exchange":"cbpro","pair":"BTC-USD","t":1567641600,"l":10452.15,"h":10666.43,"o":10581.84,"c":10574.73,"v":7432.47882878},{"exchange":"cbpro","pair":"BTC-USD","t":1567555200,"l":10380,"h":10833.14,"o":10628.48,"c":10581.84,"v":12180.82546922},{"exchange":"cbpro","pair":"BTC-USD","t":1567468800,"l":10280,"h":10790,"o":10381.26,"c":10628.48,"v":15518.02066249},{"exchange":"cbpro","pair":"BTC-USD","t":1567382400,"l":9756.54,"h":10486.77,"o":9766.62,"c":10381.26,"v":11794.06048881},{"exchange":"cbpro","pair":"BTC-USD","t":1567296000,"l":9539.58,"h":9840,"o":9600.86,"c":9766.52,"v":4200.85038239},{"exchange":"cbpro","pair":"BTC-USD","t":1567209600,"l":9436.2,"h":9707.48,"o":9582.42,"c":9600.86,"v":4057.20202851},{"exchange":"cbpro","pair":"BTC-USD","t":1567123200,"l":9337.97,"h":9699,"o":9494.8,"c":9582.42,"v":8734.15084369},{"exchange":"cbpro","pair":"BTC-USD","t":1567036800,"l":9321.73,"h":9717.03,"o":9714.01,"c":9495,"v":14421.69716916},{"exchange":"cbpro","pair":"BTC-USD","t":1566950400,"l":9522.93,"h":10277,"o":10171.95,"c":9714.31,"v":17637.06892056},{"exchange":"cbpro","pair":"BTC-USD","t":1566864000,"l":10019.56,"h":10379.87,"o":10361.65,"c":10171.85,"v":7514.28766499},{"exchange":"cbpro","pair":"BTC-USD","t":1566777600,"l":10140.9,"h":10680,"o":10142,"c":10361.65,"v":14125.38101325},{"exchange":"cbpro","pair":"BTC-USD","t":1566691200,"l":9899.95,"h":10374.85,"o":10148,"c":10138.72,"v":7288.06423633},{"exchange":"cbpro","pair":"BTC-USD","t":1566604800,"l":9886.26,"h":10429,"o":10413.45,"c":10147.96,"v":7987.20795651},{"exchange":"cbpro","pair":"BTC-USD","t":1566518400,"l":10035.84,"h":10478,"o":10105.61,"c":10410.85,"v":9413.53218337},{"exchange":"cbpro","pair":"BTC-USD","t":1566432000,"l":9759,"h":10237.53,"o":10133.34,"c":10107.15,"v":10912.33836991},{"exchange":"cbpro","pair":"BTC-USD","t":1566345600,"l":9841.59,"h":10800,"o":10768.49,"c":10130,"v":17445.28744509},{"exchange":"cbpro","pair":"BTC-USD","t":1566259200,"l":10555.7,"h":10953,"o":10917.94,"c":10769.09,"v":8820.93622259},{"exchange":"cbpro","pair":"BTC-USD","t":1566172800,"l":10265,"h":10938.76,"o":10315.48,"c":10920,"v":12220.3862029},{"exchange":"cbpro","pair":"BTC-USD","t":1566086400,"l":10066.66,"h":10513.45,"o":10217.99,"c":10315.48,"v":6794.78437545},{"exchange":"cbpro","pair":"BTC-USD","t":1566000000,"l":9978,"h":10475.82,"o":10352.78,"c":10217.79,"v":7307.99789432},{"exchange":"cbpro","pair":"BTC-USD","t":1565913600,"l":9739.99,"h":10539.9,"o":10300.01,"c":10352.78,"v":19532.59596641},{"exchange":"cbpro","pair":"BTC-USD","t":1565827200,"l":9470,"h":10445,"o":10021.13,"c":10300.01,"v":27939.82663467},{"exchange":"cbpro","pair":"BTC-USD","t":1565740800,"l":9888.88,"h":10859.97,"o":10854.92,"c":10025.86,"v":24889.57722872},{"exchange":"cbpro","pair":"BTC-USD","t":1565654400,"l":10746,"h":11438.39,"o":11389.25,"c":10854.92,"v":12500.34295603},{"exchange":"cbpro","pair":"BTC-USD","t":1565568000,"l":11222.4,"h":11555.55,"o":11540.76,"c":11389.28,"v":6095.28181493},{"exchange":"cbpro","pair":"BTC-USD","t":1565481600,"l":11088.88,"h":11585,"o":11280.95,"c":11540.76,"v":7329.58936485},{"exchange":"cbpro","pair":"BTC-USD","t":1565395200,"l":11170,"h":11969.99,"o":11860.62,"c":11280.95,"v":13852.24742434},{"exchange":"cbpro","pair":"BTC-USD","t":1565308800,"l":11651.89,"h":12040,"o":11982.39,"c":11856.1,"v":11774.51896894},{"exchange":"cbpro","pair":"BTC-USD","t":1565222400,"l":11451,"h":12050,"o":11983.41,"c":11981,"v":14887.10999049},{"exchange":"cbpro","pair":"BTC-USD","t":1565136000,"l":11366.26,"h":12147,"o":11465.49,"c":11975.03,"v":22145.48730119},{"exchange":"cbpro","pair":"BTC-USD","t":1565049600,"l":11187,"h":12320.4,"o":11811.75,"c":11465.49,"v":24773.04936684},{"exchange":"cbpro","pair":"BTC-USD","t":1564963200,"l":10977.98,"h":11950,"o":10977.98,"c":11819.49,"v":23345.19630495},{"exchange":"cbpro","pair":"BTC-USD","t":1564876800,"l":10572,"h":11089.74,"o":10822.09,"c":10977.51,"v":11813.6738868},{"exchange":"cbpro","pair":"BTC-USD","t":1564790400,"l":10500,"h":10922.08,"o":10533.62,"c":10820.76,"v":10082.35714313},{"exchange":"cbpro","pair":"BTC-USD","t":1564704000,"l":10321.42,"h":10670,"o":10404.41,"c":10533.01,"v":13217.84401203},{"exchange":"cbpro","pair":"BTC-USD","t":1564617600,"l":9881,"h":10497,"o":10089.97,"c":10405.94,"v":14432.5695627},{"exchange":"cbpro","pair":"BTC-USD","t":1564531200,"l":9570.01,"h":10135.12,"o":9589.01,"c":10087.3,"v":12849.73773412},{"exchange":"cbpro","pair":"BTC-USD","t":1564444800,"l":9371.96,"h":9839.83,"o":9499.21,"c":9589.01,"v":9411.16267094},{"exchange":"cbpro","pair":"BTC-USD","t":1564358400,"l":9356.75,"h":9729.87,"o":9533,"c":9495.01,"v":10565.16661892},{"exchange":"cbpro","pair":"BTC-USD","t":1564272000,"l":9108.88,"h":9669.11,"o":9469.37,"c":9533,"v":10054.74987437},{"exchange":"cbpro","pair":"BTC-USD","t":1564185600,"l":9292,"h":10248.41,"o":9843,"c":9479.98,"v":18982.08417104},{"exchange":"cbpro","pair":"BTC-USD","t":1564099200,"l":9657.21,"h":9898.03,"o":9880.86,"c":9843,"v":10732.61028519},{"exchange":"cbpro","pair":"BTC-USD","t":1564012800,"l":9734.58,"h":10184.99,"o":9772.59,"c":9883.33,"v":13297.27954025},{"exchange":"cbpro","pair":"BTC-USD","t":1563926400,"l":9507.38,"h":9919.08,"o":9848.9,"c":9772.6,"v":18264.50732336},{"exchange":"cbpro","pair":"BTC-USD","t":1563840000,"l":9800.23,"h":10324.28,"o":10324.13,"c":9840.12,"v":18059.22175271},{"exchange":"cbpro","pair":"BTC-USD","t":1563753600,"l":10060,"h":10688.14,"o":10590.71,"c":10323.39,"v":15798.9279419},{"exchange":"cbpro","pair":"BTC-USD","t":1563667200,"l":10320,"h":10835,"o":10761.03,"c":10590.7,"v":11939.86553507},{"exchange":"cbpro","pair":"BTC-USD","t":1563580800,"l":10360.65,"h":11112.31,"o":10536.92,"c":10761.03,"v":18390.4921253},{"exchange":"cbpro","pair":"BTC-USD","t":1563494400,"l":10111,"h":10777.21,"o":10652.76,"c":10538.06,"v":19729.47932166},{"exchange":"cbpro","pair":"BTC-USD","t":1563408000,"l":9291,"h":10799,"o":9696.39,"c":10649.07,"v":33044.50123646},{"exchange":"cbpro","pair":"BTC-USD","t":1563321600,"l":9071,"h":9998,"o":9429.8,"c":9696.31,"v":35319.410925},{"exchange":"cbpro","pair":"BTC-USD","t":1563235200,"l":9350,"h":11040,"o":10856.41,"c":9422.72,"v":43610.3814887},{"exchange":"cbpro","pair":"BTC-USD","t":1563148800,"l":9857.27,"h":11080.01,"o":10190.91,"c":10854.47,"v":34137.37304062},{"exchange":"cbpro","pair":"BTC-USD","t":1563062400,"l":10084.4,"h":11467.27,"o":11370.06,"c":10185.03,"v":25829.61014172},{"exchange":"cbpro","pair":"BTC-USD","t":1562976000,"l":10814.4,"h":11845,"o":11797.53,"c":11370.08,"v":18417.60494114},{"exchange":"cbpro","pair":"BTC-USD","t":1562889600,"l":11079.59,"h":11950,"o":11348.56,"c":11802,"v":18541.25295757},{"exchange":"cbpro","pair":"BTC-USD","t":1562803200,"l":10933,"h":12097.93,"o":12097.48,"c":11349,"v":37301.32072503},{"exchange":"cbpro","pair":"BTC-USD","t":1562716800,"l":11553.21,"h":13202.63,"o":12572.12,"c":12097.96,"v":41379.8431996},{"exchange":"cbpro","pair":"BTC-USD","t":1562630400,"l":12105.32,"h":12829.96,"o":12293.39,"c":12571.11,"v":27431.42201721},{"exchange":"cbpro","pair":"BTC-USD","t":1562544000,"l":11328.01,"h":12395,"o":11474.44,"c":12293.53,"v":20423.56124492},{"exchange":"cbpro","pair":"BTC-USD","t":1562457600,"l":11084.31,"h":11620,"o":11237.77,"c":11474.42,"v":11293.22901394},{"exchange":"cbpro","pair":"BTC-USD","t":1562371200,"l":10980.09,"h":11723.6,"o":10994.99,"c":11237.77,"v":15612.77821957},{"exchange":"cbpro","pair":"BTC-USD","t":1562284800,"l":10761.8,"h":11449.51,"o":11137.87,"c":11004.51,"v":20737.37976413},{"exchange":"cbpro","pair":"BTC-USD","t":1562198400,"l":11035.01,"h":12064.26,"o":11976.01,"c":11136,"v":22601.37480257},{"exchange":"cbpro","pair":"BTC-USD","t":1562112000,"l":10829.19,"h":12014.6,"o":10829.19,"c":11976.42,"v":38216.68004129},{"exchange":"cbpro","pair":"BTC-USD","t":1562025600,"l":9651,"h":10925,"o":10578.23,"c":10829.18,"v":43614.89365309},{"exchange":"cbpro","pair":"BTC-USD","t":1561939200,"l":9953,"h":11210.52,"o":10761.26,"c":10577.63,"v":39825.95471069},{"exchange":"cbpro","pair":"BTC-USD","t":1561852800,"l":10650.06,"h":12200,"o":11869.84,"c":10761.26,"v":28722.48538952},{"exchange":"cbpro","pair":"BTC-USD","t":1561766400,"l":11318.94,"h":12379.99,"o":12360.42,"c":11865.29,"v":28879.34994129},{"exchange":"cbpro","pair":"BTC-USD","t":1561680000,"l":10737.87,"h":12444.77,"o":11159.29,"c":12360.45,"v":42092.85495596}]
import datetime as dt
import json
import os
import mplfinance as mpf
import pandas as pd
def read_json_file(file_name):
file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), file_name)
with open(file_path) as json_file:
data = json.load(json_file)
json_file.close()
return data
def structure_data(data, columns):
# convert array of objects to dataframe
df = pd.DataFrame(data)
#rename columns
df = df.rename(index=str, columns=columns)
#replace NaN with 0
df.fillna(0, inplace = True)
# drop extra columns
df = df.drop(columns=['pair', 'exchange'])
#reorder columns
df = df[['date', 'open', 'high', 'low', 'close']]
#convert date column from unix seconds to datetime object
df['date'] = pd.to_datetime(df['date'],unit='s')
#set date column as index
df = df.set_index('date')
return df
error1 = True
if error1:
columns = {
't': 'date',
'c' : 'close',
'o' : 'open',
'h' : 'high',
'l': 'low',
'v' : 'volume'
}
else:
columns = {
't': 'Date',
'c' : 'Close',
'o' : 'Open',
'h' : 'High',
'l': 'Low',
'v' : 'Volume'
}
#read data
file_name = 'fixture.json'
data = read_json_file(file_name)
df = structure_data(data, columns)
print(df.iloc[0:10])
mpf.plot(df, type='candle')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment