Package: algo-wars
Investment Strategies Library: algo-warsalgo-warsis Python library for Investment Strategies such as Volatility Modeling, Technical Analysis, and Portfolio Optimization. The goal of this library is to provides cues for strategies to investment or trade stock, bond, or cryptocurrency, based on the statistical machine learning and the deep reignforcement learning. Especialy, this library provides apprication of the Volatility model based on Conditional Generative Adversarial Networks(Conditional GANs) and Portfolio Selection based on Deep Q-Network.Please do note that this library is currently inBETATesting. Please use this libraryat your own risk.InstallationInstall using pip:pipinstallalgo-warsSource codeThe source code is currently hosted on GitHub.accel-brain-code/Algorithm-WarsPython package index(PyPI)Installers for the latest released version are available at the Python package index.algo-wars : Python Package IndexDependenciesnumpy: v1.13.3 or higher.pandas: v0.22.0 or higher.accel-brain-base: v1.0.0 or higher.OptionsyfinanceOnly when usingalgowars/extractablehistoricaldata/facade_yfinance.py.DescriptionThe library is designing a complex of two deep architectures:Generative Adversarial Networks(GAN) that enable the generation of pseudo-historical data.Multi-agent Deep Reinforcement Learning(Multi-agent DRL) that addresses multiple investment strategies such as volatility minimization and Sharpe ratio maximization.For convenience, we named this complex systemAdversarial Generative Deep Reinforcement Learning.Multi-agent DRL can acquire high generalization performance and domain adaptability by learning both the historical data generated by GAN and the true historical data. Multi-agent DRL develops a solution under two problem settings: volatility minimization and Sharpe ratio maximization. Multiple agents are assigned to each problem setting. Finally, the portfolio of agents with the highest cost performance is output as the winning portfolio.This library uses Retrospective encoders from Zhang, K., et al. (2018) as generative models in designing GANs for modeling volatility. This model is also mentioned inAutomatic Summarization Library: pysummarization. The loss/error function and network structure are designed according to Akcay, S., et al. (2018). As used inGenerative Adversarial Networks Library: pygan, This model facilitates manifold learning by adding a re-encoder to the encoder-decoder network structure.The Multi-agent DRL is designed as a Deep Q-network derived from the decentralized partially observable Markov decision process(Dec-POMDP) proposed by Egorov, M. (2016). This model is also mentioned inReinforcement Learning Library: pyqlearning.Setup master data of ticker symbols.Before starting learning, it is necessary to prepare the master data of securities. Demo data is located inmasterdata/ticker_master_demo.csv. This master data is referred to during data preparation and learning.The column definition is as follows.ticker: Ticker Symbol.asset: Asset type.area: If the asset has regionality, write a symbol such as the category.If it's a US stock, for instance, writeUS.detail: It's just a space for notes. The system does not refer to this value.asset_allocation: Weight per asset. This value is referenced when calculating the portfolio percentage.If you want to judge purely by the algorithm, write a constant here.area_allocation: Weight per area. This value is referenced when calculating the portfolio percentage.If you want to judge purely by the algorithm, write a constant here.expense_ratio: ETF expense ratio. Write0.0for individual stocks and crypto assets.yield: Past annual yield.commission: Trading fees.tax: Tax rate on capital gains.Data PreparationHistorical data must be placed in thelogs / historical /directory as a CSV file consisting of the following formats:timestamp:YYYY-MM-DDopen: open.high: high.low: low.close: close.adjusted_close: adjusted close.volume: volume.It is necessary to prepare one CSV file for each Ticker symbols. Also, the file name must be associated with the value in thetickercolumn in the security master data.Historical data can be obtained from various REST (ful) APIs. This library already has a batch program for retrieving data from several APIs. For instance,pythonalgowars/extractablehistoricaldata/facade_yfinance.py\-vTrue\-tmp./masterdata/ticker_master_demo.csvLearning and inference can be performed from the following batch programs.pythonalgowars/portfolio_dqn_controller.py\-vTrue\-sd2013-06-24-ed2020-06-23\-gsd2021-01-01-ged2021-04-27\-df30\-an3\-ep300\-nan3\-lrdqn1e-04-lr1e-10\-in500\-bs20\-sl10\-rpm1.0\-rps0.1\-gppparams/recursive_seq_2_seq_model_re_encoder_model.params\-rppparams/recursive_seq_2_seq_model_model.params\-dppparams/discriminative_model_model.params\-dqnppparams/dqn_model.params\-tmpmasterdata/ticker_master_demo.csv\-scall\-mm120000\-mfm\-ltsl90You can check the interface specifications of the batch program with the following command.pythonalgowars/portfolio_dqn_controller.py-hA demonstration of visualizing the results of pseudo-historical data generation and portfolio optimization is demonstrated in the following notebook.demo-portfolio-optimization.ipynbReferencesAkcay, S., Atapour-Abarghouei, A., & Breckon, T. P. (2018, December). Ganomaly: Semi-supervised anomaly detection via adversarial training. In Asian Conference on Computer Vision (pp. 622-637). Springer, Cham.Donahue, J., Krähenbühl, P., & Darrell, T. (2016). Adversarial feature learning. arXiv preprint arXiv:1605.09782.Makhzani, A., Shlens, J., Jaitly, N., Goodfellow, I., & Frey, B. (2015). Adversarial autoencoders. arXiv preprint arXiv:1511.05644.Salimans, T., Goodfellow, I., Zaremba, W., Cheung, V., Radford, A., & Chen, X. (2016). Improved techniques for training gans. In Advances in neural information processing systems (pp. 2234-2242).Schlegl, T., Seeböck, P., Waldstein, S. M., Schmidt-Erfurth, U., & Langs, G. (2017, June). Unsupervised anomaly detection with generative adversarial networks to guide marker discovery. In International conference on information processing in medical imaging (pp. 146-157). Springer, Cham.Yeh, R., Chen, C., Lim, T. Y., Hasegawa-Johnson, M., & Do, M. N. (2016). Semantic image inpainting with perceptual and contextual losses. arXiv preprint arXiv:1607.07539, 2(3).Zenati, H., Foo, C. S., Lecouat, B., Manek, G., & Chandrasekhar, V. R. (2018). Efficient gan-based anomaly detection. arXiv preprint arXiv:1802.06222.Zhang, K., Grauman, K., & Sha, F. (2018). Retrospective Encoders for Video Summarization. In Proceedings of the European Conference on Computer Vision (ECCV) (pp. 383-399).Authoraccel-brainAuthor URIhttps://accel-brain.co.jp/https://accel-brain.com/LicenseGNU General Public License v2.0