mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-14 11:15:09 +08:00
MAINT: print function clean up in preparation for Python 3
- Use `print()` function for all print calls - Fix strip and format calls that were on the outside of the print function for some reason. (Which were breaking in Python 3 because of print returning None.) - Remove commented out print calls.
This commit is contained in:
@@ -974,7 +974,6 @@ shares in position"
|
||||
"should have a cost basis of 11.33"
|
||||
)
|
||||
|
||||
# print "second period pnl is {pnl}".format(pnl=pp2.pnl)
|
||||
self.assertEqual(pp.pnl, -800, "this period goes from +400 to -400")
|
||||
|
||||
pp3 = perf.PerformancePeriod(1000.0)
|
||||
|
||||
@@ -300,7 +300,7 @@ class TestTALIB(TestCase):
|
||||
and n not in BLACKLIST]
|
||||
|
||||
for name in names:
|
||||
print name
|
||||
print(name)
|
||||
zipline_transform = getattr(ta, name)(sid=0)
|
||||
talib_fn = getattr(talib.abstract, name)
|
||||
|
||||
@@ -337,7 +337,7 @@ class TestTALIB(TestCase):
|
||||
and np.all(np.isnan(expected_result))):
|
||||
self.assertTrue(np.allclose(zipline_result, expected_result))
|
||||
else:
|
||||
print '--- NAN'
|
||||
print('--- NAN')
|
||||
|
||||
# reset generator so next iteration has data
|
||||
# self.source, self.panel = \
|
||||
|
||||
@@ -163,7 +163,7 @@ def load_market_data(bm_symbol='^GSPC'):
|
||||
print("""
|
||||
data files aren't distributed with source.
|
||||
Fetching data from Yahoo Finance.
|
||||
""").strip()
|
||||
""".strip())
|
||||
dump_benchmarks(bm_symbol)
|
||||
fp_bm = get_datafile(get_benchmark_filename(bm_symbol), "rb")
|
||||
|
||||
@@ -211,7 +211,7 @@ Fetching data from Yahoo Finance.
|
||||
print("""
|
||||
data files aren't distributed with source.
|
||||
Fetching data from {0}
|
||||
""").format(source).strip()
|
||||
""".format(source).strip())
|
||||
dump_treasury_curves(module, filename)
|
||||
fp_tr = get_datafile(filename, "rb")
|
||||
|
||||
@@ -277,7 +277,7 @@ must specify stocks or indexes"""
|
||||
|
||||
if stocks is not None:
|
||||
for stock in stocks:
|
||||
print stock
|
||||
print(stock)
|
||||
cache_filename = "{stock}-{start}-{end}.csv".format(
|
||||
stock=stock,
|
||||
start=start,
|
||||
@@ -292,7 +292,7 @@ must specify stocks or indexes"""
|
||||
|
||||
if indexes is not None:
|
||||
for name, ticker in indexes.iteritems():
|
||||
print name
|
||||
print(name)
|
||||
stkd = DataReader(ticker, 'yahoo', start, end).sort_index()
|
||||
data[name] = stkd
|
||||
|
||||
|
||||
@@ -96,5 +96,5 @@ if __name__ == '__main__':
|
||||
plt.legend(loc=0)
|
||||
|
||||
sharpe = [risk['sharpe'] for risk in dma.risk_report['one_month']]
|
||||
print "Monthly Sharpe ratios:", sharpe
|
||||
print("Monthly Sharpe ratios: {0}".format(sharpe))
|
||||
plt.gcf().set_size_inches(18, 8)
|
||||
|
||||
@@ -128,9 +128,9 @@ def simplex_projection(v, b=1):
|
||||
|
||||
:Example:
|
||||
>>> proj = simplex_projection([.4 ,.3, -.4, .5])
|
||||
>>> print proj
|
||||
>>> print(proj)
|
||||
array([ 0.33333333, 0.23333333, 0. , 0.43333333])
|
||||
>>> print proj.sum()
|
||||
>>> print(proj.sum())
|
||||
1.0
|
||||
|
||||
Original matlab implementation: John Duchi (jduchi@cs.berkeley.edu)
|
||||
|
||||
@@ -340,7 +340,7 @@ class TestTargetValueAlgorithm(TradingAlgorithm):
|
||||
self.target_shares = 10
|
||||
return
|
||||
else:
|
||||
print self.portfolio
|
||||
print(self.portfolio)
|
||||
assert self.portfolio.positions[0]['amount'] == \
|
||||
self.target_shares, "Orders not filled immediately."
|
||||
assert self.portfolio.positions[0]['last_sale_price'] == \
|
||||
|
||||
Reference in New Issue
Block a user