def control(asset):
    symbol = "{}USDT".format(asset)
    Prices = client.get_all_tickers()
    for price in Prices:
        if (price['symbol'] == symbol):
            current_price = float(price['price'])

    binanceWallet = wallet.find_one({'asset': asset})
    # try:
    if (binanceWallet['updated_price'] != 0):
        updated_price_new_array = []
        wallet_updated_price = binanceWallet['updated_price']
        total_wallet_updated_price = 0

        for u_price in wallet_updated_price:
            updated_price_new_array.append(float(u_price))
            total_wallet_updated_price += float(u_price)

        updated_price_new_array.append(current_price)
        total_wallet_updated_price += current_price

        average_of_updated_prices = total_wallet_updated_price / len(
            updated_price_new_array)
        last_updated_price = updated_price_new_array[
            len(updated_price_new_array) - 1]

        if len(updated_price_new_array) >= 5:
            if (average_of_updated_prices < last_updated_price):
                # if (average_of_updated_prices - ((average_of_updated_prices/100)*20) > last_updated_price):
                print("<b><blue>Binance Wallet Sat Sinyali</blue> </b>")
                print("<b><green>Ortalama düştü</green>")
                print("<b>{} <red>⬇</red></b>".format(asset))
                notify_ending("{} Satış Sinyali".format(asset))
            else:
                print("<b>{} <blue>⬆</blue></b>".format(asset))
                condition = {"asset": asset}
                update_data = {
                    "$set": {
                        "updated_price": updated_price_new_array
                    }
                }
                wallet.update_one(condition, update_data)

        else:
            print("<b>{} <blue>⬆</blue></b>".format(asset))
            condition = {"asset": asset}
            update_data = {"$set": {"updated_price": updated_price_new_array}}
            wallet.update_one(condition, update_data)

    else:
        updated_price_init = []
        try:
            updated_price_init.append(current_price)
        except:
            updated_price_init.append(0)
            pass
        condition = {"asset": asset}
        update_data = {"$set": {"updated_price": updated_price_init}}
        wallet.update_one(condition, update_data)
        pass
Beispiel #2
0
def sell(asset):
    acc = client.get_account()
    balances = acc['balances']
    symbol = "{}USDT".format(asset)
    for balance in balances:
        if balance['asset'] != symbol:
            qty = float(balance['free'])
            print(qty)
Beispiel #3
0
def auth_refresh_token(url_root, token_refresh):
    url = url_root + '/autentificare/refresh'
    req_headers = {'Authorization': f'Bearer {token_refresh}'}
    request = requests.post(url, headers=req_headers)

    if request.status_code == 200:
        print(f'<green>** raspuns server:</green> {request.json()["msg"]}')
        return request.json()["access_token"]
    print(f'<red>** raspuns server:</red> {request.json()["msg"]}')
    sys.exit()
Beispiel #4
0
 async def initialize_obsws(self, ctx):
     print(f"initializing obs with loop: {self.loop}")
     self.obs_ws = simpleobsws.obsws(
             host=os.environ["HOSTNAME"],
             port=os.environ["PORT"],
             password=os.environ["PASSWORD"]
             #loop=self.loop
             )
     self.loop.create_task(self.obs_ws.connect())
     return
Beispiel #5
0
 async def set_visible(self, ctx=None, sceneItem=None, boolean=True):
     if ctx:
         sceneItem = ctx.message.content.split()[1:]
         if len(sceneItem) > 1: # Scene item and bool passed as arg
             sceneItem, boolean = sceneItem[0], sceneItem[1]
         else:
             sceneItem = sceneItem[0]
         print(sceneItem, boolean)
     request = "SetSceneItemProperties"
     result = await self.make_request(request, {'item': sceneItem, 'visible': boolean})
     return
Beispiel #6
0
    async def toggle_src(self, sourceName, sceneName=None):
        # Get source property, check if render is True if it is set render to false, else true
        data = {"item": sourceName}
        request = "GetSceneItemProperties"
        result = await self.make_request(request, data)
        print(f"Current scene item settings from result: ", result)

        curr_visibility = result["visible"]
        data = {"sourceName": sourceName, "sourceSettings": {"render": True}}
        result = await self.make_request("SetSourceSettings", data)
        print(f"Render set to true {result}")
