def test_Extractor(): #TEST CLASS EXTRACTOR - OHLC METHOD obj = TSC() val = obj.convert(4, 9, 2014, 1, 0) obj = PM() dic = obj.ret_diz() dic_rev = obj.ret_rev_diz() list_of_types_candles = [dic['1-m'], dic['3-m']] per = obj.make(list_of_types_candles) ext = EXTR() x = ext.ohlc("coinbase-pro", "btcusd", after=val, periods=per) if (type(x) == int and x == -1): print("Bad Request \n") elif (type(x) == int and x == -2): print("You have finished your CPU allowance, retry next hour \n") elif (type(x) == int and x == -3): print("Unexpected Error, retry please \n") else: candles_types_returned = list(x['result'].keys()) print("Candles Types Returned: ({}, {}) ".format( dic_rev[candles_types_returned[1]], dic_rev[candles_types_returned[0]])) candle_1_minute = x['result'][dic['1-m']] candle_3_minutes = x['result'][dic['3-m']] print("Size 1-Minute Candle: ({}, {})".format(len(candle_1_minute), len(candle_1_minute[0]))) print("Size 3-Minutes Candle: ({}, {})".format( len(candle_3_minutes), len(candle_3_minutes[0]))) print("Example 1-Minute Candle: {} ".format(candle_1_minute[0])) print("Example 3-Minutes Candle: {} ".format(candle_3_minutes[0]))
print("Fatal Error, missing some data file \n") exit(5) estimator = estimator['Best_M'] #Here we load the pca object result = check_file("pca.plk") if (result == 7): pca = load_data("pca.plk") pca = pca['pca'] pca_v = True #Here, we extract the daily opened candle, in order to predict the ClosePrice e = Extractor() tc = Time_Stamp_Converter() daily_not_closed_candle = e.ohlc("bitstamp", "btcusd", -5, "1549152000", "43200") if (type(daily_not_closed_candle) == int and x == -1): print( "Bad Request - Unable to download last candlestick from the internet\n" ) elif (type(daily_not_closed_candle) == int and x == -2): print( "You have finished your CPU allowance, retry next hour - Unable to download last candlestick from the internet\n" ) elif (type(daily_not_closed_candle) == int and x == -3): print( "Unexpected Error - Unable to download last candlestick from the internet\n" )
def extract_candlestick(self, exchange, pair, timestamp): extr = Extractor() print("\nQuerying the API ...") return extr.ohlc(exchange, pair, after=timestamp)