Completed

Stored procedure PostgreSQL (pgSQL)

This project was successfully completed by krokysl for $230 AUD in 6 days.

Get free quotes for a project like this
Employer working
Project Budget
$30 - $250 AUD
Completed In
6 days
Total Bids
10
Project Description

What I have; a system that get forex quotes from a server, and stores the

values in a sql database. Example of table in the database:

table AUDUSD

id, volume, bid, ask, date

1, 10, [url removed, login to view], [url removed, login to view], 2014-02-28 10:18:00

2, 20, [url removed, login to view], [url removed, login to view], 2014-02-28 10:18:30

3, 30, [url removed, login to view], [url removed, login to view], 2014-02-28 10:19:00

4, 40, [url removed, login to view], [url removed, login to view], 2014-02-28 10:19:30

5, 50, [url removed, login to view], [url removed, login to view], 2014-02-28 10:20:00

6, 60, [url removed, login to view], [url removed, login to view], 2014-02-28 10:20:30

7, 70, [url removed, login to view], [url removed, login to view], 2014-02-28 10:21:00

8, 80, [url removed, login to view], [url removed, login to view], 2014-02-28 10:21:30

9, 90, [url removed, login to view], [url removed, login to view], 2014-02-28 10:22:00

10, 80, [url removed, login to view], [url removed, login to view], 2014-02-28 10:22:30

11, 70, [url removed, login to view], [url removed, login to view], 2014-02-28 10:23:00

12, 60, [url removed, login to view], [url removed, login to view], 2014-02-28 10:23:30

13, 50, [url removed, login to view], [url removed, login to view], 2014-02-28 10:24:00

What I need:

i) Request the last value of a period X, where X could be a 30 seconds, 1 minute, 3 Minutes, 1 hour and 4 hours.

ii) Request group of values sorted by oldest value to newer value, of certain period X, where X could be a

30 seconds, 1minute, 3 Minutes, 1 hour and 4 hours.

* The answer should include the Open, High, Low and Close of each period. This is calculate using a temp

field "last", who is the average of the bid and ask fields.

See example to see how the values have to be calculated

Example:

- Select lastValue table AUDUSD in with Period 1M (1 minute)

The result has to be:

Open, High, Low, Close, volume, bid, ask, date

[url removed, login to view], [url removed, login to view], [url removed, login to view], [url removed, login to view], 130 [url removed, login to view], [url removed, login to view], 2014-02-28 10:23:00

How the values were calculated:

a) We have to check when the last minute was completed. In this case, the minute that was completed

was the one that finished before the last value displayed. So, the values to be used are the ones

with the id 11 and 12

10, [url removed, login to view], 80, [url removed, login to view], [url removed, login to view], 2014-02-28 10:22:30

11, [url removed, login to view], 70, [url removed, login to view], [url removed, login to view], 2014-02-28 10:23:00

12, [url removed, login to view], 60, [url removed, login to view], [url removed, login to view], 2014-02-28 10:23:30

13, [url removed, login to view], 50, [url removed, login to view], [url removed, login to view], 2014-02-28 10:24:00

b) So,

temp_lastValue = (bid+ask)/2

Open: First value of temp_lastValue

Hight: Highest value of temp_lastValue of group

Low: Lowest value of temp_lastValue of group

Close: Last value of temp_lastValue

Volume: Sum of the values in the group

bid: Average of the bid values of the group

ask: Average of the ask values of the group

date: First date of the group

I can write the logic in C++, if it needed

Completed by:
Skills Required

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online