examples moved to archive
This commit is contained in:
23
archive/examples/4_line_indicators/line_indicators.py
Normal file
23
archive/examples/4_line_indicators/line_indicators.py
Normal file
@ -0,0 +1,23 @@
|
||||
import pandas as pd
|
||||
from lightweight_charts import Chart
|
||||
|
||||
|
||||
def calculate_sma(df, period: int = 50):
|
||||
return pd.DataFrame({
|
||||
'time': df['date'],
|
||||
f'SMA {period}': df['close'].rolling(window=period).mean()
|
||||
}).dropna()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
chart = Chart()
|
||||
chart.legend(visible=True)
|
||||
|
||||
df = pd.read_csv('ohlcv.csv')
|
||||
chart.set(df)
|
||||
|
||||
line = chart.create_line('SMA 50')
|
||||
sma_data = calculate_sma(df, period=50)
|
||||
line.set(sma_data)
|
||||
|
||||
chart.show(block=True)
|
||||
Reference in New Issue
Block a user