mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-22 12:40:30 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a245218e34 | ||
|
|
fe3a9870aa | ||
|
|
24229561f1 | ||
|
|
722cb0011f |
@@ -6,7 +6,7 @@ import time
|
|||||||
import requests
|
import requests
|
||||||
import logbook
|
import logbook
|
||||||
|
|
||||||
DT_START = time.mktime(datetime(2010, 01, 01, 0, 0).timetuple())
|
DT_START = time.mktime(datetime(2010, 1, 1, 0, 0).timetuple())
|
||||||
CSV_OUT_FOLDER = '/var/tmp/catalyst/data/poloniex/'
|
CSV_OUT_FOLDER = '/var/tmp/catalyst/data/poloniex/'
|
||||||
CONN_RETRIES = 2
|
CONN_RETRIES = 2
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class PoloniexCurator(object):
|
|||||||
return DT_START
|
return DT_START
|
||||||
|
|
||||||
def get_data(self, currencyPair, start, end=9999999999, period=300):
|
def get_data(self, currencyPair, start, end=9999999999, period=300):
|
||||||
url = self._api_path + 'command=returnChartData¤cyPair=' + currencyPair + '&start=' + str(start) + '&end=' + str(end) + '&period=' + str(period)
|
url = self._api_path + 'command=returnChartData¤cyPair=' + currencyPair + '&start=' + str(start) + '&end=' + str(end) + '&period=' + str(period)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
@@ -77,13 +77,13 @@ class PoloniexCurator(object):
|
|||||||
log.exception(e)
|
log.exception(e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Pulls latest data for a single pair
|
Pulls latest data for a single pair
|
||||||
'''
|
'''
|
||||||
def append_data_single_pair(self, currencyPair, repeat=0):
|
def append_data_single_pair(self, currencyPair, repeat=0):
|
||||||
log.debug('Getting data for %s' % currencyPair)
|
log.debug('Getting data for %s' % currencyPair)
|
||||||
csv_fn = CSV_OUT_FOLDER + 'crypto_prices-' + currencyPair + '.csv'
|
csv_fn = CSV_OUT_FOLDER + 'crypto_prices-' + currencyPair + '.csv'
|
||||||
start = self._get_start_date(csv_fn)
|
start = self._get_start_date(csv_fn)
|
||||||
# Only fetch data if more than 5min have passed since last fetch
|
# Only fetch data if more than 5min have passed since last fetch
|
||||||
@@ -115,10 +115,10 @@ class PoloniexCurator(object):
|
|||||||
Pulls latest data for all currency pairs
|
Pulls latest data for all currency pairs
|
||||||
'''
|
'''
|
||||||
def append_data(self):
|
def append_data(self):
|
||||||
for currencyPair in self.currency_pairs:
|
for currencyPair in self.currency_pairs:
|
||||||
self.append_data_single_pair(currencyPair)
|
self.append_data_single_pair(currencyPair)
|
||||||
# Rate limit is 6 calls per second, sleep 1sec/6 to be safe
|
# Rate limit is 6 calls per second, sleep 1sec/6 to be safe
|
||||||
time.sleep(0.17)
|
time.sleep(0.17)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Returns a data frame for all pairs, or for the requests currency pair.
|
Returns a data frame for all pairs, or for the requests currency pair.
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import pandas as pd
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from pandas_datareader.data import DataReader
|
from pandas_datareader.data import DataReader
|
||||||
import datetime
|
import datetime
|
||||||
|
import time
|
||||||
import pytz
|
import pytz
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
from six.moves.urllib_error import HTTPError
|
from six.moves.urllib_error import HTTPError
|
||||||
|
|||||||
Reference in New Issue
Block a user