Пример #1
0
def _binanceTickerOps():
    # DESCR:    get tickers (xCoin-To-Bitcoin-Rate) for binance mainstream coins, spit them to splunk, update gsheet
    # ARGS:     none
    # UPDATES:  gSheet ([InterMarketLoop] tab ONLY
    # RETURNS:  nothing
    #
    BINcoinList = [
        "ETH", "LTC", "ETC", "XRP"
    ]  #NOTE THERE IS NO BITCOIN (AS WE ARE COMPARING TO BITCOIN!)
    BINdict = _BINANCE._BINapiNoAuth_getTickr("GET",
                                              "/api/v1/ticker/allPrices",
                                              BINcoinList)
    _OUTPUT._spitJSONoutToSplunk(BINdict)
    BINxCoinToBitcoinRatelist = [
        [
            "N/A",
            BINdict['ETH-BTC']['lastPrice'],
            BINdict['LTC-BTC']['lastPrice'],
            BINdict['ETC-BTC']['lastPrice'],
            "N/A",
            BINdict['XRP-BTC']['lastPrice'],
        ],
    ]
    _GOOGLE._publishToGoogleSheet(BINxCoinToBitcoinRatelist, 'USER_ENTERED',
                                  '[InterMarketLoop]!G8', 'COLUMNS')
    return
Пример #2
0
def _btcmAccountOps():
    balancesDict = _BTCMARKETS._BTCMapiAuth_getBal("GET", "/account/balance",
                                                   BTCMapiKeyPub_m,
                                                   BTCMapiKeyPri_m)
    _OUTPUT._spitJSONoutToSplunk(balancesDict)
    BTCMBalList = [
        [
            balancesDict['BTC-BAL']['balance'],
            balancesDict['ETH-BAL']['balance'],
            balancesDict['LTC-BAL']['balance'],
            balancesDict['ETC-BAL']['balance'],
            balancesDict['BCHABC-BAL']['balance'],
            balancesDict['XRP-BAL']['balance'],
            balancesDict['AUD-BAL']['balance'],
        ],
    ]
    BTCMPendList = [
        [
            balancesDict['BTC-BAL']['pending'],
            balancesDict['ETH-BAL']['pending'],
            balancesDict['LTC-BAL']['pending'],
            balancesDict['ETC-BAL']['pending'],
            balancesDict['BCHABC-BAL']['pending'],
            balancesDict['XRP-BAL']['pending'],
            balancesDict['AUD-BAL']['pending'],
        ],
    ]
    _GOOGLE._publishToGoogleSheet(BTCMBalList, 'USER_ENTERED',
                                  '[CryptoSum]!I8', 'COLUMNS')
    _GOOGLE._publishToGoogleSheet(BTCMPendList, 'USER_ENTERED',
                                  '[CryptoSum]!J8', 'COLUMNS')
    return