#        try: # TODO: get render
#            render = result["sourceSettings"]["render"]
#        except KeyError:
#            render = False
        new_visibility = not curr_visibility
        if not sceneName:
            data = {"item": sourceName, "visible": new_visibility}

        request = "SetSceneItemProperties"
        result = await self.make_request(request, data)
        return
Beispiel #7
0
 async def cam_refresh(self, ctx):
     request = "SetSourceSettings"
     print("Shutting off cam")
     await self.make_request(request, {'sourceName':"HDWebcam", 'sourceSettings': {'active': False}})
     print("Turning Camera Back On")
     result = await self.make_request(request, {'sourceName':"HDWebcam", 'sourceSettings': {'active': True}})
     print(result)
     # await ctx.send("No, stop it")
     return
Beispiel #8
0
def auth(url_root, email, password):
    url_auth = url_root + '/autentificare/login'

    data = {'email': email, 'password': password}

    try:
        request = requests.post(url_auth, json=data)
    except requests.exceptions.ConnectionError as exc:  # This is the correct syntax
        print(exc)
        sys.exit(1)

    if request.status_code == 200:
        token_refresh = request.json()['refresh_token']
        token_access = request.json()['access_token']
        print(f'<green>** raspuns server:</green> {request.json()["msg"]}')
    else:
        print(f'<red>** adresa:</red> {request.url}')
        print(f'<red>** raspuns server:</red> {request.text}')
        sys.exit()

    return token_access, token_refresh
Beispiel #9
0
def get_date_medici(url_root, token_access, token_refresh, lista_medic):
    date_medici = []
    for id in enumerate(tqdm(lista_medic)):

        url = url_root + f'/medic/{id[1]}'
        req_headers = {'Authorization': f'Bearer {token_access}'}
        request = requests.get(url, headers=req_headers)

        if request.status_code == 401:
            print(f'<yellow>** token-ul de access a expirat</yellow>')
            token_access = auth_refresh_token(url_root, token_refresh)
            req_headers = {'Authorization': f'Bearer {token_access}'}
            request = requests.get(url, headers=req_headers)
            if request.status_code != 200:
                print(f'<red>** adresa:</red> {request.url}')
                print(f'<red>** raspuns server:</red> {request.text}')

        date_medici.append(request.json()['medic'])

    return date_medici
Beispiel #10
0
def get_lista_medic(url_root, token_access, token_refresh):
    url = url_root + '/cmj/raport/lista_medic'
    lista_medic = []

    req_headers = {'Authorization': f'Bearer {token_access}'}
    request = requests.get(url, headers=req_headers)

    if request.status_code == 404:
        print(f'<red>** adresa api este incorecta</red> {request.url}')
        sys.exit()
    if request.status_code == 401:
        print(f'<yellow>** token-ul de access a expirat</yellow>')
        auth_token = auth_refresh_token(url_root, token_refresh)

        request = requests.get(url, headers=req_headers)

    if request.status_code == 200:
        lista_medic = request.json()['lista_medic']
        print(
            f'<green>** server.</green> get lista medici id <green>OK</green>')

    return token_access, lista_medic
Beispiel #11
0
def get_registre(url_root, token_auth, token_refresh):
    url = url_root + '/registre'

    req_headers = {'Authorization': f'Bearer {token_auth}'}
    request = requests.get(url, headers=req_headers)

    nume_fisier = f"export/registre_{date.today()}.json"
    os.makedirs(os.path.dirname(nume_fisier), exist_ok=True)
    with open(nume_fisier, "w") as outfile:
        json.dump(request.json(), outfile)

    if request.status_code == 404:
        print(f'<red>** adresa api este incorecta</red> {request.url}')
        sys.exit()
    if request.status_code == 401:
        print(f'<yellow>** token-ul de access a expirat</yellow>')
        auth_token = auth_refresh_token(url_root, token_refresh)

        request = requests.get(url, headers=req_headers)

    if request.status_code == 200:
        print(f'<green>** server.</green> get registre <green>OK</green>')

    return token_auth
