import time
from binance.client import Client

# Замените на свои ключи API
api_key = 'Ваш API ключ'
api_secret = 'Ваш API секрет'

client = Client(api_key, api_secret)

def buy(symbol, quantity, price):
try:
order = client.create_order(
symbol=symbol,
side=Client.SIDE_BUY,
type=Client.ORDER_TYPE_LIMIT,
timeInForce=Client.TIME_IN_FORCE_GTC,
quantity=quantity,
price=price
)
print(f"Покупка {quantity} {symbol} по цене {price}")
return order
except Exception as e:
print(f"Ошибка при покупке: {e}")
return None

def sell(symbol, quantity, price):
try:
order = client.create_order(
symbol=symbol,
side=Client.SIDE_SELL,
type=Client.ORDER_TYPE_LIMIT,
timeInForce=Client.TIME_IN_FORCE_GTC,
quantity=quantity,
price=price
)
print(f"Продажа {quantity} {symbol} по цене {price}")
return order
except Exception as e:
print(f"Ошибка при продаже: {e}")
return None

def main():
symbol = 'BTCUSDT' # Торговая пара
buy_quantity = 1.0 # Количество криптовалюты для покупки
buy_price = 50000.0 # Цена покупки

while True:
# Ваша стратегия торговли здесь
# Например, вы можете использовать анализ рынка для принятия решения о покупке и продаже.

# Покупка
buy(symbol, buy_quantity, buy_price)

# Продажа
sell(symbol, buy_quantity, buy_price)

time.sleep(60) # Подождать 60 секунд перед следующей итерацией

if __name__ == "__main__":
main()
Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.