mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-20 12:20:29 +08:00
Trying to stabilize refactoring an last few commits (still unstable)
This commit is contained in:
@@ -27,15 +27,15 @@ log = Logger('DataPortalExchange')
|
||||
|
||||
|
||||
class DataPortalExchangeBase(DataPortal):
|
||||
def __init__(self, exchanges, *args, **kwargs):
|
||||
self.exchanges = exchanges
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
self.exchanges = kwargs.pop('exchanges', None)
|
||||
# TODO: put somewhere accessible by each algo
|
||||
self.retry_get_history_window = 5
|
||||
self.retry_get_spot_value = 5
|
||||
self.retry_delay = 5
|
||||
|
||||
super(self.__class__, self).__init__(*args, **kwargs)
|
||||
super(DataPortalExchangeBase, self).__init__(*args, **kwargs)
|
||||
|
||||
def _get_history_window(self,
|
||||
assets,
|
||||
@@ -199,8 +199,8 @@ class DataPortalExchangeBase(DataPortal):
|
||||
|
||||
|
||||
class DataPortalExchangeLive(DataPortalExchangeBase):
|
||||
def __init__(self, exchanges, *args, **kwargs):
|
||||
super(self.__class__, self).__init__(exchanges, *args, **kwargs)
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DataPortalExchangeLive, self).__init__(*args, **kwargs)
|
||||
|
||||
def get_exchange_spot_value_history_window(self,
|
||||
exchange,
|
||||
|
||||
@@ -59,8 +59,7 @@ class ExchangeAlgorithmExecutor(AlgorithmSimulator):
|
||||
|
||||
class ExchangeTradingAlgorithmBase(TradingAlgorithm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.exchanges = kwargs.pop('exchanges', None)
|
||||
super(self.__class__, self).__init__(*args, **kwargs)
|
||||
super(ExchangeTradingAlgorithmBase, self).__init__(*args, **kwargs)
|
||||
|
||||
@api_method
|
||||
@preprocess(symbol_str=ensure_upper_case)
|
||||
@@ -135,7 +134,7 @@ class ExchangeTradingAlgorithm(ExchangeTradingAlgorithmBase):
|
||||
|
||||
self.stats_minutes = 5
|
||||
|
||||
super(self.__class__, self).__init__(*args, **kwargs)
|
||||
super(ExchangeTradingAlgorithm, self).__init__(*args, **kwargs)
|
||||
# TODO: fix precision before re-enabling
|
||||
# self._create_minute_writer()
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ from catalyst.utils.calendars import get_calendar
|
||||
from catalyst.utils.factory import create_simulation_parameters
|
||||
import catalyst.utils.paths as pth
|
||||
|
||||
from catalyst.exchange.algorithm_exchange import ExchangeTradingAlgorithm
|
||||
from catalyst.exchange.exchange_algorithm import ExchangeTradingAlgorithm
|
||||
from catalyst.exchange.data_portal_exchange import DataPortalExchangeLive
|
||||
from catalyst.exchange.bitfinex.bitfinex import Bitfinex
|
||||
from catalyst.exchange.asset_finder_exchange import AssetFinderExchange
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pandas as pd
|
||||
from catalyst import get_calendar
|
||||
# from catalyst import get_calendar
|
||||
from logbook import Logger
|
||||
|
||||
from catalyst.exchange.asset_finder_exchange import AssetFinderExchange
|
||||
@@ -17,7 +17,7 @@ class ExchangeDataPortalTestCase:
|
||||
def setup(self):
|
||||
log.info('creating bitfinex exchange')
|
||||
auth_bitfinex = get_exchange_auth('bitfinex')
|
||||
bitfinex = Bitfinex(
|
||||
self.bitfinex = Bitfinex(
|
||||
key=auth_bitfinex['key'],
|
||||
secret=auth_bitfinex['secret'],
|
||||
base_currency='usd'
|
||||
@@ -25,31 +25,33 @@ class ExchangeDataPortalTestCase:
|
||||
|
||||
log.info('creating bittrex exchange')
|
||||
auth_bitfinex = get_exchange_auth('bittrex')
|
||||
bittrex = Bittrex(
|
||||
self.bittrex = Bittrex(
|
||||
key=auth_bitfinex['key'],
|
||||
secret=auth_bitfinex['secret'],
|
||||
base_currency='usd'
|
||||
)
|
||||
|
||||
open_calendar = get_calendar('OPEN')
|
||||
# open_calendar = get_calendar('OPEN')
|
||||
open_calendar = None
|
||||
asset_finder = AssetFinderExchange()
|
||||
self.data_portal_live = DataPortalExchangeLive(
|
||||
exchanges=dict(bitfinex=bitfinex, bittrex=bittrex),
|
||||
exchanges=dict(bitfinex=self.bitfinex, bittrex=self.bittrex),
|
||||
asset_finder=asset_finder,
|
||||
trading_calendar=open_calendar,
|
||||
first_trading_day=pd.to_datetime('today', utc=True)
|
||||
)
|
||||
|
||||
def test_history_window_live(self):
|
||||
def test_get_history_window_live(self):
|
||||
pass
|
||||
|
||||
def test_spot_value_live(self):
|
||||
def test_get_spot_value_live(self):
|
||||
asset_finder = self.data_portal_live.asset_finder
|
||||
|
||||
now = pd.Timestamp.utcnow()
|
||||
assets = [
|
||||
asset_finder.lookup_symbol('eth_usd',now,)
|
||||
asset_finder.lookup_symbol('eth_usd', self.bitfinex),
|
||||
asset_finder.lookup_symbol('eth_usd', self.bittrex)
|
||||
]
|
||||
now = pd.Timestamp.utcnow()
|
||||
value = self.data_portal_live.get_spot_value(
|
||||
assets, field, dt, data_frequency)
|
||||
assets, 'price', now, '1m')
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user