Beispiel #12
0
    for item in hotwallet:
        if (item['asset']) == 'USDT':
            tether = item['qty']
        if (item['asset']) != 'USDT':
            for candle in candles:
                if (candle['symbol'] == item['asset']):
                    current_price = float(candle['price'])
            assetUSDT += item['qty'] * current_price
            totalUSDT = assetUSDT + tether

            profit = tether - (wallet_limit -
                               walletdb.count_documents({})) * per

    Table.add_row([
        title, '{}'.format(round(tether, 2)), '{} $'.format(round(profit, 2)),
        '% {}'.format(round(round(round(profit, 5) / 500, 5) * 100,
                            2)), wallet_limit,
        walletdb.count_documents({}),
        watchdb.count_documents({}),
        solddb.count_documents({}), '{} $'.format(round(totalUSDT, 2))
    ])


i = 1
while i <= 9:
    do(i)
    i += 1

print(Table)
Beispiel #13
0
def doTests(urlToTest):

    originalDomain, ratio = testInScope(urlToTest)
    if ratio >= 0.7:

        print("<green>LID_tests.py > DEBUG : " + urlToTest +
              " in scope</green>")

        print("LID_tests.py > DEBUG : Beginning buzzword testing")
        buzzwordGrade = testBuzzword(urlToTest)
        print("<bold>LID_tests.py > DEBUG : " + urlToTest + " graded " +
              str(buzzwordGrade) + " in buzzword testing</bold>")

        print("LID_tests.py > DEBUG : Beginning hyphen testing")
        hyphenGrade = testManyWeirdChar(urlToTest, '-')
        print("<bold>LID_tests.py > DEBUG : " + urlToTest +
              " has many hyphens ? " + str(hyphenGrade) + "</bold>")

        print("LID_tests.py > DEBUG : Beginning dot testing")
        dotsGrade = testManyWeirdChar(urlToTest, '.')
        print("<bold>LID_tests.py > DEBUG : " + urlToTest +
              " has many dots ? " + str(dotsGrade) + "</bold>")

        finalGrade = finalGrading(ratio, buzzwordGrade, hyphenGrade, dotsGrade)
        print("<bold>LID_tests.py > DEBUG : " + urlToTest +
              "\'s final grade is " + str(finalGrade) + "</bold>")

        if finalGrade >= 20.0:
            Lstix.writeStix(urlToTest, finalGrade)

    else:
        # print("<red>LID_tests.py > DEBUG : " + urlToTest + " not in scope</red>")
        return
Beispiel #14
0
def do(asset):

    # sys.stdout.write(asset)

    result = PMAX(getCandles(asset))

    WatchList = track.find_one({'asset': asset}, sort=[('_id', DESCENDING)])
    WalletList = wallet.find_one({'asset': asset}, sort=[('_id', DESCENDING)])

    current_pmax = result['pmX_4_0.1_4_7'][len(result) - 1]
    last_pmax = result['pmX_4_0.1_4_7'][len(result) - 2]

    index = 0
    numpy_data = []
    while index <= 5:
        numpy_data.append({
            'open':
            result['open'][index + (len(result) - 6)],
            'high':
            result['high'][index + (len(result) - 6)],
            'low':
            result['low'][index + (len(result) - 6)],
            'close':
            result['close'][index + (len(result) - 6)],
            'volume':
            result['volume'][index + (len(result) - 6)],
            'ATR_4':
            result['ATR_4'][index + (len(result) - 6)],
            'MA_7_4':
            result['MA_7_4'][index + (len(result) - 6)],
            'pm_4_0_1_4_7':
            result['pm_4_0.1_4_7'][index + (len(result) - 6)],
            'pmX_4_0_1_4_7':
            result['pmX_4_0.1_4_7'][index + (len(result) - 6)],
        })
        index += 1

    # Eğer Watchlist elemanı negatif değere düştüyse listeden çıkar
    if (WatchList != None):  # İzleme Listesindeyse
        time.sleep(1)

        try:
            candles = client.get_all_tickers()
        except:
            time.sleep(30)
            candles = client.get_all_tickers()
            pass

        buy_price = float(WatchList['buy_price'])
        for candle in candles:
            if (candle['symbol'] == asset):
                current_price = float(candle['price'])
                if (current_price < buy_price):
                    track.delete_one({'asset': asset})
                    print(
                        "<b><blue>Fiyat düştüğü için izleme listesinden çıkarıldı</blue> </b>"
                    )
                    print("<b>{}</b>".format(asset))

    if (last_pmax != current_pmax):
        # Satış mantığı, fiyat Pmax'e göre düşüşteyse sat. Bu kısım zarara girmeden satış yapamadı
        if (current_pmax == "down"):
            if (WalletList != None):  # Cüzdanda ise

                time.sleep(1)
                Prices = client.get_all_tickers()
                for price in Prices:
                    if (price['symbol'] == asset):
                        current_price = float(price['price'])

                _buy_price = float(WalletList['buy_price'])
                _percentage = (
                    (current_price - _buy_price) / current_price) * 100

                # %3 kâr olmadığı sürece elde tut
                if (_percentage > 3):
                    Notify.notify(asset,
                                  'Satış Alarmı - Pmax',
                                  'Trader V3',
                                  sound=True)
                    print("<b><blue>SATILDI</blue> </b>")
                    print("<b><green>Pmax Sinyali</green>")
                    print("<b>{}</b>".format(asset))

                    # Silinecek
                    WatchList = track.find_one({'asset': asset},
                                               sort=[('_id', DESCENDING)])
                    WalletList = wallet.find_one({'asset': asset},
                                                 sort=[('_id', DESCENDING)])

                    # print('WalletList', WalletList)
                    # print('Watchlist', WatchList)

                    Notify.notify(asset, 'SATIŞ', 'Trader V3', sound=True)
                    # Silinecek

                    sold.insert_one({
                        'asset':
                        asset,
                        'pmax':
                        result['pmX_4_0.1_4_7'][len(result) - 1],
                        'sold_price':
                        result['close'][len(result) - 1],
                        'buy_data':
                        WalletList,
                        'sold_time':
                        datetime.now(),
                        'candle_data':
                        numpy_data,
                        'reason':
                        'Pmax',
                    })
                    wallet.delete_one({'asset': asset})
        else:
            #  UP ise
            if (WatchList == None):  # Takip listesinde değilse
                if (WalletList == None):  # Cüzdanda değilse
                    # Notify.notify(asset, 'WatchList Aktif', 'Trader V3', sound=True)

                    print("<b><green>Takip Listesine Alındı</green> </b>")
                    print("<b>{}</b>".format(asset))
                    print("<b><fg 0,95,0><white>{}</white></fg 0,95,0></b>".
                          format(result))

                    track.insert_one({
                        'asset':
                        asset,
                        'pmax':
                        result['pmX_4_0.1_4_7'][len(result) - 1],
                        'buy_price':
                        result['close'][len(result) - 1],
                        'buy_time':
                        datetime.now(),
                        'candle_data':
                        numpy_data,
                    })
            else:  # Takip listesindeyse
                if (WalletList == None):  # Cüzdanda değilse
                    time.sleep(1)
                    try:
                        candles = client.get_all_tickers()
                    except:
                        time.sleep(30)
                        candles = client.get_all_tickers()
                        pass

                    for candle in candles:
                        if (candle['symbol'] == asset):
                            current_price = float(candle['price'])
                    buy_price = WatchList['buy_price']
                    percentage = (
                        (current_price - buy_price) / current_price) * 100
                    if (percentage >= 3):
                        # Notify.notify(asset, 'Alım Sinyali %3', 'Trader V3', sound=True)
                        print("<b><blue>SATIN ALINDI</blue> </b>")
                        print("<b>{}</b>".format(asset))
                        print(
                            "<b><fg 0,95,0><white>{}</white></fg 0,95,0></b>".
                            format(result))
                        wallet.insert_one({
                            'asset': asset,
                            'buy_price': current_price,
                            'buy_time': datetime.now(),
                            'track_data': WatchList,
                            'candle_data': numpy_data,
                        })
                        track.delete_one({'asset': asset})