mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-30 16:47:49 +08:00
remove symbols, print head
This commit is contained in:
@@ -76,8 +76,6 @@
|
||||
"source": [
|
||||
"As you can see, we first have to import some functions we would like to use. All functions commonly used in your algorithm can be found in `zipline.api`. Here we are using `order()` which takes two arguments -- a security object, and a number specifying how many stocks you would like to order (if negative, `order()` will sell/short stocks). In this case we want to order 10 shares of Apple at each iteration. For more documentation on `order()`, see the [Quantopian docs](https://www.quantopian.com/help#api-order).\n",
|
||||
"\n",
|
||||
"You don't have to use the `symbol()` function and could just pass in `AAPL` directly but it is good practice as this way your code will be Quantopian compatible.\n",
|
||||
"\n",
|
||||
"Finally, the `record()` function allows you to save the value of a variable at each iteration. You provide it with a name for the variable together with the variable itself: `varname=var`. After the algorithm finished running you will have access to each variable value you tracked with `record()` under the name you provided (we will see this further below). You also see how we can access the current price data of the AAPL stock in the `data` event frame (for more information see [here](https://www.quantopian.com/help#api-event-properties)."
|
||||
]
|
||||
},
|
||||
@@ -105,7 +103,7 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"usage: run_algo.py [-h] [-c FILE] [--algofile ALGOFILE] [--data-frequency {minute,daily}] [--start START] [--end END]\r\n",
|
||||
" [--capital_base CAPITAL_BASE] [--source {yahoo}] [--source_time_column SOURCE_TIME_COLUMN] [--symbols SYMBOLS]\r\n",
|
||||
" [--capital_base CAPITAL_BASE] [--source {yahoo}] [--source_time_column SOURCE_TIME_COLUMN]\r\n",
|
||||
" [--output OUTPUT] [--metadata_path METADATA_PATH] [--metadata_index METADATA_INDEX] [--print-algo] [--no-print-algo]\r\n",
|
||||
"\r\n",
|
||||
"Zipline version 0.8.0rc1.\r\n",
|
||||
@@ -121,7 +119,6 @@
|
||||
" --capital_base CAPITAL_BASE\r\n",
|
||||
" --source {yahoo}, -d {yahoo}\r\n",
|
||||
" --source_time_column SOURCE_TIME_COLUMN, -t SOURCE_TIME_COLUMN\r\n",
|
||||
" --symbols SYMBOLS\r\n",
|
||||
" --output OUTPUT, -o OUTPUT\r\n",
|
||||
" --metadata_path METADATA_PATH, -m METADATA_PATH\r\n",
|
||||
" --metadata_index METADATA_INDEX, -x METADATA_INDEX\r\n",
|
||||
@@ -140,7 +137,7 @@
|
||||
"source": [
|
||||
"Note that you have to omit the preceding '!' when you call `run_algo.py`, this is only required by the IPython Notebook in which this tutorial was written.\n",
|
||||
"\n",
|
||||
"As you can see there are a couple of flags that specify where to find your algorithm (`-f`) as well as parameters specifying which stock data to load from Yahoo! finance (`--symbols`) and the time-range (`--start` and `--end`). Finally, you'll want to save the performance metrics of your algorithm so that you can analyze how it performed. This is done via the `--output` flag and will cause it to write the performance `DataFrame` in the pickle Python file format. Note that you can also define a configuration file with these parameters that you can then conveniently pass to the `-c` option so that you don't have to supply the command line args all the time (see the .conf files in the examples directory).\n",
|
||||
"As you can see there are a couple of flags that specify where to find your algorithm (`-f`) as well as parameters specifying which stock data to load from Yahoo! finance and the time-range (`--start` and `--end`). Finally, you'll want to save the performance metrics of your algorithm so that you can analyze how it performed. This is done via the `--output` flag and will cause it to write the performance `DataFrame` in the pickle Python file format. Note that you can also define a configuration file with these parameters that you can then conveniently pass to the `-c` option so that you don't have to supply the command line args all the time (see the .conf files in the examples directory).\n",
|
||||
"\n",
|
||||
"Thus, to execute our algorithm from above and save the results to `buyapple_out.pickle` we would call `run_algo.py` as follows:"
|
||||
]
|
||||
@@ -164,7 +161,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!run_algo.py -f ../../zipline/examples/buyapple.py --start 2000-1-1 --end 2014-1-1 --symbols AAPL -o buyapple_out.pickle"
|
||||
"!run_algo.py -f ../../zipline/examples/buyapple.py --start 2000-1-1 --end 2014-1-1 -o buyapple_out.pickle"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -410,7 +407,7 @@
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"perf = pd.read_pickle('buyapple_out.pickle') # read in perf DataFrame\n",
|
||||
"perf.head()"
|
||||
"print perf.head()"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -513,7 +510,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%zipline --start 2000-1-1 --end 2014-1-1 --symbols AAPL -o perf_ipython\n",
|
||||
"%%zipline --start 2000-1-1 --end 2014-1-1 -o perf_ipython\n",
|
||||
"\n",
|
||||
"from zipline.api import symbol, order, record\n",
|
||||
"\n",
|
||||
@@ -867,7 +864,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%zipline --start 2000-1-1 --end 2014-1-1 --symbols AAPL -o perf_dma\n",
|
||||
"%%zipline --start 2000-1-1 --end 2014-1-1 -o perf_dma\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"from zipline.api import order_target, record, symbol, history\n",
|
||||
|
||||
Reference in New Issue
Block a user