Author

Topic: I'm getting data from an exchange using a bot, need help calculating some data. (Read 468 times)

member
Activity: 80
Merit: 14
Thank you very much, those links were very informative!
legendary
Activity: 3472
Merit: 10611
that is what i figured.
as i said you are mistaking the meaning of opening price. these prices (market open and market close) are prices of the filled orders not open orders.
this is the definition of it: http://www.wikinvest.com/metric/Opening_Price which may help you better.
also i found this reply which i think can help you understand things a lot better than i can explain with my English skills (or lack thereof) Smiley
http://money.stackexchange.com/a/4526
you only have to remember than the difference between a stock market and an altcoin market is that stock market closes on a specific time and opens in the morning each day while altcoin market never closes.


Here's an example output, where you can see that the market close of 11:45:00 is not market open of 12:00:00, makes sense?
******************************
Time: 8/31/2016 11:45:00 AM
Market open : 0.01361091
Market close : 0.01384994
Market change : 1.76%

******************************
Time: 8/31/2016 12:00:00 PM
Market open : 0.01375
Market close : 0.01394847
Market change : 1.44%


let me give you some times for the above:
11:45:20 --> someone buys XMR at 0.01361091
11:45:50 --> someone buys XMR at 0.013725
11:47:35 --> someone buys XMR at 0.014500
11:50:50 --> someone buys XMR at 0.018521
11:55:20 --> someone buys XMR at 0.013927
11:58:00 --> someone buys XMR at 0.01384994
nobody buys anything until
12:01:10 --> someone buys XMR at 0.01375
....
....
12:14:20 --> someone buys XMR at 0.01394847

{the numbers of hypothetical but close to reality}
member
Activity: 80
Merit: 14
Hi Pooya, thanks for the reply.

I'm querying the chart data using this:

returnChartData

Returns candlestick chart data. Required GET parameters are "currencyPair", "period" (candlestick period in seconds; valid values are 300, 900, 1800, 7200, 14400, and 86400), "start", and "end". "Start" and "end" are given in UNIX timestamp format and used to specify the date range for the data returned. Sample output:

[{"date":1405699200,"high":0.0045388,"low":0.00403001,"open":0.00404545,"close":0.00427592,"volume":44.11655644,
"quoteVolume":10259.29079097,"weightedAverage":0.00430015}, ...]

Call: https://poloniex.com/public?command=returnChartData¤cyPair=BTC_XMR&start=1405699200&end=9999999999&period=14400


Here's an example output, where you can see that the market close of 11:45:00 is not market open of 12:00:00, makes sense?

******************************
Time: 8/31/2016 11:45:00 AM
Market open : 0.01361091
Market close : 0.01384994
Market change : 1.76%

******************************
Time: 8/31/2016 12:00:00 PM
Market open : 0.01375
Market close : 0.01394847
Market change : 1.44%
legendary
Activity: 3472
Merit: 10611
you should always include information like the numbers you are getting from your API call. i have a little bit of trouble understanding your question, but your edit helped a little.

so i think you are mistaking the meaning of open and close prices. these are prices that and order was filled at.
for example the period 1 the close is 560 it means at the last timeframe of period 1 someone bought/sold bitcoin at 560
for period 2 which is the next timeframe someone bought/sold at 565 for example so there is a difference.

there are always times in the market that orders are opened and canceled without being filled and price moves up and down because of this.
for instance in bitfinex which has a huge volume price goes from 570 to 569 so people on polo cancel their open orders at 570 and open a new one at 569 to match the other price and since there is big spread in poloniex this can happen easily without your orders being filled
https://poloniex.com/public?command=returnOrderBook¤cyPair=USDT_BTC&depth=1
right now it is at 572.16 and 573.53 = 1.37 spread (it is USDT by the way not USD)
this spread at btc-e is 0.2 right now

i hope this helps.
member
Activity: 80
Merit: 14
Hey people, hope this is relevant to this forum.

I'm writing a bot that for now is getting information from a market, in this case it's Poloniex. I pull the chart data. Polo supports every 5, 15 and 30 minutes and higher.

I'm writing a method to calculate the progression of the value for bitcoins, in dollars, over time.

What I'm doing is this:

We start with a capital of, say, $10,000 in bitcoins.

Say in a given period bitcoin went from 560 to 580. The change in this case would be 580/560 = 1.035714286, an increase of about 3.57%. After this period, we have, in dollars, 10000*1.035714286 = $10,357.14

Next period, values were 580 and 570, so the multiplier to calculate the loss is 0.982758621, giving us $10,178.57.

So far so good. I'm calculating this for a few weeks with the information I'm getting from Polo.

My problem is that if I process this with a higher frequency (5 minutes vs 15 minutes), the final value is much higher (in case of a bull market, lower if it was bearish). The lower the frequency, the lower the final value.

I'm probably having a pretty big conceptual error about markets high & lows or something I can't see.

Could you give me a hand? Why is that calculating this with a higher frequency gives me such a wildly different result?

Thank you!

EDIT:

Checked the reply from the Polo API and clearly there's something I don't understand.
The close value of period 1 (say, 08/15) is not the same as the open value of period 2 (08/16).

What am I missing here?
Jump to: