mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 21:51:37 +08:00
Merge pull request #588 from jlowin/patch-2
Fix code block formatting in release notes
This commit is contained in:
@@ -70,24 +70,24 @@ data[security].stddev(3)
|
||||
> Also adds `context.get_market_value()`, which enables this functionality.
|
||||
|
||||
> For example:
|
||||
```python
|
||||
# this is how it works today (and this still works)
|
||||
# put 50% of my portfolio in AAPL
|
||||
order_percent('AAPL', 0.5)
|
||||
# note that if this were a fully invested portfolio, it would become 150% levered.
|
||||
|
||||
# take half of my available cash and buy AAPL
|
||||
order_percent('AAPL', 0.5, percent_of='cash')
|
||||
|
||||
# rebalance my short position, as a percentage of my current short book
|
||||
order_target_percent('MSFT', 0.1, percent_of='shorts')
|
||||
|
||||
# rebalance within a custom group of stocks
|
||||
tech_stocks = ('AAPL', 'MSFT', 'GOOGL')
|
||||
tech_filter = lambda p: p.sid in tech_stocks
|
||||
for stock in tech_stocks:
|
||||
order_target_percent(stock, 1/3, percent_of_fn=tech_filter)
|
||||
```
|
||||
> ```python
|
||||
# this is how it works today (and this still works)
|
||||
# put 50% of my portfolio in AAPL
|
||||
order_percent('AAPL', 0.5)
|
||||
# note that if this were a fully invested portfolio, it would become 150% levered.
|
||||
>
|
||||
# take half of my available cash and buy AAPL
|
||||
order_percent('AAPL', 0.5, percent_of='cash')
|
||||
>
|
||||
# rebalance my short position, as a percentage of my current short book
|
||||
order_target_percent('MSFT', 0.1, percent_of='shorts')
|
||||
>
|
||||
# rebalance within a custom group of stocks
|
||||
tech_stocks = ('AAPL', 'MSFT', 'GOOGL')
|
||||
tech_filter = lambda p: p.sid in tech_stocks
|
||||
for stock in tech_stocks:
|
||||
order_target_percent(stock, 1/3, percent_of_fn=tech_filter)
|
||||
```
|
||||
|
||||
### Major performance enhancements to history (by Dale Jung) [PR488](https://github.com/quantopian/zipline/commit/38e8d5214d46f089020703712dc6b3f4f6ee084d)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user