mercoledì 26 agosto 2020

PYTHON - MA and BOOKORDER SCALPING


Scalping signal indicator written in python. It is based on Binance data.
The simpleBinanceFut.py module can be downloaded from GitHub.
https://github.com/DanielePorcari/simpleBinanceFutures

import simpleBinanceFut as sBF

def MA(dati,periodo):
    ris=0
    i=len(dati)-1
    for c in range(periodo):
        if i>=periodo:
            prezzo=(float(dati[i][4]))
            ris=ris+prezzo
            i-=1
    ris=ris/periodo
    return ris

def bookBot(up):
    volMax=0
    priceMax=0
    if up:
        for i in range(len(book['bids'])):
            price=float(book['bids'][i][0])
            vol=float(book['bids'][i][1])
            if float(vol)>float(volMax):
                volMax=vol
                priceMax=price
        print("Buy: ",priceMax)
        volMax=0
        priceMax=0
        for i in range(len(book['asks'])):
            price=book['asks'][i][0]
            vol=book['asks'][i][1]
            if float(vol)>float(volMax):
                volMax=vol
                priceMax=price
        print("TP: ",priceMax)
    else:
        for i in range(len(book['asks'])):
            price=float(book['asks'][i][0])
            vol=float(book['asks'][i][1])
            if float(vol)>float(volMax):
                volMax=vol
                priceMax=price
        print("Sell: ",priceMax)
        volMax=0
        priceMax=0
        for i in range(len(book['bids'])):
            price=book['bids'][i][0]
            vol=book['bids'][i][1]
            if float(vol)>float(volMax):
                volMax=vol
                priceMax=price
        print("TP: ",priceMax)

coppia=input("Insert asset: ")
print("Last price: ",sBF.fbin_ultimo_prezzo(coppia))
tf=input("Insert tf:")
book=sBF.fbin_book(coppia)
prezzi=sBF.fbin_candlestick(coppia,tf,"99")
ma9=MA(prezzi,50)
ma25=MA(prezzi,25)
if ma9>ma25:
    up=True
else:
    up=False
bookBot(up)

Nessun commento:

Posta un commento