mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 21:54:18 +08:00
Working on adjusted the DataPortal class (unstable)
This commit is contained in:
@@ -96,11 +96,15 @@ class ExchangeTradingAlgorithmBase(TradingAlgorithm):
|
||||
if self._symbol_lookup_date is not None \
|
||||
else self.sim_params.end_session
|
||||
|
||||
exchange = self.exchanges[exchange_name]
|
||||
if exchange_name is None:
|
||||
exchange = self.exchanges.values()[0]
|
||||
else:
|
||||
exchange = self.exchanges[exchange_name]
|
||||
|
||||
return self.asset_finder.lookup_symbol(
|
||||
symbol_str,
|
||||
as_of_date=_lookup_date,
|
||||
exchange=exchange
|
||||
symbol=symbol_str,
|
||||
exchange=exchange,
|
||||
as_of_date=_lookup_date
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ from catalyst.utils.factory import create_simulation_parameters
|
||||
import catalyst.utils.paths as pth
|
||||
|
||||
from catalyst.exchange.algorithm_exchange import ExchangeTradingAlgorithm
|
||||
from catalyst.exchange.data_portal_exchange import DataPortalExchange
|
||||
from catalyst.exchange.data_portal_exchange import DataPortalExchangeLive
|
||||
from catalyst.exchange.bitfinex.bitfinex import Bitfinex
|
||||
from catalyst.exchange.asset_finder_exchange import AssetFinderExchange
|
||||
from catalyst.exchange.exchange_portfolio import ExchangePortfolio
|
||||
@@ -209,7 +209,7 @@ def _run(handle_data,
|
||||
)
|
||||
env.asset_finder = AssetFinderExchange()
|
||||
|
||||
data = DataPortalExchange(
|
||||
data = DataPortalExchangeLive(
|
||||
exchanges=exchanges,
|
||||
asset_finder=env.asset_finder,
|
||||
trading_calendar=open_calendar,
|
||||
|
||||
@@ -14,7 +14,7 @@ log = Logger('test_bitfinex')
|
||||
class BitfinexTestCase(BaseExchangeTestCase):
|
||||
@classmethod
|
||||
def setup(self):
|
||||
print ('creating bitfinex object')
|
||||
log.info('creating bitfinex object')
|
||||
auth = get_exchange_auth('bitfinex')
|
||||
self.exchange = Bitfinex(
|
||||
key=auth['key'],
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import pandas as pd
|
||||
from catalyst import get_calendar
|
||||
from logbook import Logger
|
||||
|
||||
from catalyst.exchange.asset_finder_exchange import AssetFinderExchange
|
||||
from catalyst.exchange.bitfinex.bitfinex import Bitfinex
|
||||
from catalyst.exchange.bittrex.bittrex import Bittrex
|
||||
from catalyst.exchange.data_portal_exchange import DataPortalExchangeBacktest, \
|
||||
DataPortalExchangeLive
|
||||
from catalyst.exchange.exchange_utils import get_exchange_auth
|
||||
|
||||
log = Logger('test_bitfinex')
|
||||
|
||||
|
||||
class ExchangeDataPortalTestCase:
|
||||
@classmethod
|
||||
def setup(self):
|
||||
log.info('creating bitfinex exchange')
|
||||
auth_bitfinex = get_exchange_auth('bitfinex')
|
||||
bitfinex = Bitfinex(
|
||||
key=auth_bitfinex['key'],
|
||||
secret=auth_bitfinex['secret'],
|
||||
base_currency='usd'
|
||||
)
|
||||
|
||||
log.info('creating bittrex exchange')
|
||||
auth_bitfinex = get_exchange_auth('bittrex')
|
||||
bittrex = Bittrex(
|
||||
key=auth_bitfinex['key'],
|
||||
secret=auth_bitfinex['secret'],
|
||||
base_currency='usd'
|
||||
)
|
||||
|
||||
open_calendar = get_calendar('OPEN')
|
||||
asset_finder = AssetFinderExchange()
|
||||
self.data_portal_live = DataPortalExchangeLive(
|
||||
exchanges=dict(bitfinex=bitfinex, bittrex=bittrex),
|
||||
asset_finder=asset_finder,
|
||||
trading_calendar=open_calendar,
|
||||
first_trading_day=pd.to_datetime('today', utc=True)
|
||||
)
|
||||
|
||||
def test_history_window_live(self):
|
||||
pass
|
||||
|
||||
def test_spot_value_live(self):
|
||||
asset_finder = self.data_portal_live.asset_finder
|
||||
|
||||
now = pd.Timestamp.utcnow()
|
||||
assets = [
|
||||
asset_finder.lookup_symbol('eth_usd',now,)
|
||||
]
|
||||
value = self.data_portal_live.get_spot_value(
|
||||
assets, field, dt, data_frequency)
|
||||
pass
|
||||
Reference in New Issue
Block a user