Exemple #1
0
 def __init__(self,
              name=None,
              username=None,
              pwd=None,
              raw=True,
              symbols=None,
              query=['quotation', 'orders', 'deal', 'info'],
              **kwargs):
     super().__init__(name=name, **kwargs)
     if (username == None):
         self.username = input('请输入新浪登录帐号:')
     else:
         self.username = username
     if (pwd == None):
         self.pwd = getpass.getpass("输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
     else:
         self.pwd = pwd
     self.rsaPubkey = '10001'
     self.ip = util.get_client_ip()
     self.session = requests.Session()
     a = requests.adapters.HTTPAdapter(pool_connections=10,
                                       pool_maxsize=100)
     self.session.mount("https://", a)
     self.isLogin = self.login()
     self.raw = raw
     self.query = query
     if symbols is None:
         sina = V('Sina')
         self.symbols = sina.get_symbols()
     else:
         self.symbols = symbols
Exemple #2
0
    def __init__(
            self,
            username=None,
            pwd=None,
            symbols=None,
            hq='hq_pjb',
            query=['quotation', 'transaction'],
            # ['quotation', 'orders', 'transaction', 'info']
            on_recv_data=None,  # 收到数据以后的回调函数
            use_logger=True,
            **kwargs):
        super().__init__(**kwargs)
        self.on_recv_data = on_recv_data  # 回调函数
        self.ip = util.get_client_ip()
        self.hq = hq
        self.query = query

        # 如果是dHydra框架内调用,则直接用框架内的Sina类,
        # 否则作为独立的类在外部调用
        try:
            self.sina = get_vendor('Sina')
        except Exception as e:
            self.sina = Sina()
        self.is_login = self.login()

        if symbols is None:
            self.symbols = self.sina.get_symbols()
        else:
            self.symbols = symbols
        self.websockets = dict()
Exemple #3
0
    def __init__(self, account="sina.json", login=False, **kwargs):
        super().__init__(**kwargs)
        config = util.read_config(os.path.join(os.getcwd(), account))

        if "username" in config.keys():
            self.username = config["username"]
        else:
            if login:
                self.username = input('请输入新浪登录帐号:')
            else:
                self.username = None


        if "password" in config.keys():
            self.pwd = config["password"]
        else:
            if login:
                self.pwd = getpass.getpass("输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
            else:
                self.username = None

        self.rsa_pubkey = '10001'
        self.ip = util.get_client_ip()
        self.session = requests.Session()
        self.quote = None
        self.is_login = False
Exemple #4
0
 def __init__(self,
              name=None,
              username=None,
              pwd=None,
              symbols=None,
              hq='hq_pjb',
              query=['quotation', 'orders', 'deal', 'info'],
              **kwargs):
     super().__init__(name=name, **kwargs)
     if (username == None):
         self.username = input('请输入新浪登录帐号:')
     else:
         self.username = username
     if (pwd == None):
         self.pwd = getpass.getpass("输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
     else:
         self.pwd = pwd
     self.rsaPubkey = '10001'
     self.ip = util.get_client_ip()
     self.session = requests.Session()
     self.hq = hq
     self.isLogin = self.login()
     self.query = query
     if symbols is None:
         sina = V('Sina')
         self.symbols = sina.get_symbols()
     else:
         self.symbols = symbols
     self.websockets = dict()
Exemple #5
0
	def __init__(self, username = None, pwd = None):
		super().__init__()
		if (username is None):
			if "sinaUsername" in config.keys():
				self.username = config["sinaUsername"]
			else:
				self.username = input('请输入新浪登录帐号:')
		else:
			self.username=username
		if (pwd is None):
			if "sinaPassword" in config.keys():
				self.pwd = config["sinaPassword"]
			else:
				self.pwd = getpass.getpass("输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
		else:
			self.pwd = pwd
		self.rsa_pubkey = '10001'
		self.ip = util.get_client_ip()
		self.session = requests.Session()
		self.quote = None
		self.is_login = False
		self.logger.info("正在从新浪获取全市场代码")
		try:
			self.symbols = self.get_symbols()
		except Exception as e:
			self.logger.warning(e)
Exemple #6
0
    def __init__(self, account="account/sina.json", login=False, **kwargs):
        super().__init__(**kwargs)
        config = util.read_config(os.path.join(os.getcwd(), account))

        if "username" in config.keys():
            self.username = config["username"]
        else:
            if login:
                self.username = input('请输入新浪登录帐号:')
            else:
                self.username = None


        if "password" in config.keys():
            self.pwd = config["password"]
        else:
            if login:
                self.pwd = getpass.getpass("输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
            else:
                self.username = None

        self.rsa_pubkey = '10001'
        self.ip = util.get_client_ip()
        self.session = requests.Session()
        self.quote = None
        self.is_login = False
Exemple #7
0
 def __init__(self, username=None, pwd=None):
     super().__init__()
     if (username is None):
         if "sinaUsername" in config.keys():
             self.username = config["sinaUsername"]
         else:
             self.username = input('请输入新浪登录帐号:')
     else:
         self.username = username
     if (pwd is None):
         if "sinaPassword" in config.keys():
             self.pwd = config["sinaPassword"]
         else:
             self.pwd = getpass.getpass("输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
     else:
         self.pwd = pwd
     self.rsa_pubkey = '10001'
     self.ip = util.get_client_ip()
     self.session = requests.Session()
     self.quote = None
     self.is_login = False
     self.logger.info("正在从新浪获取全市场代码")
     try:
         self.symbols = self.get_symbols()
     except Exception as e:
         self.logger.warning(e)
Exemple #8
0
	def __init__(self, name = None, username = None, pwd = None, symbols = None, hq = 'hq_pjb', query = ['quotation', 'orders', 'deal', 'info'], **kwargs):
		super().__init__( name=name, **kwargs )
		if (username is None):
			if "sinaUsername" in config.keys():
				self.username = config["sinaUsername"]
			else:
				self.username = input('请输入新浪登录帐号:')
		else:
			self.username=username
		if (pwd is None):
			if "sinaPassword" in config.keys():
				self.pwd = config["sinaPassword"]
			else:
				self.pwd = getpass.getpass("输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
		else:
			self.pwd = pwd
		self.rsaPubkey = '10001'
		self.ip = util.get_client_ip()
		self.session = requests.Session()
		self.hq = hq
		self.isLogin = self.login()
		self.query = query
		if symbols is None:
			sina = V('Sina')
			self.symbols = sina.get_symbols()
		else:
			self.symbols = symbols
		self.websockets = dict()
	def __init__(self, name = None, username = None, pwd = None, symbols = None, hq = 'hq_pjb', query = ['quotation', 'orders', 'deal', 'info'], **kwargs):
		super().__init__( name=name, **kwargs )
		self.ip = util.get_client_ip()
		self.hq = hq
		self.query = query
		# 登录模块在V('Sina')中
		self.sina = V('Sina')
		self.is_login = self.login()
		if symbols is None:
			self.symbols = self.sina.get_symbols()
		else:
			self.symbols = symbols
		self.websockets = dict()
Exemple #10
0
 def __init__(self,
              username=None,
              pwd=None,
              symbols=None,
              hq='hq_pjb',
              query=['quotation', 'orders', 'deal', 'info'],
              **kwargs):
     super().__init__(**kwargs)  # You are not supposed to change THIS
     self.ip = util.get_client_ip()
     self.hq = hq
     self.query = query
     self.sina = get_vendor('Sina')
     self.is_login = self.login()
     # symbols = ["sz000001"]
     if symbols is None:
         self.symbols = self.sina.get_symbols()
     else:
         self.symbols = symbols
     self.websockets = dict()
	def __init__(self, name = None, username = None, pwd = None,raw = False, symbols = None, query = ['quotation', 'orders', 'deal', 'info'], **kwargs):
		super().__init__( name=name, **kwargs )
		if (username == None):
			self.username = input('请输入新浪登录帐号:')
		else:
			self.username=username
		if (pwd == None):
			self.pwd = getpass.getpass("输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
		else:
			self.pwd = pwd
		self.rsaPubkey = '10001'
		self.ip = util.get_client_ip()
		self.session = requests.Session()
		self.isLogin = self.login()
		self.raw = raw
		self.query = query
		if symbols is None:
			sina = V('Sina')
			self.symbols = sina.get_symbols()
		else:
			self.symbols = symbols
Exemple #12
0
 def __init__(self, username=None, pwd=None, **kwargs):
     super().__init__(**kwargs)
     config = util.read_config(os.getcwd() + "/sina.json")
     if (username is None):
         if "username" in config.keys():
             self.username = config["username"]
         else:
             self.username = input('请输入新浪登录帐号:')
     else:
         self.username = username
     if (pwd is None):
         if "password" in config.keys():
             self.pwd = config["password"]
         else:
             self.pwd = getpass.getpass("输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
     else:
         self.pwd = pwd
     self.rsa_pubkey = '10001'
     self.ip = util.get_client_ip()
     self.session = requests.Session()
     self.quote = None
     self.is_login = False