| | |
| | | """ |
| | | |
| | | # 股票代码相关的参数 |
| | | import decimal |
| | | import time |
| | | |
| | | import gpcode_manager |
| | | import mysql_data |
| | | import redis_manager |
| | | import tool |
| | | |
| | | _redisManager = redis_manager.RedisManager(0) |
| | | |
| | | |
| | | # 代码对应的价格是否正确 |
| | | def is_same_code_with_price(code, price): |
| | | # 昨日收盘价 |
| | | price_close = gpcode_manager.get_price_pre(code) |
| | | max_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal("1.1")) |
| | | min_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal("0.9")) |
| | | if min_price <= decimal.Decimal(str(price)) <= max_price: |
| | | return True |
| | | return False |
| | | |
| | | # 自由流通股本工具类 |
| | | class ZYLTGBUtil: |
| | |
| | | if val is not None: |
| | | return int(val) |
| | | return None |
| | | |
| | | @classmethod |
| | | def save_list(self, datasList): |
| | | # 保存自由流通市值 |
| | | mysqldb = mysql_data.Mysqldb() |
| | | for data in datasList: |
| | | # 保存 |
| | | _dict = {"_id": data["code"], "zyltgb": data["zyltgb"], "zyltgb_unit": data["zyltgb_unit"], |
| | | "update_time": int(round(time.time() * 1000))} |
| | | if float(data["zyltgb"]) > 0: |
| | | # 保存10天 |
| | | ZYLTGBUtil.save(data["code"], data["zyltgb"], data["zyltgb_unit"]) |
| | | result = mysqldb.select_one("select * from ths_zylt where _id='{}'".format(data["code"])) |
| | | if result is None: |
| | | mysqldb.execute( |
| | | "insert into ths_zylt(_id,zyltgb,zyltgb_unit,update_time) values ('{}','{}',{},{})".format( |
| | | data["code"], data["zyltgb"], data["zyltgb_unit"], round(time.time() * 1000))) |
| | | else: |
| | | mysqldb.execute( |
| | | "update ths_zylt set zyltgb='{}',zyltgb_unit={},update_time={} where _id='{}'".format( |
| | | data["zyltgb"], data["zyltgb_unit"], round(time.time() * 1000), data["code"])) |