diff --git a/.idea/csv-plugin.xml b/.idea/csv-plugin.xml
new file mode 100644
index 0000000..888d63f
--- /dev/null
+++ b/.idea/csv-plugin.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8edf60b..bd67bfe 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,7 @@
+
+
+
\ No newline at end of file
diff --git a/market_trade/constants.py b/market_trade/constants.py
index 48f3fd8..b925ef2 100644
--- a/market_trade/constants.py
+++ b/market_trade/constants.py
@@ -2,4 +2,6 @@ import pathlib
ROOT_PATH = pathlib.Path(__file__).parent.parent
_CANDLESTICK_DATASETS_RELATIVE_PATH = pathlib.Path('data/candlesticks')
+_TEST_CANDLESTICK_RELATIVE_PATH = pathlib.Path('data/EURUSD_price_candlestick.csv')
CANDLESTICK_DATASETS_PATH = ROOT_PATH / _CANDLESTICK_DATASETS_RELATIVE_PATH
+TEST_CANDLESTICKS_PATH = ROOT_PATH / _TEST_CANDLESTICK_RELATIVE_PATH
diff --git a/market_trade/dataloader.py b/market_trade/dataloader.py
new file mode 100644
index 0000000..e48308a
--- /dev/null
+++ b/market_trade/dataloader.py
@@ -0,0 +1,28 @@
+import pandas as pd
+
+
+class DukaMTInterface:
+ """
+ Interface between my askbid candlesticks and sasha's price candlesticks
+
+ has two attributes -- bids and asks
+ """
+
+ def __init__(self, duka_candlesticks_filepath):
+ # reading index from column 0 and header takes two rows, because of multirow indexers
+ self.duka_dataset = pd.read_csv(duka_candlesticks_filepath, index_col=0, header=[0, 1], parse_dates=True)
+
+ # renaming timestamp to date
+ self.duka_dataset['date'] = self.duka_dataset.index
+
+ # droppnig old timestamp index
+ self.duka_dataset.reset_index(inplace=True, drop=True)
+
+
+ # adding bids
+ self.bid_candlesticks = self.duka_dataset['bid'].copy()
+ self.bid_candlesticks['date'] = self.duka_dataset['date']
+
+ # adding asks
+ self.ask_candlesticks = self.duka_dataset['ask'].copy()
+ self.ask_candlesticks['date'] = self.duka_dataset['date']
diff --git a/market_trade/notebooks/autogen/Make unified candlesticks data import.py b/market_trade/notebooks/autogen/Make unified candlesticks data import.py
index 1d40725..0dca64f 100644
--- a/market_trade/notebooks/autogen/Make unified candlesticks data import.py
+++ b/market_trade/notebooks/autogen/Make unified candlesticks data import.py
@@ -3,7 +3,7 @@
# Let's try to get filepath of any candlesticks file.
-# In[2]:
+# In[1]:
import market_trade.constants
@@ -15,7 +15,7 @@ candlesticks_filepath
# Let's import that file to pandas
-# In[18]:
+# In[2]:
import pandas as pd
@@ -24,13 +24,22 @@ import pandas as pd
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 = candlesticks_df['ask'].copy()
ask_candlesticks_df.head()
-# Everything imported beatifully.
+# Everything imported beatifully, let's attach the date to it
-# In[17]:
+# In[3]:
+
+
+ask_candlesticks_df['date'] = candlesticks_df['date']
+ask_candlesticks_df.head()
+
+
+# Let's test it
+
+# In[4]:
"""
@@ -43,11 +52,115 @@ 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],
+ 'df': ask_candlesticks_df,
'params': ind_params,
'needFig': False,
'showOnlyIndex': False,
'drawFig': True
}
a = market_trade.signals.Signal1.SignalBollingerBands1({'BB': indEl1})
+a.analiz
+
+
+# Let's test that i didn't broke the file. Let's import test file, and compare results.
+#
+# Importing
+
+# In[5]:
+
+
+test_candlesticks = pd.read_csv(market_trade.constants.TEST_CANDLESTICKS_PATH)
+test_candlesticks['date'] = test_candlesticks['timestamp']
+test_candlesticks.drop(['timestamp'], axis=1, inplace=True)
+test_candlesticks.head()
+
+
+# Comparing results
+
+# In[6]:
+
+
+"""
+expected results
+{'chstota': 0.3555926544240401,
+ 'zeroNum %': 0.5963272120200334,
+ 't %': 0.37963272120200336,
+ 'f %': 0.024040066777963272,
+ 'toch': 0.9404466501240695}
+"""
+
+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': test_candlesticks[:3000],
+ 'params': ind_params,
+ 'needFig': False,
+ 'showOnlyIndex': False,
+ 'drawFig': True
+}
+a = market_trade.signals.Signal1.SignalBollingerBands1({'BB': indEl1})
+a.analiz
+
+
+# Nice! And lets try full file
+
+# In[16]:
+
+
+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': test_candlesticks[:10000],
+ 'params': ind_params,
+ 'needFig': False,
+ 'showOnlyIndex': False,
+ 'drawFig': True
+}
+a = market_trade.signals.Signal1.SignalBollingerBands1({'BB': indEl1})
+a.analiz
+
+
+# Let's test our file loading
+
+# In[8]:
+
+
+candlesticks_filepaths
+
+
+# Let's choose EURUSD candletsicks
+
+# In[11]:
+
+
+candlesticks_filepath = candlesticks_filepaths[5]
+
+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'].copy()
+ask_candlesticks_df['date'] = candlesticks_df['date']
+ask_candlesticks_df.head()
+
+
+# Let's test
+
+# In[15]:
+
+
+ind_params = {'MeanType': 'SMA', 'window': 5, 'valueType': 'low', 'kDev': 2}
+indEl1 = {
+ 'df': ask_candlesticks_df[:10000],
+ 'params': ind_params,
+ 'needFig': False,
+ 'showOnlyIndex': False,
+ 'drawFig': True
+}
+a = market_trade.signals.Signal1.SignalBollingerBands1({'BB': indEl1})
+a.analiz
diff --git a/market_trade/tests/test_dataloader.py b/market_trade/tests/test_dataloader.py
new file mode 100644
index 0000000..8884091
--- /dev/null
+++ b/market_trade/tests/test_dataloader.py
@@ -0,0 +1,12 @@
+import market_trade.dataloader
+import market_trade.constants
+
+def test_dataloader(data_path):
+ duka_interface = (market_trade.dataloader.DukaMTInterface(data_path))
+ print(duka_interface.ask_candlesticks)
+
+
+if __name__ == '__main__':
+ candlesticks_filepaths = [filepath for filepath in market_trade.constants.CANDLESTICK_DATASETS_PATH.iterdir()]
+ candlesticks_filepath = candlesticks_filepaths[0]
+ test_dataloader(candlesticks_filepath)
\ No newline at end of file