Sök
Products
Community
Markets
News
Brokers
More
SV
Kom igång
Community
/
Idéer
/
waqar
AXS / TetherUS PERPETUAL CONTRACT
waqar
By w44629
Följ
Följ
4 okt. 2023
0
Heja
Heja
4 okt. 2023
import pandas as pd
import numpy as np
# Sample historical price data (replace with your own data)
data = {
'timestamp': ['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04', '2023-01-05'],
'price': [100, 110, 120, 130, 140]
}
# Create a DataFrame from the data
df = pd.DataFrame(data)
df['timestamp'] = pd.to_datetime(df['timestamp'])
df.set_index('timestamp', inplace=True)
# Define the period for the SMA
sma_period = 3 # You can adjust this to your preferred period
# Calculate the SMA
df['SMA'] = df['price'].rolling(window=sma_period).mean()
# Print the DataFrame with SMA values
print(df)
Trend Analysis
w44629
Följ
Frånsägelse av ansvar
Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i
Användarvillkoren
.