Package: hiquant
Hiquant阅读此文档的中文版本Hiquant is a quatitative trading framework and out-of-box toolset for assisting stock/fund investment.FeaturesData acquisition: fetch data from financial websites, including indices, stocks, funds, financial reports, history data, realtime data, etc.Valuation analysis: extract key abstract info from financial reports like ROE, calculate PE/PB percentiles, find “cheap valuation” stocks, export to stock poolPlot stock with indicators: plot k-line diagram of stocks with indicators, comparing earning curve of multiple indices or even multiple stocksStrategy framework: implemented a strategy framework for backtesting, with sample code for demo purposes, and provides a command to create a new strategy from the template, which is convenient for users to write their own strategiesSimulated backtesting: Use historical market data, to simulate backtesting of one or more portfolio strategies, output data analysis of investment returns, and draw yield curves for comparisonSimulated realtime trading: Synchronize real-time market data, calculate trading decisions based on strategies, and send email notifications to remind users to tradeMulti markets: currently supports China, Hong Kong and United States market, will add support for markets in other countries if requested and data availableTODO: Automated trading: call the quantitative trading interface to realize automated trading (not yet implemented, planned)Other features:Evaluate funds: search and filter funds, calculate sharpe ratio and max drawdown, evaluate funds, comparing earning curve of multiple funds, comparing investment performance of fund managersInstallationPlease make sure your Python is v3.7 or above, as it's required by Matplotlib 3.4 for plottting.python3--version
python3-mpipinstallhiquantOr, clone from GitHub:gitclonehttps://github.com/floatinghotpot/hiquant.gitcdhiquant
python3-mpipinstall-e.ExamplesDraw stock indicators and yield curvehiquantstockAAPL-ma-macdDraw trade signal of mixed indicators, holding time, and yield curvehiquantstockAAPL-ma-macd-mixCompare ROI of multiple stockshiquantstockplotAAPLGOOGAMZN-years=5"-base=^IXIC,^GSPC"Backtrade with one portoflioBacktrade with multiple portofliosCommand quick starthiquantcreatemyProjcdmyProj

hiquantindexlistus
hiquantstocklistus

hiquantstockplotAAPL-ma-macd-kdj
hiquantstockplotAAPL-all
hiquantstockplotAAPL-wr-bias-mix

hiquantstockpoolAAPLGOOGAMZNTSLAMSFT-out=stockpool/mystocks.csv

hiquantstrategycreatestrategy/mystrategy.py
hiquantbackteststrategy/mystrategy.py

hiquanttradecreateetc/myfund.conf
hiquantbacktradeetc/myfund.conf
hiquantrunetc/myfund.confCode quick startimportpandasaspdimporthiquantashqclassMyStrategy(hq.BasicStrategy):def__init__(self,fund):super().__init__(fund,__file__)self.max_stocks=10self.max_weight=1.2self.stop_loss=1+(-0.10)self.stop_earn=1+(+0.20)defselect_targets(self):return['AAPL','MSFT','AMZN','TSLA','0700.HK']defgen_trade_signal(self,symbol,init_data=False):market=self.fund.marketifinit_data:df=market.get_daily(symbol)else:df=market.get_daily(symbol,end=market.current_date,count=26+9)dif,dea,macd_hist=hq.MACD(df.close,fast=12,slow=26,signal=9)returnpd.Series(hq.CROSS(dif,dea),index=df.index)defget_signal_comment(self,symbol,signal):return'MACD golden cross'if(signal>0)else'MACD dead cross'definit(fund):strategy=MyStrategy(fund)if__name__=='__main__':backtest_args=dict(#start_cash= 1000000.00,#date_start= hq.date_from_str('3 years ago'),#date_end= hq.date_from_str('yesterday'),#out_file= 'output/demo.png',#parallel= True,compare_index='^GSPC',)hq.backtest_strategy(MyStrategy,**backtest_args)UsageRead following docs for more details:How to use hiquant toolDevelop with HiquantRead this document on how to develop with Hiquant:How to develop with HiquantCreditsGreat appreciate developers of following projects. This project is based on their great works: Pandas, Matplotlib, Mplfinance, Akshare, etc.Thanks folloowing websites for providing data service: Sina, Legu, Yahoo, Nasdaq, etc.Thanks the warm-hearted knowledge sharing on Zhihu and Baidu websites.DisclaimerThis software and related codes are for research purposes only and do not constitute any investment advice.If anyone invests money in actual investment based on this, please bear all risks by yourself.This software is developed on Mac, and the examples in this document are written with Mac environment. They are similiar for Linux, but might be a little difference on Windows.