Open acemi1 opened 2 years ago
#from parameters import *
from binance.spot import Spot as Client # python3 -m pip install python-binance #pip install binance-connector
import pandas as pd
import pandas_ta as ta
from functions import cross_above as crossA
# import talib
spot_client = Client(key="", secret="")
# Sembol için geçerli olan ortalama fiyat
def avg_price(coinName: str):
coin_avg = spot_client.avg_price(symbol=str(coinName))
return coin_avg['price']
# print(avg_price('BTCUSDT'))
# borsa Verileri
def exchangeInfo(coinName: str):
exc = spot_client.exchange_info(symbol=str(coinName))
return exc
# mum verileri
def spot_klinesCoin(coinName: str, period: str, limit: int = None):
kline = spot_client.klines(symbol=str(coinName), interval=str(period), limit=limit)
return kline
# 24 saatlik değişimin verisi
def ticker24h(coinName: str):
hticker24 = spot_client.ticker_24hr(symbol=str(coinName))
return hticker24
# fiyat
def price(coinName: str):
return spot_client.ticker_price(symbol=str(coinName))['price']
# timestamp
def serverTime():
return spot_client.time()['serverTime']
# emir defteri
def book(coinName: str, limit: int):
return spot_client.depth(symbol=coinName, limit=limit)
# tüm spot verileri
def spot_all_symbols():
response = spot_client.exchange_info()
return list(map(lambda symbol: symbol['symbol'], response['symbols']))
# spottaki tüm koinleri sınıflandırma
usdtList = []
btcList = []
ethList = []
for coin in spot_all_symbols():
if 'USDT' in coin and 'UP' not in coin and 'DOWN' not in coin:
usdtList.append(coin)
elif 'BTC' in coin:
btcList.append(coin)
elif 'ETH' in coin:
ethList.append(coin)
# print (coin)
# print (usdtList)
# içerisine aktarılan kline veriyi sınıflandırma, dataframe'e dönüştürme
def spot_symbols_data(coinName: str, period: str, limit: int):
kline = spot_klinesCoin(coinName=coinName, period=period, limit=limit)
converted = pd.DataFrame(kline, columns=['open_time', 'open', 'high', 'low', 'close', 'volume', 'close_time',
'quote_asset_volume', 'number_of_trades', 'tbbav', 'tbqav', 'ignore'],
dtype=float)
return converted
# print(spot_symbols_data(coinName='BTCUSDT', period='1h',limit=50))
#btc_data = spot_symbols_data(coinName='BTCUSDT', period='1h', limit=250)
#rsi = ta.rsi(btc_data['close'], 14)
#print(rsi)
def explorer(coinList):
result = []
value = 70
period ='1d'
for coin in coinList:
data = spot_symbols_data(coinName=coin, period=period, limit=500)
#rsi = ta.rsi(data['close'], 14)
sma20 = ta.sma(data['close'], 20)
sma50 = ta.sma(data['close'], 50)
# if rsi[len(rsi) - 1] > value:
# result.append(coin)
# print(f"{coin}'in {period} zaman diliminde RSI değeri {value} den büyüktür")
if crossA(sma20,sma50):
result.append(coin)
print(f"{coin}'in {period} zaman diliminde hareketli ortalama kesişimi var.")
print ("------------- Liste sonuna gelindi -------------")
# print (f"RSI Değeri {value}' den büyük olan coinler : \n {result} \n ")
# print(f"RSI Değeri {value}' den büyük olan coinler : \n {result} \n Coin sayısı : {len(result)}")
explorer(usdtList)
Traceback (most recent call last): File "C:/pythondene/binance-spot-market.py", line 110, in
explorer(usdtList)
File "C:/pythondene/binance-spot-market.py", line 101, in explorer
if crossA(sma20,sma50):
File "C:\pythondene\functions.py", line 88, in cross_above
if pre_short < pre_long and short > long:
TypeError: '<' not supported between instances of 'float' and 'NoneType'Traceback (most recent call last):
File "C:/pythondene/binance-spot-market.py", line 110, in
explorer(usdtList)
File "C:/pythondene/binance-spot-market.py", line 101, in explorer
if crossA(sma20,sma50):
File "C:\pythondene\functions.py", line 88, in cross_above
if pre_short < pre_long and short > long:
TypeError: '<' not supported between instances of 'float' and 'NoneType'
sma değerlerini sma2 ve sma5 olarak değiştirirsem tarama yapıyor. ve aşağıdaki hatayı veriyor pre_short = series_a.iloc[-2] AttributeError: 'NoneType' object has no attribute 'iloc'