answersLogoWhite

0


Best Answer

! Program to read tick data (dat file) of stock prices and output one second bars to the screen with an open blank line every second.

program one_second_bar

implicit none

! Declare the variables

integer, parameter :: maxSize = 30000 ! Maximum size of dat file

integer :: n, i, time_read ! n: number of elements in dat file ; i: loop index ; time_read: time of the last read element

real, dimension(maxSize) :: stock_price ! Array to store stock prices

real :: open_price, high_price, low_price, close_price ! variables to store open, high, low, close prices

! Read the data file and store data into array

open(unit=10, file='stock_price.dat')

read(10, *) n

do i = 1, n

read(10, *) stock_price(i)

end do

close(10)

! Iterate through the array and calculate open, high, low and close prices

time_read = 0

open_price = stock_price(1)

high_price = stock_price(1)

low_price = stock_price(1)

do i = 2, n

if (i > time_read + 1) then

  write(*,*) 'Open: ', open_price, ' High: ', high_price, ' Low: ', low_price, ' Close: ', close_price

  write(*,*)

  time_read = i

  open_price = stock_price(i)

  high_price = stock_price(i)

  low_price = stock_price(i)

else

  if (stock_price(i) > high_price) then

    high_price = stock_price(i)

  else if (stock_price(i) < low_price) then

    low_price = stock_price(i)

  end if

end if

end do

! Output the last bar

close_price = stock_price(n)

write(,) 'Open: ', open_price, ' High: ', high_price, ' Low: ', low_price, ' Close: ', close_price

end program one_second_bar

User Avatar

David Denton

Lvl 10
1y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Using Fortran, create a program that reads tick data (dat file) of stock prices and outputs one second bars to the screen with an open blank line every second?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which of the following comparisons best isolates the impact that changes in prices of inputs and outputs have on performance?

static planning budget and flexible budget


Was a new deal program that set prices of many products to ensure fair competition?

The National Industrial Recovery Act was a New Deal program that set the prices of many products to ensure fair competition.


What program regulated industry and raised wages and prices?

emergency banking act


When businesses combine to create a trust their goal is to?

reduce competition and regulate prices.


Is Static planning budget and flexible budget or Flexible budget and actual results comparisons that best isolates the impact that changes in prices of inputs and outputs have on performance?

flexible budget and actual results


What is the name of the TV program about the sale of repossessed self storage treasures for sometimes ridiculous prices?

The name of the television program about the sale of repossessed self storage treasures for sometimes ridiculous prices is Storage Wars. Storage Wars airs on the channel A&amp;E and is a popular American television program.


What chain auto parts store has the lowest prices?

autozone has a money back program


What was a new deal program that set prices of many products to ensure fair competition?

The National Industrial Recovery Act was a New Deal program that set the prices of many products to ensure fair competition.


How much does the leadership programs cost?

The cost of a leadership program depends on where the program is being conducted, the length of the program, and who is conducting it. Prices vary and programs should be compared before deciding on which one to attend.


If you are using cable broadband how do you connect your laptop to internet from another area in your home?

You purchase a wireless router and short ethernet cable (some routers include the cable) and connect it to the cable modem output with the short ethernet cable, then connect the ethernet cable that was connected to your modem outputs to the wireless router outputs. This will only work if your Laptop has WiFi capability The prices of wireless router vary greatly and many can be purchased less than for retail price. Review online prices before making a purchase to prevent overpaying.


Can you get Walmart coupon codes by joining their website?

Walmart does not have a coupon program rewards program. They do however always have some great prices on their products. You should just be happy with that.


Where can the computer program Super Antispyware be purchased?

The computer program, Super Antispyware, can be purchased directly from the official website. There are various versions, including licenses, at various prices.