Package: quick-trade
quick_tradeDependencies:
 ├──ta (Bukosabino   https://github.com/bukosabino/ta (by Darío López Padial))
 ├──plotly (https://github.com/plotly/plotly.py)
 ├──pandas (https://github.com/pandas-dev/pandas)
 ├──numpy (https://github.com/numpy/numpy)
 ├──tqdm (https://github.com/tqdm/tqdm)
 ├──scikit-learn (https://github.com/scikit-learn/scikit-learn)
 └──ccxt (https://github.com/ccxt/ccxt)Documentation:🚧https://quick-trade.github.io/quick_trade/#/🚧Twitter:@quick_trade_twDiscord:quick_tradeInstallation:Quick install:$ pip3 install quick-tradeFor development:$ git clone https://github.com/quick-trade/quick_trade.git
$ pip3 install -r quick_trade/requirements.txt
$ cd quick_trade
$ python3 setup.py install
$ cd ..Customize your strategy!fromquick_trade.plotsimportTraderGraph,make_trader_figureimportccxtfromquick_tradeimportstrategy,TradingClient,Traderfromquick_trade.utilsimportTradeSideclassMyTrader(qtr.Trader):@strategydefstrategy_sell_and_hold(self):ret=[]foriinself.df['Close'].values:ret.append(TradeSide.SELL)self.returns=retself.set_credit_leverages(2)# if you want to use a leverageself.set_open_stop_and_take(stop)# or... set a stop loss with only one line of codereturnretclient=TradingClient(ccxt.binance())df=client.get_data_historical("BTC/USDT")trader=MyTrader("BTC/USDT",df=df)trader.connect_graph(TraderGraph(make_trader_figure()))trader.set_client(client)trader.strategy_sell_and_hold()trader.backtest()Find the best strategy!importquick_tradeasqtrimportccxtfromquick_trade.tunerimport*fromquick_tradeimportTradingClientclassTest(qtr.ExampleStrategies):@strategydefstrategy_supertrend1(self,plot:bool=False,*st_args,**st_kwargs):self.strategy_supertrend(plot=plot,*st_args,**st_kwargs)self.convert_signal()# only long tradesreturnself.returns@strategydefmacd(self,histogram=False,**kwargs):ifnothistogram:self.strategy_macd(**kwargs)else:self.strategy_macd_histogram_diff(**kwargs)self.convert_signal()returnself.returns@strategydefpsar(self,**kwargs):self.strategy_parabolic_SAR(plot=False,**kwargs)self.convert_signal()returnself.returnsparams={'strategy_supertrend1':[{'multiplier':Linspace(0.5,22,5)}],'macd':[{'slow':Linspace(10,100,3),'fast':Linspace(3,60,3),'histogram':Choise([False,True])}],'psar':[{'step':0.01,'max_step':0.1},{'step':0.02,'max_step':0.2}]}tuner=QuickTradeTuner(TradingClient(ccxt.binance()),['BTC/USDT','OMG/USDT','XRP/USDT'],['15m','5m'],[1000,700,800,500],params)tuner.tune(Test)print(tuner.sort_tunes())tuner.save_tunes('quick-trade-tunes.json')# save tunes as JSONYou can also set rules for arranging arguments for each strategy by using_RULES_andkwargsto access the values of the arguments:params={'strategy_3_sma':[dict(plot=False,slow=Choise([2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597]),fast=Choise([2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597]),mid=Choise([2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597]),_RULES_='kwargs["slow"] > kwargs["mid"] > kwargs["fast"]')],}User's code example (backtest)fromquick_tradeimportbrokersfromquick_tradeimporttrading_sysasqtrfromquick_trade.plotsimport*importccxtfromnumpyimportinfclient=brokers.TradingClient(ccxt.binance())df=client.get_data_historical('BTC/USDT','15m',1000)trader=qtr.ExampleStrategies('BTC/USDT',df=df,interval='15m')trader.set_client(client)trader.connect_graph(TraderGraph(make_trader_figure(height=731,width=1440,row_heights=[10,5,2])))trader.strategy_2_sma(55,21)trader.backtest(deposit=1000,commission=0.075,bet=inf)# backtest on one pairOutput plotly chart:Output printlosses: 12
trades: 20
profits: 8
mean year percentage profit: 215.1878652911773%
winrate: 40.0%
mean deviation: 2.917382949881604%
Sharpe ratio: 0.02203412259055281
Sortino ratio: 0.02774402450236864
calmar ratio: 21.321078596349782
max drawdown: 10.092728860725552%Run strategyUse the strategy on real moneys. YES, IT'S FULLY AUTOMATED!importdatetimefromquick_trade.trading_sysimportExampleStrategiesfromquick_trade.brokersimportTradingClientfromquick_trade.plotsimportTraderGraph,make_figureimportccxtticker='MATIC/USDT'start_time=datetime.datetime(2021,# year6,# month24,# day5,# hour16,# minute57)# second (Leave a few seconds to download data from the exchange)classMyTrade(ExampleStrategies):@strategydefstrategy(self):self.strategy_supertrend(multiplier=2,length=1,plot=False)self.convert_signal()self.set_credit_leverages(1)self.sl_tp_adder(10)returnself.returnskeys={'apiKey':'your api key','secret':'your secret key'}client=TradingClient(ccxt.binance(config=keys))# or any other exchangetrader=MyTrade(ticker=ticker,interval='1m',df=client.get_data_historical(ticker,limit=10))fig=make_trader_figure()graph=TraderGraph(figure=fig)trader.connect_graph(graph)trader.set_client(client)trader.realtime_trading(strategy=trader.strategy,start_time=start_time,ticker=ticker,limit=100,wait_sl_tp_checking=5)Additional ResourcesOld documentation (V3 doc):https://vladkochetov007.github.io/quick_trade.github.ioLicensequick_tradebyVladyslav Kochetovis licensed under aCreative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.Permissions beyond the scope of this license may be available atvladyslavdrrragonkoch@gmail.com.