mirror of
https://github.com/wassname/catalyst.git
synced 2026-09-12 12:12:04 +08:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import shutil
|
import shutil
|
||||||
|
import random
|
||||||
import tempfile
|
import tempfile
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
@@ -6,6 +7,8 @@ from catalyst.exchange.exchange_bundle import ExchangeBundle
|
|||||||
from catalyst.exchange.exchange_bcolz import BcolzExchangeBarWriter, \
|
from catalyst.exchange.exchange_bcolz import BcolzExchangeBarWriter, \
|
||||||
BcolzExchangeBarReader
|
BcolzExchangeBarReader
|
||||||
|
|
||||||
|
from catalyst.exchange.bundle_utils import get_df_from_arrays
|
||||||
|
|
||||||
from nose.tools import assert_equals
|
from nose.tools import assert_equals
|
||||||
|
|
||||||
|
|
||||||
@@ -24,7 +27,7 @@ class TestBcolzWriter(object):
|
|||||||
bundle = ExchangeBundle(exchange_name)
|
bundle = ExchangeBundle(exchange_name)
|
||||||
index = bundle.get_calendar_periods_range(start, end, freq)
|
index = bundle.get_calendar_periods_range(start, end, freq)
|
||||||
df = pd.DataFrame(index=index, columns=self.columns)
|
df = pd.DataFrame(index=index, columns=self.columns)
|
||||||
df.fillna(1, inplace=True)
|
df.fillna(random.random(), inplace=True)
|
||||||
return df
|
return df
|
||||||
|
|
||||||
def test_bcolz_write_daily_past(self):
|
def test_bcolz_write_daily_past(self):
|
||||||
@@ -107,14 +110,18 @@ class TestBcolzWriter(object):
|
|||||||
def bcolz_exchange_daily_write_read(self, exchange_name):
|
def bcolz_exchange_daily_write_read(self, exchange_name):
|
||||||
start = pd.to_datetime('2017-10-01 00:00')
|
start = pd.to_datetime('2017-10-01 00:00')
|
||||||
end = pd.to_datetime('today')
|
end = pd.to_datetime('today')
|
||||||
freq = 'minute'
|
freq = 'daily'
|
||||||
|
|
||||||
|
bundle = ExchangeBundle(exchange_name)
|
||||||
|
|
||||||
df = self.generate_df(exchange_name, freq, start, end)
|
df = self.generate_df(exchange_name, freq, start, end)
|
||||||
|
|
||||||
|
print df.index[0],df.index[-1]
|
||||||
|
|
||||||
writer = BcolzExchangeBarWriter(
|
writer = BcolzExchangeBarWriter(
|
||||||
rootdir=self.root_dir,
|
rootdir=self.root_dir,
|
||||||
start_session=start,
|
start_session=df.index[0],
|
||||||
end_session=end,
|
end_session=df.index[-1],
|
||||||
data_frequency=freq,
|
data_frequency=freq,
|
||||||
write_metadata=True)
|
write_metadata=True)
|
||||||
|
|
||||||
@@ -125,9 +132,15 @@ class TestBcolzWriter(object):
|
|||||||
reader = BcolzExchangeBarReader(rootdir=self.root_dir,
|
reader = BcolzExchangeBarReader(rootdir=self.root_dir,
|
||||||
data_frequency=freq)
|
data_frequency=freq)
|
||||||
|
|
||||||
dx = reader.load_raw_arrays(self.columns, start, end, [1, ])
|
arrays = reader.load_raw_arrays(self.columns, start, end, [1, ])
|
||||||
|
|
||||||
# assert_equals(dx, df)
|
periods = bundle.get_calendar_periods_range(
|
||||||
|
start, end, freq
|
||||||
|
)
|
||||||
|
|
||||||
|
dx = get_df_from_arrays(arrays, periods)
|
||||||
|
|
||||||
|
assert_equals(df.equals(df), True)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_bcolz_bitfinex_daily_write_read(self):
|
def test_bcolz_bitfinex_daily_write_read(self):
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
from logging import Logger
|
from logging import getLogger
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ from catalyst.exchange.exchange_utils import get_exchange_folder
|
|||||||
from catalyst.exchange.init_utils import get_exchange
|
from catalyst.exchange.init_utils import get_exchange
|
||||||
from catalyst.utils.paths import ensure_directory
|
from catalyst.utils.paths import ensure_directory
|
||||||
|
|
||||||
log = Logger('test_exchange_bundle')
|
log = getLogger('test_exchange_bundle')
|
||||||
|
|
||||||
|
|
||||||
class TestExchangeBundle:
|
class TestExchangeBundle:
|
||||||
@@ -298,7 +298,7 @@ class TestExchangeBundle:
|
|||||||
data_frequency = 'minute'
|
data_frequency = 'minute'
|
||||||
|
|
||||||
exchange = get_exchange(exchange_name)
|
exchange = get_exchange(exchange_name)
|
||||||
asset = exchange.get_asset('neo_btc')
|
asset = exchange.get_asset('neos_btc')
|
||||||
|
|
||||||
path = get_bcolz_chunk(
|
path = get_bcolz_chunk(
|
||||||
exchange_name=exchange_name,
|
exchange_name=exchange_name,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class TestPoloniexTestCase(BaseExchangeTestCase):
|
|||||||
|
|
||||||
def test_order(self):
|
def test_order(self):
|
||||||
log.info('creating order')
|
log.info('creating order')
|
||||||
asset = self.exchange.get_asset('neo_btc')
|
asset = self.exchange.get_asset('neos_btc')
|
||||||
order_id = self.exchange.order(
|
order_id = self.exchange.order(
|
||||||
asset=asset,
|
asset=asset,
|
||||||
limit_price=0.0005,
|
limit_price=0.0005,
|
||||||
@@ -33,7 +33,7 @@ class TestPoloniexTestCase(BaseExchangeTestCase):
|
|||||||
|
|
||||||
def test_open_orders(self):
|
def test_open_orders(self):
|
||||||
log.info('retrieving open orders')
|
log.info('retrieving open orders')
|
||||||
asset = self.exchange.get_asset('neo_btc')
|
asset = self.exchange.get_asset('neos_btc')
|
||||||
orders = self.exchange.get_open_orders(asset)
|
orders = self.exchange.get_open_orders(asset)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -53,13 +53,13 @@ class TestPoloniexTestCase(BaseExchangeTestCase):
|
|||||||
log.info('retrieving candles')
|
log.info('retrieving candles')
|
||||||
ohlcv_neo = self.exchange.get_candles(
|
ohlcv_neo = self.exchange.get_candles(
|
||||||
data_frequency='5m',
|
data_frequency='5m',
|
||||||
assets=self.exchange.get_asset('neo_btc')
|
assets=self.exchange.get_asset('neos_btc')
|
||||||
)
|
)
|
||||||
ohlcv_neo_ubq = self.exchange.get_candles(
|
ohlcv_neo_ubq = self.exchange.get_candles(
|
||||||
data_frequency='5m',
|
data_frequency='5m',
|
||||||
assets=[
|
assets=[
|
||||||
self.exchange.get_asset('neo_btc'),
|
self.exchange.get_asset('neos_btc'),
|
||||||
self.exchange.get_asset('ubq_btc')
|
self.exchange.get_asset('via_btc')
|
||||||
],
|
],
|
||||||
bar_count=14
|
bar_count=14
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user