Пример #3
0
def _btcmTickerOps():
    # DESCR:    Stripped down version of the BTCMARKETS version, just to update gSheet [InterMarketLoop] tab at the same time as this script now runs (every 1min rather than waiting on 5min timer for other update)
    # ARGS:     none
    # UPDATES:  gSheet ([InterMarketLoop] tab ONLY
    # RETURNS:  nothing
    #
    #COINS TO AUD
    btcmTkDict = {"kCryptoDictType": 'BTCMticker'}
    ######COIN CANT BE EXCHANGED ON BINANCE TO BITCOIN:   btcmTkDict.update(    {"BTC-DATA":    _BTCMARKETS._BTCMapiNoAuth_getTickr("BTC", "AUD")} )
    btcmTkDict.update(
        {"ETH-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("ETH", "AUD")})
    btcmTkDict.update(
        {"LTC-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("LTC", "AUD")})
    btcmTkDict.update(
        {"ETC-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("ETC", "AUD")})
    ######COIN CANT BE EXCHANGED ON BINANCE TO BITCOIN:   btcmTkDict.update(    {"BCH-DATA":    _BTCMARKETS._BTCMapiNoAuth_getTickr("BCH", "AUD")} )
    btcmTkDict.update(
        {"XRP-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("XRP", "AUD")})
    #UPDATE GSHEETS WITH ABOVE
    btcmTickList_AUD = [
        [
            "N/A",
            btcmTkDict['ETH-DATA']['lastPrice'],
            btcmTkDict['LTC-DATA']['lastPrice'],
            btcmTkDict['ETC-DATA']['lastPrice'],
            "N/A",
            btcmTkDict['XRP-DATA']['lastPrice'],
        ],
    ]
    _GOOGLE._publishToGoogleSheet(btcmTickList_AUD, 'USER_ENTERED',
                                  '[InterMarketLoop]!C8', 'COLUMNS')
    return
Пример #4
0
def _btcmTickerOps():
    #COINS TO AUD
    btcmTkDict = {"kCryptoDictType": 'BTCMticker'}
    btcmTkDict.update(
        {"BTC-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("BTC", "AUD")})
    btcmTkDict.update(
        {"ETH-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("ETH", "AUD")})
    btcmTkDict.update(
        {"LTC-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("LTC", "AUD")})
    btcmTkDict.update(
        {"ETC-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("ETC", "AUD")})
    btcmTkDict.update(
        {"BCHABC-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("BCHABC", "AUD")})
    btcmTkDict.update(
        {"XRP-DATA": _BTCMARKETS._BTCMapiNoAuth_getTickr("XRP", "AUD")})
    _OUTPUT._spitJSONoutToSplunk(btcmTkDict)
    #UPDATE GSHEETS WITH ABOVE
    btcmTickList_AUD = [
        [
            btcmTkDict['BTC-DATA']['lastPrice'],
            btcmTkDict['ETH-DATA']['lastPrice'],
            btcmTkDict['LTC-DATA']['lastPrice'],
            btcmTkDict['ETC-DATA']['lastPrice'],
            btcmTkDict['BCHABC-DATA']['lastPrice'],
            btcmTkDict['XRP-DATA']['lastPrice'],
        ],
    ]
    _GOOGLE._publishToGoogleSheet(btcmTickList_AUD, 'USER_ENTERED',
                                  '[CryptoSum]!C8:C13', 'COLUMNS')

    return
Пример #5
0
def _forexRates():
    forexEURAUD = _FOREX._getForex('EUR', 'AUD')
    forexGBPAUD = _FOREX._getForex('GBP', 'AUD')
#    forexGBPAUD = _1FORGE._getForex(my1forgeAPIkey,'GBPAUD')
#    forexEURAUD = 1.666666
#    forexGBPAUD = 1.888888
    resultsList = [ [ forexEURAUD,forexGBPAUD, ], ]
    _GOOGLE._publishToGoogleSheet(resultsList, 'USER_ENTERED', '[arbFIAT]!C2',       'COLUMNS')
Пример #6
0
def _timestampGsheet():
    timeList = [
        [
            strftime("%d/%m/%Y %H:%M:%S"),
        ],
    ]
    _GOOGLE._publishToGoogleSheet(timeList, 'USER_ENTERED',
                                  '[InterMarketLoop]!C20', 'COLUMNS')
    return
Пример #7
0
def _timestampGsheet():
    timeList = [
        [
            strftime("%d/%m/%Y %H:%M:%S"),
        ],
    ]
    _GOOGLE._publishToGoogleSheet(timeList, 'USER_ENTERED', '[CryptoSum]!C25',
                                  'COLUMNS')
    return
Пример #8
0
def _nanoPoolOps():
    nanoDict = {"NanoPool": _collectNANOPOOLdata()}
    nanoDict.update({"kCryptoDictType": 'nanopool'})
    _OUTPUT._spitJSONoutToSplunk(nanoDict)
    if nanoDict['NanoPool']['status']:
        nanoValues = [
            [
                nanoDict['NanoPool']['ETHminingBal'],
            ],
        ]
        _GOOGLE._publishToGoogleSheet(nanoValues, 'USER_ENTERED',
                                      '[CryptoSum]!C21', 'COLUMNS')
    return
Пример #9
0
def _resetAlert_btcmTicker(googleSheetRangeBlock):
    #ALERTS SHOULD BE RESET IF (FOR A LOW ALERT) THE PRICE *RAISES* ABOVE THE LOW ALERT VALUE AGAIN.  VICE VERSA FOR HIGH ALERT.
    #KNOTE THAT googleSheetRangeBlock WILL THOW OUT OF BOUNDS ERROR (i.e. when referencing row[5] IF YOU DONT HAVE DATA IN *ALL* CELLS IN THE GSHEET. ANNOYING !
    if not googleSheetRangeBlock:
        print('No data found.')
    else:
        #CHECK FOR BREACHES, FIRE ALERT IF ONE FOUND
        resetAlertValue = [ [ 'onAlert', ], ]
        currentRow = 8   #THIS NEEDS TO BE SET TO THE ROW NUMBER WHERE YOUR FIRST ROW IS
        for row in googleSheetRangeBlock:
            #LOGIC CAN BE TRICKY HERE>.. TIPS = MAKE SURE GSHEETS FORMATTING IS SIMPLE, NO COMMAS IE 1,001.00 IS BAD (CANT CONVERT TO FLOAT)... ALSO WITHOUT THE FLOAT CONVERSION THE BELOW MISBEHAVES...
            #print('%s, %s, %s, %s, %s, %s' % ( row[0], row[1], row[2], row[3], row[4], row[5] ))
            if (row[4] == "FIRED") and (float(row[1]) > float(row[2])) :
                _GOOGLE._publishToGoogleSheet(resetAlertValue, 'USER_ENTERED', '[CryptoSum]!F' + str(currentRow), 'COLUMNS')
            elif (row[5] == "FIRED") and (float(row[1]) < float(row[3])) :
                _GOOGLE._publishToGoogleSheet(resetAlertValue, 'USER_ENTERED', '[CryptoSum]!G' + str(currentRow), 'COLUMNS')
            currentRow = currentRow + 1
    return
Пример #10
0
def _breachCheck_btcmTicker(googleSheetRangeBlock):
    slackWebhook = 'https://hooks.slack.com/services/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'
    if not googleSheetRangeBlock:
        print('No data found.')
    else:
        #CHECK FOR BREACHES, FIRE ALERT IF ONE FOUND
        resetAlertValue = [ [ 'FIRED', ], ]
        currentRow = 8   #THIS NEEDS TO BE SET TO THE ROW NUMBER WHERE YOUR FIRST ROW IS
        for row in googleSheetRangeBlock:
            #LOGIC CAN BE TRICKY HERE>.. TIPS = MAKE SURE GSHEETS FORMATTING IS SIMPLE, NO COMMAS IE 1,001.00 IS BAD (CANT CONVERT TO FLOAT)... ALSO WITHOUT THE FLOAT CONVERSION THE BELOW MISBEHAVES...
            #print('%s, %s, %s, %s, %s, %s' % ( row[0], row[1], row[2], row[3], row[4], row[5] ))
            if (float(row[1]) < float(row[2]))  and  (row[4] != "FIRED") :
                #print('%s LOW BREECH!' % (row[0]))
                slackMessage = '[*%s @ $%s*] _LOW_ breach! _(threshold was $%s)_ :point_down:'  % (row[0], row[1], row[2])
                _OUTPUT._pushMessageToSlack(slackWebhook, slackMessage)
                _GOOGLE._publishToGoogleSheet(resetAlertValue, 'USER_ENTERED', '[CryptoSum]!F' + str(currentRow), 'COLUMNS')
            elif (float(row[1]) > float(row[3]))  and  (row[5] != "FIRED") :
                #print('%s HIGH BREECH!' % (row[0]))
                slackMessage = '[*%s @ $%s*] _HIGH_ breach! _(threshold was $%s)_ :point_up:'  % (row[0], row[1], row[3])
                _OUTPUT._pushMessageToSlack(slackWebhook, slackMessage)
                _GOOGLE._publishToGoogleSheet(resetAlertValue, 'USER_ENTERED', '[CryptoSum]!G' + str(currentRow), 'COLUMNS')
            currentRow = currentRow + 1
    return
Пример #11
0
def _binanceAccountOps():
    #GET MAINSTREAM COIN ACCOUNT/BALANCE DETAILS - MAINSTREAM COINS
    BINcoinList = ["BTC", "ETH", "LTC", "ETC", "XRP"]
    #    BINcoinList         = ["BTC"]
    BINacDict = _BINANCE._BINapiAuth_getAccount("GET", "/api/v3/account",
                                                BINapiKeyPub_m, BINapiKeyPri_m,
                                                BINcoinList)

    _OUTPUT._spitJSONoutToSplunk(BINacDict)
    BINaclist = [
        [
            BINacDict['BTC']['balance'],
            BINacDict['ETH']['balance'],
            BINacDict['LTC']['balance'],
            BINacDict['ETC']['balance'],
            "N/A",
            BINacDict['XRP']['balance'],
        ],
    ]
    BINpendlist = [
        [
            BINacDict['BTC']['pending'],
            BINacDict['ETH']['pending'],
            BINacDict['LTC']['pending'],
            BINacDict['ETC']['pending'],
            "N/A",
            BINacDict['XRP']['pending'],
        ],
    ]
    _GOOGLE._publishToGoogleSheet(BINaclist, 'USER_ENTERED', '[CryptoSum]!N8',
                                  'COLUMNS')
    _GOOGLE._publishToGoogleSheet(BINpendlist, 'USER_ENTERED',
                                  '[CryptoSum]!O8', 'COLUMNS')

    #GET ALT-COIN ACCOUNT/BALANCE DETAILS (these vary, hence allow to be driven by user input on the gsheet)
    #GET LIST OF COINS FIRST
    googleSheetBlock = _GOOGLE._readFromGoogleSheet('[CryptoSum]!S8:S21')
    myBINaltCoinList = _BINANCE._makeBINaltCoinsOfInterestList(
        googleSheetBlock)

    #NEXT GET BALANCES OF THOSE COINS
    BINaltAcDict = _BINANCE._BINapiAuth_getAccount("GET", "/api/v3/account",
                                                   BINapiKeyPub_m,
                                                   BINapiKeyPri_m,
                                                   myBINaltCoinList)

    _OUTPUT._spitJSONoutToSplunk(BINaltAcDict)
    BINaltBalList = []
    BINaltPenList = []
    for i in range(len(myBINaltCoinList)):
        BINaltBalList.append(BINaltAcDict[myBINaltCoinList[i]]['balance'])
        BINaltPenList.append(BINaltAcDict[myBINaltCoinList[i]]['pending'])

    gSheetListOfListsBal = [
        BINaltBalList,
    ]
    gSheetListOfListsPen = [
        BINaltPenList,
    ]
    _GOOGLE._publishToGoogleSheet(gSheetListOfListsBal, 'USER_ENTERED',
                                  '[CryptoSum]!T8', 'COLUMNS')
    _GOOGLE._publishToGoogleSheet(gSheetListOfListsPen, 'USER_ENTERED',
                                  '[CryptoSum]!U8', 'COLUMNS')

    #GET VALUES OF THOSE COINS AGAINST BITCOIN (BINANCE DOES NOT DO AUD)
    BINaltDict = _BINANCE._BINapiNoAuth_getTickr("GET",
                                                 "/api/v1/ticker/allPrices",
                                                 myBINaltCoinList)
    #    _OUTPUT._spitJSONoutToSplunk(BINaltDict)
    BINaltExRateList = []
    for i in range(len(myBINaltCoinList)):
        coinBTC = myBINaltCoinList[i] + "-BTC"
        BINaltExRateList.append(BINaltDict[coinBTC]['lastPrice'])

    gSheetListOfLists = [
        BINaltExRateList,
    ]
    _GOOGLE._publishToGoogleSheet(gSheetListOfLists, 'USER_ENTERED',
                                  '[CryptoSum]!V8', 'COLUMNS')

    return
Пример #12
0
def _arbKrakenGBP():
    coinsList = ['XBTGBP','ETHGBP']
    resultsDict = _KRACKEN._KRACKENapiNoAuth_getTickr(coinsList)
    #UPDATE GSHEETS WITH ABOVE
    resultsList    = [ [ resultsDict['XBTGBP']['lastPrice'], resultsDict['ETHGBP']['lastPrice'], ], ]
    _GOOGLE._publishToGoogleSheet(resultsList, 'USER_ENTERED', '[arbFIAT]!G8',       'COLUMNS')