Русский
Открыть в Telegram

Веткаfrom binance.client import Client

2 сообщения · –
В
from binance.client import Client import pandas as pd import datetime import pytz # Binance API credentials api_key = 'your_api_key' api_secret = 'your_api_secret' client = Client(api_key, api_secret) # Define the symbol for ETH/USDT pair symbol = 'ETHUSDT' # Define custom start and end time in UTC utc_zone = pytz.utc start_time = datetime.datetime(2023, 1, 1, 0, 0, 0, tzinfo=utc_zone) end_time = datetime.datetime(2023, 1, 1, 23, 59, 59, tzinfo=utc_zone) # Fetch minute level kline data for ETH/USDT for January 1st, 2023 klines = client.get_historical_klines(symbol=symbol, interval=Client.KLINE_INTERVAL_1MINUTE, start_str=start_time.isoformat(), end_str=end_time.isoformat()) # Convert the data into a pandas dataframe df = pd.DataFrame(klines, columns=['Open Time', 'Open', 'High', 'Low', 'Close', 'Volume', 'Close Time', 'Quote Asset Volume', 'Number of Trades', 'Taker Buy Base Asset Volume', 'Taker Buy Quote Asset Volume', 'Ignore']) # Convert relevant columns to floats columns_to_convert = ['Open', 'High', 'Low', 'Close', 'Volume'] df[columns_to_convert] = df[columns_to_convert].astype(float) # Calculate the weighted average trade price df['Weighted Price'] = df['Close'] * df['Volume'] weighted_average_price = df['Weighted Price'].sum() / df['Volume'].sum() print(f"Weighted average trade price for ETH/USDT on January 1st, 2023: {weighted_average_price}") # Calculate and print the sum of the first 8 digits after the comma sum_of_digits = sum(int(digit) for digit in f"{weighted_average_price:.8f}".split('.')[1][:8]) print(f"Sum of the first 8 digits after the comma: {sum_of_digits}")
  1. В
    всё получилось, нужно было другой ТФ брать для торговых свечей
ССообщество Python ПрограммистовСообщество Python Программистов@python_scripts · группа · Технологии
4 169участников43пишущих за 30 дней
Лента площадки Открыть в Telegram

Открытая публичная лента из поискового индекса ChatCrawler — «Google по публичному Telegram»; обновляется по мере обхода площадки. Время — UTC.

Только публичный контент, официальный API Telegram. О проекте · Вопросы · Границы индекса · Убрать страницу из выдачи · Каталог · Поиск · Как мы считаем