marketTrade/market_trade/notebooks/autogen/Make unified candlesticks data import.py

54 lines
1.2 KiB
Python

#!/usr/bin/env python
# coding: utf-8
# Let's try to get filepath of any candlesticks file.
# In[2]:
import market_trade.constants
candlesticks_filepaths = [filepath for filepath in market_trade.constants.CANDLESTICK_DATASETS_PATH.iterdir()]
candlesticks_filepath = candlesticks_filepaths[0]
candlesticks_filepath
# Let's import that file to pandas
# In[18]:
import pandas as pd
# we set two rows as multiheader, and parse dates in index
candlesticks_df = pd.read_csv(candlesticks_filepath,index_col=0, header=[0,1], parse_dates=True)
candlesticks_df['date'] = candlesticks_df.index
candlesticks_df.reset_index(inplace=True, drop=True)
ask_candlesticks_df = candlesticks_df['ask']
ask_candlesticks_df.head()
# Everything imported beatifully.
# In[17]:
"""
extract from test signal file
"""
import market_trade.signals.Signal1
ind_params = {'MeanType': 'SMA', 'window': 5, 'valueType': 'low', 'kDev': 2}
# df_candle[:3000],ind_params,True,False,True
# window 5..100 (5) | valueType: 'open', 'low' | 'kdev' : 1..4 (0.1)
indEl1 = {
'df': ask_candlesticks_df[:3000],
'params': ind_params,
'needFig': False,
'showOnlyIndex': False,
'drawFig': True
}
a = market_trade.signals.Signal1.SignalBollingerBands1({'BB': indEl1})