docker run -d --name freqtrade -v ${PWD}/config.json:/freqtrade/config.json -v ${PWD}/tradesv3.sqlite:/freqtrade/tradesv3.sqlite -v ${PWD}/user_data/:/freqtrade/user_data/ freqtrade backtesting --strategy-list Strategy001 Strategy002 Strategy005
This commit is contained in:
parent
2e7faa782c
commit
b57035bafb
17
freqtrade-strategies-master/.github/ISSUE_TEMPLATE.md
vendored
Normal file
17
freqtrade-strategies-master/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
*For requestion a new strategy. Please use the template below.*
|
||||||
|
*Any strategy request that does not follow the template will be closed.*
|
||||||
|
|
||||||
|
## Step 1: What indicators are required?
|
||||||
|
*Please list all the indicators required for the buy and sell strategy.*
|
||||||
|
|
||||||
|
## Step 2: Explain the Buy Strategy
|
||||||
|
*Please explain in details the indicators you need to run the buy strategy, then
|
||||||
|
explain in detail what is the trigger to buy.*
|
||||||
|
|
||||||
|
## Step 1: Explain the Sell Strategy
|
||||||
|
*Please explain in details the indicators you need to run the sell strategy, then
|
||||||
|
explain in detail what is the trigger to sell.*
|
||||||
|
|
||||||
|
## Source
|
||||||
|
What come from this strategy? Cite your source:
|
||||||
|
* http://
|
11
freqtrade-strategies-master/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
11
freqtrade-strategies-master/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Thank you for sending your pull request.
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
Explain in one sentence the goal of this PR / Strategy
|
||||||
|
|
||||||
|
Solve the issue: #___
|
||||||
|
|
||||||
|
## Quick strategy idea
|
||||||
|
|
||||||
|
- <change log #1>
|
||||||
|
- <change log #2>
|
79
freqtrade-strategies-master/.gitignore
vendored
Normal file
79
freqtrade-strategies-master/.gitignore
vendored
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
.idea
|
||||||
|
.vscode
|
674
freqtrade-strategies-master/LICENSE
Normal file
674
freqtrade-strategies-master/LICENSE
Normal file
@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
110
freqtrade-strategies-master/README.md
Normal file
110
freqtrade-strategies-master/README.md
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
# Freqtrade strategies
|
||||||
|
|
||||||
|
This Git repo contains free buy/sell strategies for [Freqtrade](https://github.com/freqtrade/freqtrade).
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
These strategies are for educational purposes only. Do not risk money
|
||||||
|
which you are afraid to lose. USE THE SOFTWARE AT YOUR OWN RISK. THE
|
||||||
|
AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING
|
||||||
|
RESULTS.
|
||||||
|
|
||||||
|
Always start by testing strategies with a backtesting then run the
|
||||||
|
trading bot in Dry-run. Do not engage money before you understand how
|
||||||
|
it works and what profit/loss you should expect.
|
||||||
|
|
||||||
|
We strongly recommend you to have coding and Python knowledge. Do not
|
||||||
|
hesitate to read the source code and understand the mechanism of this
|
||||||
|
bot.
|
||||||
|
|
||||||
|
## Table of Content
|
||||||
|
|
||||||
|
- [Free trading strategies](#free-trading-strategies)
|
||||||
|
- [Contribute](#share-your-own-strategies-and-contribute-to-this-repo)
|
||||||
|
- [FAQ](#faq)
|
||||||
|
- [What is Freqtrade?](#what-is-freqtrade)
|
||||||
|
- [What includes these strategies?](#what-includes-these-strategies)
|
||||||
|
- [How to install a strategy?](#how-to-install-a-strategy)
|
||||||
|
- [How to test a strategy?](#how-to-test-a-strategy)
|
||||||
|
- [How to create/optimize a strategy?](https://www.freqtrade.io/en/latest/strategy-customization/)
|
||||||
|
|
||||||
|
## Free trading strategies
|
||||||
|
|
||||||
|
Value below are result from backtesting from 2018-01-10 to 2018-01-30 and
|
||||||
|
`ask_strategy.sell_profit_only` enabled. More detail on each strategy
|
||||||
|
page.
|
||||||
|
|
||||||
|
| Strategy | Buy count | AVG profit % | Total profit | AVG duration | Backtest period |
|
||||||
|
|-----------|-----------|--------------|--------------|--------------|-----------------|
|
||||||
|
| [Strategy 001](https://github.com/freqtrade/freqtrade-strategies/blob/master/user_data/strategies/Strategy001.py) | 55 | 0.05 | 0.00012102 | 476.1 | 2018-01-10 to 2018-01-30 |
|
||||||
|
| [Strategy 002](https://github.com/freqtrade/freqtrade-strategies/blob/master/user_data/strategies/Strategy002.py) | 9 | 3.21 | 0.00114807 | 189.4 | 2018-01-10 to 2018-01-30 |
|
||||||
|
| [Strategy 003](https://github.com/freqtrade/freqtrade-strategies/blob/master/user_data/strategies/Strategy003.py) | 14 | 1.47 | 0.00081740 | 227.5 | 2018-01-10 to 2018-01-30 |
|
||||||
|
| [Strategy 004](https://github.com/freqtrade/freqtrade-strategies/blob/master/user_data/strategies/Strategy004.py) | 37 | 0.69 | 0.00102128 | 367.3 | 2018-01-10 to 2018-01-30 |
|
||||||
|
| [Strategy 005](https://github.com/freqtrade/freqtrade-strategies/blob/master/user_data/strategies/Strategy005.py) | 180 | 1.16 | 0.00827589 | 156.2 | 2018-01-10 to 2018-01-30 |
|
||||||
|
|
||||||
|
|
||||||
|
Strategies from this repo are free to use. Feel free to update them.
|
||||||
|
Most of them were designed from Hyperopt calculations.
|
||||||
|
|
||||||
|
Some only work in specific market conditions, while others are more "general purpose" strategies.
|
||||||
|
It's noteworthy that depending on the exchange and Pairs used, further optimization can bring better results.
|
||||||
|
|
||||||
|
Please keep in mind, results will heavily depend on the pairs, timeframe and timerange used to backtest - so please run your own backtests that mirror your usecase, to evaluate each strategy for yourself.
|
||||||
|
|
||||||
|
## Share your own strategies and contribute to this repo
|
||||||
|
|
||||||
|
Feel free to send your strategies, comments, optimizations and pull requests via an
|
||||||
|
[Issue ticket](https://github.com/freqtrade/freqtrade-strategies/issues/new) or as a [Pull request](https://github.com/freqtrade/freqtrade-strategies/pulls) enhancing this repository.
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
### What is Freqtrade?
|
||||||
|
|
||||||
|
[Freqtrade](https://github.com/freqtrade/freqtrade) Freqtrade is a free and open source crypto trading bot written in Python.
|
||||||
|
It is designed to support all major exchanges and be controlled via Telegram. It contains backtesting, plotting and money management tools as well as strategy optimization by machine learning.
|
||||||
|
|
||||||
|
### What includes these strategies?
|
||||||
|
|
||||||
|
Each Strategies includes:
|
||||||
|
|
||||||
|
- [x] **Minimal ROI**: Minimal ROI optimized for the strategy.
|
||||||
|
- [x] **Stoploss**: Optimimal stoploss.
|
||||||
|
- [x] **Buy signals**: Result from Hyperopt or based on exisiting trading strategies.
|
||||||
|
- [x] **Sell signals**: Result from Hyperopt or based on exisiting trading strategies.
|
||||||
|
- [x] **Indicators**: Includes the indicators required to run the strategy.
|
||||||
|
|
||||||
|
Best backtest multiple strategies with the exchange and pairs you're interrested in, and finetune the strategy to the markets you're trading.
|
||||||
|
|
||||||
|
### How to install a strategy?
|
||||||
|
|
||||||
|
First you need a [working Freqtrade](https://freqtrade.io).
|
||||||
|
|
||||||
|
Once you have the bot on the right version, follow this steps:
|
||||||
|
|
||||||
|
1. Select the strategy you want. All strategies of the repo are into
|
||||||
|
[user_data/strategies](https://github.com/freqtrade/freqtrade/tree/develop/user_data/strategies)
|
||||||
|
2. Copy the strategy file
|
||||||
|
3. Paste it into your `user_data/strategies` folder
|
||||||
|
4. Run the bot with the parameter `--strategy <STRATEGY CLASS NAME>` (ex: `freqtrade trade --strategy Strategy001`)
|
||||||
|
|
||||||
|
More information [about backtesting](https://www.freqtrade.io/en/latest/backtesting/) and [strategy customization](https://www.freqtrade.io/en/latest/strategy-customization/).
|
||||||
|
|
||||||
|
### How to test a strategy?
|
||||||
|
|
||||||
|
Let assume you have selected the strategy `strategy001.py`:
|
||||||
|
|
||||||
|
#### Simple backtesting
|
||||||
|
|
||||||
|
```bash
|
||||||
|
freqtrade backtesting --strategy Strategy001
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Refresh your test data
|
||||||
|
|
||||||
|
```bash
|
||||||
|
freqtrade download-data --days 100
|
||||||
|
```
|
||||||
|
|
||||||
|
*Note:* Generally, it's recommended to use static backtest data (from a defined period of time) for comparable results.
|
||||||
|
|
||||||
|
Please check out the [official backtesting documentation](https://www.freqtrade.io/en/latest/backtesting/) for more information.
|
@ -0,0 +1,154 @@
|
|||||||
|
import talib.abstract as ta
|
||||||
|
from pandas import DataFrame
|
||||||
|
from typing import Dict, Any, Callable, List
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
from skopt.space import Categorical, Dimension, Integer, Real
|
||||||
|
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from freqtrade.optimize.hyperopt_interface import IHyperOpt
|
||||||
|
|
||||||
|
shortRangeBegin = 10
|
||||||
|
shortRangeEnd = 20
|
||||||
|
mediumRangeBegin = 100
|
||||||
|
mediumRangeEnd = 120
|
||||||
|
|
||||||
|
|
||||||
|
class AverageHyperopt(IHyperOpt):
|
||||||
|
"""
|
||||||
|
Hyperopt file for optimizing AverageStrategy.
|
||||||
|
Uses ranges of EMA periods to find the best parameter combination.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def populate_indicators(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
for short in range(shortRangeBegin, shortRangeEnd):
|
||||||
|
dataframe[f'maShort({short})'] = ta.EMA(dataframe, timeperiod=short)
|
||||||
|
|
||||||
|
for medium in range(mediumRangeBegin, mediumRangeEnd):
|
||||||
|
dataframe[f'maMedium({medium})'] = ta.EMA(dataframe, timeperiod=medium)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def buy_strategy_generator(params: Dict[str, Any]) -> Callable:
|
||||||
|
"""
|
||||||
|
Define the buy strategy parameters to be used by hyperopt
|
||||||
|
"""
|
||||||
|
def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Buy strategy Hyperopt will build and use
|
||||||
|
"""
|
||||||
|
conditions = []
|
||||||
|
# TRIGGERS
|
||||||
|
if 'trigger' in params:
|
||||||
|
conditions.append(qtpylib.crossed_above(
|
||||||
|
dataframe[f"maShort({params['trigger'][0]})"],
|
||||||
|
dataframe[f"maMedium({params['trigger'][1]})"])
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check that volume is not 0
|
||||||
|
conditions.append(dataframe['volume'] > 0)
|
||||||
|
|
||||||
|
if conditions:
|
||||||
|
dataframe.loc[
|
||||||
|
reduce(lambda x, y: x & y, conditions),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
return populate_buy_trend
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def indicator_space() -> List[Dimension]:
|
||||||
|
"""
|
||||||
|
Define your Hyperopt space for searching strategy parameters
|
||||||
|
"""
|
||||||
|
buyTriggerList = []
|
||||||
|
for short in range(shortRangeBegin, shortRangeEnd):
|
||||||
|
for medium in range(mediumRangeBegin, mediumRangeEnd):
|
||||||
|
# The output will be (short, long)
|
||||||
|
buyTriggerList.append(
|
||||||
|
(short, medium)
|
||||||
|
)
|
||||||
|
return [
|
||||||
|
Categorical(buyTriggerList, name='trigger')
|
||||||
|
]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def sell_strategy_generator(params: Dict[str, Any]) -> Callable:
|
||||||
|
"""
|
||||||
|
Define the sell strategy parameters to be used by hyperopt
|
||||||
|
"""
|
||||||
|
def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Sell strategy Hyperopt will build and use
|
||||||
|
"""
|
||||||
|
# print(params)
|
||||||
|
conditions = []
|
||||||
|
|
||||||
|
# TRIGGERS
|
||||||
|
if 'sell-trigger' in params:
|
||||||
|
conditions.append(qtpylib.crossed_above(
|
||||||
|
dataframe[f"maMedium({params['sell-trigger'][1]})"],
|
||||||
|
dataframe[f"maShort({params['sell-trigger'][0]})"])
|
||||||
|
)
|
||||||
|
|
||||||
|
if conditions:
|
||||||
|
dataframe.loc[
|
||||||
|
reduce(lambda x, y: x & y, conditions),
|
||||||
|
'sell'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
return populate_sell_trend
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def sell_indicator_space() -> List[Dimension]:
|
||||||
|
"""
|
||||||
|
Define your Hyperopt space for searching sell strategy parameters
|
||||||
|
"""
|
||||||
|
sellTriggerList = []
|
||||||
|
for short in range(shortRangeBegin, shortRangeEnd):
|
||||||
|
for medium in range(mediumRangeBegin, mediumRangeEnd):
|
||||||
|
# The output will be (short, long)
|
||||||
|
sellTriggerList.append(
|
||||||
|
(short, medium)
|
||||||
|
)
|
||||||
|
|
||||||
|
return [
|
||||||
|
Categorical(sellTriggerList, name='sell-trigger')
|
||||||
|
]
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators. Should be a copy of from strategy
|
||||||
|
must align to populate_indicators in this file
|
||||||
|
Only used when --spaces does not include buy
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_above(
|
||||||
|
dataframe[f'maShort({shortRangeBegin})'],
|
||||||
|
dataframe[f'maMedium({mediumRangeBegin})'])
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators. Should be a copy of from strategy
|
||||||
|
must align to populate_indicators in this file
|
||||||
|
Only used when --spaces does not include sell
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_above(
|
||||||
|
dataframe[f'maMedium({mediumRangeBegin})'],
|
||||||
|
dataframe[f'maShort({shortRangeBegin})'])
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
@ -0,0 +1,130 @@
|
|||||||
|
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
from pandas import DataFrame
|
||||||
|
from typing import Dict, Any, Callable, List
|
||||||
|
|
||||||
|
# import numpy as np
|
||||||
|
from skopt.space import Categorical, Dimension, Integer, Real
|
||||||
|
|
||||||
|
# import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from freqtrade.optimize.hyperopt_interface import IHyperOpt
|
||||||
|
|
||||||
|
class_name = 'MACDStrategy_hyperopt'
|
||||||
|
|
||||||
|
|
||||||
|
# This class is a sample. Feel free to customize it.
|
||||||
|
class MACDStrategy_hyperopt(IHyperOpt):
|
||||||
|
"""
|
||||||
|
This is an Example hyperopt to inspire you. - corresponding to MACDStrategy in this repository.
|
||||||
|
|
||||||
|
To run this, best use the following command (adjust to your environment if needed):
|
||||||
|
```
|
||||||
|
freqtrade hyperopt --strategy MACDStrategy --hyperopt MACDStrategy_hyperopt --spaces buy sell
|
||||||
|
```
|
||||||
|
The idea is to optimize only the CCI value.
|
||||||
|
- Buy side: CCI between -700 and 0
|
||||||
|
- Sell side: CCI between 0 and 700
|
||||||
|
|
||||||
|
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/hyperopt.md
|
||||||
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def populate_indicators(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def buy_strategy_generator(params: Dict[str, Any]) -> Callable:
|
||||||
|
"""
|
||||||
|
Define the buy strategy parameters to be used by hyperopt
|
||||||
|
"""
|
||||||
|
def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Buy strategy Hyperopt will build and use
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] > dataframe['macdsignal']) &
|
||||||
|
(dataframe['cci'] <= params['buy-cci-value']) &
|
||||||
|
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
return populate_buy_trend
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def indicator_space() -> List[Dimension]:
|
||||||
|
"""
|
||||||
|
Define your Hyperopt space for searching strategy parameters
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
Integer(-700, 0, name='buy-cci-value'),
|
||||||
|
]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def sell_strategy_generator(params: Dict[str, Any]) -> Callable:
|
||||||
|
"""
|
||||||
|
Define the sell strategy parameters to be used by hyperopt
|
||||||
|
"""
|
||||||
|
def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Sell strategy Hyperopt will build and use
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] < dataframe['macdsignal']) &
|
||||||
|
(dataframe['cci'] >= params['sell-cci-value'])
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
return populate_sell_trend
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def sell_indicator_space() -> List[Dimension]:
|
||||||
|
"""
|
||||||
|
Define your Hyperopt space for searching sell strategy parameters
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
Integer(0, 700, name='sell-cci-value'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators. Should be a copy of from strategy
|
||||||
|
must align to populate_indicators in this file
|
||||||
|
Only used when --spaces does not include buy
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] > dataframe['macdsignal']) &
|
||||||
|
(dataframe['cci'] <= -50.0)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators. Should be a copy of from strategy
|
||||||
|
must align to populate_indicators in this file
|
||||||
|
Only used when --spaces does not include sell
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] < dataframe['macdsignal']) &
|
||||||
|
(dataframe['cci'] >= 100.0)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
@ -0,0 +1,195 @@
|
|||||||
|
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||||
|
|
||||||
|
from functools import reduce
|
||||||
|
from typing import Any, Callable, Dict, List
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
from pandas import DataFrame
|
||||||
|
from skopt.space import Categorical, Dimension, Integer
|
||||||
|
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from freqtrade.optimize.hyperopt_interface import IHyperOpt
|
||||||
|
|
||||||
|
|
||||||
|
class ReinforcedSmoothScalp(IHyperOpt):
|
||||||
|
"""
|
||||||
|
Default hyperopt provided by the Freqtrade bot.
|
||||||
|
You can override it with your own Hyperopt
|
||||||
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def buy_strategy_generator(params: Dict[str, Any]) -> Callable:
|
||||||
|
"""
|
||||||
|
Define the buy strategy parameters to be used by Hyperopt.
|
||||||
|
"""
|
||||||
|
def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Buy strategy Hyperopt will build and use.
|
||||||
|
"""
|
||||||
|
conditions = []
|
||||||
|
|
||||||
|
# GUARDS AND TRENDS
|
||||||
|
if 'mfi-enabled' in params and params['mfi-enabled']:
|
||||||
|
conditions.append(dataframe['mfi'] < params['mfi-value'])
|
||||||
|
if 'fastd-enabled' in params and params['fastd-enabled']:
|
||||||
|
conditions.append(dataframe['fastd'] < params['fastd-value'])
|
||||||
|
if 'adx-enabled' in params and params['adx-enabled']:
|
||||||
|
conditions.append(dataframe['adx'] > params['adx-value'])
|
||||||
|
# if 'rsi-enabled' in params and params['rsi-enabled']:
|
||||||
|
# conditions.append(dataframe['rsi'] < params['rsi-value'])
|
||||||
|
if 'fastk-enabled' in params and params['fastk-enabled']:
|
||||||
|
conditions.append(dataframe['fastk'] < params['fastk-value'])
|
||||||
|
# TRIGGERS
|
||||||
|
# if 'trigger' in params:
|
||||||
|
# if params['trigger'] == 'bb_lower':
|
||||||
|
# conditions.append(dataframe['close'] < dataframe['bb_lowerband'])
|
||||||
|
# if params['trigger'] == 'macd_cross_signal':
|
||||||
|
# conditions.append(qtpylib.crossed_above(
|
||||||
|
# dataframe['macd'], dataframe['macdsignal']
|
||||||
|
# ))
|
||||||
|
# if params['trigger'] == 'sar_reversal':
|
||||||
|
# conditions.append(qtpylib.crossed_above(
|
||||||
|
# dataframe['close'], dataframe['sar']
|
||||||
|
# ))
|
||||||
|
|
||||||
|
# Check that volume is not 0
|
||||||
|
conditions.append(dataframe['volume'] > 0)
|
||||||
|
|
||||||
|
if conditions:
|
||||||
|
dataframe.loc[
|
||||||
|
reduce(lambda x, y: x & y, conditions),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
return populate_buy_trend
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def indicator_space() -> List[Dimension]:
|
||||||
|
"""
|
||||||
|
Define your Hyperopt space for searching buy strategy parameters.
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
Integer(10, 25, name='mfi-value'),
|
||||||
|
Integer(15, 45, name='fastd-value'),
|
||||||
|
Integer(15, 45, name='fastk-value'),
|
||||||
|
Integer(20, 50, name='adx-value'),
|
||||||
|
# Integer(20, 40, name='rsi-value'),
|
||||||
|
Categorical([True, False], name='mfi-enabled'),
|
||||||
|
Categorical([True, False], name='fastd-enabled'),
|
||||||
|
Categorical([True, False], name='adx-enabled'),
|
||||||
|
Categorical([True, False], name='fastk-enabled'),
|
||||||
|
# Categorical([True, False], name='rsi-enabled'),
|
||||||
|
# Categorical(['bb_lower', 'macd_cross_signal', 'sar_reversal'], name='trigger')
|
||||||
|
]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def sell_strategy_generator(params: Dict[str, Any]) -> Callable:
|
||||||
|
"""
|
||||||
|
Define the sell strategy parameters to be used by Hyperopt.
|
||||||
|
"""
|
||||||
|
def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Sell strategy Hyperopt will build and use.
|
||||||
|
"""
|
||||||
|
conditions = []
|
||||||
|
|
||||||
|
# GUARDS AND TRENDS
|
||||||
|
if 'sell-mfi-enabled' in params and params['sell-mfi-enabled']:
|
||||||
|
conditions.append(dataframe['mfi'] > params['sell-mfi-value'])
|
||||||
|
if 'sell-fastd-enabled' in params and params['sell-fastd-enabled']:
|
||||||
|
conditions.append(dataframe['fastd'] > params['sell-fastd-value'])
|
||||||
|
if 'sell-adx-enabled' in params and params['sell-adx-enabled']:
|
||||||
|
conditions.append(dataframe['adx'] < params['sell-adx-value'])
|
||||||
|
if 'sell-fastk-enabled' in params and params['sell-fastk-enabled']:
|
||||||
|
conditions.append(dataframe['fastk'] > params['sell-fastk-value'])
|
||||||
|
if 'sell-cci-enabled' in params and params['sell-cci-enabled']:
|
||||||
|
conditions.append(dataframe['cci'] > params['sell-cci-value'])
|
||||||
|
|
||||||
|
# TRIGGERS
|
||||||
|
# if 'sell-trigger' in params:
|
||||||
|
# if params['sell-trigger'] == 'sell-bb_upper':
|
||||||
|
# conditions.append(dataframe['close'] > dataframe['bb_upperband'])
|
||||||
|
# if params['sell-trigger'] == 'sell-macd_cross_signal':
|
||||||
|
# conditions.append(qtpylib.crossed_above(
|
||||||
|
# dataframe['macdsignal'], dataframe['macd']
|
||||||
|
# ))
|
||||||
|
# if params['sell-trigger'] == 'sell-sar_reversal':
|
||||||
|
# conditions.append(qtpylib.crossed_above(
|
||||||
|
# dataframe['sar'], dataframe['close']
|
||||||
|
# ))
|
||||||
|
|
||||||
|
# Check that volume is not 0
|
||||||
|
conditions.append(dataframe['volume'] > 0)
|
||||||
|
|
||||||
|
if conditions:
|
||||||
|
dataframe.loc[
|
||||||
|
reduce(lambda x, y: x & y, conditions),
|
||||||
|
'sell'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
return populate_sell_trend
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def sell_indicator_space() -> List[Dimension]:
|
||||||
|
"""
|
||||||
|
Define your Hyperopt space for searching sell strategy parameters.
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
Integer(75, 100, name='sell-mfi-value'),
|
||||||
|
Integer(50, 100, name='sell-fastd-value'),
|
||||||
|
Integer(50, 100, name='sell-fastk-value'),
|
||||||
|
Integer(50, 100, name='sell-adx-value'),
|
||||||
|
Integer(100, 200, name='sell-cci-value'),
|
||||||
|
Categorical([True, False], name='sell-mfi-enabled'),
|
||||||
|
Categorical([True, False], name='sell-fastd-enabled'),
|
||||||
|
Categorical([True, False], name='sell-adx-enabled'),
|
||||||
|
Categorical([True, False], name='sell-cci-enabled'),
|
||||||
|
Categorical([True, False], name='sell-fastk-enabled'),
|
||||||
|
# Categorical(['sell-bb_upper',
|
||||||
|
# 'sell-macd_cross_signal',
|
||||||
|
# 'sell-sar_reversal'], name='sell-trigger')
|
||||||
|
]
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['open'] < dataframe['ema_low']) &
|
||||||
|
(dataframe['adx'] > 30) &
|
||||||
|
(dataframe['mfi'] < 30) &
|
||||||
|
(
|
||||||
|
(dataframe['fastk'] < 30) &
|
||||||
|
(dataframe['fastd'] < 30) &
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], dataframe['fastd']))
|
||||||
|
) &
|
||||||
|
(dataframe['resample_sma'] < dataframe['close'])
|
||||||
|
)
|
||||||
|
# |
|
||||||
|
# # try to get some sure things independent of resample
|
||||||
|
# ((dataframe['rsi'] - dataframe['mfi']) < 10) &
|
||||||
|
# (dataframe['mfi'] < 30) &
|
||||||
|
# (dataframe['cci'] < -200)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['open'] >= dataframe['ema_high'])
|
||||||
|
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], 70)) |
|
||||||
|
(qtpylib.crossed_above(dataframe['fastd'], 70))
|
||||||
|
|
||||||
|
)
|
||||||
|
) & (dataframe['cci'] > 100)
|
||||||
|
)
|
||||||
|
,
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,128 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class InformativeSample(IStrategy):
|
||||||
|
"""
|
||||||
|
Sample strategy implementing Informative Pairs - compares stake_currency with USDT.
|
||||||
|
Not performing very well - but should serve as an example how to use a referential pair against USDT.
|
||||||
|
author@: xmatthias
|
||||||
|
github@: https://github.com/freqtrade/freqtrade-strategies
|
||||||
|
|
||||||
|
How to use it?
|
||||||
|
> python3 freqtrade -s InformativeSample
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"60": 0.01,
|
||||||
|
"30": 0.03,
|
||||||
|
"20": 0.04,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.10
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
# trailing stoploss
|
||||||
|
trailing_stop = False
|
||||||
|
trailing_stop_positive = 0.01
|
||||||
|
trailing_stop_positive_offset = 0.02
|
||||||
|
|
||||||
|
# run "populate_indicators" only for new candle
|
||||||
|
ta_on_candle = False
|
||||||
|
|
||||||
|
# Experimental settings (configuration will overide these if set)
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = True
|
||||||
|
ignore_roi_if_buy_signal = False
|
||||||
|
|
||||||
|
# Optional order type mapping
|
||||||
|
order_types = {
|
||||||
|
'buy': 'limit',
|
||||||
|
'sell': 'limit',
|
||||||
|
'stoploss': 'market',
|
||||||
|
'stoploss_on_exchange': False
|
||||||
|
}
|
||||||
|
|
||||||
|
def informative_pairs(self):
|
||||||
|
"""
|
||||||
|
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||||
|
These pair/interval combinations are non-tradeable, unless they are part
|
||||||
|
of the whitelist as well.
|
||||||
|
For more information, please consult the documentation
|
||||||
|
:return: List of tuples in the format (pair, interval)
|
||||||
|
Sample: return [("ETH/USDT", "5m"),
|
||||||
|
("BTC/USDT", "15m"),
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
return [(f"{self.config['stake_currency']}/USDT", self.timeframe)]
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Adds several different TA indicators to the given DataFrame
|
||||||
|
|
||||||
|
Performance Note: For the best performance be frugal on the number of indicators
|
||||||
|
you are using. Let uncomment only the indicator you are using in your strategies
|
||||||
|
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
dataframe['ema20'] = ta.EMA(dataframe, timeperiod=20)
|
||||||
|
dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
|
||||||
|
dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)
|
||||||
|
if self.dp:
|
||||||
|
# Get ohlcv data for informative pair.
|
||||||
|
data = self.dp.get_pair_dataframe(pair=f"{self.stake_currency}/USDT",
|
||||||
|
timeframe=self.timeframe)
|
||||||
|
# Combine the 2 dataframes using 'close'.
|
||||||
|
# This will result in a column named 'closeETH' or 'closeBTC' - depending on stake_currency.
|
||||||
|
dataframe = dataframe.merge(data[["date", "close"]], on="date", how="left", suffixes=("", self.config['stake_currency']))
|
||||||
|
|
||||||
|
# Calculate SMA20 on 'close' data for stake_currency/USDT. Resulting column is named as 'smaETH20' (if stake_currency is ETH)
|
||||||
|
dataframe[f"sma{self.config['stake_currency']}20"] = dataframe[f'close{self.stake_currency}'].rolling(20).mean()
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['ema20'] > dataframe['ema50']) &
|
||||||
|
# stake/USDT above sma(stake/USDT, 20)
|
||||||
|
(dataframe[f'close{self.stake_currency}'] > dataframe[f'sma{self.stake_currency}20'])
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['ema20'] < dataframe['ema50']) &
|
||||||
|
# stake/USDT below sma(stake/USDT, 20)
|
||||||
|
(dataframe[f'close{self.stake_currency}'] < dataframe[f'sma{self.stake_currency}20'])
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
121
freqtrade-strategies-master/user_data/strategies/Strategy001.py
Normal file
121
freqtrade-strategies-master/user_data/strategies/Strategy001.py
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class Strategy001(IStrategy):
|
||||||
|
"""
|
||||||
|
Strategy 001
|
||||||
|
author@: Gerald Lonlas
|
||||||
|
github@: https://github.com/freqtrade/freqtrade-strategies
|
||||||
|
|
||||||
|
How to use it?
|
||||||
|
> python3 ./freqtrade/main.py -s Strategy001
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"60": 0.01,
|
||||||
|
"30": 0.03,
|
||||||
|
"20": 0.04,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.10
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
# trailing stoploss
|
||||||
|
trailing_stop = False
|
||||||
|
trailing_stop_positive = 0.01
|
||||||
|
trailing_stop_positive_offset = 0.02
|
||||||
|
|
||||||
|
# run "populate_indicators" only for new candle
|
||||||
|
process_only_new_candles = False
|
||||||
|
|
||||||
|
# Experimental settings (configuration will overide these if set)
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = True
|
||||||
|
ignore_roi_if_buy_signal = False
|
||||||
|
|
||||||
|
# Optional order type mapping
|
||||||
|
order_types = {
|
||||||
|
'buy': 'limit',
|
||||||
|
'sell': 'limit',
|
||||||
|
'stoploss': 'market',
|
||||||
|
'stoploss_on_exchange': False
|
||||||
|
}
|
||||||
|
|
||||||
|
def informative_pairs(self):
|
||||||
|
"""
|
||||||
|
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||||
|
These pair/interval combinations are non-tradeable, unless they are part
|
||||||
|
of the whitelist as well.
|
||||||
|
For more information, please consult the documentation
|
||||||
|
:return: List of tuples in the format (pair, interval)
|
||||||
|
Sample: return [("ETH/USDT", "5m"),
|
||||||
|
("BTC/USDT", "15m"),
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Adds several different TA indicators to the given DataFrame
|
||||||
|
|
||||||
|
Performance Note: For the best performance be frugal on the number of indicators
|
||||||
|
you are using. Let uncomment only the indicator you are using in your strategies
|
||||||
|
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
dataframe['ema20'] = ta.EMA(dataframe, timeperiod=20)
|
||||||
|
dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
|
||||||
|
dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)
|
||||||
|
|
||||||
|
heikinashi = qtpylib.heikinashi(dataframe)
|
||||||
|
dataframe['ha_open'] = heikinashi['open']
|
||||||
|
dataframe['ha_close'] = heikinashi['close']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_above(dataframe['ema20'], dataframe['ema50']) &
|
||||||
|
(dataframe['ha_close'] > dataframe['ema20']) &
|
||||||
|
(dataframe['ha_open'] < dataframe['ha_close']) # green bar
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_above(dataframe['ema50'], dataframe['ema100']) &
|
||||||
|
(dataframe['ha_close'] < dataframe['ema20']) &
|
||||||
|
(dataframe['ha_open'] > dataframe['ha_close']) # red bar
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
135
freqtrade-strategies-master/user_data/strategies/Strategy002.py
Normal file
135
freqtrade-strategies-master/user_data/strategies/Strategy002.py
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
|
||||||
|
class Strategy002(IStrategy):
|
||||||
|
"""
|
||||||
|
Strategy 002
|
||||||
|
author@: Gerald Lonlas
|
||||||
|
github@: https://github.com/freqtrade/freqtrade-strategies
|
||||||
|
|
||||||
|
How to use it?
|
||||||
|
> python3 ./freqtrade/main.py -s Strategy002
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"60": 0.01,
|
||||||
|
"30": 0.03,
|
||||||
|
"20": 0.04,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.10
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
# trailing stoploss
|
||||||
|
trailing_stop = False
|
||||||
|
trailing_stop_positive = 0.01
|
||||||
|
trailing_stop_positive_offset = 0.02
|
||||||
|
|
||||||
|
# run "populate_indicators" only for new candle
|
||||||
|
process_only_new_candles = False
|
||||||
|
|
||||||
|
# Experimental settings (configuration will overide these if set)
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = True
|
||||||
|
ignore_roi_if_buy_signal = False
|
||||||
|
|
||||||
|
# Optional order type mapping
|
||||||
|
order_types = {
|
||||||
|
'buy': 'limit',
|
||||||
|
'sell': 'limit',
|
||||||
|
'stoploss': 'market',
|
||||||
|
'stoploss_on_exchange': False
|
||||||
|
}
|
||||||
|
|
||||||
|
def informative_pairs(self):
|
||||||
|
"""
|
||||||
|
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||||
|
These pair/interval combinations are non-tradeable, unless they are part
|
||||||
|
of the whitelist as well.
|
||||||
|
For more information, please consult the documentation
|
||||||
|
:return: List of tuples in the format (pair, interval)
|
||||||
|
Sample: return [("ETH/USDT", "5m"),
|
||||||
|
("BTC/USDT", "15m"),
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Adds several different TA indicators to the given DataFrame
|
||||||
|
|
||||||
|
Performance Note: For the best performance be frugal on the number of indicators
|
||||||
|
you are using. Let uncomment only the indicator you are using in your strategies
|
||||||
|
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Stoch
|
||||||
|
stoch = ta.STOCH(dataframe)
|
||||||
|
dataframe['slowk'] = stoch['slowk']
|
||||||
|
|
||||||
|
# RSI
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe)
|
||||||
|
|
||||||
|
# Inverse Fisher transform on RSI, values [-1.0, 1.0] (https://goo.gl/2JGGoy)
|
||||||
|
rsi = 0.1 * (dataframe['rsi'] - 50)
|
||||||
|
dataframe['fisher_rsi'] = (numpy.exp(2 * rsi) - 1) / (numpy.exp(2 * rsi) + 1)
|
||||||
|
|
||||||
|
# Bollinger bands
|
||||||
|
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
|
||||||
|
# SAR Parabol
|
||||||
|
dataframe['sar'] = ta.SAR(dataframe)
|
||||||
|
|
||||||
|
# Hammer: values [0, 100]
|
||||||
|
dataframe['CDLHAMMER'] = ta.CDLHAMMER(dataframe)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['rsi'] < 30) &
|
||||||
|
(dataframe['slowk'] < 20) &
|
||||||
|
(dataframe['bb_lowerband'] > dataframe['close']) &
|
||||||
|
(dataframe['CDLHAMMER'] == 100)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['sar'] > dataframe['close']) &
|
||||||
|
(dataframe['fisher_rsi'] > 0.3)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
152
freqtrade-strategies-master/user_data/strategies/Strategy003.py
Normal file
152
freqtrade-strategies-master/user_data/strategies/Strategy003.py
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
|
||||||
|
class Strategy003(IStrategy):
|
||||||
|
"""
|
||||||
|
Strategy 003
|
||||||
|
author@: Gerald Lonlas
|
||||||
|
github@: https://github.com/freqtrade/freqtrade-strategies
|
||||||
|
|
||||||
|
How to use it?
|
||||||
|
> python3 ./freqtrade/main.py -s Strategy003
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"60": 0.01,
|
||||||
|
"30": 0.03,
|
||||||
|
"20": 0.04,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.10
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
# trailing stoploss
|
||||||
|
trailing_stop = False
|
||||||
|
trailing_stop_positive = 0.01
|
||||||
|
trailing_stop_positive_offset = 0.02
|
||||||
|
|
||||||
|
# run "populate_indicators" only for new candle
|
||||||
|
process_only_new_candles = False
|
||||||
|
|
||||||
|
# Experimental settings (configuration will overide these if set)
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = True
|
||||||
|
ignore_roi_if_buy_signal = False
|
||||||
|
|
||||||
|
# Optional order type mapping
|
||||||
|
order_types = {
|
||||||
|
'buy': 'limit',
|
||||||
|
'sell': 'limit',
|
||||||
|
'stoploss': 'market',
|
||||||
|
'stoploss_on_exchange': False
|
||||||
|
}
|
||||||
|
|
||||||
|
def informative_pairs(self):
|
||||||
|
"""
|
||||||
|
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||||
|
These pair/interval combinations are non-tradeable, unless they are part
|
||||||
|
of the whitelist as well.
|
||||||
|
For more information, please consult the documentation
|
||||||
|
:return: List of tuples in the format (pair, interval)
|
||||||
|
Sample: return [("ETH/USDT", "5m"),
|
||||||
|
("BTC/USDT", "15m"),
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Adds several different TA indicators to the given DataFrame
|
||||||
|
|
||||||
|
Performance Note: For the best performance be frugal on the number of indicators
|
||||||
|
you are using. Let uncomment only the indicator you are using in your strategies
|
||||||
|
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# MFI
|
||||||
|
dataframe['mfi'] = ta.MFI(dataframe)
|
||||||
|
|
||||||
|
# Stoch fast
|
||||||
|
stoch_fast = ta.STOCHF(dataframe)
|
||||||
|
dataframe['fastd'] = stoch_fast['fastd']
|
||||||
|
dataframe['fastk'] = stoch_fast['fastk']
|
||||||
|
|
||||||
|
# RSI
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe)
|
||||||
|
|
||||||
|
# Inverse Fisher transform on RSI, values [-1.0, 1.0] (https://goo.gl/2JGGoy)
|
||||||
|
rsi = 0.1 * (dataframe['rsi'] - 50)
|
||||||
|
dataframe['fisher_rsi'] = (numpy.exp(2 * rsi) - 1) / (numpy.exp(2 * rsi) + 1)
|
||||||
|
|
||||||
|
# Bollinger bands
|
||||||
|
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
|
||||||
|
# EMA - Exponential Moving Average
|
||||||
|
dataframe['ema5'] = ta.EMA(dataframe, timeperiod=5)
|
||||||
|
dataframe['ema10'] = ta.EMA(dataframe, timeperiod=10)
|
||||||
|
dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
|
||||||
|
dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)
|
||||||
|
|
||||||
|
# SAR Parabol
|
||||||
|
dataframe['sar'] = ta.SAR(dataframe)
|
||||||
|
|
||||||
|
# SMA - Simple Moving Average
|
||||||
|
dataframe['sma'] = ta.SMA(dataframe, timeperiod=40)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['rsi'] < 28) &
|
||||||
|
(dataframe['rsi'] > 0) &
|
||||||
|
(dataframe['close'] < dataframe['sma']) &
|
||||||
|
(dataframe['fisher_rsi'] < -0.94) &
|
||||||
|
(dataframe['mfi'] < 16.0) &
|
||||||
|
(
|
||||||
|
(dataframe['ema50'] > dataframe['ema100']) |
|
||||||
|
(qtpylib.crossed_above(dataframe['ema5'], dataframe['ema10']))
|
||||||
|
) &
|
||||||
|
(dataframe['fastd'] > dataframe['fastk']) &
|
||||||
|
(dataframe['fastd'] > 0)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['sar'] > dataframe['close']) &
|
||||||
|
(dataframe['fisher_rsi'] > 0.3)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
154
freqtrade-strategies-master/user_data/strategies/Strategy004.py
Normal file
154
freqtrade-strategies-master/user_data/strategies/Strategy004.py
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
|
||||||
|
|
||||||
|
class Strategy004(IStrategy):
|
||||||
|
|
||||||
|
"""
|
||||||
|
Strategy 004
|
||||||
|
author@: Gerald Lonlas
|
||||||
|
github@: https://github.com/freqtrade/freqtrade-strategies
|
||||||
|
|
||||||
|
How to use it?
|
||||||
|
> python3 ./freqtrade/main.py -s Strategy004
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"60": 0.01,
|
||||||
|
"30": 0.03,
|
||||||
|
"20": 0.04,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.10
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
# trailing stoploss
|
||||||
|
trailing_stop = False
|
||||||
|
trailing_stop_positive = 0.01
|
||||||
|
trailing_stop_positive_offset = 0.02
|
||||||
|
|
||||||
|
# run "populate_indicators" only for new candle
|
||||||
|
process_only_new_candles = False
|
||||||
|
|
||||||
|
# Experimental settings (configuration will overide these if set)
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = True
|
||||||
|
ignore_roi_if_buy_signal = False
|
||||||
|
|
||||||
|
# Optional order type mapping
|
||||||
|
order_types = {
|
||||||
|
'buy': 'limit',
|
||||||
|
'sell': 'limit',
|
||||||
|
'stoploss': 'market',
|
||||||
|
'stoploss_on_exchange': False
|
||||||
|
}
|
||||||
|
|
||||||
|
def informative_pairs(self):
|
||||||
|
"""
|
||||||
|
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||||
|
These pair/interval combinations are non-tradeable, unless they are part
|
||||||
|
of the whitelist as well.
|
||||||
|
For more information, please consult the documentation
|
||||||
|
:return: List of tuples in the format (pair, interval)
|
||||||
|
Sample: return [("ETH/USDT", "5m"),
|
||||||
|
("BTC/USDT", "15m"),
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Adds several different TA indicators to the given DataFrame
|
||||||
|
|
||||||
|
Performance Note: For the best performance be frugal on the number of indicators
|
||||||
|
you are using. Let uncomment only the indicator you are using in your strategies
|
||||||
|
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# ADX
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
dataframe['slowadx'] = ta.ADX(dataframe, 35)
|
||||||
|
|
||||||
|
# Commodity Channel Index: values Oversold:<-100, Overbought:>100
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe)
|
||||||
|
|
||||||
|
# Stoch
|
||||||
|
stoch = ta.STOCHF(dataframe, 5)
|
||||||
|
dataframe['fastd'] = stoch['fastd']
|
||||||
|
dataframe['fastk'] = stoch['fastk']
|
||||||
|
dataframe['fastk-previous'] = dataframe.fastk.shift(1)
|
||||||
|
dataframe['fastd-previous'] = dataframe.fastd.shift(1)
|
||||||
|
|
||||||
|
# Slow Stoch
|
||||||
|
slowstoch = ta.STOCHF(dataframe, 50)
|
||||||
|
dataframe['slowfastd'] = slowstoch['fastd']
|
||||||
|
dataframe['slowfastk'] = slowstoch['fastk']
|
||||||
|
dataframe['slowfastk-previous'] = dataframe.slowfastk.shift(1)
|
||||||
|
dataframe['slowfastd-previous'] = dataframe.slowfastd.shift(1)
|
||||||
|
|
||||||
|
# EMA - Exponential Moving Average
|
||||||
|
dataframe['ema5'] = ta.EMA(dataframe, timeperiod=5)
|
||||||
|
|
||||||
|
dataframe['mean-volume'] = dataframe['volume'].mean()
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['adx'] > 50) |
|
||||||
|
(dataframe['slowadx'] > 26)
|
||||||
|
) &
|
||||||
|
(dataframe['cci'] < -100) &
|
||||||
|
(
|
||||||
|
(dataframe['fastk-previous'] < 20) &
|
||||||
|
(dataframe['fastd-previous'] < 20)
|
||||||
|
) &
|
||||||
|
(
|
||||||
|
(dataframe['slowfastk-previous'] < 30) &
|
||||||
|
(dataframe['slowfastd-previous'] < 30)
|
||||||
|
) &
|
||||||
|
(dataframe['fastk-previous'] < dataframe['fastd-previous']) &
|
||||||
|
(dataframe['fastk'] > dataframe['fastd']) &
|
||||||
|
(dataframe['mean-volume'] > 0.75) &
|
||||||
|
(dataframe['close'] > 0.00000100)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['slowadx'] < 25) &
|
||||||
|
((dataframe['fastk'] > 70) | (dataframe['fastd'] > 70)) &
|
||||||
|
(dataframe['fastk-previous'] < dataframe['fastd-previous']) &
|
||||||
|
(dataframe['close'] > dataframe['ema5'])
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
158
freqtrade-strategies-master/user_data/strategies/Strategy005.py
Normal file
158
freqtrade-strategies-master/user_data/strategies/Strategy005.py
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
|
||||||
|
class Strategy005(IStrategy):
|
||||||
|
"""
|
||||||
|
Strategy 005
|
||||||
|
author@: Gerald Lonlas
|
||||||
|
github@: https://github.com/freqtrade/freqtrade-strategies
|
||||||
|
|
||||||
|
How to use it?
|
||||||
|
> python3 ./freqtrade/main.py -s Strategy005
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"1440": 0.01,
|
||||||
|
"80": 0.02,
|
||||||
|
"40": 0.03,
|
||||||
|
"20": 0.04,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.10
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
# trailing stoploss
|
||||||
|
trailing_stop = False
|
||||||
|
trailing_stop_positive = 0.01
|
||||||
|
trailing_stop_positive_offset = 0.02
|
||||||
|
|
||||||
|
# run "populate_indicators" only for new candle
|
||||||
|
process_only_new_candles = False
|
||||||
|
|
||||||
|
# Experimental settings (configuration will overide these if set)
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = True
|
||||||
|
ignore_roi_if_buy_signal = False
|
||||||
|
|
||||||
|
# Optional order type mapping
|
||||||
|
order_types = {
|
||||||
|
'buy': 'limit',
|
||||||
|
'sell': 'limit',
|
||||||
|
'stoploss': 'market',
|
||||||
|
'stoploss_on_exchange': False
|
||||||
|
}
|
||||||
|
|
||||||
|
def informative_pairs(self):
|
||||||
|
"""
|
||||||
|
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||||
|
These pair/interval combinations are non-tradeable, unless they are part
|
||||||
|
of the whitelist as well.
|
||||||
|
For more information, please consult the documentation
|
||||||
|
:return: List of tuples in the format (pair, interval)
|
||||||
|
Sample: return [("ETH/USDT", "5m"),
|
||||||
|
("BTC/USDT", "15m"),
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Adds several different TA indicators to the given DataFrame
|
||||||
|
|
||||||
|
Performance Note: For the best performance be frugal on the number of indicators
|
||||||
|
you are using. Let uncomment only the indicator you are using in your strategies
|
||||||
|
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# MACD
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
|
||||||
|
# Minus Directional Indicator / Movement
|
||||||
|
dataframe['minus_di'] = ta.MINUS_DI(dataframe)
|
||||||
|
|
||||||
|
# RSI
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe)
|
||||||
|
|
||||||
|
# Inverse Fisher transform on RSI, values [-1.0, 1.0] (https://goo.gl/2JGGoy)
|
||||||
|
rsi = 0.1 * (dataframe['rsi'] - 50)
|
||||||
|
dataframe['fisher_rsi'] = (numpy.exp(2 * rsi) - 1) / (numpy.exp(2 * rsi) + 1)
|
||||||
|
# Inverse Fisher transform on RSI normalized, value [0.0, 100.0] (https://goo.gl/2JGGoy)
|
||||||
|
dataframe['fisher_rsi_norma'] = 50 * (dataframe['fisher_rsi'] + 1)
|
||||||
|
|
||||||
|
# Stoch fast
|
||||||
|
stoch_fast = ta.STOCHF(dataframe)
|
||||||
|
dataframe['fastd'] = stoch_fast['fastd']
|
||||||
|
dataframe['fastk'] = stoch_fast['fastk']
|
||||||
|
|
||||||
|
# Overlap Studies
|
||||||
|
# ------------------------------------
|
||||||
|
|
||||||
|
# SAR Parabol
|
||||||
|
dataframe['sar'] = ta.SAR(dataframe)
|
||||||
|
|
||||||
|
# SMA - Simple Moving Average
|
||||||
|
dataframe['sma'] = ta.SMA(dataframe, timeperiod=40)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
# Prod
|
||||||
|
(
|
||||||
|
(dataframe['close'] > 0.00000200) &
|
||||||
|
(dataframe['volume'] > dataframe['volume'].rolling(200).mean() * 4) &
|
||||||
|
(dataframe['close'] < dataframe['sma']) &
|
||||||
|
(dataframe['fastd'] > dataframe['fastk']) &
|
||||||
|
(dataframe['rsi'] > 0) &
|
||||||
|
(dataframe['fastd'] > 0) &
|
||||||
|
# (dataframe['fisher_rsi'] < -0.94)
|
||||||
|
(dataframe['fisher_rsi_norma'] < 38.900000000000006)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
# Prod
|
||||||
|
(
|
||||||
|
(qtpylib.crossed_above(dataframe['rsi'], 50)) &
|
||||||
|
(dataframe['macd'] < 0) &
|
||||||
|
(dataframe['minus_di'] > 0)
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
(dataframe['sar'] > dataframe['close']) &
|
||||||
|
(dataframe['fisher_rsi'] > 0.3)
|
||||||
|
),
|
||||||
|
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,68 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
import talib.abstract as ta
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class ADXMomentum(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
converted from:
|
||||||
|
|
||||||
|
https://github.com/sthewissen/Mynt/blob/master/src/Mynt.Core/Strategies/AdxMomentum.cs
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# adjust based on market conditions. We would recommend to keep it low for quick turn arounds
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
stoploss = -0.25
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '1h'
|
||||||
|
|
||||||
|
# Number of candles the strategy requires before producing valid signals
|
||||||
|
startup_candle_count: int = 20
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe, timeperiod=14)
|
||||||
|
dataframe['plus_di'] = ta.PLUS_DI(dataframe, timeperiod=25)
|
||||||
|
dataframe['minus_di'] = ta.MINUS_DI(dataframe, timeperiod=25)
|
||||||
|
dataframe['sar'] = ta.SAR(dataframe)
|
||||||
|
dataframe['mom'] = ta.MOM(dataframe, timeperiod=14)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['adx'] > 25) &
|
||||||
|
(dataframe['mom'] > 0) &
|
||||||
|
(dataframe['minus_di'] > 25) &
|
||||||
|
(dataframe['plus_di'] > dataframe['minus_di'])
|
||||||
|
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['adx'] > 25) &
|
||||||
|
(dataframe['mom'] < 0) &
|
||||||
|
(dataframe['minus_di'] > 25) &
|
||||||
|
(dataframe['plus_di'] < dataframe['minus_di'])
|
||||||
|
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,85 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class ASDTSRockwellTrading(IStrategy):
|
||||||
|
"""
|
||||||
|
trading strategy based on the concept explained at https://www.youtube.com/watch?v=mmAWVmKN4J0
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
idea:
|
||||||
|
|
||||||
|
uptrend definition:
|
||||||
|
MACD above 0 line AND above MACD signal
|
||||||
|
|
||||||
|
|
||||||
|
downtrend definition:
|
||||||
|
MACD below 0 line and below MACD signal
|
||||||
|
|
||||||
|
sell definition:
|
||||||
|
MACD below MACD signal
|
||||||
|
|
||||||
|
it's basically a very simple MACD based strategy and we ignore the definition of the entry and exit points in this case, since the trading bot, will take of this already
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"60": 0.01,
|
||||||
|
"30": 0.03,
|
||||||
|
"20": 0.04,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.3
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] > 0) &
|
||||||
|
(dataframe['macd'] > dataframe['macdsignal'])
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] < dataframe['macdsignal'])
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,60 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class AdxSmas(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
converted from:
|
||||||
|
|
||||||
|
https://github.com/sthewissen/Mynt/blob/master/src/Mynt.Core/Strategies/AdxSmas.cs
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# adjust based on market conditions. We would recommend to keep it low for quick turn arounds
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
stoploss = -0.25
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '1h'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe, timeperiod=14)
|
||||||
|
dataframe['short'] = ta.SMA(dataframe, timeperiod=3)
|
||||||
|
dataframe['long'] = ta.SMA(dataframe, timeperiod=6)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['adx'] > 25) &
|
||||||
|
(qtpylib.crossed_above(dataframe['short'], dataframe['long']))
|
||||||
|
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['adx'] < 25) &
|
||||||
|
(qtpylib.crossed_above(dataframe['long'], dataframe['short']))
|
||||||
|
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,64 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class AverageStrategy(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
idea:
|
||||||
|
buys and sells on crossovers - doesn't really perfom that well and its just a proof of concept
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.2
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '4h'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
dataframe['maShort'] = ta.EMA(dataframe, timeperiod=8)
|
||||||
|
dataframe['maMedium'] = ta.EMA(dataframe, timeperiod=21)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_above(dataframe['maShort'], dataframe['maMedium'])
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_above(dataframe['maMedium'], dataframe['maShort'])
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,66 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class AwesomeMacd(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
converted from:
|
||||||
|
|
||||||
|
https://github.com/sthewissen/Mynt/blob/master/src/Mynt.Core/Strategies/AwesomeMacd.cs
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# adjust based on market conditions. We would recommend to keep it low for quick turn arounds
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
stoploss = -0.25
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '1h'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe, timeperiod=14)
|
||||||
|
dataframe['ao'] = qtpylib.awesome_oscillator(dataframe)
|
||||||
|
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] > 0) &
|
||||||
|
(dataframe['ao'] > 0) &
|
||||||
|
(dataframe['ao'].shift() < 0)
|
||||||
|
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] < 0) &
|
||||||
|
(dataframe['ao'] < 0) &
|
||||||
|
(dataframe['ao'].shift() > 0)
|
||||||
|
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,63 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class BbandRsi(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
converted from:
|
||||||
|
|
||||||
|
https://github.com/sthewissen/Mynt/blob/master/src/Mynt.Core/Strategies/BbandRsi.cs
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# adjust based on market conditions. We would recommend to keep it low for quick turn arounds
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
stoploss = -0.25
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '1h'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
|
||||||
|
|
||||||
|
# Bollinger bands
|
||||||
|
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['rsi'] < 30) &
|
||||||
|
(dataframe['close'] < dataframe['bb_lowerband'])
|
||||||
|
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['rsi'] > 70)
|
||||||
|
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,135 @@
|
|||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame, DatetimeIndex, merge
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
|
||||||
|
class BinHV27(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
strategy sponsored by user BinH from slack
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 1
|
||||||
|
}
|
||||||
|
|
||||||
|
stoploss = -0.50
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe['rsi'] = numpy.nan_to_num(ta.RSI(dataframe, timeperiod=5))
|
||||||
|
rsiframe = DataFrame(dataframe['rsi']).rename(columns={'rsi': 'close'})
|
||||||
|
dataframe['emarsi'] = numpy.nan_to_num(ta.EMA(rsiframe, timeperiod=5))
|
||||||
|
dataframe['adx'] = numpy.nan_to_num(ta.ADX(dataframe))
|
||||||
|
dataframe['minusdi'] = numpy.nan_to_num(ta.MINUS_DI(dataframe))
|
||||||
|
minusdiframe = DataFrame(dataframe['minusdi']).rename(columns={'minusdi': 'close'})
|
||||||
|
dataframe['minusdiema'] = numpy.nan_to_num(ta.EMA(minusdiframe, timeperiod=25))
|
||||||
|
dataframe['plusdi'] = numpy.nan_to_num(ta.PLUS_DI(dataframe))
|
||||||
|
plusdiframe = DataFrame(dataframe['plusdi']).rename(columns={'plusdi': 'close'})
|
||||||
|
dataframe['plusdiema'] = numpy.nan_to_num(ta.EMA(plusdiframe, timeperiod=5))
|
||||||
|
dataframe['lowsma'] = numpy.nan_to_num(ta.EMA(dataframe, timeperiod=60))
|
||||||
|
dataframe['highsma'] = numpy.nan_to_num(ta.EMA(dataframe, timeperiod=120))
|
||||||
|
dataframe['fastsma'] = numpy.nan_to_num(ta.SMA(dataframe, timeperiod=120))
|
||||||
|
dataframe['slowsma'] = numpy.nan_to_num(ta.SMA(dataframe, timeperiod=240))
|
||||||
|
dataframe['bigup'] = dataframe['fastsma'].gt(dataframe['slowsma']) & ((dataframe['fastsma'] - dataframe['slowsma']) > dataframe['close'] / 300)
|
||||||
|
dataframe['bigdown'] = ~dataframe['bigup']
|
||||||
|
dataframe['trend'] = dataframe['fastsma'] - dataframe['slowsma']
|
||||||
|
dataframe['preparechangetrend'] = dataframe['trend'].gt(dataframe['trend'].shift())
|
||||||
|
dataframe['preparechangetrendconfirm'] = dataframe['preparechangetrend'] & dataframe['trend'].shift().gt(dataframe['trend'].shift(2))
|
||||||
|
dataframe['continueup'] = dataframe['slowsma'].gt(dataframe['slowsma'].shift()) & dataframe['slowsma'].shift().gt(dataframe['slowsma'].shift(2))
|
||||||
|
dataframe['delta'] = dataframe['fastsma'] - dataframe['fastsma'].shift()
|
||||||
|
dataframe['slowingdown'] = dataframe['delta'].lt(dataframe['delta'].shift())
|
||||||
|
return dataframe
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
dataframe['slowsma'].gt(0) &
|
||||||
|
dataframe['close'].lt(dataframe['highsma']) &
|
||||||
|
dataframe['close'].lt(dataframe['lowsma']) &
|
||||||
|
dataframe['minusdi'].gt(dataframe['minusdiema']) &
|
||||||
|
dataframe['rsi'].ge(dataframe['rsi'].shift()) &
|
||||||
|
(
|
||||||
|
(
|
||||||
|
~dataframe['preparechangetrend'] &
|
||||||
|
~dataframe['continueup'] &
|
||||||
|
dataframe['adx'].gt(25) &
|
||||||
|
dataframe['bigdown'] &
|
||||||
|
dataframe['emarsi'].le(20)
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
~dataframe['preparechangetrend'] &
|
||||||
|
dataframe['continueup'] &
|
||||||
|
dataframe['adx'].gt(30) &
|
||||||
|
dataframe['bigdown'] &
|
||||||
|
dataframe['emarsi'].le(20)
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
~dataframe['continueup'] &
|
||||||
|
dataframe['adx'].gt(35) &
|
||||||
|
dataframe['bigup'] &
|
||||||
|
dataframe['emarsi'].le(20)
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
dataframe['continueup'] &
|
||||||
|
dataframe['adx'].gt(30) &
|
||||||
|
dataframe['bigup'] &
|
||||||
|
dataframe['emarsi'].le(25)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
~dataframe['preparechangetrendconfirm'] &
|
||||||
|
~dataframe['continueup'] &
|
||||||
|
(dataframe['close'].gt(dataframe['lowsma']) | dataframe['close'].gt(dataframe['highsma'])) &
|
||||||
|
dataframe['highsma'].gt(0) &
|
||||||
|
dataframe['bigdown']
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
~dataframe['preparechangetrendconfirm'] &
|
||||||
|
~dataframe['continueup'] &
|
||||||
|
dataframe['close'].gt(dataframe['highsma']) &
|
||||||
|
dataframe['highsma'].gt(0) &
|
||||||
|
(dataframe['emarsi'].ge(75) | dataframe['close'].gt(dataframe['slowsma'])) &
|
||||||
|
dataframe['bigdown']
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
~dataframe['preparechangetrendconfirm'] &
|
||||||
|
dataframe['close'].gt(dataframe['highsma']) &
|
||||||
|
dataframe['highsma'].gt(0) &
|
||||||
|
dataframe['adx'].gt(30) &
|
||||||
|
dataframe['emarsi'].ge(80) &
|
||||||
|
dataframe['bigup']
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
dataframe['preparechangetrendconfirm'] &
|
||||||
|
~dataframe['continueup'] &
|
||||||
|
dataframe['slowingdown'] &
|
||||||
|
dataframe['emarsi'].ge(75) &
|
||||||
|
dataframe['slowsma'].gt(0)
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
dataframe['preparechangetrendconfirm'] &
|
||||||
|
dataframe['minusdi'].lt(dataframe['plusdi']) &
|
||||||
|
dataframe['close'].gt(dataframe['lowsma']) &
|
||||||
|
dataframe['slowsma'].gt(0)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,57 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
import numpy as np
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
def bollinger_bands(stock_price, window_size, num_of_std):
|
||||||
|
rolling_mean = stock_price.rolling(window=window_size).mean()
|
||||||
|
rolling_std = stock_price.rolling(window=window_size).std()
|
||||||
|
lower_band = rolling_mean - (rolling_std * num_of_std)
|
||||||
|
|
||||||
|
return rolling_mean, lower_band
|
||||||
|
|
||||||
|
|
||||||
|
class BinHV45(IStrategy):
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.0125
|
||||||
|
}
|
||||||
|
|
||||||
|
stoploss = -0.05
|
||||||
|
timeframe = '1m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
mid, lower = bollinger_bands(dataframe['close'], window_size=40, num_of_std=2)
|
||||||
|
dataframe['mid'] = np.nan_to_num(mid)
|
||||||
|
dataframe['lower'] = np.nan_to_num(lower)
|
||||||
|
dataframe['bbdelta'] = (dataframe['mid'] - dataframe['lower']).abs()
|
||||||
|
dataframe['pricedelta'] = (dataframe['open'] - dataframe['close']).abs()
|
||||||
|
dataframe['closedelta'] = (dataframe['close'] - dataframe['close'].shift()).abs()
|
||||||
|
dataframe['tail'] = (dataframe['close'] - dataframe['low']).abs()
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
dataframe['lower'].shift().gt(0) &
|
||||||
|
dataframe['bbdelta'].gt(dataframe['close'] * 0.008) &
|
||||||
|
dataframe['closedelta'].gt(dataframe['close'] * 0.0175) &
|
||||||
|
dataframe['tail'].lt(dataframe['bbdelta'] * 0.25) &
|
||||||
|
dataframe['close'].lt(dataframe['lower'].shift()) &
|
||||||
|
dataframe['close'].le(dataframe['close'].shift())
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
no sell signal
|
||||||
|
"""
|
||||||
|
dataframe['sell'] = 0
|
||||||
|
return dataframe
|
@ -0,0 +1,119 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame, Series, DatetimeIndex, merge
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class CCIStrategy(IStrategy):
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.02
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '1m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe = self.resample(dataframe, self.timeframe, 5)
|
||||||
|
|
||||||
|
dataframe['cci_one'] = ta.CCI(dataframe, timeperiod=170)
|
||||||
|
dataframe['cci_two'] = ta.CCI(dataframe, timeperiod=34)
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe)
|
||||||
|
dataframe['mfi'] = ta.MFI(dataframe)
|
||||||
|
|
||||||
|
dataframe['cmf'] = self.chaikin_mf(dataframe)
|
||||||
|
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['cci_one'] < -100)
|
||||||
|
& (dataframe['cci_two'] < -100)
|
||||||
|
& (dataframe['cmf'] < -0.1)
|
||||||
|
& (dataframe['mfi'] < 25)
|
||||||
|
|
||||||
|
# insurance
|
||||||
|
& (dataframe['resample_medium'] > dataframe['resample_short'])
|
||||||
|
& (dataframe['resample_long'] < dataframe['close'])
|
||||||
|
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['cci_one'] > 100)
|
||||||
|
& (dataframe['cci_two'] > 100)
|
||||||
|
& (dataframe['cmf'] > 0.3)
|
||||||
|
& (dataframe['resample_sma'] < dataframe['resample_medium'])
|
||||||
|
& (dataframe['resample_medium'] < dataframe['resample_short'])
|
||||||
|
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def chaikin_mf(self, df, periods=20):
|
||||||
|
close = df['close']
|
||||||
|
low = df['low']
|
||||||
|
high = df['high']
|
||||||
|
volume = df['volume']
|
||||||
|
|
||||||
|
mfv = ((close - low) - (high - close)) / (high - low)
|
||||||
|
mfv = mfv.fillna(0.0) # float division by zero
|
||||||
|
mfv *= volume
|
||||||
|
cmf = mfv.rolling(periods).sum() / volume.rolling(periods).sum()
|
||||||
|
|
||||||
|
return Series(cmf, name='cmf')
|
||||||
|
|
||||||
|
def resample(self, dataframe, interval, factor):
|
||||||
|
# defines the reinforcement logic
|
||||||
|
# resampled dataframe to establish if we are in an uptrend, downtrend or sideways trend
|
||||||
|
df = dataframe.copy()
|
||||||
|
df = df.set_index(DatetimeIndex(df['date']))
|
||||||
|
ohlc_dict = {
|
||||||
|
'open': 'first',
|
||||||
|
'high': 'max',
|
||||||
|
'low': 'min',
|
||||||
|
'close': 'last'
|
||||||
|
}
|
||||||
|
df = df.resample(str(int(interval[:-1]) * factor) + 'min', label="right").agg(ohlc_dict)
|
||||||
|
df['resample_sma'] = ta.SMA(df, timeperiod=100, price='close')
|
||||||
|
df['resample_medium'] = ta.SMA(df, timeperiod=50, price='close')
|
||||||
|
df['resample_short'] = ta.SMA(df, timeperiod=25, price='close')
|
||||||
|
df['resample_long'] = ta.SMA(df, timeperiod=200, price='close')
|
||||||
|
df = df.drop(columns=['open', 'high', 'low', 'close'])
|
||||||
|
df = df.resample(interval[:-1] + 'min')
|
||||||
|
df = df.interpolate(method='time')
|
||||||
|
df['date'] = df.index
|
||||||
|
df.index = range(len(df))
|
||||||
|
dataframe = merge(dataframe, df, on='date', how='left')
|
||||||
|
return dataframe
|
@ -0,0 +1,95 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
# Add your lib to import here
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
|
||||||
|
# This class is a sample. Feel free to customize it.
|
||||||
|
class CMCWinner(IStrategy):
|
||||||
|
"""
|
||||||
|
This is a test strategy to inspire you.
|
||||||
|
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||||
|
|
||||||
|
You can:
|
||||||
|
- Rename the class name (Do not forget to update class_name)
|
||||||
|
- Add any methods you want to build your strategy
|
||||||
|
- Add any lib you need to build your strategy
|
||||||
|
|
||||||
|
You must keep:
|
||||||
|
- the lib in the section "Do not remove these libs"
|
||||||
|
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||||
|
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"40": 0.0,
|
||||||
|
"30": 0.02,
|
||||||
|
"20": 0.03,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.05
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '15m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Adds several different TA indicators to the given DataFrame
|
||||||
|
|
||||||
|
Performance Note: For the best performance be frugal on the number of indicators
|
||||||
|
you are using. Let uncomment only the indicator you are using in your strategies
|
||||||
|
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Commodity Channel Index: values Oversold:<-100, Overbought:>100
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe)
|
||||||
|
|
||||||
|
# MFI
|
||||||
|
dataframe['mfi'] = ta.MFI(dataframe)
|
||||||
|
|
||||||
|
# CMO
|
||||||
|
dataframe['cmo'] = ta.CMO(dataframe)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['cci'].shift(1) < -100) &
|
||||||
|
(dataframe['mfi'].shift(1) < 20) &
|
||||||
|
(dataframe['cmo'].shift(1) < -50)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['cci'].shift(1) > 100) &
|
||||||
|
(dataframe['mfi'].shift(1) > 80) &
|
||||||
|
(dataframe['cmo'].shift(1) > 50)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,83 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame, DatetimeIndex, merge
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
|
||||||
|
class ClucMay72018(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
works on new objectify branch!
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.05
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=5)
|
||||||
|
rsiframe = DataFrame(dataframe['rsi']).rename(columns={'rsi': 'close'})
|
||||||
|
dataframe['emarsi'] = ta.EMA(rsiframe, timeperiod=5)
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['ema100'] = ta.EMA(dataframe, timeperiod=50)
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['close'] < dataframe['ema100']) &
|
||||||
|
(dataframe['close'] < 0.985 * dataframe['bb_lowerband']) &
|
||||||
|
(dataframe['volume'] < (dataframe['volume'].rolling(window=30).mean().shift(1) * 20))
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['close'] > dataframe['bb_middleband'])
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,80 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import talib.abstract as ta
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class CofiBitStrategy(IStrategy):
|
||||||
|
"""
|
||||||
|
taken from slack by user CofiBit
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"40": 0.05,
|
||||||
|
"30": 0.06,
|
||||||
|
"20": 0.07,
|
||||||
|
"0": 0.10
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.25
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
stoch_fast = ta.STOCHF(dataframe, 5, 3, 0, 3, 0)
|
||||||
|
dataframe['fastd'] = stoch_fast['fastd']
|
||||||
|
dataframe['fastk'] = stoch_fast['fastk']
|
||||||
|
dataframe['ema_high'] = ta.EMA(dataframe, timeperiod=5, price='high')
|
||||||
|
dataframe['ema_close'] = ta.EMA(dataframe, timeperiod=5, price='close')
|
||||||
|
dataframe['ema_low'] = ta.EMA(dataframe, timeperiod=5, price='low')
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['open'] < dataframe['ema_low']) &
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], dataframe['fastd'])) &
|
||||||
|
# (dataframe['fastk'] > dataframe['fastd']) &
|
||||||
|
(dataframe['fastk'] < 30) &
|
||||||
|
(dataframe['fastd'] < 30) &
|
||||||
|
(dataframe['adx'] > 30)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['open'] >= dataframe['ema_high'])
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
# (dataframe['fastk'] > 70) &
|
||||||
|
# (dataframe['fastd'] > 70)
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], 70)) |
|
||||||
|
(qtpylib.crossed_above(dataframe['fastd'], 70))
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
@ -0,0 +1,75 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy as np
|
||||||
|
# --------------------------------
|
||||||
|
import talib.abstract as ta
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
|
||||||
|
|
||||||
|
def bollinger_bands(stock_price, window_size, num_of_std):
|
||||||
|
rolling_mean = stock_price.rolling(window=window_size).mean()
|
||||||
|
rolling_std = stock_price.rolling(window=window_size).std()
|
||||||
|
lower_band = rolling_mean - (rolling_std * num_of_std)
|
||||||
|
return np.nan_to_num(rolling_mean), np.nan_to_num(lower_band)
|
||||||
|
|
||||||
|
|
||||||
|
class CombinedBinHAndCluc(IStrategy):
|
||||||
|
# Based on a backtesting:
|
||||||
|
# - the best perfomance is reached with "max_open_trades" = 2 (in average for any market),
|
||||||
|
# so it is better to increase "stake_amount" value rather then "max_open_trades" to get more profit
|
||||||
|
# - if the market is constantly green(like in JAN 2018) the best performance is reached with
|
||||||
|
# "max_open_trades" = 2 and minimal_roi = 0.01
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
stoploss = -0.05
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = True
|
||||||
|
ignore_roi_if_buy_signal = False
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
# strategy BinHV45
|
||||||
|
mid, lower = bollinger_bands(dataframe['close'], window_size=40, num_of_std=2)
|
||||||
|
dataframe['lower'] = lower
|
||||||
|
dataframe['bbdelta'] = (mid - dataframe['lower']).abs()
|
||||||
|
dataframe['closedelta'] = (dataframe['close'] - dataframe['close'].shift()).abs()
|
||||||
|
dataframe['tail'] = (dataframe['close'] - dataframe['low']).abs()
|
||||||
|
# strategy ClucMay72018
|
||||||
|
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
dataframe['ema_slow'] = ta.EMA(dataframe, timeperiod=50)
|
||||||
|
dataframe['volume_mean_slow'] = dataframe['volume'].rolling(window=30).mean()
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
( # strategy BinHV45
|
||||||
|
dataframe['lower'].shift().gt(0) &
|
||||||
|
dataframe['bbdelta'].gt(dataframe['close'] * 0.008) &
|
||||||
|
dataframe['closedelta'].gt(dataframe['close'] * 0.0175) &
|
||||||
|
dataframe['tail'].lt(dataframe['bbdelta'] * 0.25) &
|
||||||
|
dataframe['close'].lt(dataframe['lower'].shift()) &
|
||||||
|
dataframe['close'].le(dataframe['close'].shift())
|
||||||
|
) |
|
||||||
|
( # strategy ClucMay72018
|
||||||
|
(dataframe['close'] < dataframe['ema_slow']) &
|
||||||
|
(dataframe['close'] < 0.985 * dataframe['bb_lowerband']) &
|
||||||
|
(dataframe['volume'] < (dataframe['volume_mean_slow'].shift(1) * 20))
|
||||||
|
),
|
||||||
|
'buy'
|
||||||
|
] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(dataframe['close'] > dataframe['bb_middleband']),
|
||||||
|
'sell'
|
||||||
|
] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,44 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class DoesNothingStrategy(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
just a skeleton
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# adjust based on market conditions. We would recommend to keep it low for quick turn arounds
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
stoploss = -0.25
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,85 @@
|
|||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
|
||||||
|
class EMASkipPump(IStrategy):
|
||||||
|
|
||||||
|
"""
|
||||||
|
basic strategy, which trys to avoid pump and dump market conditions. Shared from the tradingview
|
||||||
|
slack
|
||||||
|
"""
|
||||||
|
EMA_SHORT_TERM = 5
|
||||||
|
EMA_MEDIUM_TERM = 12
|
||||||
|
EMA_LONG_TERM = 21
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# we only sell after 100%, unless our sell points are found before
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
# should be converted to a trailing stop loss
|
||||||
|
stoploss = -0.05
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
""" Adds several different TA indicators to the given DataFrame
|
||||||
|
"""
|
||||||
|
|
||||||
|
dataframe['ema_{}'.format(self.EMA_SHORT_TERM)] = ta.EMA(
|
||||||
|
dataframe, timeperiod=self.EMA_SHORT_TERM
|
||||||
|
)
|
||||||
|
dataframe['ema_{}'.format(self.EMA_MEDIUM_TERM)] = ta.EMA(
|
||||||
|
dataframe, timeperiod=self.EMA_MEDIUM_TERM
|
||||||
|
)
|
||||||
|
dataframe['ema_{}'.format(self.EMA_LONG_TERM)] = ta.EMA(
|
||||||
|
dataframe, timeperiod=self.EMA_LONG_TERM
|
||||||
|
)
|
||||||
|
|
||||||
|
bollinger = qtpylib.bollinger_bands(
|
||||||
|
qtpylib.typical_price(dataframe), window=20, stds=2
|
||||||
|
)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
|
||||||
|
dataframe['min'] = ta.MIN(dataframe, timeperiod=self.EMA_MEDIUM_TERM)
|
||||||
|
dataframe['max'] = ta.MAX(dataframe, timeperiod=self.EMA_MEDIUM_TERM)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
dataframe.loc[
|
||||||
|
(dataframe['volume'] < (dataframe['volume'].rolling(window=30).mean().shift(1) * 20)) &
|
||||||
|
(dataframe['close'] < dataframe['ema_{}'.format(self.EMA_SHORT_TERM)]) &
|
||||||
|
(dataframe['close'] < dataframe['ema_{}'.format(self.EMA_MEDIUM_TERM)]) &
|
||||||
|
(dataframe['close'] == dataframe['min']) &
|
||||||
|
(dataframe['close'] <= dataframe['bb_lowerband']),
|
||||||
|
'buy'
|
||||||
|
] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
dataframe.loc[
|
||||||
|
(dataframe['close'] > dataframe['ema_{}'.format(self.EMA_SHORT_TERM)]) &
|
||||||
|
(dataframe['close'] > dataframe['ema_{}'.format(self.EMA_MEDIUM_TERM)]) &
|
||||||
|
(dataframe['close'] >= dataframe['max']) &
|
||||||
|
(dataframe['close'] >= dataframe['bb_upperband']),
|
||||||
|
'sell'
|
||||||
|
] = 1
|
||||||
|
|
||||||
|
return dataframe
|
@ -0,0 +1,49 @@
|
|||||||
|
# Freqtrade_backtest_validation_freqtrade1.py
|
||||||
|
# This script is 1 of a pair the other being freqtrade_backtest_validation_tradingview1
|
||||||
|
# These should be executed on their respective platforms for the same coin/period/resolution
|
||||||
|
# The purpose is to test Freqtrade backtest provides like results to a known industry platform.
|
||||||
|
#
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
# Add your lib to import here
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class Freqtrade_backtest_validation_freqtrade1(IStrategy):
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
minimal_roi = {
|
||||||
|
"40": 2.0,
|
||||||
|
"30": 2.01,
|
||||||
|
"20": 2.02,
|
||||||
|
"0": 2.04
|
||||||
|
}
|
||||||
|
|
||||||
|
stoploss = -0.90
|
||||||
|
timeframe = '1h'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
# SMA - Simple Moving Average
|
||||||
|
dataframe['fastMA'] = ta.SMA(dataframe, timeperiod=14)
|
||||||
|
dataframe['slowMA'] = ta.SMA(dataframe, timeperiod=28)
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['fastMA'] > dataframe['slowMA'])
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['fastMA'] < dataframe['slowMA'])
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,108 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame, DatetimeIndex, merge
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
# import numpy as np # noqa
|
||||||
|
|
||||||
|
class Low_BB(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Thorsten
|
||||||
|
|
||||||
|
works on new objectify branch!
|
||||||
|
|
||||||
|
idea:
|
||||||
|
buy after crossing .98 * lower_bb and sell if trailing stop loss is hit
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.9,
|
||||||
|
"1": 0.05,
|
||||||
|
"10": 0.04,
|
||||||
|
"15": 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.015
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '1m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
##################################################################################
|
||||||
|
# buy and sell indicators
|
||||||
|
|
||||||
|
bollinger = qtpylib.bollinger_bands(
|
||||||
|
qtpylib.typical_price(dataframe), window=20, stds=2
|
||||||
|
)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
|
||||||
|
# dataframe['cci'] = ta.CCI(dataframe)
|
||||||
|
# dataframe['mfi'] = ta.MFI(dataframe)
|
||||||
|
# dataframe['rsi'] = ta.RSI(dataframe, timeperiod=7)
|
||||||
|
|
||||||
|
# dataframe['canbuy'] = np.NaN
|
||||||
|
# dataframe['canbuy2'] = np.NaN
|
||||||
|
# dataframe.loc[dataframe.close.rolling(49).min() <= 1.1 * dataframe.close, 'canbuy'] == 1
|
||||||
|
# dataframe.loc[dataframe.close.rolling(600).max() < 1.2 * dataframe.close, 'canbuy'] = 1
|
||||||
|
# dataframe.loc[dataframe.close.rolling(600).max() * 0.8 > dataframe.close, 'canbuy2'] = 1
|
||||||
|
##################################################################################
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
|
||||||
|
(dataframe['close'] <= 0.98 * dataframe['bb_lowerband'])
|
||||||
|
|
||||||
|
)
|
||||||
|
,
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,83 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
|
||||||
|
|
||||||
|
class MACDStrategy(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
idea:
|
||||||
|
|
||||||
|
uptrend definition:
|
||||||
|
MACD above MACD signal
|
||||||
|
and CCI < -50
|
||||||
|
|
||||||
|
downtrend definition:
|
||||||
|
MACD below MACD signal
|
||||||
|
and CCI > 100
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"60": 0.01,
|
||||||
|
"30": 0.03,
|
||||||
|
"20": 0.04,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.3
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] > dataframe['macdsignal']) &
|
||||||
|
(dataframe['cci'] <= -50.0)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['macd'] < dataframe['macdsignal']) &
|
||||||
|
(dataframe['cci'] >= 100.0)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
@ -0,0 +1,77 @@
|
|||||||
|
|
||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class MACDStrategy_crossed(IStrategy):
|
||||||
|
"""
|
||||||
|
buy:
|
||||||
|
MACD crosses MACD signal above
|
||||||
|
and CCI < -50
|
||||||
|
sell:
|
||||||
|
MACD crosses MACD signal below
|
||||||
|
and CCI > 100
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"60": 0.01,
|
||||||
|
"30": 0.03,
|
||||||
|
"20": 0.04,
|
||||||
|
"0": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.3
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_above(dataframe['macd'], dataframe['macdsignal']) &
|
||||||
|
(dataframe['cci'] <= -50.0)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_below(dataframe['macd'], dataframe['macdsignal']) &
|
||||||
|
(dataframe['cci'] >= 100.0)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
@ -0,0 +1,70 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
import talib.abstract as ta
|
||||||
|
from technical.util import resample_to_interval, resampled_merge
|
||||||
|
|
||||||
|
|
||||||
|
class MultiRSI(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
based on work from Creslin
|
||||||
|
|
||||||
|
"""
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
stoploss = -0.05
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def get_ticker_indicator(self):
|
||||||
|
return int(self.timeframe[:-1])
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
dataframe['sma5'] = ta.SMA(dataframe, timeperiod=5)
|
||||||
|
dataframe['sma200'] = ta.SMA(dataframe, timeperiod=200)
|
||||||
|
|
||||||
|
# resample our dataframes
|
||||||
|
dataframe_short = resample_to_interval(dataframe, self.get_ticker_indicator() * 2)
|
||||||
|
dataframe_long = resample_to_interval(dataframe, self.get_ticker_indicator() * 8)
|
||||||
|
|
||||||
|
# compute our RSI's
|
||||||
|
dataframe_short['rsi'] = ta.RSI(dataframe_short, timeperiod=14)
|
||||||
|
dataframe_long['rsi'] = ta.RSI(dataframe_long, timeperiod=14)
|
||||||
|
|
||||||
|
# merge dataframe back together
|
||||||
|
dataframe = resampled_merge(dataframe, dataframe_short)
|
||||||
|
dataframe = resampled_merge(dataframe, dataframe_long)
|
||||||
|
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
|
||||||
|
|
||||||
|
dataframe.fillna(method='ffill', inplace=True)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
# must be bearish
|
||||||
|
(dataframe['sma5'] >= dataframe['sma200']) &
|
||||||
|
(dataframe['rsi'] < (dataframe['resample_{}_rsi'.format(self.get_ticker_indicator() * 8)] - 20))
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['rsi'] > dataframe['resample_{}_rsi'.format(self.get_ticker_indicator()*2)]) &
|
||||||
|
(dataframe['rsi'] > dataframe['resample_{}_rsi'.format(self.get_ticker_indicator()*8)])
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,77 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class Quickie(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
idea:
|
||||||
|
momentum based strategie. The main idea is that it closes trades very quickly, while avoiding excessive losses. Hence a rather moderate stop loss in this case
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"100": 0.01,
|
||||||
|
"30": 0.03,
|
||||||
|
"15": 0.06,
|
||||||
|
"10": 0.15,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.25
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
|
||||||
|
dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9)
|
||||||
|
dataframe['sma_200'] = ta.SMA(dataframe, timeperiod=200)
|
||||||
|
dataframe['sma_50'] = ta.SMA(dataframe, timeperiod=200)
|
||||||
|
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['adx'] > 30) &
|
||||||
|
(dataframe['tema'] < dataframe['bb_middleband']) &
|
||||||
|
(dataframe['tema'] > dataframe['tema'].shift(1)) &
|
||||||
|
(dataframe['sma_200'] > dataframe['close'])
|
||||||
|
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['adx'] > 70) &
|
||||||
|
(dataframe['tema'] > dataframe['bb_middleband']) &
|
||||||
|
(dataframe['tema'] < dataframe['tema'].shift(1))
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,96 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame, merge, DatetimeIndex
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from technical.util import resample_to_interval, resampled_merge
|
||||||
|
from freqtrade.exchange import timeframe_to_minutes
|
||||||
|
|
||||||
|
|
||||||
|
class ReinforcedAverageStrategy(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
idea:
|
||||||
|
buys and sells on crossovers - doesn't really perfom that well and its just a proof of concept
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.2
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '4h'
|
||||||
|
|
||||||
|
# trailing stoploss
|
||||||
|
trailing_stop = False
|
||||||
|
trailing_stop_positive = 0.01
|
||||||
|
trailing_stop_positive_offset = 0.02
|
||||||
|
trailing_only_offset_is_reached = False
|
||||||
|
|
||||||
|
# run "populate_indicators" only for new candle
|
||||||
|
process_only_new_candles = False
|
||||||
|
|
||||||
|
# Experimental settings (configuration will overide these if set)
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = False
|
||||||
|
ignore_roi_if_buy_signal = False
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|
||||||
|
dataframe['maShort'] = ta.EMA(dataframe, timeperiod=8)
|
||||||
|
dataframe['maMedium'] = ta.EMA(dataframe, timeperiod=21)
|
||||||
|
##################################################################################
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
self.resample_interval = timeframe_to_minutes(self.timeframe) * 12
|
||||||
|
dataframe_long = resample_to_interval(dataframe, self.resample_interval)
|
||||||
|
dataframe_long['sma'] = ta.SMA(dataframe_long, timeperiod=50, price='close')
|
||||||
|
dataframe = resampled_merge(dataframe, dataframe_long, fill_na=True)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_above(dataframe['maShort'], dataframe['maMedium']) &
|
||||||
|
(dataframe['close'] > dataframe[f'resample_{self.resample_interval}_sma']) &
|
||||||
|
(dataframe['volume'] > 0)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
qtpylib.crossed_above(dataframe['maMedium'], dataframe['maShort']) &
|
||||||
|
(dataframe['volume'] > 0)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,194 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame, DatetimeIndex, merge
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
class ReinforcedQuickie(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
works on new objectify branch!
|
||||||
|
|
||||||
|
idea:
|
||||||
|
only buy on an upward tending market
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.05
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
# resample factor to establish our general trend. Basically don't buy if a trend is not given
|
||||||
|
resample_factor = 12
|
||||||
|
|
||||||
|
EMA_SHORT_TERM = 5
|
||||||
|
EMA_MEDIUM_TERM = 12
|
||||||
|
EMA_LONG_TERM = 21
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe = self.resample(dataframe, self.timeframe, self.resample_factor)
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
# buy and sell indicators
|
||||||
|
|
||||||
|
dataframe['ema_{}'.format(self.EMA_SHORT_TERM)] = ta.EMA(
|
||||||
|
dataframe, timeperiod=self.EMA_SHORT_TERM
|
||||||
|
)
|
||||||
|
dataframe['ema_{}'.format(self.EMA_MEDIUM_TERM)] = ta.EMA(
|
||||||
|
dataframe, timeperiod=self.EMA_MEDIUM_TERM
|
||||||
|
)
|
||||||
|
dataframe['ema_{}'.format(self.EMA_LONG_TERM)] = ta.EMA(
|
||||||
|
dataframe, timeperiod=self.EMA_LONG_TERM
|
||||||
|
)
|
||||||
|
|
||||||
|
bollinger = qtpylib.bollinger_bands(
|
||||||
|
qtpylib.typical_price(dataframe), window=20, stds=2
|
||||||
|
)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
|
||||||
|
dataframe['min'] = ta.MIN(dataframe, timeperiod=self.EMA_MEDIUM_TERM)
|
||||||
|
dataframe['max'] = ta.MAX(dataframe, timeperiod=self.EMA_MEDIUM_TERM)
|
||||||
|
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe)
|
||||||
|
dataframe['mfi'] = ta.MFI(dataframe)
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=7)
|
||||||
|
|
||||||
|
dataframe['average'] = (dataframe['close'] + dataframe['open'] + dataframe['high'] + dataframe['low']) / 4
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['close'] < dataframe['ema_{}'.format(self.EMA_SHORT_TERM)]) &
|
||||||
|
(dataframe['close'] < dataframe['ema_{}'.format(self.EMA_MEDIUM_TERM)]) &
|
||||||
|
(dataframe['close'] == dataframe['min']) &
|
||||||
|
(dataframe['close'] <= dataframe['bb_lowerband'])
|
||||||
|
)
|
||||||
|
|
|
||||||
|
# simple v bottom shape (lopsided to the left to increase reactivity)
|
||||||
|
# which has to be below a very slow average
|
||||||
|
# this pattern only catches a few, but normally very good buy points
|
||||||
|
(
|
||||||
|
(dataframe['average'].shift(5) > dataframe['average'].shift(4))
|
||||||
|
& (dataframe['average'].shift(4) > dataframe['average'].shift(3))
|
||||||
|
& (dataframe['average'].shift(3) > dataframe['average'].shift(2))
|
||||||
|
& (dataframe['average'].shift(2) > dataframe['average'].shift(1))
|
||||||
|
& (dataframe['average'].shift(1) < dataframe['average'].shift(0))
|
||||||
|
& (dataframe['low'].shift(1) < dataframe['bb_middleband'])
|
||||||
|
& (dataframe['cci'].shift(1) < -100)
|
||||||
|
& (dataframe['rsi'].shift(1) < 30)
|
||||||
|
& (dataframe['mfi'].shift(1) < 30)
|
||||||
|
|
||||||
|
)
|
||||||
|
)
|
||||||
|
# safeguard against down trending markets and a pump and dump
|
||||||
|
&
|
||||||
|
(
|
||||||
|
(dataframe['volume'] < (dataframe['volume'].rolling(window=30).mean().shift(1) * 20)) &
|
||||||
|
(dataframe['resample_sma'] < dataframe['close']) &
|
||||||
|
(dataframe['resample_sma'].shift(1) < dataframe['resample_sma'])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
,
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['close'] > dataframe['ema_{}'.format(self.EMA_SHORT_TERM)]) &
|
||||||
|
(dataframe['close'] > dataframe['ema_{}'.format(self.EMA_MEDIUM_TERM)]) &
|
||||||
|
(dataframe['close'] >= dataframe['max']) &
|
||||||
|
(dataframe['close'] >= dataframe['bb_upperband']) &
|
||||||
|
(dataframe['mfi'] > 80)
|
||||||
|
) |
|
||||||
|
|
||||||
|
# always sell on eight green candles
|
||||||
|
# with a high rsi
|
||||||
|
(
|
||||||
|
(dataframe['open'] < dataframe['close']) &
|
||||||
|
(dataframe['open'].shift(1) < dataframe['close'].shift(1)) &
|
||||||
|
(dataframe['open'].shift(2) < dataframe['close'].shift(2)) &
|
||||||
|
(dataframe['open'].shift(3) < dataframe['close'].shift(3)) &
|
||||||
|
(dataframe['open'].shift(4) < dataframe['close'].shift(4)) &
|
||||||
|
(dataframe['open'].shift(5) < dataframe['close'].shift(5)) &
|
||||||
|
(dataframe['open'].shift(6) < dataframe['close'].shift(6)) &
|
||||||
|
(dataframe['open'].shift(7) < dataframe['close'].shift(7)) &
|
||||||
|
(dataframe['rsi'] > 70)
|
||||||
|
)
|
||||||
|
,
|
||||||
|
'sell'
|
||||||
|
] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def resample(self, dataframe, interval, factor):
|
||||||
|
# defines the reinforcement logic
|
||||||
|
# resampled dataframe to establish if we are in an uptrend, downtrend or sideways trend
|
||||||
|
df = dataframe.copy()
|
||||||
|
df = df.set_index(DatetimeIndex(df['date']))
|
||||||
|
ohlc_dict = {
|
||||||
|
'open': 'first',
|
||||||
|
'high': 'max',
|
||||||
|
'low': 'min',
|
||||||
|
'close': 'last'
|
||||||
|
}
|
||||||
|
df = df.resample(str(int(interval[:-1]) * factor) + 'min',
|
||||||
|
label="right").agg(ohlc_dict).dropna(how='any')
|
||||||
|
df['resample_sma'] = ta.SMA(df, timeperiod=25, price='close')
|
||||||
|
df = df.drop(columns=['open', 'high', 'low', 'close'])
|
||||||
|
df = df.resample(interval[:-1] + 'min')
|
||||||
|
df = df.interpolate(method='time')
|
||||||
|
df['date'] = df.index
|
||||||
|
df.index = range(len(df))
|
||||||
|
dataframe = merge(dataframe, df, on='date', how='left')
|
||||||
|
return dataframe
|
@ -0,0 +1,102 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from freqtrade.strategy import timeframe_to_minutes
|
||||||
|
from pandas import DataFrame
|
||||||
|
from technical.util import resample_to_interval, resampled_merge
|
||||||
|
import numpy # noqa
|
||||||
|
# --------------------------------
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class ReinforcedSmoothScalp(IStrategy):
|
||||||
|
"""
|
||||||
|
this strategy is based around the idea of generating a lot of potentatils buys and make tiny profits on each trade
|
||||||
|
|
||||||
|
we recommend to have at least 60 parallel trades at any time to cover non avoidable losses
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.02
|
||||||
|
}
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
# should not be below 3% loss
|
||||||
|
|
||||||
|
stoploss = -0.1
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
# the shorter the better
|
||||||
|
timeframe = '1m'
|
||||||
|
|
||||||
|
# resample factor to establish our general trend. Basically don't buy if a trend is not given
|
||||||
|
resample_factor = 5
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
tf_res = timeframe_to_minutes(self.timeframe) * 5
|
||||||
|
df_res = resample_to_interval(dataframe, tf_res)
|
||||||
|
df_res['sma'] = ta.SMA(df_res, 50, price='close')
|
||||||
|
dataframe = resampled_merge(dataframe, df_res, fill_na=True)
|
||||||
|
dataframe['resample_sma'] = dataframe[f'resample_{tf_res}_sma']
|
||||||
|
|
||||||
|
dataframe['ema_high'] = ta.EMA(dataframe, timeperiod=5, price='high')
|
||||||
|
dataframe['ema_close'] = ta.EMA(dataframe, timeperiod=5, price='close')
|
||||||
|
dataframe['ema_low'] = ta.EMA(dataframe, timeperiod=5, price='low')
|
||||||
|
stoch_fast = ta.STOCHF(dataframe, 5, 3, 0, 3, 0)
|
||||||
|
dataframe['fastd'] = stoch_fast['fastd']
|
||||||
|
dataframe['fastk'] = stoch_fast['fastk']
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe, timeperiod=20)
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
|
||||||
|
dataframe['mfi'] = ta.MFI(dataframe)
|
||||||
|
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['open'] < dataframe['ema_low']) &
|
||||||
|
(dataframe['adx'] > 30) &
|
||||||
|
(dataframe['mfi'] < 30) &
|
||||||
|
(
|
||||||
|
(dataframe['fastk'] < 30) &
|
||||||
|
(dataframe['fastd'] < 30) &
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], dataframe['fastd']))
|
||||||
|
) &
|
||||||
|
(dataframe['resample_sma'] < dataframe['close'])
|
||||||
|
)
|
||||||
|
# |
|
||||||
|
# # try to get some sure things independent of resample
|
||||||
|
# ((dataframe['rsi'] - dataframe['mfi']) < 10) &
|
||||||
|
# (dataframe['mfi'] < 30) &
|
||||||
|
# (dataframe['cci'] < -200)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['open'] >= dataframe['ema_high'])
|
||||||
|
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], 70)) |
|
||||||
|
(qtpylib.crossed_above(dataframe['fastd'], 70))
|
||||||
|
|
||||||
|
)
|
||||||
|
) & (dataframe['cci'] > 100)
|
||||||
|
)
|
||||||
|
,
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,78 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
# --------------------------------
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class Scalp(IStrategy):
|
||||||
|
"""
|
||||||
|
this strategy is based around the idea of generating a lot of potentatils buys and make tiny profits on each trade
|
||||||
|
|
||||||
|
we recommend to have at least 60 parallel trades at any time to cover non avoidable losses.
|
||||||
|
|
||||||
|
Recommended is to only sell based on ROI for this strategy
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.01
|
||||||
|
}
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
# should not be below 3% loss
|
||||||
|
|
||||||
|
stoploss = -0.04
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
# the shorter the better
|
||||||
|
timeframe = '1m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe['ema_high'] = ta.EMA(dataframe, timeperiod=5, price='high')
|
||||||
|
dataframe['ema_close'] = ta.EMA(dataframe, timeperiod=5, price='close')
|
||||||
|
dataframe['ema_low'] = ta.EMA(dataframe, timeperiod=5, price='low')
|
||||||
|
stoch_fast = ta.STOCHF(dataframe, 5, 3, 0, 3, 0)
|
||||||
|
dataframe['fastd'] = stoch_fast['fastd']
|
||||||
|
dataframe['fastk'] = stoch_fast['fastk']
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['open'] < dataframe['ema_low']) &
|
||||||
|
(dataframe['adx'] > 30) &
|
||||||
|
(
|
||||||
|
(dataframe['fastk'] < 30) &
|
||||||
|
(dataframe['fastd'] < 30) &
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], dataframe['fastd']))
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['open'] >= dataframe['ema_high'])
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], 70)) |
|
||||||
|
(qtpylib.crossed_above(dataframe['fastd'], 70))
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,75 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class Simple(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
idea:
|
||||||
|
this strategy is based on the book, 'The Simple Strategy' and can be found in detail here:
|
||||||
|
|
||||||
|
https://www.amazon.com/Simple-Strategy-Powerful-Trading-Futures-ebook/dp/B00E66QPCG/ref=sr_1_1?ie=UTF8&qid=1525202675&sr=8-1&keywords=the+simple+strategy
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# adjust based on market conditions. We would recommend to keep it low for quick turn arounds
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
stoploss = -0.25
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
# MACD
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
|
||||||
|
# RSI
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=7)
|
||||||
|
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=12, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['macd'] > 0) # over 0
|
||||||
|
& (dataframe['macd'] > dataframe['macdsignal']) # over signal
|
||||||
|
& (dataframe['bb_upperband'] > dataframe['bb_upperband'].shift(1)) # pointed up
|
||||||
|
& (dataframe['rsi'] > 70) # optional filter, need to investigate
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
# different strategy used for sell points, due to be able to duplicate it to 100%
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['rsi'] > 80)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,303 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
# DO NOT USE, just playing with smooting and graphs!
|
||||||
|
|
||||||
|
|
||||||
|
class SmoothOperator(IStrategy):
|
||||||
|
"""
|
||||||
|
|
||||||
|
author@: Gert Wohlgemuth
|
||||||
|
|
||||||
|
idea:
|
||||||
|
|
||||||
|
The concept is about combining several common indicators, with a heavily smoothing, while trying to detect
|
||||||
|
a none completed peak shape.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# we only sell after 100%, unless our sell points are found before
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.10
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
# should be converted to a trailing stop loss
|
||||||
|
stoploss = -0.05
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
##################################################################################
|
||||||
|
# required for entry and exit
|
||||||
|
# CCI
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe, timeperiod=20)
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
dataframe['mfi'] = ta.MFI(dataframe)
|
||||||
|
dataframe['mfi_smooth'] = ta.EMA(dataframe, timeperiod=11, price='mfi')
|
||||||
|
dataframe['cci_smooth'] = ta.EMA(dataframe, timeperiod=11, price='cci')
|
||||||
|
dataframe['rsi_smooth'] = ta.EMA(dataframe, timeperiod=11, price='rsi')
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
|
||||||
|
# MACD
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
# required for entry
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=1.6)
|
||||||
|
dataframe['entry_bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['entry_bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['entry_bb_middleband'] = bollinger['mid']
|
||||||
|
|
||||||
|
dataframe['bpercent'] = (dataframe['close'] - dataframe['bb_lowerband']) / (
|
||||||
|
dataframe['bb_upperband'] - dataframe['bb_lowerband']) * 100
|
||||||
|
|
||||||
|
dataframe['bsharp'] = (dataframe['bb_upperband'] - dataframe['bb_lowerband']) / (
|
||||||
|
dataframe['bb_middleband'])
|
||||||
|
|
||||||
|
# these seem to be kind useful to measure when bands widen
|
||||||
|
# but than they are directly based on the moving average
|
||||||
|
dataframe['bsharp_slow'] = ta.SMA(dataframe, price='bsharp', timeperiod=11)
|
||||||
|
dataframe['bsharp_medium'] = ta.SMA(dataframe, price='bsharp', timeperiod=8)
|
||||||
|
dataframe['bsharp_fast'] = ta.SMA(dataframe, price='bsharp', timeperiod=5)
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
# rsi and mfi are slightly weighted
|
||||||
|
dataframe['mfi_rsi_cci_smooth'] = (dataframe['rsi_smooth'] * 1.125 + dataframe['mfi_smooth'] * 1.125 +
|
||||||
|
dataframe[
|
||||||
|
'cci_smooth']) / 3
|
||||||
|
|
||||||
|
dataframe['mfi_rsi_cci_smooth'] = ta.TEMA(dataframe, timeperiod=21, price='mfi_rsi_cci_smooth')
|
||||||
|
|
||||||
|
# playgound
|
||||||
|
dataframe['candle_size'] = (dataframe['close'] - dataframe['open']) * (
|
||||||
|
dataframe['close'] - dataframe['open']) / 2
|
||||||
|
|
||||||
|
# helps with pattern recognition
|
||||||
|
dataframe['average'] = (dataframe['close'] + dataframe['open'] + dataframe['high'] + dataframe['low']) / 4
|
||||||
|
dataframe['sma_slow'] = ta.SMA(dataframe, timeperiod=200, price='close')
|
||||||
|
dataframe['sma_medium'] = ta.SMA(dataframe, timeperiod=100, price='close')
|
||||||
|
dataframe['sma_fast'] = ta.SMA(dataframe, timeperiod=50, price='close')
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
|
||||||
|
# protection against pump and dump
|
||||||
|
# (dataframe['volume'] < (dataframe['volume'].rolling(window=30).mean().shift(1) * 20))
|
||||||
|
#
|
||||||
|
# & (dataframe['macd'] < dataframe['macdsignal'])
|
||||||
|
# & (dataframe['macd'] > 0)
|
||||||
|
|
||||||
|
# # spike below entry band for 3 consecutive ticks
|
||||||
|
# & (dataframe['low'] < dataframe['entry_bb_lowerband'])
|
||||||
|
# & (dataframe['low'].shift(1) < dataframe['bb_lowerband'].shift(1))
|
||||||
|
# & (dataframe['low'].shift(2) < dataframe['bb_lowerband'].shift(2))
|
||||||
|
# # pattern recognition
|
||||||
|
# & (
|
||||||
|
# (dataframe['close'] > dataframe['open'])
|
||||||
|
# | (dataframe['CDLHAMMER'] == 100)
|
||||||
|
# | (dataframe['CDLINVERTEDHAMMER'] == 100)
|
||||||
|
# | (dataframe['CDLDRAGONFLYDOJI'] == 100)
|
||||||
|
# )
|
||||||
|
# bottom curve detection
|
||||||
|
# & (dataframe['mfi_rsi_cci_smooth'] < 0)
|
||||||
|
#
|
||||||
|
# |
|
||||||
|
|
||||||
|
(
|
||||||
|
# simple v bottom shape (lopsided to the left to increase reactivity)
|
||||||
|
# which has to be below a very slow average
|
||||||
|
# this pattern only catches a few, but normally very good buy points
|
||||||
|
(
|
||||||
|
(dataframe['average'].shift(5) > dataframe['average'].shift(4))
|
||||||
|
& (dataframe['average'].shift(4) > dataframe['average'].shift(3))
|
||||||
|
& (dataframe['average'].shift(3) > dataframe['average'].shift(2))
|
||||||
|
& (dataframe['average'].shift(2) > dataframe['average'].shift(1))
|
||||||
|
& (dataframe['average'].shift(1) < dataframe['average'].shift(0))
|
||||||
|
& (dataframe['low'].shift(1) < dataframe['bb_middleband'])
|
||||||
|
& (dataframe['cci'].shift(1) < -100)
|
||||||
|
& (dataframe['rsi'].shift(1) < 30)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
|
||||||
|
# buy in very oversold conditions
|
||||||
|
(
|
||||||
|
(dataframe['low'] < dataframe['bb_middleband'])
|
||||||
|
& (dataframe['cci'] < -200)
|
||||||
|
& (dataframe['rsi'] < 30)
|
||||||
|
& (dataframe['mfi'] < 30)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
# etc tends to trade like this
|
||||||
|
# over very long periods of slowly building up coins
|
||||||
|
# does not happen often, but once in a while
|
||||||
|
(
|
||||||
|
(dataframe['mfi'] < 10)
|
||||||
|
& (dataframe['cci'] < -150)
|
||||||
|
& (dataframe['rsi'] < dataframe['mfi'])
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
&
|
||||||
|
# ensure we have an overall uptrend
|
||||||
|
(dataframe['close'] > dataframe['close'].shift())
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
# different strategy used for sell points, due to be able to duplicate it to 100%
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
# This generates very nice sale points, and mostly sit's one stop behind
|
||||||
|
# the top of the peak
|
||||||
|
(
|
||||||
|
(dataframe['mfi_rsi_cci_smooth'] > 100)
|
||||||
|
& (dataframe['mfi_rsi_cci_smooth'].shift(1) > dataframe['mfi_rsi_cci_smooth'])
|
||||||
|
& (dataframe['mfi_rsi_cci_smooth'].shift(2) < dataframe['mfi_rsi_cci_smooth'].shift(1))
|
||||||
|
& (dataframe['mfi_rsi_cci_smooth'].shift(3) < dataframe['mfi_rsi_cci_smooth'].shift(2))
|
||||||
|
)
|
||||||
|
|
|
||||||
|
# This helps with very long, sideways trends, to get out of a market before
|
||||||
|
# it dumps
|
||||||
|
(
|
||||||
|
StrategyHelper.eight_green_candles(dataframe)
|
||||||
|
)
|
||||||
|
|
|
||||||
|
# in case of very overbought market, like some one pumping
|
||||||
|
# sell
|
||||||
|
(
|
||||||
|
(dataframe['cci'] > 200)
|
||||||
|
& (dataframe['rsi'] > 70)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
|
||||||
|
class StrategyHelper:
|
||||||
|
"""
|
||||||
|
simple helper class to predefine a couple of patterns for our
|
||||||
|
strategy
|
||||||
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def seven_green_candles(dataframe):
|
||||||
|
"""
|
||||||
|
evaluates if we are having 7 green candles in a row
|
||||||
|
:param self:
|
||||||
|
:param dataframe:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
(dataframe['open'] < dataframe['close']) &
|
||||||
|
(dataframe['open'].shift(1) < dataframe['close'].shift(1)) &
|
||||||
|
(dataframe['open'].shift(2) < dataframe['close'].shift(2)) &
|
||||||
|
(dataframe['open'].shift(3) < dataframe['close'].shift(3)) &
|
||||||
|
(dataframe['open'].shift(4) < dataframe['close'].shift(4)) &
|
||||||
|
(dataframe['open'].shift(5) < dataframe['close'].shift(5)) &
|
||||||
|
(dataframe['open'].shift(6) < dataframe['close'].shift(6)) &
|
||||||
|
(dataframe['open'].shift(7) < dataframe['close'].shift(7))
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def eight_green_candles(dataframe):
|
||||||
|
"""
|
||||||
|
evaluates if we are having 8 green candles in a row
|
||||||
|
:param self:
|
||||||
|
:param dataframe:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
(dataframe['open'] < dataframe['close']) &
|
||||||
|
(dataframe['open'].shift(1) < dataframe['close'].shift(1)) &
|
||||||
|
(dataframe['open'].shift(2) < dataframe['close'].shift(2)) &
|
||||||
|
(dataframe['open'].shift(3) < dataframe['close'].shift(3)) &
|
||||||
|
(dataframe['open'].shift(4) < dataframe['close'].shift(4)) &
|
||||||
|
(dataframe['open'].shift(5) < dataframe['close'].shift(5)) &
|
||||||
|
(dataframe['open'].shift(6) < dataframe['close'].shift(6)) &
|
||||||
|
(dataframe['open'].shift(7) < dataframe['close'].shift(7)) &
|
||||||
|
(dataframe['open'].shift(8) < dataframe['close'].shift(8))
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def eight_red_candles(dataframe, shift=0):
|
||||||
|
"""
|
||||||
|
evaluates if we are having 8 red candles in a row
|
||||||
|
:param self:
|
||||||
|
:param dataframe:
|
||||||
|
:param shift: shift the pattern by n
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
(dataframe['open'].shift(shift) > dataframe['close'].shift(shift)) &
|
||||||
|
(dataframe['open'].shift(1 + shift) > dataframe['close'].shift(1 + shift)) &
|
||||||
|
(dataframe['open'].shift(2 + shift) > dataframe['close'].shift(2 + shift)) &
|
||||||
|
(dataframe['open'].shift(3 + shift) > dataframe['close'].shift(3 + shift)) &
|
||||||
|
(dataframe['open'].shift(4 + shift) > dataframe['close'].shift(4 + shift)) &
|
||||||
|
(dataframe['open'].shift(5 + shift) > dataframe['close'].shift(5 + shift)) &
|
||||||
|
(dataframe['open'].shift(6 + shift) > dataframe['close'].shift(6 + shift)) &
|
||||||
|
(dataframe['open'].shift(7 + shift) > dataframe['close'].shift(7 + shift)) &
|
||||||
|
(dataframe['open'].shift(8 + shift) > dataframe['close'].shift(8 + shift))
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def four_green_one_red_candle(dataframe):
|
||||||
|
"""
|
||||||
|
evaluates if we are having a red candle and 4 previous green
|
||||||
|
:param self:
|
||||||
|
:param dataframe:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
(dataframe['open'] > dataframe['close']) &
|
||||||
|
(dataframe['open'].shift(1) < dataframe['close'].shift(1)) &
|
||||||
|
(dataframe['open'].shift(2) < dataframe['close'].shift(2)) &
|
||||||
|
(dataframe['open'].shift(3) < dataframe['close'].shift(3)) &
|
||||||
|
(dataframe['open'].shift(4) < dataframe['close'].shift(4))
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def four_red_one_green_candle(dataframe):
|
||||||
|
"""
|
||||||
|
evaluates if we are having a green candle and 4 previous red
|
||||||
|
:param self:
|
||||||
|
:param dataframe:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
(dataframe['open'] < dataframe['close']) &
|
||||||
|
(dataframe['open'].shift(1) > dataframe['close'].shift(1)) &
|
||||||
|
(dataframe['open'].shift(2) > dataframe['close'].shift(2)) &
|
||||||
|
(dataframe['open'].shift(3) > dataframe['close'].shift(3)) &
|
||||||
|
(dataframe['open'].shift(4) > dataframe['close'].shift(4))
|
||||||
|
)
|
@ -0,0 +1,101 @@
|
|||||||
|
# --- Do not remove these libs ---
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame
|
||||||
|
# --------------------------------
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from typing import Dict, List
|
||||||
|
from functools import reduce
|
||||||
|
from pandas import DataFrame, DatetimeIndex, merge
|
||||||
|
# --------------------------------
|
||||||
|
import talib.abstract as ta
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
import numpy # noqa
|
||||||
|
|
||||||
|
|
||||||
|
class SmoothScalp(IStrategy):
|
||||||
|
"""
|
||||||
|
this strategy is based around the idea of generating a lot of potentatils buys and make tiny profits on each trade
|
||||||
|
|
||||||
|
we recommend to have at least 60 parallel trades at any time to cover non avoidable losses
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy.
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.01
|
||||||
|
}
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
# This attribute will be overridden if the config file contains "stoploss"
|
||||||
|
# should not be below 3% loss
|
||||||
|
|
||||||
|
stoploss = -0.5
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
# the shorter the better
|
||||||
|
timeframe = '1m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe['ema_high'] = ta.EMA(dataframe, timeperiod=5, price='high')
|
||||||
|
dataframe['ema_close'] = ta.EMA(dataframe, timeperiod=5, price='close')
|
||||||
|
dataframe['ema_low'] = ta.EMA(dataframe, timeperiod=5, price='low')
|
||||||
|
stoch_fast = ta.STOCHF(dataframe, 5, 3, 0, 3, 0)
|
||||||
|
dataframe['fastd'] = stoch_fast['fastd']
|
||||||
|
dataframe['fastk'] = stoch_fast['fastk']
|
||||||
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe, timeperiod=20)
|
||||||
|
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
|
||||||
|
dataframe['mfi'] = ta.MFI(dataframe)
|
||||||
|
|
||||||
|
# required for graphing
|
||||||
|
bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2)
|
||||||
|
dataframe['bb_lowerband'] = bollinger['lower']
|
||||||
|
dataframe['bb_upperband'] = bollinger['upper']
|
||||||
|
dataframe['bb_middleband'] = bollinger['mid']
|
||||||
|
|
||||||
|
macd = ta.MACD(dataframe)
|
||||||
|
dataframe['macd'] = macd['macd']
|
||||||
|
dataframe['macdsignal'] = macd['macdsignal']
|
||||||
|
dataframe['macdhist'] = macd['macdhist']
|
||||||
|
dataframe['cci'] = ta.CCI(dataframe)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['open'] < dataframe['ema_low']) &
|
||||||
|
(dataframe['adx'] > 30) &
|
||||||
|
(dataframe['mfi'] < 30) &
|
||||||
|
(
|
||||||
|
(dataframe['fastk'] < 30) &
|
||||||
|
(dataframe['fastd'] < 30) &
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], dataframe['fastd']))
|
||||||
|
) &
|
||||||
|
(dataframe['cci'] < -150)
|
||||||
|
)
|
||||||
|
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['open'] >= dataframe['ema_high'])
|
||||||
|
|
||||||
|
) |
|
||||||
|
(
|
||||||
|
(qtpylib.crossed_above(dataframe['fastk'], 70)) |
|
||||||
|
(qtpylib.crossed_above(dataframe['fastd'], 70))
|
||||||
|
|
||||||
|
)
|
||||||
|
) & (dataframe['cci'] > 150)
|
||||||
|
)
|
||||||
|
,
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,151 @@
|
|||||||
|
import talib.abstract as ta
|
||||||
|
from pandas import DataFrame
|
||||||
|
import scipy.signal
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
|
||||||
|
|
||||||
|
class TDSequentialStrategy(IStrategy):
|
||||||
|
"""
|
||||||
|
Strategy based on TD Sequential indicator.
|
||||||
|
source:
|
||||||
|
https://hackernoon.com/how-to-buy-sell-cryptocurrency-with-number-indicator-td-sequential-5af46f0ebce1
|
||||||
|
|
||||||
|
Buy trigger:
|
||||||
|
When you see 9 consecutive closes "lower" than the close 4 bars prior.
|
||||||
|
An ideal buy is when the low of bars 6 and 7 in the count are exceeded by the low of bars 8 or 9.
|
||||||
|
|
||||||
|
Sell trigger:
|
||||||
|
When you see 9 consecutive closes "higher" than the close 4 candles prior.
|
||||||
|
An ideal sell is when the the high of bars 6 and 7 in the count are exceeded by the high of bars 8 or 9.
|
||||||
|
|
||||||
|
Created by @bmoulkaf
|
||||||
|
"""
|
||||||
|
INTERFACE_VERSION = 2
|
||||||
|
|
||||||
|
# Minimal ROI designed for the strategy
|
||||||
|
minimal_roi = {'0': 5}
|
||||||
|
|
||||||
|
# Optimal stoploss designed for the strategy
|
||||||
|
stoploss = -0.05
|
||||||
|
|
||||||
|
# Trailing stoploss
|
||||||
|
trailing_stop = False
|
||||||
|
# trailing_only_offset_is_reached = False
|
||||||
|
# trailing_stop_positive = 0.01
|
||||||
|
# trailing_stop_positive_offset = 0.0 # Disabled / not configured
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '1h'
|
||||||
|
|
||||||
|
# These values can be overridden in the "ask_strategy" section in the config.
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = False
|
||||||
|
ignore_roi_if_buy_signal = False
|
||||||
|
|
||||||
|
# Optional order type mapping
|
||||||
|
order_types = {
|
||||||
|
'buy': 'limit',
|
||||||
|
'sell': 'limit',
|
||||||
|
'stoploss': 'limit',
|
||||||
|
'stoploss_on_exchange': False
|
||||||
|
}
|
||||||
|
|
||||||
|
# Number of candles the strategy requires before producing valid signals
|
||||||
|
startup_candle_count: int = 30
|
||||||
|
|
||||||
|
# Optional time in force for orders
|
||||||
|
order_time_in_force = {
|
||||||
|
'buy': 'gtc',
|
||||||
|
'sell': 'gtc',
|
||||||
|
}
|
||||||
|
|
||||||
|
def informative_pairs(self):
|
||||||
|
"""
|
||||||
|
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||||
|
These pair/interval combinations are non-tradeable, unless they are part
|
||||||
|
of the whitelist as well.
|
||||||
|
For more information, please consult the documentation
|
||||||
|
:return: List of tuples in the format (pair, interval)
|
||||||
|
Sample: return [("ETH/USDT", "5m"),
|
||||||
|
("BTC/USDT", "15m"),
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Adds several different TA indicators to the given DataFrame
|
||||||
|
|
||||||
|
Performance Note: For the best performance be frugal on the number of indicators
|
||||||
|
you are using. Let uncomment only the indicator you are using in your strategies
|
||||||
|
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||||
|
:param dataframe: Raw data from the exchange and parsed by parse_ticker_dataframe()
|
||||||
|
:param metadata: Additional information, like the currently traded pair
|
||||||
|
:return: a Dataframe with all mandatory indicators for the strategies
|
||||||
|
"""
|
||||||
|
|
||||||
|
dataframe['exceed_high'] = False
|
||||||
|
dataframe['exceed_low'] = False
|
||||||
|
|
||||||
|
# count consecutive closes “lower” than the close 4 bars prior.
|
||||||
|
dataframe['seq_buy'] = dataframe['close'] < dataframe['close'].shift(4)
|
||||||
|
dataframe['seq_buy'] = dataframe['seq_buy'] * (dataframe['seq_buy'].groupby(
|
||||||
|
(dataframe['seq_buy'] != dataframe['seq_buy'].shift()).cumsum()).cumcount() + 1)
|
||||||
|
|
||||||
|
# count consecutive closes “higher” than the close 4 bars prior.
|
||||||
|
dataframe['seq_sell'] = dataframe['close'] > dataframe['close'].shift(4)
|
||||||
|
dataframe['seq_sell'] = dataframe['seq_sell'] * (dataframe['seq_sell'].groupby(
|
||||||
|
(dataframe['seq_sell'] != dataframe['seq_sell'].shift()).cumsum()).cumcount() + 1)
|
||||||
|
|
||||||
|
for index, row in dataframe.iterrows():
|
||||||
|
# check if the low of bars 6 and 7 in the count are exceeded by the low of bars 8 or 9.
|
||||||
|
seq_b = row['seq_buy']
|
||||||
|
if seq_b == 8:
|
||||||
|
dataframe.loc[index, 'exceed_low'] = (row['low'] < dataframe.loc[index - 2, 'low']) | \
|
||||||
|
(row['low'] < dataframe.loc[index - 1, 'low'])
|
||||||
|
if seq_b > 8:
|
||||||
|
dataframe.loc[index, 'exceed_low'] = (row['low'] < dataframe.loc[index - 3 - (seq_b - 9), 'low']) | \
|
||||||
|
(row['low'] < dataframe.loc[index - 2 - (seq_b - 9), 'low'])
|
||||||
|
if seq_b == 9:
|
||||||
|
dataframe.loc[index, 'exceed_low'] = row['exceed_low'] | dataframe.loc[index-1, 'exceed_low']
|
||||||
|
|
||||||
|
# check if the high of bars 6 and 7 in the count are exceeded by the high of bars 8 or 9.
|
||||||
|
seq_s = row['seq_sell']
|
||||||
|
if seq_s == 8:
|
||||||
|
dataframe.loc[index, 'exceed_high'] = (row['high'] > dataframe.loc[index - 2, 'high']) | \
|
||||||
|
(row['high'] > dataframe.loc[index - 1, 'high'])
|
||||||
|
if seq_s > 8:
|
||||||
|
dataframe.loc[index, 'exceed_high'] = (row['high'] > dataframe.loc[index - 3 - (seq_s - 9), 'high']) | \
|
||||||
|
(row['high'] > dataframe.loc[index - 2 - (seq_s - 9), 'high'])
|
||||||
|
if seq_s == 9:
|
||||||
|
dataframe.loc[index, 'exceed_high'] = row['exceed_high'] | dataframe.loc[index-1, 'exceed_high']
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the buy signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:param metadata: Additional information, like the currently traded pair
|
||||||
|
:return: DataFrame with buy column
|
||||||
|
"""
|
||||||
|
dataframe["buy"] = 0
|
||||||
|
dataframe.loc[((dataframe['exceed_low']) &
|
||||||
|
(dataframe['seq_buy'] > 8))
|
||||||
|
, 'buy'] = 1
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
"""
|
||||||
|
Based on TA indicators, populates the sell signal for the given dataframe
|
||||||
|
:param dataframe: DataFrame
|
||||||
|
:param metadata: Additional information, like the currently traded pair
|
||||||
|
:return: DataFrame with buy columnNA / NaN values
|
||||||
|
"""
|
||||||
|
dataframe["sell"] = 0
|
||||||
|
dataframe.loc[((dataframe['exceed_high']) |
|
||||||
|
(dataframe['seq_sell'] > 8))
|
||||||
|
, 'sell'] = 1
|
||||||
|
return dataframe
|
@ -0,0 +1,40 @@
|
|||||||
|
from pandas import DataFrame
|
||||||
|
from technical.indicators import cmf
|
||||||
|
|
||||||
|
from freqtrade.strategy.interface import IStrategy
|
||||||
|
|
||||||
|
|
||||||
|
class TechnicalExampleStrategy(IStrategy):
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
stoploss = -0.05
|
||||||
|
|
||||||
|
# Optimal timeframe for the strategy
|
||||||
|
timeframe = '5m'
|
||||||
|
|
||||||
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe['cmf'] = cmf(dataframe, 21)
|
||||||
|
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(dataframe['cmf'] < 0)
|
||||||
|
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'buy'] = 1
|
||||||
|
return dataframe
|
||||||
|
|
||||||
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
# different strategy used for sell points, due to be able to duplicate it to 100%
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
(dataframe['cmf'] > 0)
|
||||||
|
),
|
||||||
|
'sell'] = 1
|
||||||
|
return dataframe
|
Loading…
Reference in New Issue
Block a user