473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Correct return in plot but not when printing values of function

Hi. My code below:


Expand|Select|Wrap|Line Numbers
  1. def simulate_stock(start,rate,vol,days):
  2.     daily_yields=np.random.normal(loc=(rate/252),scale=(vol/(252**0.5)),size=days)
  3.     cumulative_yields=np.cumsum(daily_yields)
  4.     daily_multipliers=np.exp(cumulative_yields)
  5.     simulated_prices = np.round(start * daily_multipliers, 2)
  6.     simulated_prices = np.concatenate(([start],simulated_prices))
  7.     return simulated_prices
  8.  
  9.  
  10. def find_yield(run):
  11.     sim_price_length = len(simulated_prices)
  12.     final_price = simulated_prices[sim_price_length-1]
  13.     init_price = simulated_prices[0]
  14.     annual_yield = math.log(final_price/init_price, math.e)*(252/(days))
  15.     return annual_yield
  16.  
  17. i = 0
  18. yield_list = []
  19. for i in range(25):
  20.     simulations = simulate_stock(100,0.06,0.4,200)
  21.     plt.plot(simulations)
  22.     yield_val = find_yield(simulations)
  23.     yield_list.append(yield_val)

Now when I plot different graphs as needed. When I print yield_list*I see a single array with an only value which doesn't make sense. What I am doing wrong?
Regards
Oct 11 '20 #1
0 1735

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Alec | last post by:
Hi, I am trying to print an HTML page from Internet Explorer and it always put the page title and page count at the top of the page. How can I disable printing page title and page count? Thanks.
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
1
by: adiel | last post by:
Hello everyone. The problem is when printing, the text gets cut half way and prints the other half on to the next page when printing using internet explorer and an asp.net datagrid. I am sure...
4
by: Jack Russell | last post by:
Any bright ideas on how I can calculate how wide a piece of text will be when printing. When writing text to the screen in graphics mode I put it in a invisible text box to get its height and...
8
by: CJM | last post by:
What is the best way to force a page break when printing from a browser? A page in my application generates a series of tables which are usually less than will fit on a page of A4. Ideally I want...
6
by: J Ames | last post by:
I have an ASP.NET (VB) form that has two drop downs, a horizontal rule and a button. The button invokes a stored procedure and several tables are created on the page with data populated. I want...
2
by: galexyus | last post by:
I have an Access database for which I need to write reporting software. One of the tables has datetime columns such as RingTime, HoldTime, TalkTime, which are supposed to contain the time each...
13
by: hari | last post by:
Hi all, Is it legal to return a local variable from function. Regards Hari
3
by: dylan | last post by:
How to correct the error when odbc Exception was unhandled? Private Function search(ByVal username As String) As Boolean ' Try Dim Sql As String Sql = "Select * from...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.