Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:Bitcoin价格更新程序中断“;股票“;“Excel中的函数”#价值&引用;错误_Python_Excel_Pandas_Automation_Bitcoin - Fatal编程技术网

Python:Bitcoin价格更新程序中断“;股票“;“Excel中的函数”#价值&引用;错误

Python:Bitcoin价格更新程序中断“;股票“;“Excel中的函数”#价值&引用;错误,python,excel,pandas,automation,bitcoin,Python,Excel,Pandas,Automation,Bitcoin,背景: 我使用Excel来跟踪我的资产和财务状况。使用Excel内置的“股票”功能(在“数据”选项卡中),我能够跟踪股票价格。最近,我将比特币添加到我的投资组合中,所以很自然地,我希望自动跟踪比特币的价格以及我的其他资产 流程和代码: import cryptocompare import pandas as pd from pandas import ExcelWriter import openpyxl from openpyxl import load_workbook #Getting

背景: 我使用Excel来跟踪我的资产和财务状况。使用Excel内置的“股票”功能(在“数据”选项卡中),我能够跟踪股票价格。最近,我将比特币添加到我的投资组合中,所以很自然地,我希望自动跟踪比特币的价格以及我的其他资产

流程和代码:

import cryptocompare
import pandas as pd
from pandas import ExcelWriter
import openpyxl
from openpyxl import load_workbook

#Getting price of BTC
BTC = cryptocompare.get_price('BTC', currency='AUD', full=False)
df = pd.DataFrame(BTC)

#Sending price to new excel workbook "bitcoin_price"
writer.ExcelWriter(r'C:\Documents\Finance\bitcoin_price.xlsx')
df.to_excel(writer, 'Crypto_prices')
writer.save()

#Sending "Crypto_prices" sheet from "bitcoin_price" to existing "asset_tracker" workbook
price = pd.read_excel(r'C:\Documents\Finance\bitcoin_price.xlsx', sheet_name='Crypto_prices')
book = load_workbook(r'C:\Documents\Finance\Asset_tracker.xlsx')
writer = pd.ExcelWriter(r'C:\Documents\Finance\Asset_tracker.xlsx', engine='openpyxl')
writer.book = book
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
price.to_excel(writer, 'Crypto_prices')
writer.save()
问题: 当我运行脚本(在Anaconda中,runipy BTC_update.ipynb)时,“加密价格”表将成功发送到“资产跟踪器”工作簿。但是,所有在excel中使用“Stocks”功能的股票代码都将替换为“#VALUE!”错误。我已经尝试用相应的股票代码符号替换错误,启用“Stocks”功能,并再次运行脚本以显示相同的错误

有没有一种方法可以将加密价格表发送到asset_tracker工作簿,而不破坏预先存在的“Stocks”功能?或者,我如何在excel工作簿中跟踪比特币的价格而不破坏“股票”功能