예제 #1
0
 def fetchdataset(self, symbol, count):
     global dataset
     global latest_milisec
     global oldest_milisec
     dataset.clear()
     url = settings.kline_endpoint+ settings.param_symbol_tag + symbol + settings.param_interval_tag + settings.trade_ticker_interval + settings.param_limit_tag + str(count)
     response = common.requests_retry_session().get(url)
     dataset_json = json.loads(response.text)
     for candle in reversed(dataset_json):
         kline = kline_object.kLine(candle)
         dataset.append(float(kline.CLOSE_PRICE))
     
     oldest_milisec = int(kline_object.kLine(dataset_json[0]).OPEN_TIME)
     latest_milisec = int(kline_object.kLine(dataset_json[int(count)-1]).OPEN_TIME)
예제 #2
0
파일: rsi.py 프로젝트: yulnicorn/moonlight
    def __init__(self, ds, period):
        '''ds being ascending timestamp order '''
        self.closePriceInOrder = []  #first item being most recent
        self.movements = []
        self.Ups = []
        self.Downs = []

        self.dataset = self.convertToList(ds)[(
            len(ds) - period - 1):]  # period + 1 to compute movement
        self.n = period
        self.prevKline = kline_object.kLine(self.dataset[period - 1])

        #get interval ms
        self.intervalMs = self.dataset[1][6] - self.dataset[0][6]

        #collect close price
        for row in self.dataset:
            self.closePriceInOrder.append(float(
                row[4]))  #index 5 is the close price, 4 for api call
            self.nextCloseTime = row[6]
        #add 1min of ms it
        self.nextCloseTime += 60000

        self.__computeMovement()
        self.__computeUpDown()
예제 #3
0
파일: ema.py 프로젝트: yulnicorn/moonlight
    def addKlineAndGetEMA(newKline):
        global emaValue, latestClosePrice

        kline = kline_object.kLine(newKline)

        newClosePrice = kline.CLOSE_PRICE
        emaValue = self.computeEMA(newClosePrice)
        latestClosePrice = newClosePrice

        return emaValue
예제 #4
0
파일: ema.py 프로젝트: yulnicorn/moonlight
 def __init__(self, ds):
     #ema = (closeprice - ema(previous day) * multiplier + ema(previous day))
     #initial ema is computed with sma instead
     global n
     global emaValue
     global weight
     global latestClosePrice
     n = len(ds)
     weight = self.getWeightedMultiplier(n)
     latestClosePrice = kline_object.kLine(ds.pop()).CLOSE_PRICE
     emaValue = sma = simpleMovingAverage(ds).getSMA()
     #use sma to compute ema for next point
     emaValue = self.computeEMA()
예제 #5
0
 def getNewkline(self):
     '''gets the latest candle from api'''
     response = common.requests_retry_session().get(self.url)
     return kline_object.kLine(json.loads(response.text))