Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python Financial Computing Framework Prophet

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report