finlab-python / finlab_crypto Goto Github PK
View Code? Open in Web Editor NEWDocumentation
Home Page: https://finlab-python.github.io/finlab_crypto/index.html
License: GNU General Public License v3.0
Documentation
Home Page: https://finlab-python.github.io/finlab_crypto/index.html
License: GNU General Public License v3.0
class Strategy(object):
def backtest(self, ohlcv, variables=dict(),
filters=dict(), lookback=None, plot=False,
signals=False, side='long', cscv_nbins=10,
cscv_objective=lambda r: r.mean(), html=None, compounded=True, execution_price='close', **args):
There might be a potential issue if using dictionary
as the default argument for variables
and filters
, since dictionary
is mutable.
I will argue that using None
as the default argument might be a safer approach.
the colors red and green of the candlesticks render seems inverted. In uptrend are red, downtrend green I think should be the opposite.
For example like the pictures here: https://www.mt5traders.com/trend-candlesticks-metatrader-4-forex-indicator/
167 figures['entries & exits'] = pd.DataFrame(
168 {'entries':entries.squeeze(), 'exits': exits.squeeze()})
169 figures['performance'] = portfolio.cumulative_returns()
--> 171 c, info = chart.chart(ohlcv, overlaps=overlaps,
172 figures=figures, markerlines=mark_lines,
173 start_date=ohlcv.index[-min(1000, len(ohlcv))], end_date=ohlcv.index[-1], k_colors=k_colors)
174 c.load_javascript()
175 if html is not None:
...
161 # indicators
162 #################
164 def is_item(item):
TypeError: add_yaxis() got an unexpected keyword argument 'yaxis_data'
seems due to pyecharts library, you need to update your utility.py file to the new pyecharts version that receive 'y_axis' instead of 'yaxis_data'
ERROR: Cannot install finlab-crypto==0.1.0, finlab-crypto==0.1.1, finlab-crypto==0.1.10, finlab-crypto==0.1.11, finlab-crypto==0.1.12, finlab-crypto==0.1.13, finlab-crypto==0.1.14, finlab-crypto==0.1.15, finlab-crypto==0.1.16, finlab-crypto==0.1.17, finlab-crypto==0.1.18, finlab-crypto==0.1.19, finlab-crypto==0.1.2, finlab-crypto==0.1.3, finlab-crypto==0.1.4, finlab-crypto==0.1.5, finlab-crypto==0.1.6, finlab-crypto==0.1.7, finlab-crypto==0.1.8, finlab-crypto==0.1.9, finlab-crypto==0.2.0, finlab-crypto==0.2.1, finlab-crypto==0.2.10, finlab-crypto==0.2.11, finlab-crypto==0.2.12, finlab-crypto==0.2.13, finlab-crypto==0.2.14, finlab-crypto==0.2.15, finlab-crypto==0.2.16, finlab-crypto==0.2.17, finlab-crypto==0.2.18, finlab-crypto==0.2.19, finlab-crypto==0.2.2, finlab-crypto==0.2.20, finlab-crypto==0.2.21, finlab-crypto==0.2.22, finlab-crypto==0.2.23, finlab-crypto==0.2.3, finlab-crypto==0.2.4, finlab-crypto==0.2.5, finlab-crypto==0.2.6, finlab-crypto==0.2.7, finlab-crypto==0.2.8 and finlab-crypto==0.2.9 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
could you please provide an example how to use stop loss and trailing stop with backtest
Hello,
I am currently using Python 3.8.4 to run the tutorial with the finlab_crypto version 0.2.27.
I have encountered an issue where candlestick charts are not being displayed during the test.
Additionally, when running the optimization process, I encountered a TypeError: "pivot() takes 1 positional argument but 3 were given."
As a newcomer to Python, I would appreciate guidance on whether I need to install any additional dependencies or provide additional information to help identify the cause of these issues.
Thank you for your assistance.
__init__
, __call__
, set_parameters
and show_parameters
methods looks similar in Strategy
and Filter
.
My suggestion is using Inheritance
to refractor the code as following:
class BaseDec:
delattr_clsname = {'Strategy'}
def __init__(self, **default_parameters):
self.func = None
self._variables = None
self.filters = {}
self._default_parameters = default_parameters
self.set_parameters(default_parameters)
def __call__(self, func):
self.func = func
return self
def set_parameters(self, variables):
if type(self).__name__ in self.delattr_clsname:
stop_vars = ['sl_stop', 'tp_stop', 'ts_stop']
for svar in stop_vars:
if hasattr(self, svar):
delattr(self, svar)
if variables:
for key, val in variables.items():
setattr(self, key, val)
self._variables = variables
def show_parameters(self):
print(self._variables)
class Filter(BaseDec):
...
class Strategy(BaseDec):
...
I would like to suggest including a .gitignore file in the repo.
We could use the template that github provided and modify it in the future if needed.
Stumbled upon this while researching vectorbt. I have few questions. hope you can answer
can u please give some guidance for me to code alpaca brokerage for stocks
Thanks for sharing this great repo!
I can't help but notice that the version of vectorbt is a bit outdated. I think it'd be very helpful to upgrade it to the latest 0.21.0, which offers enhanced stats and pnl analysis, and many more new features. I've created a pr #16 to support this. Hopefully you also find it useful. Thanks!
in function defined in crawler.py file row 100
get_nbars_binance(symbol, interval, nbars, client):
...
client (Binance.Client) (optional): Binance Client object.
It is not optional.
I've fixed with this: get_nbars_binance(symbol, interval, nbars, client=Client()):
In DH Bailey's paper "The probability of backtest overfitting", they used sharpe ratio as their default objective function.
However, in fin_crypto
library, objective function was set up as objective=lambda r: r.mean()
.
Just want to clarify, needn't the default of objective function be set as objective=lambda r: sharpe_ratio(r)
?
Great project!. A feature suggestion/request: cctx already standardizes data from many exchanges. Would be great to be able to use that data in order to have access to instruments supported on different exchanges (ex: futures, deribit options).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.