The contract trading system is a derivative product of digital assets.Users can gain gains from the rise/fall of the price of digital assets by judging the rise and fall and choosing to buy long or sell short contracts.The contract trading system uses the differential delivery mode.When the contract expires,all open positions will be closed according to the arithmetic average price of the last period of the index price,rather than physical delivery
def in_longhu(ts_code,date):
date=str(date)
y=date[0:4]
m=date[4:6]
d=date[6:8]
global market
#date=y+-+m+-+d
path=./longhudata/
faceDir=Path(path)
if faceDir.exists():
file_dir=path+market+date+.csv
else:
os.mkdir(faceDir)
file_dir=path+market+date+.csv
#判断文件是否存在,不存在则通过网络接口获得
if os.path.exists(file_dir):【更全面的开发源码搭建可看我昵称】
df=pd.read_csv(file_dir)
codes=df[ts_code].values
else:
#初始化pro接口
pro=ts.pro_api(ee5c0e991e17949cdafbcf8ec42321ef4bac94e9ca3474e4d62313a3)
df=pro.top_list(trade_date=date)
df.to_csv(file_dir,index=False,encoding="utf_8_sig")
codes=df[ts_code].values
#print(codes)
for c in codes:
if c==ts_code:
print(c,ts_code,date,True)
return True
#print(date,ts_code,False)
return False
def get_gainian():
pro=ts.pro_api(ee5c0e991e17949cdafbcf8ec42321ef4bac94e9ca3474e4d62313a3)