A collection of investment tools used by the Turtle Traders.
Project description
turtle-trading
A Python Package containing a collection of investing tools using the Turtle Traders Original Rules. All code is based on the ideas in The Original Turtle Trading Rules. Page numbers are referenced in the code.
Download using pip:
pip install turtle-trading
Examples using the position_sizing
and entries
modules:
NOTE: The exits
and stops
modules aren't finished yet.
from turtle_trading.position_sizing import getn, getunit
from turtle_trading.entries import getsignal, addunits
# your account value
account = 1_000_000.00
# Chapter 3: Position Sizing
""" Get 'N' of an asset. """
asset = getn(asset="AAPL")
print(asset) # e.g. returns.. > 2.19987
""" Find the Unit Size of an asset. """
unit = getunit(asset="AAPL", n=asset, account_size=account)
print(unit) # e.g. returns.. > 2334
# Chapter 4: Entries
""" Get an Entry Signal - True for long entry, False for short entry, None for no entry. """
from yahoo_fin.stock_info import get_data, get_live_price
dataframe = get_data(ticker="AAPL", interval="1d")
price = get_live_price(ticker="AAPL")
signal_using_system_one = getsignal(asset="AAPL", price=price, system=1)
signal_using_system_two = getsignal(asset="AAPL", price=price, system=2)
print(signal_using_system_one) # e.g. returns... > True
print(signal_using_system_two) # e.g. returns... > False
""" Add Units to entries. """
n = 1.20
breakout = 28.30
new_units = addunits(n=n, breakout=breakout, units=4)
print(new_units) # e.g. returns... > [28.30, 28.90, 29.50, 30.10]
More will be published soon.
For issues, look here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
turtle_trading-2.2.1.tar.gz
(11.0 kB
view hashes)
Built Distribution
Close
Hashes for turtle_trading-2.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 183ae91c19a89357e43260e651343c6a8b864a59f5cc2685d485ebb3039bcebd |
|
MD5 | f13fae92ce4dad4a0b7afeedec50b255 |
|
BLAKE2b-256 | 9841364289710068e1c8bcfd77d8b0db73ec8bac11c9797cef202628e5dc7de7 |