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.
Download using pip:
pip install turtle-trading
USAGE: First, initialize a DataFrameLoader
class to pass as an argument to each turtle_trading
function.
from turtle_trading import DataFrameLoader
ticker = 'aapl'
dataframe = DataFrameLoader(ticker)
position_sizing
module
""" using the position_sizing module """
from turtle_trading.position_sizing import getn, getunitsize
import datetime
date = datetime.date(2023, 11, 10)
getn(dataframe) # >>> 2.7421
getn(dataframe, date=date) # >>> 2.9932
getunitsize(dataframe=dataframe, account=1000000, n=2.7421) # >>> 20.0475
getunitsize(dataframe=dataframe, account=1000000, date=date) # >>> 17.9233
entries
module
""" using the entries module """
from turtle_trading.entries import getsignal, addunits
getsignal(dataframe=dataframe, system=1) # >>> True
getsignal(dataframe=dataframe, system=2) # >>> True
addunits(breakout=310, n=2.50) # >>> [310, 311.25, 312.5, 313.75]
addunits(breakout=310, n=2.50, units=6) # >>> [310, 311.25, 312.5, 313.75, 315.0, 316.25]
stops
module
""" using the stops module """
from turtle_trading.entries import addunits
from turtle_trading.stops import getstops
units = addunits(breakout=28.30, n=1.20) # >>> [28.3, 28.9, 29.5, 30.1]
getstops(unit_list=units, n=1.20) # >>> [27.7, 27.7, 27.7, 27.7]
getstops(unit_list=units, n=1.20, stop_system="whipsaw") # >>> [27.7, 28.3, 28.9, 29.5]
gapped_units = [28.3, 28.9, 29.5, 30.8]
getstops(unit_list=gapped_units, n=1.20) # >>> [27.7, 27.7, 27.7, 28.4]
getstops(unit_list=gapped_units, n=1.20, stop_system="whipsaw") # >>> [27.7, 28.3, 28.9, 30.2]
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.13.tar.gz
(9.4 kB
view hashes)
Built Distribution
Close
Hashes for turtle_trading-2.13-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9f53b406eb1f0a352d7acb309b42de3179fa90aadf374d626d156260f6a1b11 |
|
MD5 | dc66db96c943beeb4ac59deb81f8540a |
|
BLAKE2b-256 | 743e7db60602f9d9ac17140b495688189c25ce67651e3e5ad77d918a1b921a88 |