Closed Yemeen closed 3 years ago
@Yemeen I am completely lost/new to working with APIs - can pull data using the read me example; however, I am at a loss how to even get my balance? ie, in your above example, where do you put your Private Key in? do you also have to put the Public key in?
running your code as is throws:
FileNotFoundError: [Errno 2] No such file or directory: 'kraken.key'
that said, I get the same error when I use my public or private api key for krakenkey in line 4
You need to place your key in kraken.key. Look in the examples folder!
thanks are you talking about the python3-krakenex examples folder? I don't see any examples folder in this repository
I was actually able to establish a connection by using code found in the krakenex issues page, ie:
import krakenex
from krakenex import API
from pykrakenapi import KrakenAPI
api = krakenex.API()
API_KEY = 'xxxx'
SECRET_KEY = 'yyyy'
api = API(API_KEY, SECRET_KEY)
k = KrakenAPI(api)
balance = k.get_account_balance()
print(balance)
k.get_trades_history()
is this similar to your approach?
also, when I attempt to put a limit buy in:
k.add_standard_order(
pair='XXBTZUSD',
type='buy',
ordertype='limit',
price=10000,
volume=0.001
)
it returns:
Out[73]: {'descr': {'order': 'buy 0.00100000 XBTUSD @ limit 10000.0'}}
but the order does not look like its actually being sent to the exchange, ie is not appearing in my account and:
k.get_open_orders( )
returns an empty dataframe
This is expected. Kraken API requires to read Every parameters to avoid problems.
Le 17 février 2021 22:22:52 Tucker Sferro notifications@github.com a écrit :
also, when I attempt to put a limit buy in: k.add_standard_order( pair='XXBTZUSD', type='buy', ordertype='limit', price=10000, volume=0.001 )
it returns: Out[73]: {'descr': {'order': 'buy 0.00100000 XBTUSD @ limit 10000.0'}} but the order does not look like its actually being sent to the exchange, ie is not appearing in my account and: k.get_open_orders( ) returns an empty dataframe — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
thanks @mans17 ; however as far as I can tell I've passed all the non-optional arguments: (https://www.kraken.com/features/api#add-standard-order)
validate=false should help. True IS default.
Le 17 février 2021 22:29:40 Tucker Sferro notifications@github.com a écrit :
thanks @mans17 ; however as far as I can tell I've passed all the non-optional arguments: (https://www.kraken.com/features/api#add-standard-order) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
@mans17 that did it, thanks!
I was able to send/open a small ETHUSD position, but k.get_open_positions()
returns an empty dictionary...any ideas?
Is position already closed ? (Visible as opened on kraken ?)
Le 17 février 2021 23:06:58 Tucker Sferro notifications@github.com a écrit :
@mans17 that did it, thanks! I was able to send/open a small ETHUSD position, but k.get_open_positions() returns an empty dictionary...any ideas? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
actually I looked more closely and the order was for some reason closed which is strange because the market traded through it:
buy/limit | ETH/USD | $1,854.00 | 0.01000000 | $18.54 | Closed | 02-17-21 22:01:59 +0000
-- | -- | -- | -- | -- | -- | --
I tried another order of size 0.03 ETHUSD and that was also "CLOSED" when the market traded through the price, I have no idea why that would happen:
[buy/limit | ETH/USD | $1,854.00 | 0.01000000 | $18.54 | Closed | 02-17-21 22:01:59 +0000 |
---|
](url)
Since 1854 > 1844 (current level), seems pretty legit to me that you could buy immediatly.
Le 17 février 2021 23:11:06 Tucker Sferro notifications@github.com a écrit :
actually I looked more closely and the order was for some reason closed which is strange because the market traded through it:
buy/limit ETH/USD $1,854.00 0.01000000 $18.54 Closed 02-17-21 22:01:59 +0000 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
yes and I saw both orders in the market depth AND the offer price went below my bid/bid disappeared ?!?!?!?
...looking closer, the trades did execute, ie they are showing up in get_account_balance() and get_trades_history(); however, when I call get_open_positions(), I get an empty dictionary
plus - the trades are not showing up on kraken.com "Open Positions by Order" BUT they ARE showing in my kraken.com Balances page ?!?
just FYI for anyone reading this thread, I heard back from kraken in regards to this issue and:
_"...open positions are only relevant to margin orders.
Thus, a traditional order, such as a limit or market, will not show up in the open positions tab.
However, you will be able to see this information via the OpenOrders or QueryOrders API Endpoint."_
and:
_BalanceEx Endpoint
The REST API BalanceEx endpoint will provide the information that you are looking for, namely the amount of each account balance currency that is withheld (due to existing open orders, for example).
(Note: this Is a newer endpoint and undocumented)_
The issue seems to be resolved, please reopen if I'm mistaken.
I'm trying to get account balance like so:
and get the following:
but when I use Kraken's api I can get a balance although with an error:
balance = api.query_private('Balance')
gives the following{'error': [], 'result': {'ZUSD': 'My very large balance bc I am not poor', 'XXBT': 'touche'}}
I thought it might be my kraken.key but I put the key and secret on their own lines??
Thanks for all your hard work!