# Path: zaifbot/exchange/candle_sticks.py
# class CandleSticks:
#     MAX_COUNT = 1500
# 
#     def __init__(self, currency_pair, period):
#         self._currency_pair = CurrencyPair(currency_pair)
#         self._period = Period(period)
#         self._dao = CandleSticksDao(self._currency_pair, self._period)
# 
#     def request_data(self, count=100, to_epoch_time=None):
#         count = min(count, self.MAX_COUNT)
#         to_epoch_time = int_epoch_time(to_epoch_time)
#         end_time_rounded = self._period.truncate_sec(to_epoch_time)
#         start_time = self._period.calc_start(count, end_time_rounded)
# 
#         return self._dao.get_by_duration(count, start_time, end_time_rounded)
# 
#     def last_price(self, timestamp):
#         return self.request_data(count=1, to_epoch_time=timestamp)[0]['close']
# 
# Path: zaifbot/exchange/currency_pairs.py
# class CurrencyPair:
#     _lock = Lock()
#     _instances = {}
# 
#     def __new__(cls, name):
#         with cls._lock:
#             name = str(name)
#             if cls._instances.get(name, None) is None:
#                 cls._instances[name] = super().__new__(cls)
#         return cls._instances[name]
# 
#     def __init__(self, name):
#         self._name = str(name)
#         self._info = _ZaifCurrencyPairsInfo()[self._name]
# 
#     def __str__(self):
#         return self._name
# 
#     @property
#     def name(self):
#         return self._name
# 
#     @property
#     def info(self):
#         return self._info
# 
#     @property
#     def is_token(self):
#         return self._info['is_token']
# 
# Path: zaifbot/exchange/period.py
# def Period(period):
#     for cls in _TradePeriod.__subclasses__():
#         if isinstance(period, str):
#             if cls.is_my_label(period):
#                 return cls(period)
#             continue
# 
#         if isinstance(period, int):
#             if cls.is_my_sec(period):
#                 return cls(period)
#             continue
# 
#         if isinstance(period, _TradePeriod):
#             return period
# 
#     raise ValueError('illegal argument received')


from abc import ABCMeta, abstractmethod
from talib import abstract
from pandas import DataFrame
from zaifbot.exchange.candle_sticks import CandleSticks
from zaifbot.exchange.currency_pairs import CurrencyPair
from zaifbot.exchange.period import Period


class Indicator(metaclass=ABCMeta):
    _MAX_LENGTH = 100
    _MAX_COUNT = 1000
    _NAME = None

    def __init__(self, currency_pair, period):

# Path: zaifbot/exchange/candle_sticks.py
# class CandleSticks:
#     MAX_COUNT = 1500
# 
#     def __init__(self, currency_pair, period):
#         self._currency_pair = CurrencyPair(currency_pair)
#         self._period = Period(period)
#         self._dao = CandleSticksDao(self._currency_pair, self._period)
# 
#     def request_data(self, count=100, to_epoch_time=None):
#         count = min(count, self.MAX_COUNT)
#         to_epoch_time = int_epoch_time(to_epoch_time)
#         end_time_rounded = self._period.truncate_sec(to_epoch_time)
#         start_time = self._period.calc_start(count, end_time_rounded)
# 
#         return self._dao.get_by_duration(count, start_time, end_time_rounded)
# 
#     def last_price(self, timestamp):
#         return self.request_data(count=1, to_epoch_time=timestamp)[0]['close']
# 
# Path: zaifbot/exchange/currency_pairs.py
# class CurrencyPair:
#     _lock = Lock()
#     _instances = {}
# 
#     def __new__(cls, name):
#         with cls._lock:
#             name = str(name)
#             if cls._instances.get(name, None) is None:
#                 cls._instances[name] = super().__new__(cls)
#         return cls._instances[name]
# 
#     def __init__(self, name):
#         self._name = str(name)
#         self._info = _ZaifCurrencyPairsInfo()[self._name]
# 
#     def __str__(self):
#         return self._name
# 
#     @property
#     def name(self):
#         return self._name
# 
#     @property
#     def info(self):
#         return self._info
# 
#     @property
#     def is_token(self):
#         return self._info['is_token']
# 
# Path: zaifbot/exchange/period.py
# def Period(period):
#     for cls in _TradePeriod.__subclasses__():
#         if isinstance(period, str):
#             if cls.is_my_label(period):
#                 return cls(period)
#             continue
# 
#         if isinstance(period, int):
#             if cls.is_my_sec(period):
#                 return cls(period)
#             continue
# 
#         if isinstance(period, _TradePeriod):
#             return period
# 
#     raise ValueError('illegal argument received')


# Path: zaifbot/indicators/indicator.py
from abc import ABCMeta, abstractmethod
from talib import abstract
from pandas import DataFrame
from zaifbot.exchange.candle_sticks import CandleSticks
from zaifbot.exchange.currency_pairs import CurrencyPair
from zaifbot.exchange.period import Period



class Indicator(metaclass=ABCMeta):
    _MAX_LENGTH = 100
    _MAX_COUNT = 1000
    _NAME = None

    def __init__(self, currency_pair, period):

        self._currency_pair = CurrencyPair(currency_pair)