我在Pymongo中发挥了拖曳功能,但是我想要的是与从功能中获得的不同想法有所不同?
节省关闭,符号,时间范围
def Save_(self,collection,symbol,price,TF):
db = self.get_db('MTF')[collection]
B = {'ts':time.time(),"Symbol":symbol,
"Price":price,'TimeFrame':TF}
data = db.insert_one(B)
return data
获取数据
def find_all(self,collection):
db = self.get_db('MTF')[collection]
Symbols ={}
data = db.find({})
for i in data:
Symbols[i['Symbol']] = [i['Price'],i['TimeFrame']]
return Symbols
功能的函数从mongodb [2]: https://i.sstatic.net/rltnz.png
功能 [1]: https://i.sstatic.net/atwsy.png
如果您看到的话函数B的图像仅在时间范围内给了我,但是功能保存有4个时间范围
Funtion that save Close,Symbol, Timeframe
def Save_(self,collection,symbol,price,TF):
db = self.get_db('MTF')[collection]
B = {'ts':time.time(),"Symbol":symbol,
"Price":price,'TimeFrame':TF}
data = db.insert_one(B)
return data
Function to get data from mongodb
def find_all(self,collection):
db = self.get_db('MTF')[collection]
Symbols ={}
data = db.find({})
for i in data:
Symbols[i['Symbol']] = [i['Price'],i['TimeFrame']]
return Symbols
images from mongodb
[2]: https://i.sstatic.net/RLtnz.png
images from B Function
[1]: https://i.sstatic.net/AtwSy.png
if u see the image from Function B only gave me on timeframe but Function Save have 4 timeframe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看此循环:
如果您的
符号
来自MongoDB,它将覆盖任何先前的值,因此您只会获得每个符号的最终值,这就是您所看到的。要修复它,您有一些选项:您可以检查键并创建值或将值附加到符号;或者,您可以在汇总查询中使用
$ push
。Looking at this loop:
If you have the same
Symbol
coming from MongoDB, it will overwrite any previous value, so you will only get the final value for each Symbol which is what you are seeing.To fix it you have a few options: you could check the key and either create or append the values to Symbols; or you could use
$push
in an aggregate query.