Sunnatskilletskillet127

import ccxt import talib # Borsa API-ga ulanish exchange = ccxt

BITSTAMP:BTCUSD   Bitcoin
import ccxt
import talib

# Borsa API-ga ulanish
exchange = ccxt.binance({
'apiKey': 'sizning_api_key',
'secret': 'sizning_api_secret',
})

# Almashtirish nomi
symbol = 'BTC/USDT'

# Borsa kurslarini olish
def get_market_data(symbol, timeframe='1h', limit=100):
ohlcv = exchange.fetch_ohlcv(symbol, timeframe, limit)
close_prices = [candle for candle in ohlcv] # 4 - close
return close_prices

# Simple Moving Average (SMA) ni hisoblash
def calculate_sma(data, period=20):
return talib.SMA(data, timeperiod=period)

# Strategiya: Agar SMA ning o'rtacha narxi, joriy kursdan yuqori bo'lsa, sotish buyurtmasi bering
def trade_strategy(symbol, timeframe='1h', limit=100, sma_period=20):
close_prices = get_market_data(symbol, timeframe, limit)
sma_values = calculate_sma(close_prices, sma_period)

current_price = close_prices
last_sma_value = sma_values

if current_price > last_sma_value:
# Borsaga buyurtma jo'natish
place_order(symbol, 'buy', current_price, 0.001)
print(f'Sotish buyurtmasi berildi! Narxi: {current_price}')

# Buyurtma yaratish va borsaga jo'natish
def place_order(symbol, order_type, price, quantity):
order = exchange.create_limit_buy_order(symbol, quantity, price) if order_type == 'buy' else exchange.create_limit_sell_order(symbol, quantity, price)
return order

# Strategiyani har bir mumni tekshirish
trade_strategy(symbol)
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.