def scrapeWithDic(self, timeframe, size=99999): d = mt5.copy_rates_from_pos(self.stock, setting.timeframeConstant(timeframe) , 0, size) data = self.convert2Array(d) array = self.toDicArray(data) dic = {} dic['name'] = self.stock dic['timeframe'] = timeframe dic['length'] = len(data) dic['data'] = array return dic
def scrapeRange(self, timeframe, begin_jst, end_jst): # タイムゾーンをUTCに設定する timezone = pytz.timezone("Etc/UTC") # create 'datetime' objects in UTC time zone to avoid the implementation of a local time zone offset if isXmSummerTime(end_jst): delta = deltaHour(6) else: delta = deltaHour(7) utc_from = datetime(begin_jst.year, begin_jst.month, begin_jst.day, begin_jst.hour, begin_jst.minute, 0, tzinfo=timezone) - delta utc_to = datetime(end_jst.year, end_jst.month, end_jst.day, end_jst.hour, end_jst.minute, 0, tzinfo=timezone) - delta d = mt5.copy_rates_range(self.stock, setting.timeframeConstant(timeframe) , utc_from, utc_to) data = self.convert2Array(d) return data
def scrapeTicks(self, timeframe, from_jst, size=100000): # タイムゾーンをUTCに設定する timezone = pytz.timezone("Etc/UTC") # create 'datetime' objects in UTC time zone to avoid the implementation of a local time zone offset if isXmSummerTime(from_jst): delta = deltaHour(6) else: delta = deltaHour(7) utc_from = datetime(from_jst.year, from_jst.month, from_jst.day, from_jst.hour, from_jst.minute, 0, tzinfo=timezone) - delta d = mt5.copy_ticks_from(self.stock, setting.timeframeConstant(timeframe) , utc_from, size, mt5.COPY_TICKS_ALL) data = self.convert2Array(d) #df = pd.DataFrame(data = out, columns=['Time', 'Bid', 'Ask']) #df.to_csv(market + '_' + str(year) +'-' + str(month) + '-' + str(day) + '.csv', index=False) return data
def scrapeWithTimeSeries(self, timeframe, size=99999): d = mt5.copy_rates_from_pos(self.stock, setting.timeframeConstant(timeframe) , 0, size) data = self.convert2Array(d) return self.toTimeSeries(data)
def getMinute(self, timeframe, begin_time, end_time): begin = self.roundMinute(begin_time, timeframe) end = self.roundMinute(end_time, timeframe) tf = setting.timeframeConstant(timeframe) data = mt5.copy_rates_range(self.stock, tf , begin, end) return self.convert2Array(data)
def getHour(self, timeframe, begin_time, end_time): begin = self.cutUnderHour(begin_time, 0) end = self.cutUnderHour(end_time, 1) data = mt5.copy_rates_range(self.stock, setting.timeframeConstant(timeframe), begin, end) return self.convert2Array(data)
def getDay(self, timeframe, begin_time, end_time): begin = xmTime(begin_time.year, begin_time.month, begin_time.day, 0, 0) end = xmTime(end_time.year, end_time.month, end_time.day, 0, 0) data = mt5.copy_rates_range(self.stock, setting.timeframeConstant(timeframe), begin, end) return self.convert2Array(data)