stock-indicators-python
stock-indicators-python copied to clipboard
Python.Runtime.PythonException: 'dict' value cannot be converted to Skender.Stock.Indicators.Quote
What happened?
Python.Runtime.PythonException: 'dict' value cannot be converted to Skender.Stock.Indicators.Quote
The above exception was the direct cause of the following exception:
System.ArgumentException: 'dict' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote) ---> Python.Runtime.PythonException: 'dict' value cannot be converted to Skender.Stock.Indicators.Quote --- End of inner exception stack trace ---
The above exception was the direct cause of the following exception:
System.AggregateException: One or more errors occurred. ('dict' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote)) ---> System.ArgumentException: 'dict' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote) ---> Python.Runtime.PythonException: 'dict' value cannot be converted to Skender.Stock.Indicators.Quote --- End of inner exception stack trace --- --- End of inner exception stack trace ---
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Administrator\e.py", line 29, in
Code usage
import pandas as pd
import matplotlib.pyplot as plt
from stock_indicators import indicators
from stock_indicators import EndType
def load_historical_data(filename):
data = pd.read_csv(filename)
data['timestamp'] = pd.to_datetime(data['timestamp'])
quotes = []
for index, row in data.iterrows():
quotes.append({
'timestamp': row['timestamp'],
'close': row['close'],
'high': row['high'],
'low': row['low']
})
return quotes
quotes = load_historical_data('Price.csv')
results = indicators.get_zig_zag(quotes, EndType.CLOSE, 3)
results_df = pd.DataFrame(results)
print(results_df)
plt.figure(figsize=(14, 7))
plt.plot(results_df['timestamp'], results_df['zigzag'], label='ZigZag', color='red')
plt.plot([q['timestamp'] for q in quotes], [q['close'] for q in quotes], label='Close Price', color='blue', alpha=0.5)
plt.title('ZigZag Indicator with Close Prices')
plt.xlabel('Date')
plt.ylabel('Price')
plt.xticks(rotation=45)
plt.legend()
plt.grid()
plt.tight_layout()
plt.savefig('zigzag_plot.png')
plt.close()
Log output
No response