Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help Getting History Data #51

Closed
Metaphor31 opened this issue Sep 12, 2017 · 5 comments
Closed

Help Getting History Data #51

Metaphor31 opened this issue Sep 12, 2017 · 5 comments
Labels

Comments

@Metaphor31
Copy link

Metaphor31 commented Sep 12, 2017

Versions

OS:       
Python: 3.6
krakenex: 0.1.4

What are you trying to achieve?

I want to create a function returning a dataframe with all prices history for a list of pairs,
For example all closing prices between 2015 and 2017 for BTCUSD and ETHEUR.

1st Step is to know how to download history with dates. as parameters.

# code sample
k = krakenex.API()
k.load_key('kraken.key.txt')
ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'}) #here I want to add parameters to ask for a #specific dates or period. 
ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'},req(start_date, end_date, 1) )

What do you expect to happen?

#I have found this : 
th = k.query_private('TradesHistory', req(start_date, end_date, 1))
#I would like to transpose it not with tradeshistory but just ticker and dates but doing this : 
ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'},req(start_date, end_date, 1) )
# does not work

What happens instead?

ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'},req(start_date, end_date, 1) )
error: AttributeError: 'dict' object has no attribute '_request'

# Output of the line : 
ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'})
# Am I supposed to get this : 'error': [],
# Output : 
{'error': [],
 'result': {'XXBTZUSD': {'a': ['4307.30000', '1', '1.000'],
   'b': ['4305.60000', '3', '3.000'],
   'c': ['4305.50000', '0.03977220'],
   'h': ['4399.00000', '4399.00000'],
   'l': ['4211.10000', '4180.10000'],
   'o': '4226.20000',
   'p': ['4306.30564', '4281.68920'],
   't': [8134, 13490],
   'v': ['2470.05812705', '3969.08612297']}}}
@veox
Copy link
Owner

veox commented Sep 12, 2017

Note: I've edited the report formatting somewhat.

@veox
Copy link
Owner

veox commented Sep 12, 2017

Kraken's docs for Ticker suggest that the only thing you can specify for it is pair.

For your use case, what you want is OHLC. Take a look at examples/log-ohlc.py.

Note that since might be tricky, as discussed in #44.

The example doesn't change the default interval, which is touched on in the comments. For a weekly, you'd want 10080 (60247).


Finally,

ticker_1 = k.query_public('Ticker', {'pair': 'XXBTZUSD'},req(start_date, end_date, 1) )

... doesn't work, because the third positional parameter is a krakenex.Connection - see docs.

@veox veox added the question label Sep 12, 2017
@veox
Copy link
Owner

veox commented Sep 12, 2017

Somewhat OT: Take a look at the Reddit thread that spawned the example (also linked from therein).

Depending on your final final use of the retrieved dataframe, you might be disapponted, since the data could change ever so slightly.

At the time of that Reddit discussion, the previous statement used to be true. I've decided not to implement a monitoring bot that would keep checking if the fact has changed, seeing how Kraken's API is already overloaded.

If your application does not require strict historic data consistency, and you decide to go ahead with it, be sure to save responses. krakenex does not provide such facilities.

@veox
Copy link
Owner

veox commented Sep 21, 2017

OK to close?..

@Metaphor31
Copy link
Author

Metaphor31 commented Sep 21, 2017 via email

@veox veox closed this as completed Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants