+ +
+

Catalyst & Jupyter Notebook

+

(Feel free to check out the actual Notebook file +here)

+

The Jupyter Notebook is a very powerful +browser-based interface to a Python interpreter. As it is already the +de-facto interface for most quantitative researchers, catalyst +provides an easy way to run your algorithm inside the Notebook without +requiring you to use the CLI.

+
+

Install

+

In order to use Jupyter Notebook, you first have to install it inside your +environment. It’s available as pip package, so regardless of how you +installed Catalyst, go inside your catalyst environemnt and run:

+
(catalyst)$ pip install jupyter
+
+
+

Once you have Jupyter Notebook installed, every time you want to use it run:

+
(catalyst)$ jupyter notebook
+
+
+

A local server will launch, and will open a new window on your browser. That’s +the interface through which you will interact with Jupyter Notebook.

+
+
+

Running Algorithms

+

To use it you have to write your algorithm in a cell and let +catalyst know that it is supposed to run this algorithm. This is +done via the %%catalyst IPython magic command that is available +after you import catalyst from within the Notebook. This magic takes +the same arguments as the command line interface. Thus to run the +algorithm just supply the same parameters as the CLI but without the -f +and -o arguments. We just have to execute the following cell after +importing catalyst to register the magic.

+
# Register the catalyst magic
+%load_ext catalyst
+
+
+
# Setup matplotlib to display graphs inline in this Notebook
+%matplotlib inline
+
+
+

Note below that we do not have to specify an input file (-f) since the +magic will use the contents of the cell and look for your algorithm +functions.

+
%%catalyst --start 2015-3-2 --end 2017-6-28 --capital-base 100000 -x bitfinex
+
+from catalyst.finance.slippage import VolumeShareSlippage
+
+from catalyst.api import (
+    order_target_value,
+    symbol,
+    record,
+    cancel_order,
+    get_open_orders,
+)
+
+def initialize(context):
+    context.ASSET_NAME = 'btc_usd'
+    context.TARGET_HODL_RATIO = 0.8
+    context.RESERVE_RATIO = 1.0 - context.TARGET_HODL_RATIO
+
+    # For all trading pairs in the poloniex bundle, the default denomination
+    # currently supported by Catalyst is 1/1000th of a full coin. Use this
+    # constant to scale the price of up to that of a full coin if desired.
+    context.TICK_SIZE = 1000.0
+
+    context.is_buying = True
+    context.asset = symbol(context.ASSET_NAME)
+
+    context.i = 0
+
+def handle_data(context, data):
+    context.i += 1
+
+    starting_cash = context.portfolio.starting_cash
+    target_hodl_value = context.TARGET_HODL_RATIO * starting_cash
+    reserve_value = context.RESERVE_RATIO * starting_cash
+
+    # Cancel any outstanding orders
+    orders = get_open_orders(context.asset) or []
+    for order in orders:
+        cancel_order(order)
+
+    # Stop buying after passing the reserve threshold
+    cash = context.portfolio.cash
+    if cash <= reserve_value:
+        context.is_buying = False
+
+    # Retrieve current asset price from pricing data
+    price = data.current(context.asset, 'price')
+
+    # Check if still buying and could (approximately) afford another purchase
+    if context.is_buying and cash > price:
+        # Place order to make position in asset equal to target_hodl_value
+        order_target_value(
+            context.asset,
+            target_hodl_value,
+            limit_price=price*1.1,
+            stop_price=price*0.9,
+        )
+
+    record(
+        price=price,
+        volume=data.current(context.asset, 'volume'),
+        cash=cash,
+        starting_cash=context.portfolio.starting_cash,
+        leverage=context.account.leverage,
+    )
+
+def analyze(context=None, results=None):
+    import matplotlib.pyplot as plt
+
+    # Plot the portfolio and asset data.
+    ax1 = plt.subplot(611)
+    results[['portfolio_value']].plot(ax=ax1)
+    ax1.set_ylabel('Portfolio Value (USD)')
+
+    ax2 = plt.subplot(612, sharex=ax1)
+    ax2.set_ylabel('{asset} (USD)'.format(asset=context.ASSET_NAME))
+    (context.TICK_SIZE * results[['price']]).plot(ax=ax2)
+
+    trans = results.ix[[t != [] for t in results.transactions]]
+    buys = trans.ix[
+        [t[0]['amount'] > 0 for t in trans.transactions]
+    ]
+    ax2.plot(
+        buys.index,
+        context.TICK_SIZE * results.price[buys.index],
+        '^',
+        markersize=10,
+        color='g',
+    )
+
+    ax3 = plt.subplot(613, sharex=ax1)
+    results[['leverage', 'alpha', 'beta']].plot(ax=ax3)
+    ax3.set_ylabel('Leverage ')
+
+    ax4 = plt.subplot(614, sharex=ax1)
+    results[['starting_cash', 'cash']].plot(ax=ax4)
+    ax4.set_ylabel('Cash (USD)')
+
+    results[[
+        'treasury',
+        'algorithm',
+        'benchmark',
+    ]] = results[[
+        'treasury_period_return',
+        'algorithm_period_return',
+        'benchmark_period_return',
+    ]]
+
+    ax5 = plt.subplot(615, sharex=ax1)
+    results[[
+        'treasury',
+        'algorithm',
+        'benchmark',
+    ]].plot(ax=ax5)
+    ax5.set_ylabel('Percent Change')
+
+    ax6 = plt.subplot(616, sharex=ax1)
+    results[['volume']].plot(ax=ax6)
+    ax6.set_ylabel('Volume (mCoins/5min)')
+
+    plt.legend(loc=3)
+
+    # Show the plot.
+    plt.gcf().set_size_inches(18, 8)
+    plt.show()
+
+
+
[2017-08-11 07:19:46.411748] INFO: Loader: Loading benchmark data for 'USDT_BTC' from 1989-12-31 00:00:00+00:00 to 2017-08-09 00:00:00+00:00
+[2017-08-11 07:19:46.418983] INFO: Loader: Loading data for /Users/<snipped>/.catalyst/data/USDT_BTC_benchmark.csv failed with error [Unknown string format].
+[2017-08-11 07:19:46.419740] INFO: Loader: Cache at /Users/<snipped>/.catalyst/data/USDT_BTC_benchmark.csv does not have data from 1990-01-01 00:00:00+00:00 to 2017-08-09 00:00:00+00:00.
+
+[2017-08-11 07:19:46.420770] INFO: Loader: Downloading benchmark data for 'USDT_BTC' from 1989-12-31 00:00:00+00:00 to 2017-08-09 00:00:00+00:00
+[2017-08-11 07:19:50.060244] WARNING: Loader: Still don't have expected data after redownload!
+[2017-08-11 07:19:50.097334] WARNING: Loader: Refusing to download new treasury data because a download succeeded at 2017-08-11 06:56:49+00:00.
+[2017-08-11 07:19:54.618399] INFO: Performance: Simulated 851 trading days out of 851.
+[2017-08-11 07:19:54.619301] INFO: Performance: first open: 2015-03-01 00:00:00+00:00
+[2017-08-11 07:19:54.620430] INFO: Performance: last close: 2017-06-28 23:59:00+00:00
+
+
+
+png +

png

+
+

algo_volatility

+

algorithm_period_return

+

alpha

+

benchmark_period_return

+

benchmark_volatility

+

beta

+

capital_used

+

cash

+

ending_cash

+

ending_exposure

+

+

starting_cash

+

starting_exposure

+

starting_value

+

trading_days

+

transactions

+

treasury_period_return

+

volume

+

treasury

+

algorithm

+

benchmark

+

2015-03-01 23:59:00+00:00

+

NaN

+

0.000000

+

NaN

+

0.045833

+

NaN

+

NaN

+

0.000000

+

100000.000000

+

100000.000000

+

0.000

+

+

100000.0

+

0.000

+

0.000

+

1

+

[]

+

0.0200

+

317

+

0.0200

+

0.000000

+

0.045833

+

2015-03-02 23:59:00+00:00

+

0.000278

+

-0.000025

+

0.011045

+

0.120833

+

0.290503

+

-0.000956

+

-85544.474955

+

14455.525045

+

14455.525045

+

85542.000

+

+

100000.0

+

0.000

+

0.000

+

2

+

[{u’commission’: None, u’amount’: 318, u’sid’:…

+

0.0208

+

98063

+

0.0208

+

-0.000025

+

0.120833

+

2015-03-03 23:59:00+00:00

+

0.051796

+

-0.005688

+

-1.197544

+

0.113416

+

0.633538

+

0.077239

+

0.000000

+

14455.525045

+

14455.525045

+

84975.642

+

+

100000.0

+

85542.000

+

85542.000

+

3

+

[]

+

0.0212

+

442983

+

0.0212

+

-0.005688

+

0.113416

+

2015-03-04 23:59:00+00:00

+

0.342118

+

0.034955

+

0.401861

+

0.166666

+

0.524400

+

0.181468

+

0.000000

+

14455.525045

+

14455.525045

+

89040.000

+

+

100000.0

+

84975.642

+

84975.642

+

4

+

[]

+

0.0212

+

245889

+

0.0212

+

0.034955

+

0.166666

+

2015-03-05 23:59:00+00:00

+

0.637226

+

-0.038185

+

-3.914003

+

0.070834

+

0.976896

+

0.550520

+

0.000000

+

14455.525045

+

14455.525045

+

81726.000

+

+

100000.0

+

89040.000

+

89040.000

+

5

+

[]

+

0.0211

+

117440

+

0.0211

+

-0.038185

+

0.070834

+

2015-03-06 23:59:00+00:00

+

0.580521

+

-0.028645

+

-3.100822

+

0.083333

+

0.874082

+

0.546703

+

0.000000

+

14455.525045

+

14455.525045

+

82680.000

+

+

100000.0

+

81726.000

+

81726.000

+

6

+

[]

+

0.0224

+

84197

+

0.0224

+

-0.028645

+

0.083333

+

2015-03-07 23:59:00+00:00

+

0.530557

+

-0.028645

+

-2.625704

+

0.083333

+

0.802793

+

0.536589

+

0.000000

+

14455.525045

+

14455.525045

+

82680.000

+

+

100000.0

+

82680.000

+

82680.000

+

7

+

[]

+

0.0224

+

181

+

0.0224

+

-0.028645

+

0.083333

+

2015-03-08 23:59:00+00:00

+

0.491628

+

-0.028645

+

-2.276841

+

0.083333

+

0.746605

+

0.529163

+

0.000000

+

14455.525045

+

14455.525045

+

82680.000

+

+

100000.0

+

82680.000

+

82680.000

+

8

+

[]

+

0.0224

+

30900

+

0.0224

+

-0.028645

+

0.083333

+

2015-03-09 23:59:00+00:00

+

0.467885

+

-0.015925

+

-1.895269

+

0.100000

+

0.698764

+

0.532652

+

0.000000

+

14455.525045

+

14455.525045

+

83952.000

+

+

100000.0

+

82680.000

+

82680.000

+

9

+

[]

+

0.0220

+

128367

+

0.0220

+

-0.015925

+

0.100000

+

2015-03-10 23:59:00+00:00

+

0.626552

+

0.069935

+

-1.625285

+

0.212500

+

0.800983

+

0.676289

+

0.000000

+

14455.525045

+

14455.525045

+

92538.000

+

+

100000.0

+

83952.000

+

83952.000

+

10

+

[]

+

0.0214

+

54961

+

0.0214

+

0.069935

+

0.212500

+

2015-03-11 23:59:00+00:00

+

0.644515

+

0.022235

+

-1.727710

+

0.150000

+

0.834650

+

0.684052

+

0.000000

+

14455.525045

+

14455.525045

+

87768.000

+

+

100000.0

+

92538.000

+

92538.000

+

11

+

[]

+

0.0211

+

42511

+

0.0211

+

0.022235

+

0.150000

+

2015-03-12 23:59:00+00:00

+

0.614650

+

0.022235

+

-1.573455

+

0.150000

+

0.798403

+

0.680882

+

0.000000

+

14455.525045

+

14455.525045

+

87768.000

+

+

100000.0

+

87768.000

+

87768.000

+

12

+

[]

+

0.0210

+

2909

+

0.0210

+

0.022235

+

0.150000

+

2015-03-13 23:59:00+00:00

+

0.588942

+

0.019405

+

-1.454733

+

0.146291

+

0.767688

+

0.677881

+

0.000000

+

14455.525045

+

14455.525045

+

87484.980

+

+

100000.0

+

87768.000

+

87768.000

+

13

+

[]

+

0.0213

+

57613

+

0.0213

+

0.019405

+

0.146291

+

2015-03-14 23:59:00+00:00

+

0.565911

+

0.019373

+

-1.344915

+

0.146250

+

0.739230

+

0.675665

+

0.000000

+

14455.525045

+

14455.525045

+

87481.800

+

+

100000.0

+

87484.980

+

87484.980

+

14

+

[]

+

0.0213

+

48310

+

0.0213

+

0.019373

+

0.146250

+

2015-03-15 23:59:00+00:00

+

0.551394

+

0.041659

+

-1.191436

+

0.175450

+

0.714876

+

0.680484

+

0.000000

+

14455.525045

+

14455.525045

+

89710.344

+

+

100000.0

+

87481.800

+

87481.800

+

15

+

[]

+

0.0213

+

29454

+

0.0213

+

0.041659

+

0.175450

+

2015-03-16 23:59:00+00:00

+

0.541846

+

0.019055

+

-1.188212

+

0.145833

+

0.706049

+

0.680281

+

0.000000

+

14455.525045

+

14455.525045

+

87450.000

+

+

100000.0

+

89710.344

+

89710.344

+

16

+

[]

+

0.0210

+

25564

+

0.0210

+

0.019055

+

0.145833

+

2015-03-17 23:59:00+00:00

+

0.524682

+

0.019055

+

-1.115149

+

0.145833

+

0.684599

+

0.678870

+

0.000000

+

14455.525045

+

14455.525045

+

87450.000

+

+

100000.0

+

87450.000

+

87450.000

+

17

+

[]

+

0.0206

+

9

+

0.0206

+

0.019055

+

0.145833

+

2015-03-18 23:59:00+00:00

+

0.532621

+

-0.021999

+

-1.180440

+

0.092041

+

0.696261

+

0.685307

+

0.000000

+

14455.525045

+

14455.525045

+

83344.620

+

+

100000.0

+

87450.000

+

87450.000

+

18

+

[]

+

0.0193

+

164911

+

0.0193

+

-0.021999

+

0.092041

+

2015-03-19 23:59:00+00:00

+

0.518811

+

-0.013234

+

-1.096387

+

0.103526

+

0.676861

+

0.686186

+

0.000000

+

14455.525045

+

14455.525045

+

84221.028

+

+

100000.0

+

83344.620

+

83344.620

+

19

+

[]

+

0.0198

+

713904

+

0.0198

+

-0.013234

+

0.103526

+

2015-03-20 23:59:00+00:00

+

0.505168

+

-0.017324

+

-1.050273

+

0.098170

+

0.659945

+

0.685070

+

0.000000

+

14455.525045

+

14455.525045

+

83812.080

+

+

100000.0

+

84221.028

+

84221.028

+

20

+

[]

+

0.0193

+

132725

+

0.0193

+

-0.017324

+

0.098170

+

2015-03-21 23:59:00+00:00

+

0.492384

+

-0.018494

+

-1.002051

+

0.096637

+

0.643679

+

0.684283

+

0.000000

+

14455.525045

+

14455.525045

+

83695.056

+

+

100000.0

+

83812.080

+

83812.080

+

21

+

[]

+

0.0193

+

201155

+

0.0193

+

-0.018494

+

0.096637

+

2015-03-22 23:59:00+00:00

+

0.482998

+

-0.004744

+

-0.927947

+

0.114653

+

0.629319

+

0.686478

+

0.000000

+

14455.525045

+

14455.525045

+

85070.088

+

+

100000.0

+

83695.056

+

83695.056

+

22

+

[]

+

0.0193

+

64378

+

0.0193

+

-0.004744

+

0.114653

+

2015-03-23 23:59:00+00:00

+

0.477523

+

-0.026505

+

-0.935352

+

0.086139

+

0.623502

+

0.687025

+

0.000000

+

14455.525045

+

14455.525045

+

82894.014

+

+

100000.0

+

85070.088

+

85070.088

+

23

+

[]

+

0.0192

+

61850

+

0.0192

+

-0.026505

+

0.086139

+

2015-03-24 23:59:00+00:00

+

0.504086

+

-0.084215

+

-1.021023

+

0.010523

+

0.655188

+

0.701025

+

0.000000

+

14455.525045

+

14455.525045

+

77122.950

+

+

100000.0

+

82894.014

+

82894.014

+

24

+

[]

+

0.0188

+

490180

+

0.0188

+

-0.084215

+

0.010523

+

2015-03-25 23:59:00+00:00

+

0.497690

+

-0.068474

+

-0.952786

+

0.031148

+

0.644272

+

0.704251

+

0.000000

+

14455.525045

+

14455.525045

+

78697.050

+

+

100000.0

+

77122.950

+

77122.950

+

25

+

[]

+

0.0193

+

90862

+

0.0193

+

-0.068474

+

0.031148

+

2015-03-26 23:59:00+00:00

+

0.489730

+

-0.084215

+

-0.943240

+

0.010523

+

0.634965

+

0.703738

+

0.000000

+

14455.525045

+

14455.525045

+

77122.950

+

+

100000.0

+

78697.050

+

78697.050

+

26

+

[]

+

0.0201

+

2299

+

0.0201

+

-0.084215

+

0.010523

+

2015-03-27 23:59:00+00:00

+

0.495916

+

-0.049785

+

-0.857592

+

0.055636

+

0.636644

+

0.713671

+

0.000000

+

14455.525045

+

14455.525045

+

80565.936

+

+

100000.0

+

77122.950

+

77122.950

+

27

+

[]

+

0.0195

+

663

+

0.0195

+

-0.049785

+

0.055636

+

2015-03-28 23:59:00+00:00

+

0.488469

+

-0.064490

+

-0.848769

+

0.036368

+

0.627920

+

0.713212

+

0.000000

+

14455.525045

+

14455.525045

+

79095.504

+

+

100000.0

+

80565.936

+

80565.936

+

28

+

[]

+

0.0195

+

7061

+

0.0195

+

-0.064490

+

0.036368

+

2015-03-29 23:59:00+00:00

+

0.479671

+

-0.066903

+

-0.822844

+

0.033205

+

0.616787

+

0.712868

+

0.000000

+

14455.525045

+

14455.525045

+

78854.142

+

+

100000.0

+

79095.504

+

79095.504

+

29

+

[]

+

0.0195

+

8526

+

0.0195

+

-0.066903

+

0.033205

+

2015-03-30 23:59:00+00:00

+

0.476306

+

-0.046605

+

-0.769239

+

0.059803

+

0.610002

+

0.716464

+

0.000000

+

14455.525045

+

14455.525045

+

80883.936

+

+

100000.0

+

78854.142

+

78854.142

+

30

+

[]

+

0.0196

+

29654

+

0.0196

+

-0.046605

+

0.059803

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

2017-05-30 23:59:00+00:00

+

0.495432

+

5.949752

+

-0.016611

+

7.916664

+

0.554369

+

0.888883

+

0.000000

+

14455.525045

+

14455.525045

+

680519.682

+

+

100000.0

+

701826.000

+

701826.000

+

822

+

[]

+

0.0221

+

40157964723

+

0.0221

+

5.949752

+

7.916664

+

2017-05-31 23:59:00+00:00

+

0.495243

+

6.102328

+

-0.017086

+

8.154164

+

0.554182

+

0.888844

+

0.000000

+

14455.525045

+

14455.525045

+

695777.322

+

+

100000.0

+

680519.682

+

680519.682

+

823

+

[]

+

0.0221

+

31098652109

+

0.0221

+

6.102328

+

8.154164

+

2017-06-01 23:59:00+00:00

+

0.495836

+

6.504967

+

-0.014668

+

8.644144

+

0.554541

+

0.889303

+

0.000000

+

14455.525045

+

14455.525045

+

736041.210

+

+

100000.0

+

695777.322

+

695777.322

+

824

+

[]

+

0.0221

+

40944880757

+

0.0221

+

6.504967

+

8.644144

+

2017-06-02 23:59:00+00:00

+

0.495948

+

6.801995

+

-0.013641

+

9.033331

+

0.554581

+

0.889440

+

0.000000

+

14455.525045

+

14455.525045

+

765744.000

+

+

100000.0

+

736041.210

+

736041.210

+

825

+

[]

+

0.0215

+

22364557424

+

0.0215

+

6.801995

+

9.033331

+

2017-06-03 23:59:00+00:00

+

0.495729

+

6.952409

+

-0.013100

+

9.230418

+

0.554317

+

0.889470

+

0.000000

+

14455.525045

+

14455.525045

+

780785.400

+

+

100000.0

+

765744.000

+

765744.000

+

826

+

[]

+

0.0215

+

23687278961

+

0.0215

+

6.952409

+

9.230418

+

2017-06-04 23:59:00+00:00

+

0.495450

+

7.042244

+

-0.012768

+

9.348122

+

0.553999

+

0.889479

+

0.000000

+

14455.525045

+

14455.525045

+

789768.900

+

+

100000.0

+

780785.400

+

780785.400

+

827

+

[]

+

0.0215

+

21332021248

+

0.0215

+

7.042244

+

9.348122

+

2017-06-05 23:59:00+00:00

+

0.496148

+

7.524987

+

-0.011320

+

9.980649

+

0.554578

+

0.889805

+

0.000000

+

14455.525045

+

14455.525045

+

838043.208

+

+

100000.0

+

789768.900

+

789768.900

+

828

+

[]

+

0.0218

+

22372229837

+

0.0218

+

7.524987

+

9.980649

+

2017-06-06 23:59:00+00:00

+

0.497592

+

8.194835

+

-0.009554

+

10.858330

+

0.555841

+

0.890368

+

0.000000

+

14455.525045

+

14455.525045

+

905028.000

+

+

100000.0

+

838043.208

+

838043.208

+

829

+

[]

+

0.0214

+

81923184446

+

0.0214

+

8.194835

+

10.858330

+

2017-06-07 23:59:00+00:00

+

0.498895

+

7.557258

+

-0.011975

+

10.022932

+

0.557003

+

0.890845

+

0.000000

+

14455.525045

+

14455.525045

+

841270.272

+

+

100000.0

+

905028.000

+

905028.000

+

830

+

[]

+

0.0218

+

49070430356

+

0.0218

+

7.557258

+

10.022932

+

2017-06-08 23:59:00+00:00

+

0.499349

+

8.010395

+

-0.010676

+

10.616664

+

0.557357

+

0.891092

+

0.000000

+

14455.525045

+

14455.525045

+

886584.000

+

+

100000.0

+

841270.272

+

841270.272

+

831

+

[]

+

0.0219

+

34013412940

+

0.0219

+

8.010395

+

10.616664

+

2017-06-09 23:59:00+00:00

+

0.499063

+

8.099750

+

-0.010386

+

10.733746

+

0.557033

+

0.891098

+

0.000000

+

14455.525045

+

14455.525045

+

895519.482

+

+

100000.0

+

886584.000

+

886584.000

+

832

+

[]

+

0.0221

+

25275425996

+

0.0221

+

8.099750

+

10.733746

+

2017-06-10 23:59:00+00:00

+

0.498769

+

8.086143

+

-0.010416

+

10.715915

+

0.556705

+

0.891098

+

0.000000

+

14455.525045

+

14455.525045

+

894158.760

+

+

100000.0

+

895519.482

+

895519.482

+

833

+

[]

+

0.0221

+

30620792046

+

0.0221

+

8.086143

+

10.715915

+

2017-06-11 23:59:00+00:00

+

0.498971

+

8.484533

+

-0.009305

+

11.237914

+

0.556827

+

0.891266

+

0.000000

+

14455.525045

+

14455.525045

+

933997.800

+

+

100000.0

+

894158.760

+

894158.760

+

834

+

[]

+

0.0221

+

30830678595

+

0.0221

+

8.484533

+

11.237914

+

2017-06-12 23:59:00+00:00

+

0.503448

+

7.320494

+

-0.014065

+

9.712706

+

0.560936

+

0.892695

+

0.000000

+

14455.525045

+

14455.525045

+

817593.900

+

+

100000.0

+

933997.800

+

933997.800

+

835

+

[]

+

0.0221

+

88704710635

+

0.0221

+

7.320494

+

9.712706

+

2017-06-13 23:59:00+00:00

+

0.503565

+

7.656697

+

-0.013054

+

10.153225

+

0.560981

+

0.892830

+

0.000000

+

14455.525045

+

14455.525045

+

851214.132

+

+

100000.0

+

817593.900

+

817593.900

+

836

+

[]

+

0.0221

+

42251296767

+

0.0221

+

7.656697

+

10.153225

+

2017-06-14 23:59:00+00:00

+

0.506845

+

6.734516

+

-0.016873

+

8.944917

+

0.563995

+

0.893862

+

0.000000

+

14455.525045

+

14455.525045

+

758996.040

+

+

100000.0

+

851214.132

+

851214.132

+

837

+

[]

+

0.0215

+

63183088135

+

0.0215

+

6.734516

+

8.944917

+

2017-06-15 23:59:00+00:00

+

0.506562

+

6.695367

+

-0.016991

+

8.893622

+

0.563678

+

0.893865

+

0.000000

+

14455.525045

+

14455.525045

+

755081.142

+

+

100000.0

+

758996.040

+

758996.040

+

838

+

[]

+

0.0216

+

104677533974

+

0.0216

+

6.695367

+

8.893622

+

2017-06-16 23:59:00+00:00

+

0.506404

+

6.887855

+

-0.016343

+

9.145831

+

0.563472

+

0.893913

+

0.000000

+

14455.525045

+

14455.525045

+

774330.000

+

+

100000.0

+

755081.142

+

755081.142

+

839

+

[]

+

0.0216

+

43479966625

+

0.0216

+

6.887855

+

9.145831

+

2017-06-17 23:59:00+00:00

+

0.507407

+

7.435283

+

-0.014812

+

9.863113

+

0.564341

+

0.894311

+

0.000000

+

14455.525045

+

14455.525045

+

829072.746

+

+

100000.0

+

774330.000

+

774330.000

+

840

+

[]

+

0.0216

+

36800919715

+

0.0216

+

7.435283

+

9.863113

+

2017-06-18 23:59:00+00:00

+

0.507740

+

7.070069

+

-0.016112

+

9.384581

+

0.564605

+

0.894482

+

0.000000

+

14455.525045

+

14455.525045

+

792551.400

+

+

100000.0

+

829072.746

+

829072.746

+

841

+

[]

+

0.0216

+

46411759478

+

0.0216

+

7.070069

+

9.384581

+

2017-06-19 23:59:00+00:00

+

0.507754

+

7.358645

+

-0.015226

+

9.762694

+

0.564557

+

0.894583

+

0.000000

+

14455.525045

+

14455.525045

+

821408.946

+

+

100000.0

+

792551.400

+

792551.400

+

842

+

[]

+

0.0219

+

28294406623

+

0.0219

+

7.358645

+

9.762694

+

2017-06-20 23:59:00+00:00

+

0.507705

+

7.628795

+

-0.014414

+

10.116664

+

0.564451

+

0.894665

+

0.000000

+

14455.525045

+

14455.525045

+

848424.000

+

+

100000.0

+

821408.946

+

821408.946

+

843

+

[]

+

0.0216

+

36903854052

+

0.0216

+

7.628795

+

10.116664

+

2017-06-21 23:59:00+00:00

+

0.507531

+

7.476155

+

-0.014900

+

9.916664

+

0.564238

+

0.894696

+

0.000000

+

14455.525045

+

14455.525045

+

833160.000

+

+

100000.0

+

848424.000

+

848424.000

+

844

+

[]

+

0.0216

+

43815656010

+

0.0216

+

7.476155

+

9.916664

+

2017-06-22 23:59:00+00:00

+

0.507315

+

7.645891

+

-0.014372

+

10.139065

+

0.563979

+

0.894725

+

0.000000

+

14455.525045

+

14455.525045

+

850133.568

+

+

100000.0

+

833160.000

+

833160.000

+

845

+

[]

+

0.0215

+

22304647568

+

0.0215

+

7.645891

+

10.139065

+

2017-06-23 23:59:00+00:00

+

0.507020

+

7.635155

+

-0.014388

+

10.124997

+

0.563652

+

0.894725

+

0.000000

+

14455.525045

+

14455.525045

+

849060.000

+

+

100000.0

+

850133.568

+

850133.568

+

846

+

[]

+

0.0215

+

13090231864

+

0.0215

+

7.635155

+

10.124997

+

2017-06-24 23:59:00+00:00

+

0.507936

+

7.105628

+

-0.016304

+

9.431173

+

0.564463

+

0.895061

+

0.000000

+

14455.525045

+

14455.525045

+

796107.276

+

+

100000.0

+

849060.000

+

849060.000

+

847

+

[]

+

0.0215

+

34088563732

+

0.0215

+

7.105628

+

9.431173

+

2017-06-25 23:59:00+00:00

+

0.507675

+

7.036714

+

-0.016515

+

9.340880

+

0.564168

+

0.895069

+

0.000000

+

14455.525045

+

14455.525045

+

789215.898

+

+

100000.0

+

796107.276

+

796107.276

+

848

+

[]

+

0.0215

+

41560204433

+

0.0215

+

7.036714

+

9.340880

+

2017-06-26 23:59:00+00:00

+

0.507780

+

6.761571

+

-0.017485

+

8.980368

+

0.564221

+

0.895175

+

0.000000

+

14455.525045

+

14455.525045

+

761701.584

+

+

100000.0

+

789215.898

+

789215.898

+

849

+

[]

+

0.0214

+

73840480752

+

0.0214

+

6.761571

+

8.980368

+

2017-06-27 23:59:00+00:00

+

0.508048

+

7.126355

+

-0.016390

+

9.458331

+

0.564409

+

0.895349

+

0.000000

+

14455.525045

+

14455.525045

+

798180.000

+

+

100000.0

+

761701.584

+

761701.584

+

850

+

[]

+

0.0221

+

62426319778

+

0.0221

+

7.126355

+

9.458331

+

2017-06-28 23:59:00+00:00

+

0.507750

+

7.135895

+

-0.016340

+

9.470831

+

0.564078

+

0.895349

+

0.000000

+

14455.525045

+

14455.525045

+

799134.000

+

+

100000.0

+

798180.000

+

798180.000

+

851

+

[]

+

0.0222

+

39676839183

+

0.0222

+

7.135895

+

9.470831

+

851 rows × 45 columns

+

Also, instead of defining an output file we are accessing it via the “_” +variable that will be created in the name space and contain the +performance DataFrame.

+
_.head()
+
+
+

algo_volatility

+

algorithm_period_return

+

alpha

+

benchmark_period_return

+

benchmark_volatility

+

beta

+

capital_used

+

cash

+

ending_cash

+

ending_exposure

+

+

starting_cash

+

starting_exposure

+

starting_value

+

trading_days

+

transactions

+

treasury_period_return

+

volume

+

treasury

+

algorithm

+

benchmark

+

2015-03-01 23:59:00+00:00

+

NaN

+

0.000000

+

NaN

+

0.045833

+

NaN

+

NaN

+

0.000000

+

100000.000000

+

100000.000000

+

0.000

+

+

100000.0

+

0.000

+

0.000

+

1

+

[]

+

0.0200

+

317

+

0.0200

+

0.000000

+

0.045833

+

2015-03-02 23:59:00+00:00

+

0.000278

+

-0.000025

+

0.011045

+

0.120833

+

0.290503

+

-0.000956

+

-85544.474955

+

14455.525045

+

14455.525045

+

85542.000

+

+

100000.0

+

0.000

+

0.000

+

2

+

[{u’commission’: None, u’amount’: 318, u’sid’:…

+

0.0208

+

98063

+

0.0208

+

-0.000025

+

0.120833

+

2015-03-03 23:59:00+00:00

+

0.051796

+

-0.005688

+

-1.197544

+

0.113416

+

0.633538

+

0.077239

+

0.000000

+

14455.525045

+

14455.525045

+

84975.642

+

+

100000.0

+

85542.000

+

85542.000

+

3

+

[]

+

0.0212

+

442983

+

0.0212

+

-0.005688

+

0.113416

+

2015-03-04 23:59:00+00:00

+

0.342118

+

0.034955

+

0.401861

+

0.166666

+

0.524400

+

0.181468

+

0.000000

+

14455.525045

+

14455.525045

+

89040.000

+

+

100000.0

+

84975.642

+

84975.642

+

4

+

[]

+

0.0212

+

245889

+

0.0212

+

0.034955

+

0.166666

+

2015-03-05 23:59:00+00:00

+

0.637226

+

-0.038185

+

-3.914003

+

0.070834

+

0.976896

+

0.550520

+

0.000000

+

14455.525045

+

14455.525045

+

81726.000

+

+

100000.0

+

89040.000

+

89040.000

+

5

+

[]

+

0.0211

+

117440

+

0.0211

+

-0.038185

+

0.070834

+

5 rows × 45 columns

+

+
+ + +