Quantopian Tutorial LESSON 9

This is a continuation of Last time.

LESSON 9 Slippage and Commission

Slippage set_slippage() To set slippage, use the set_slippage () method. This also exists without a definition. ʻIt must be defined in the initialize ()` function. Pass the slippage model described later as an argument.

set_slippage(slippage.VolumeShareSlippage(volume_limit=0.025, price_impact=0.1))

Slippage Models Slippage models can be FixedSlippage and VolumeShareSlippage, as well as customized models. The model belongs to the slippage module, which is pre-imported.

FixedSlippage Specify a fixed bid / ask spread. It is not suitable for stocks with low liquidity.

VolumeShareSlippage Set the ratio of the number of orders to the volume in the keyword argument volume_limit. The default is 0.025. For example, if you order 60 shares for a stock with a trading volume of 1000 per minute, the order will be divided into 25 shares, 25 shares, and 10 shares and executed.

Set the keyword argument price_impact to a constant that has a market impact. The default is 0.1. The market impact is the square of the ratio of volume to order quantity multiplied by this constant. If you order 25 shares for a stock with a trading volume of 1000, the market impact will be as follows.

0.1 * (25 / 1000) ** 2 = 0.00625%

In addition, orders that could not be filled will be canceled at the end of the day. Compared to the FixedSlippage model, it seems to be a fairly practical model.

Commission The fee uses the set_commission () method.

set_commission(commission.PerShare(cost=0.0075, min_trade_cost=1))

Commission Models Slippage models have PerShare and PerTrade The model belongs to the commission module, which is pre-imported.

PerTrade Set the commission per order.

PerShare Set the commission per share in the keyword argument cost. The default is $ 0.0075. Set the keyword argument min_trade_cost to the minimum fee per order. The default is $ 1.

LESSON 8<-->LESSON10

Recommended Posts

Quantopian Tutorial LESSON 10
Quantopian Tutorial LESSON 8
Quantopian Tutorial LESSON 1, 2
Quantopian Tutorial LESSON 6
Quantopian Tutorial LESSON 9
Quantopian Tutorial LESSON 5
Quantopian Tutorial LESSON 3
Quantopian Tutorial LESSON 7
Quantopian Tutorial LESSON 4
Quantopian Tutorial LESSON 11
sqlalchemy tutorial
PyODE Tutorial 2
Python tutorial
PyODE Tutorial 1
PyODE Tutorial 3
TensorFlow tutorial tutorial