# Path: OpenTrader/PandasMt4.py
# def oReadMt4Csv(sResampledCsv, sTimeFrame, sSymbol, sYear=""):
#     global dDF_OHLC
#     sKey = sSymbol + sTimeFrame + sYear
#     if sKey not in dDF_OHLC:
#         print "INFO: reading " + sResampledCsv
#         dDF_OHLC[sKey] = pandas.read_csv(sResampledCsv,
#                                          names=['T', 'O', 'H', 'L', 'C'],
#                                          parse_dates={'timestamp': ['T']},
#                                          index_col='timestamp',
#                                          dtype={'O': 'float64',
#                                                 'H': 'float64',
#                                                 'L': 'float64',
#                                                 'C': 'float64'})
#     return dDF_OHLC[sKey]


import sys
import os
import pandas
from collections import OrderedDict
from OpenTrader.PandasMt4 import oReadMt4Csv
    def __init__(self, sHdfStore="", oFd=sys.stdout):
        self.oHdfStore = None
        self.oFd = oFd
        if sHdfStore:
            # ugly - active
            self.oHdfStore = pandas.HDFStore(sHdfStore, mode='w')
            self.oFd.write("INFO: hdf store" +self.oHdfStore.filename +'\n')

        self.oRecipe = None
        self.oChefModule = None

    def oAddHdfStore(self, sHdfStore):
        if os.path.isabs(sHdfStore):
            assert os.path.isdir(os.path.dirname(sHdfStore)), \
                   "ERROR: directory not found: " +sHdfStore
        self.oHdfStore = pandas.HDFStore(sHdfStore, mode='w')
        self.oFd.write("INFO: hdf store: " +self.oHdfStore.filename +'\n')
        return self.oHdfStore
            
    def oRestore(self, sHdfStore):
        assert os.path.exists(sHdfStore)
        # FixMe:
        self.oHdfStore = None
        return self.oHdfStore
        
    # Is this an Omlette method? its generic and the use of self is tangential
    # It is because it adds components to the HDF fuke, which is the omlette.
    def dGetFeedFrame(self, sCsvFile, sTimeFrame, sSymbol, sYear):
        dFeedParams = OrderedDict(sTimeFrame=sTimeFrame, sSymbol=sSymbol, sYear=sYear)
        # PandasMt4.dDF_OHLC[sKey = sSymbol + sTimeFrame + sYear]

# Path: OpenTrader/PandasMt4.py
# def oReadMt4Csv(sResampledCsv, sTimeFrame, sSymbol, sYear=""):
#     global dDF_OHLC
#     sKey = sSymbol + sTimeFrame + sYear
#     if sKey not in dDF_OHLC:
#         print "INFO: reading " + sResampledCsv
#         dDF_OHLC[sKey] = pandas.read_csv(sResampledCsv,
#                                          names=['T', 'O', 'H', 'L', 'C'],
#                                          parse_dates={'timestamp': ['T']},
#                                          index_col='timestamp',
#                                          dtype={'O': 'float64',
#                                                 'H': 'float64',
#                                                 'L': 'float64',
#                                                 'C': 'float64'})
#     return dDF_OHLC[sKey]


# Path: OpenTrader/Omlettes/Omlette.py
import sys
import os
import pandas
from collections import OrderedDict
from OpenTrader.PandasMt4 import oReadMt4Csv

    def __init__(self, sHdfStore="", oFd=sys.stdout):
        self.oHdfStore = None
        self.oFd = oFd
        if sHdfStore:
            # ugly - active
            self.oHdfStore = pandas.HDFStore(sHdfStore, mode='w')
            self.oFd.write("INFO: hdf store" +self.oHdfStore.filename +'\n')

        self.oRecipe = None
        self.oChefModule = None

    def oAddHdfStore(self, sHdfStore):
        if os.path.isabs(sHdfStore):
            assert os.path.isdir(os.path.dirname(sHdfStore)), \
                   "ERROR: directory not found: " +sHdfStore
        self.oHdfStore = pandas.HDFStore(sHdfStore, mode='w')
        self.oFd.write("INFO: hdf store: " +self.oHdfStore.filename +'\n')
        return self.oHdfStore
            
    def oRestore(self, sHdfStore):
        assert os.path.exists(sHdfStore)
        # FixMe:
        self.oHdfStore = None
        return self.oHdfStore
        
    # Is this an Omlette method? its generic and the use of self is tangential
    # It is because it adds components to the HDF fuke, which is the omlette.
    def dGetFeedFrame(self, sCsvFile, sTimeFrame, sSymbol, sYear):
        dFeedParams = OrderedDict(sTimeFrame=sTimeFrame, sSymbol=sSymbol, sYear=sYear)
        # PandasMt4.dDF_OHLC[sKey = sSymbol + sTimeFrame + sYear]

        dFeedParams['mFeedOhlc'] = oReadMt4Csv(sCsvFile, **dFeedParams)