vnpy/tests/backtesting/.ipynb_checkpoints/turtle-checkpoint.ipynb

85 lines
1.7 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#%%\n",
"from vnpy.app.cta_strategy.backtesting import BacktestingEngine\n",
"from vnpy.app.cta_strategy.strategies.turtle_signal_strategy import (\n",
" TurtleSignalStrategy,\n",
")\n",
"from datetime import datetime"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#%%\n",
"engine = BacktestingEngine()\n",
"engine.set_parameters(\n",
" vt_symbol=\"IF88.CFFEX\",\n",
" interval=\"1m\",\n",
" start=datetime(2013, 1, 1),\n",
" end=datetime(2015, 3, 30),\n",
" rate=0,\n",
" slippage=0,\n",
" size=300,\n",
" pricetick=0.2,\n",
" capital=1_000_000,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"#%%\n",
"engine.add_strategy(TurtleSignalStrategy, {})\n",
"engine.load_data()\n",
"engine.run_backtesting()\n",
"df = engine.calculate_result()\n",
"engine.calculate_statistics()\n",
"engine.show_chart()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}