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()
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.