Ejemplo n.º 1
0
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]))
Ejemplo n.º 2
0
 def __init__(self, exchange, pair):        
     self.exchange = exchange
     self.pair = pair
     
     self.jsav = JSave()
     self.periodMaker = PM()
     self.dataMaker = DM(exchange, pair)
Ejemplo n.º 3
0
def test_Dataset_Maker():
    #TEST CLASS DATASET_MAKER - LOAD_JSON AND PRINT_CONTAINER
    exchange = "bitstamp"
    pair = "btcusd"
    per_mak = PM()
    periods_list = per_mak.ret_diz()
    period = periods_list["12-h"]

    dataMaker = DataMak(exchange, pair)
    dataset = dataMaker.load_json_candlestick(period)
    dataMaker.print_data(dataset)
    dataMaker.save_on_file(dataset)
Ejemplo n.º 4
0
def test_Period_Maker():
    #TEST CLASS PERIODS_MAKER
    obj = PM()
    dic = obj.ret_diz()
    dic_rev = obj.ret_rev_diz()
    obj.print_candles_types()

    list_of_types_candles = [dic['1-m'], dic['3-m']]
    print(list_of_types_candles)  #EXPECTED ['60','180']
    periods = obj.make(list_of_types_candles)

    if (periods == -1):
        print("Error, you have inserted an/some Unknown Candle/es Type/es \n")
        exit()
    print("\n")
    return periods, dic, dic_rev
Ejemplo n.º 5
0
    def print_data(self, dataset):
        candles = dataset[1]
        close_matrix = dataset[0]
        per_mak = PM()
        periods_list = per_mak.ret_rev_diz()
        output_period = periods_list[self.period]
        tsc = TSC()

        for i in range(len(candles)):
            print("{}\t".format(tsc.get_date(candles[i][0])), end="")
            print("${}\t\t".format(int(close_matrix[i])), end="")
            print("BTC {}".format(round(candles[i][4], 2)))

        print("\n" + self.exchange.title() + " - " + self.pair.upper())
        print("Candles Stick Period:", output_period)
        print("Total Candles:", len(dataset[0]))
Ejemplo n.º 6
0
    def open_feature_scaling_max(self):
        periodMaker = PM()
        periods_list = periodMaker.ret_diz()
        self.period = periods_list[self.period]
	
        filepath = "./lib/{}_feature_scaling_max.plk".format(self.period) 
        with open(filepath, "rb") as inp:
            fs_max = pickle.load(inp)
            
        closePrice = fs_max.get("closePrice")
        closeTime = fs_max.get("closeTime")
        openPrice = fs_max.get("openPrice")
        highPrice = fs_max.get("highPrice")
        lowPrice = fs_max.get("lowPrice")
        volume = fs_max.get("volume")
            
        return closePrice, closeTime, openPrice, highPrice, lowPrice, volume
Ejemplo n.º 7
0
 def __init__(self, exchange, pair, period):
     self.exchange = exchange
     self.pair = pair
     self.period = period
     self.periodMaker = PM()