mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 16:29:48 +08:00
MAINT: Convert dictionary .values() to list for python3
This commit is contained in:
@@ -88,11 +88,11 @@ class AssetDispatchBarReader(with_metaclass(ABCMeta)):
|
||||
if self._last_available_dt is not None:
|
||||
return self._last_available_dt
|
||||
else:
|
||||
return min(r.last_available_dt for r in self._readers.values())
|
||||
return min(r.last_available_dt for r in list(self._readers.values()))
|
||||
|
||||
@lazyval
|
||||
def first_trading_day(self):
|
||||
return max(r.first_trading_day for r in self._readers.values())
|
||||
return max(r.first_trading_day for r in list(self._readers.values()))
|
||||
|
||||
def get_value(self, sid, dt, field):
|
||||
asset = self._asset_finder.retrieve_asset(sid)
|
||||
|
||||
@@ -84,7 +84,7 @@ def handle_data(context, data):
|
||||
def analyze(context, perf):
|
||||
|
||||
# Get the base_currency that was passed as a parameter to the simulation
|
||||
base_currency = context.exchanges.values()[0].base_currency.upper()
|
||||
base_currency = list(context.exchanges.values())[0].base_currency.upper()
|
||||
|
||||
# First chart: Plot portfolio value using base_currency
|
||||
ax1 = plt.subplot(411)
|
||||
|
||||
@@ -161,7 +161,7 @@ def analyze(context=None, perf=None):
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
# The base currency of the algo exchange
|
||||
base_currency = context.exchanges.values()[0].base_currency.upper()
|
||||
base_currency = list(context.exchanges.values())[0].base_currency.upper()
|
||||
|
||||
# Plot the portfolio value over time.
|
||||
ax1 = plt.subplot(611)
|
||||
|
||||
@@ -161,7 +161,7 @@ def analyze(context=None, perf=None):
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
# The base currency of the algo exchange
|
||||
base_currency = context.exchanges.values()[0].base_currency.upper()
|
||||
base_currency = list(context.exchanges.values())[0].base_currency.upper()
|
||||
|
||||
# Plot the portfolio value over time.
|
||||
ax1 = plt.subplot(611)
|
||||
|
||||
@@ -175,7 +175,7 @@ def handle_data(context, data):
|
||||
def analyze(context=None, results=None):
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
base_currency = context.exchanges.values()[0].base_currency.upper()
|
||||
base_currency = list(context.exchanges.values())[0].base_currency.upper()
|
||||
# Plot the portfolio and asset data.
|
||||
ax1 = plt.subplot(611)
|
||||
results.loc[:, 'portfolio_value'].plot(ax=ax1)
|
||||
|
||||
@@ -57,7 +57,7 @@ def analyze(context, perf):
|
||||
log.info('the stats: {}'.format(get_pretty_stats(perf)))
|
||||
|
||||
# The base currency of the algo exchange
|
||||
base_currency = context.exchanges.values()[0].base_currency.upper()
|
||||
base_currency = list(context.exchanges.values())[0].base_currency.upper()
|
||||
|
||||
# Plot the portfolio value over time.
|
||||
ax1 = plt.subplot(611)
|
||||
|
||||
@@ -41,7 +41,7 @@ from catalyst.exchange.utils.exchange_utils import get_exchange_symbols
|
||||
|
||||
def initialize(context):
|
||||
context.i = -1 # minute counter
|
||||
context.exchange = context.exchanges.values()[0].name.lower()
|
||||
context.exchange = list(context.exchanges.values())[0].name.lower()
|
||||
context.base_currency = context.exchanges.values()[0].base_currency.lower()
|
||||
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ def get_pretty_stats(stats, recorded_cols=None, num_rows=10, show_tail=True):
|
||||
|
||||
"""
|
||||
if isinstance(stats, pd.DataFrame):
|
||||
stats = stats.T.to_dict().values()
|
||||
stats = list(stats.T.to_dict().values())
|
||||
stats.sort(key=itemgetter('period_close'))
|
||||
|
||||
if len(stats) > num_rows:
|
||||
|
||||
@@ -142,7 +142,7 @@ class TermGraph(object):
|
||||
at the end of execution.
|
||||
"""
|
||||
refcounts = self.graph.out_degree()
|
||||
for t in self.outputs.values():
|
||||
for t in list(self.outputs.values()):
|
||||
refcounts[t] += 1
|
||||
|
||||
for t in initial_terms:
|
||||
@@ -238,7 +238,7 @@ class ExecutionPlan(TermGraph):
|
||||
min_extra_rows=0):
|
||||
super(ExecutionPlan, self).__init__(terms)
|
||||
|
||||
for term in terms.values():
|
||||
for term in list(terms.values()):
|
||||
self.set_extra_rows(
|
||||
term,
|
||||
all_dates,
|
||||
|
||||
@@ -144,7 +144,7 @@ class SpecificEquityTrades(object):
|
||||
for identifier in self.identifiers:
|
||||
assets_by_identifier[identifier] = env.asset_finder.\
|
||||
lookup_generic(identifier, datetime.now())[0]
|
||||
self.sids = [asset.sid for asset in assets_by_identifier.values()]
|
||||
self.sids = [asset.sid for asset in list(assets_by_identifier.values())]
|
||||
for event in self.event_list:
|
||||
event.sid = assets_by_identifier[event.sid].sid
|
||||
|
||||
@@ -167,7 +167,7 @@ class SpecificEquityTrades(object):
|
||||
for identifier in self.identifiers:
|
||||
assets_by_identifier[identifier] = env.asset_finder.\
|
||||
lookup_generic(identifier, datetime.now())[0]
|
||||
self.sids = [asset.sid for asset in assets_by_identifier.values()]
|
||||
self.sids = [asset.sid for asset in list(assets_by_identifier.values())]
|
||||
|
||||
# Hash_value for downstream sorting.
|
||||
self.arg_string = hash_args(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user