コード例 #1
0
ファイル: collect_history.py プロジェクト: marciowsaraiva/IQ
class HistoryCollector(object):
    """Calss for IQ Option API starter."""
    def __init__(self, config):
        self.config = config

        self.api = IQOption(self.config.get_broker_hostname(),
                            self.config.get_broker_username(),
                            self.config.get_broker_password())

        self.db = psycopg2.connect(database=config.get_db_postgres_database(),
                                   user=config.get_db_postgres_username(),
                                   host=config.get_db_postgres_hostname(),
                                   password=config.get_db_postgres_password())

        active_name = config.get_active()
        active_helper = ActiveHelper(self.db)
        self.active = {
            "name": active_name,
            "db_id": active_helper.get_id_by_name(active_name),
            "platform_id": api_constants.ACTIVES[active_name]
        }

        self.create_connection()

    def create_connection(self):
        """Method for create connection to IQ Option API."""
        logger = logging.getLogger(__name__)
        logger.info("Create connection.")
        self.api.connect()
        self.api.setactives([self.active["platform_id"]])
        logger.info("Successfully connected.")
コード例 #2
0
class Starter(object):
    """Calss for IQ Option API starter."""

    def __init__(self, config):
        """
        :param config: The instance of :class:`Settings
            <iqpy.settings.settigns.Settings>`.
        """
        self.config = config
        self.active = self.config.get_active()
        self.broker = self.config.get_broker()
        self.api = IQOption(
            self.config.get_broker_hostname(),
            self.config.get_broker_username(),
            self.config.get_broker_password()
        )
        self.create_connection()
        self.db = psycopg2.connect(
            database=self.config.get_db_postgres_database(),
            user=self.config.get_db_postgres_username(),
            host=self.config.get_db_postgres_hostname(),
            password=self.config.get_db_postgres_password()
        )

    def create_connection(self):
        """Method for create connection to IQ Option API."""
        logger = logging.getLogger(__name__)
        logger.info("Create connection for active '%s'.", self.active)
        self.api.connect()
        logger.info("Successfully connected for active '%s'.", self.active)

    def analyzer(self):
        analyzer = create_analyzer(self.api, self.active, self.db)
        return analyzer
コード例 #3
0
ファイル: collect_history.py プロジェクト: marciowsaraiva/IQ
class HistoryCollector(object):
    """Calss for IQ Option API starter."""
    def __init__(self, config, setting_id):
        self.config = config

        self.api = IQOption(self.config.get_broker_hostname(),
                            self.config.get_broker_username(),
                            self.config.get_broker_password())

        self.db = psycopg2.connect(database=config.get_db_postgres_database(),
                                   user=config.get_db_postgres_username(),
                                   host=config.get_db_postgres_hostname(),
                                   password=config.get_db_postgres_password())

        self.settings = Settings(self.db, setting_id)
        if self.settings.error:
            print "Error:", self.settings.error
            sys.exit(1)

        self.create_connection()

    def create_connection(self):
        """Method for create connection to IQ Option API."""
        logger = logging.getLogger(__name__)
        logger.info("Create connection.")
        self.api.connect()
        self.api.setactives([self.settings.active["platform_id"]])
        logger.info("Successfully connected.")
コード例 #4
0
ファイル: starter.py プロジェクト: marciowsaraiva/IQ
    def __init__(self, config, setting_id):
        self.config = config

        self.redis = redis.StrictRedis(
            host=self.config.get_db_redis_hostname(),
            port=self.config.get_db_redis_port(),
            db=self.config.get_db_redis_db())

        self.db = psycopg2.connect(
            database=self.config.get_db_postgres_database(),
            user=self.config.get_db_postgres_username(),
            host=self.config.get_db_postgres_hostname(),
            password=self.config.get_db_postgres_password()
        )

        self.api = IQOption(
            self.config.get_broker_hostname(),
            self.config.get_broker_username(),
            self.config.get_broker_password()
        )

        self.settings = Settings(self.db, setting_id)
        if self.settings.error:
            print "Error:", self.settings.error
            sys.exit(1)

        self.create_connection()
コード例 #5
0
ファイル: starter.py プロジェクト: marciowsaraiva/IQ
class Starter(object):
    """Calss for IQ Option API starter."""

    def __init__(self, config, setting_id):
        self.config = config

        self.redis = redis.StrictRedis(
            host=self.config.get_db_redis_hostname(),
            port=self.config.get_db_redis_port(),
            db=self.config.get_db_redis_db())

        self.db = psycopg2.connect(
            database=self.config.get_db_postgres_database(),
            user=self.config.get_db_postgres_username(),
            host=self.config.get_db_postgres_hostname(),
            password=self.config.get_db_postgres_password()
        )

        self.api = IQOption(
            self.config.get_broker_hostname(),
            self.config.get_broker_username(),
            self.config.get_broker_password()
        )

        self.settings = Settings(self.db, setting_id)
        if self.settings.error:
            print "Error:", self.settings.error
            sys.exit(1)

        self.create_connection()

    def create_connection(self):
        """Method for create connection to IQ Option API."""
        logger = logging.getLogger(__name__)
        logger.info("Create connection for active '%s'.", self.settings.active["name"])
        self.api.connect()
        logger.info("Successfully connected for active '%s'.", self.settings.active["name"])

    def start_collector(self):
        """Method for start signalers."""
        logger = logging.getLogger("collector")
        logger.info("Create collector for active '%s'.", self.settings.active["name"])
        return create_collector(self.api, self.db, self.settings)
コード例 #6
0
 def __init__(self, config):
     """
     :param config: The instance of :class:`Settings
         <iqpy.settings.settigns.Settings>`.
     """
     self.config = config
     self.active = self.config.get_active()
     self.broker = self.config.get_broker()
     self.api = IQOption(
         self.config.get_broker_hostname(),
         self.config.get_broker_username(),
         self.config.get_broker_password()
     )
     self.create_connection()
     self.db = psycopg2.connect(
         database=self.config.get_db_postgres_database(),
         user=self.config.get_db_postgres_username(),
         host=self.config.get_db_postgres_hostname(),
         password=self.config.get_db_postgres_password()
     )
コード例 #7
0
ファイル: collect_history.py プロジェクト: marciowsaraiva/IQ
    def __init__(self, config):
        self.config = config

        self.api = IQOption(self.config.get_broker_hostname(),
                            self.config.get_broker_username(),
                            self.config.get_broker_password())

        self.db = psycopg2.connect(database=config.get_db_postgres_database(),
                                   user=config.get_db_postgres_username(),
                                   host=config.get_db_postgres_hostname(),
                                   password=config.get_db_postgres_password())

        active_name = config.get_active()
        active_helper = ActiveHelper(self.db)
        self.active = {
            "name": active_name,
            "db_id": active_helper.get_id_by_name(active_name),
            "platform_id": api_constants.ACTIVES[active_name]
        }

        self.create_connection()