- Главная
- Сообщество
- Программирование
- Newbie - struggling to export community sentiment data
Advertisement
Edit Your Comment
Newbie - struggling to export community sentiment data
Участник с Dec 18, 2010
2 комментариев
Oct 24, 2024 at 09:56
Участник с Dec 18, 2010
2 комментариев
Hi all,
Please can you help me to confirm the correct API Key / token to use to pull sentiment data.
When I have the correct key, will this basic script do the job?
..................................
import requests
import csv
import datetime
import time
# Your Myfxbook API credentials
API_KEY = '?' # Replace with actual API key
def get_sentiment_data():
endpoint = "https://www.myfxbook.com/api/get-community-outlook.json"
params = {'session': API_KEY}
response = requests.get(endpoint, params=params)
if response.status_code == 200:
data = response.json()
if data['error'] == 0:
return data['outlook']
else:
print(f"Error: {data['message']}")
return None
else:
print(f"Failed to retrieve data. Status code: {response.status_code}")
return None
def save_to_csv(data):
filename = 'sentiment_data.csv'
with open(filename, mode='a', newline='') as file:
writer = csv.writer(file)
# Write the header if the file is new
if file.tell() == 0:
writer.writerow(['Date', 'Symbol', 'Short Percentage', 'Long Percentage', 'Short Volume', 'Long Volume'])
for symbol in data['symbols']:
writer.writerow([
datetime.datetime.now().strftime("%Y-%m-%d"),
symbol['name'],
symbol['shortPercentage'],
symbol['longPercentage'],
symbol['shortVolume'],
symbol['longVolume']
])
def main():
while True:
sentiment_data = get_sentiment_data()
if sentiment_data:
save_to_csv(sentiment_data)
time.sleep(86400) # Sleep for 24 hours
if __name__ == "__main__":
main()
......................
Thanks in advance
Jason
Please can you help me to confirm the correct API Key / token to use to pull sentiment data.
When I have the correct key, will this basic script do the job?
..................................
import requests
import csv
import datetime
import time
# Your Myfxbook API credentials
API_KEY = '?' # Replace with actual API key
def get_sentiment_data():
endpoint = "https://www.myfxbook.com/api/get-community-outlook.json"
params = {'session': API_KEY}
response = requests.get(endpoint, params=params)
if response.status_code == 200:
data = response.json()
if data['error'] == 0:
return data['outlook']
else:
print(f"Error: {data['message']}")
return None
else:
print(f"Failed to retrieve data. Status code: {response.status_code}")
return None
def save_to_csv(data):
filename = 'sentiment_data.csv'
with open(filename, mode='a', newline='') as file:
writer = csv.writer(file)
# Write the header if the file is new
if file.tell() == 0:
writer.writerow(['Date', 'Symbol', 'Short Percentage', 'Long Percentage', 'Short Volume', 'Long Volume'])
for symbol in data['symbols']:
writer.writerow([
datetime.datetime.now().strftime("%Y-%m-%d"),
symbol['name'],
symbol['shortPercentage'],
symbol['longPercentage'],
symbol['shortVolume'],
symbol['longVolume']
])
def main():
while True:
sentiment_data = get_sentiment_data()
if sentiment_data:
save_to_csv(sentiment_data)
time.sleep(86400) # Sleep for 24 hours
if __name__ == "__main__":
main()
......................
Thanks in advance
Jason
The trader is as big as the things that make him angry.
Участник с Oct 17, 2024
2 комментариев
Nov 23, 2024 at 11:11
Участник с Oct 17, 2024
2 комментариев
Hi.
Just wondered if you figured this out, as I'm vurrently trying to do the same tbing.
AJM
Just wondered if you figured this out, as I'm vurrently trying to do the same tbing.
AJM
Участник с Dec 18, 2010
2 комментариев
Dec 15, 2024 at 15:01
Участник с Dec 18, 2010
2 комментариев
Hi AJM,
Sadly not. FXCM Support say that it cannot be done.
Sadly not. FXCM Support say that it cannot be done.
The trader is as big as the things that make him angry.

*Коммерческое использование и спам не допускаются и могут привести к аннулированию аккаунта.
Совет: Размещенные изображения или ссылки на Youtube автоматически вставляются в ваше сообщение!
Совет: введите знак @ для автоматического заполнения имени пользователя, участвующего в этом обсуждении.