Python Trading - Script - Py
Python Trading - Script - Py
import pandas as pd
import time
# Binance connection
exchange = ccxt.binance({
'apiKey': api_key,
'secret': api_secret,
})
# Trading parameters
symbol = 'BTC/USDT'
timeframe = '1m'
trad_size = 40 # Traditional Renko size
volume_threshold = 500 # Minimum volume for drawing line (in BTC)
line_duration_days = 2 # Duration for which the line should be valid
# Main loop
while True:
# Fetch 1-minute data
ohlcv = exchange.fetch_ohlcv(symbol, timeframe)
df = pd.DataFrame(ohlcv, columns=['timestamp', 'open', 'high', 'low', 'close',
'volume'])
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
df.set_index('timestamp', inplace=True)
# Generate signals
signals_df = generate_signals(renko_df)