首页 > 其他分享 >001量化项目总结 --01获取实时价格

001量化项目总结 --01获取实时价格

时间:2024-05-02 17:44:36浏览次数:19  
标签:01 -- s1 value 001 sip scode key sport

一、获取实时价格

def tdxgetprice(self,scode):                               # 取实时价格
price =0.0
pmarkcode =0
sip =''
sport =0
time_now =datetime.now().minute

if (scode[0]=='0' and scode[1]=='0') or scode[0]=='3':
pmarkcode=0
else:
pmarkcode=1

api = TdxHq_API()
if time_now%2==0 and time_now%4==0:
sip='218.*.51.*'
sport =7709
elif time_now%2==0 and time_now%4!=0:

sip='*.235.*.14'
sport=7711
else:
sip='*.73.48.*'
sport=7709
with api.connect(sip,sport):
data = api.get_security_quotes([pmarkcode,scode])
cdata = api.get_company_info_category(pmarkcode,scode)
d1= collections.OrderedDict()
d1 = data[0]
#print(d1)
for key ,value in d1.items():
if key=='price':
price= value
api.disconnect()
return price
二、返回当日数据 价格 成交量 开盘, 最低、最高价格。
def getnewdata(self, scode):  # 

s1 = []
Date1 = str(datetime.now().date())
s1.insert(0, Date1)
napi = TdxHq_API()
sip = self.getserverip()[0]
sport = self.getserverip()[1]
markcode = int(self.getmarkcode(scode))
with napi.connect(sip, sport):
ndata = napi.get_security_quotes([markcode, scode])
d1 = ndata[0]

for key, value in d1.items():
if key == 'open':
s1.insert(1, value)
if key == 'price':
s1.insert(2, value)
if key == 'high':
s1.insert(3, value)
if key == 'low':
s1.insert(4, value)
if key == 'amount':
s1.insert(5, value)
napi.disconnect()

return s1

标签:01,--,s1,value,001,sip,scode,key,sport
From: https://www.cnblogs.com/lionmxs/p/18170370

相关文章

  • 001量化项目总结 --02获取五档买盘价格
    一、获取五档买盘price=0.0pmarkcode=0sip=''sport=0l1=[]time_now=datetime.now().minuteif(scode[0]=='0'andscode[1]=='0')orscode[0]=='3':pmarkcode=0else:pmarkcode=1api=TdxHq_API()iftime_no......
  • WPF CollectionViewSource ICollectionViewLiveShaping IsLiveSorting
    <Windowx:Class="WpfApp82.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.......
  • 树链剖分
    树链剖分我们一般使用重链剖分,就是子树大的先剖分,应为这样可以保证时间在\(log_n\)如图,先按照\(dfs\)序遍历出有一棵树,那么\(dfs\)序就是\([1,2,3,4,5,6,7,8,9]\),如果碰到一条边上\(dfn[f]-dfn[u]!=1\)则断一次,就可以剖出链了,如图,链为\([1,2,3][4,5]......
  • SpringBoot中分页插件PageHelper的使用
    SpringBoot如何使用PageHelper实现分页查询在原始的分页查询方法中,需要编写复杂的SQL语句来限制查询结果的范围,通常需要使用LIMIT或者ROWNUM等数据库特定的语法来实现分页。在每个需要分页的查询方法中,都需要手动计算分页的起始位置和偏移量,通常需要根据页码和每页数量来计算,这部......
  • SystemVerilog -- 2.4 Data Types ~ SystemVerilog Arrays
    SystemVerilogArraysSystemVerilog在通过不同类型的数组构建复杂的数据结构方面提供了很大的灵活性。静态阵列动态阵列关联数组队列StaticArrays静态数组是指其大小在编译时间之前已知的数组。在下面显示的示例中,声明了一个8位宽的静态数组,为其分配了一些值并循环访问......
  • 对于 CF1107E 中 dp 状态设计的一点想法
    不太想发到洛谷讨论区,就往这里放了。我觉得现有的题解都没说明白为什么本题的状态和转移能覆盖所有情况,并且感觉也非常不自然,没见过的话感觉挺难发现这么一个东西。然而这个dp其实是可以自然地推导出来的。首先发现这个过程非常难以描述,主要原因在于很难刻画一个局面。然而,如......
  • 使用LinkAI创建AI智能体,并快速接入到微信/企微/公众号/钉钉/飞书..
    ​ LinkAI作为企业级一站式AIAgent智能体搭建与接入平台,不仅为用户和客户提供能够快速搭建具备行业知识和个性化设定的AI智能体的能力;还基于企业级场景提供丰富的应用接入能力,让智能体不再是“玩具”,而是真正能够落地应用提升生产力的“工具”。​ 现在,你可以使用LinkAI创建......
  • 基于CodeMirror开发在线编辑器时遇到的问题及解决方案
    需求:实现json在线编辑并支持校验,基于此使用了CodeMirror在线编辑,jsonlint校验输入数据//package.json:"dependencies":{"codemirror":"^5.53.2","core-js":"^3.8.3","jsonlint":"^1.6.3","vu......
  • 【VMware vCenter】连接和使用vCenter Server嵌入式vPostgres数据库。
    vCenterServer早期支持内嵌(embedded)和外部(external)数据库,内嵌数据库就是vPostgres,基于VMwarePostgres数据库(PostgreSQL数据库),外部数据库用的多的是Oracle数据库和SQLServer数据库。因为早期使用内嵌的PostgreSQL数据库只能用于小型环境,比如仅支持几十台主机以及几百个虚拟机,所......
  • 一个demo快速理解序列号和反序列化
    一个demo快速理解序列号和反序列化分享一个例子用来快速理解序列化和反序列化其实序列化和反序列化就是为了交换数据,(简单粗暴的理解就是把运行中的对象存进文件里面)importjava.io.*;publicclassMain{publicstaticvoidmain(String[]args)throwsException{......