Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Python Financial Computing Framework Prophet

Shulou Source: shulou.com Published: 2022-06-03 00:19:10 10月02日 Update

Python financial computing framework Prophet how to use, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Preface

Prophet is a Python micro-framework for financial markets. Prophet allows developers to focus on financial strategy models, portfolio management, and analysis.

Sample code:

From datetime import datetimefrom prophet import Prophetfrom prophet.data import YahooCloseDatafrom prophet.analyze import default_analyzersfrom prophet.orders import Ordersclass OrderGenerator (object): def _ init__ (self): super (OrderGenerator, self). _ _ init__ () self._data = dict () def run (self, prices, timestamp, cash, * * kwargs): symbol = "AAPL" orders = Orders () if (prices.loc [timestamp Symbol] * 100) < cash: orders.add_order (symbol, 100) return ordersprophet = Prophet () prophet.set_universe (['AAPL',' XOM']) prophet.register_data_generators (YahooCloseData ()) prophet.set_order_generator (OrderGenerator ()) backtest = prophet.run_backtest (start=datetime (1,1) 1) prophet.register_portfolio_analyzers (default_analyzers) analysis = prophet.analyze_backtest (backtest) print (analysis) # +-+ # | sharpe | 1.09754359611 | # | average_return | 0.00105478425027 | # | cumulative_return | 2.168833 | # | volatility | 0.01525608189 | # +-+ # Generate orders for you to execute today# Using Nov 10 2014 as the date because there might be no data for today's# date (Market might not be open) and we don't want examples to fail.today = datetime (2014, 11, 10) print (prophet.generate_orders (today)) # Orders [Order (symbol='AAPL', shares=100)] is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Finance framework help clarity people code content preface to this market article novice more model knowledge example strategy energy industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MySQL Microsoft Shulou Information Shulou Tech Info