Having issues when paper accounts are made after 9 30 am

this is what im getting back for a account response

i expect something like

but i get



weird api responses

Update: it might be an error on my system if the api keys didn’t reset after the account was changed to new defaluts on alpaca, e.x. if it was using old api keys

new update: i tried my system on another account and it works fine so im not sure whos side this is on

upon further inspection the account traded although it shouldn’t have, since there was only. one way commutation going to alpaca so the server couldn’t react to the trades correctly since there was no data sent back to my end

just wanted to tag you guys in on this since it looks like a bug

@kris The error “forbidden” when calling the account endpoint can only be one (or more) of four things

  1. incorrect API key
  2. incorrect API Secret Key
  3. incorrect base url (ie one must use https://paper-api.alpaca.markets when accessing a paper account and https://api.alpaca.markets for a live account)
  4. trying to access an old paper account which has been reset (using the old paper account keys).

Often, if storing keys in a OS system variable or file, these values may not be updated properly especially if one resets the paper account and simply edits the keys. One may need to restart the system to bring in the updated variables. For debugging and see if this is the issue, put a log or print statement immediately before the line of code where the trading client is instantiated to verify the keys which are being used. For example

trading_client = TradingClient(API_KEY, SECRET_KEY)

I would suggest verifying the API key and Secret key are correct and associated with the account you are expecting to work with.

thank you ill put keys in the log for if it happens again, it was the first time i reset a account around 9 33 am and seen that out come, im thinking it might just have been that the api keys never updated on my end

im not sure though how since the system would need the new api keys to send the order flow but on the off chance that im wrong, i think it was a key mix up but on the api side that makes the keys since the server did send trades and the account reflects that.

if i was to say from my input it kind of looks like its on your end

also api keys are stored in a file a like thus
with php

 		$ACC_SETING = "$WEB_DIR/API/ALPACA_TYPE.DATA"; // I was running the code on localhost, and hence the path!
	$api_acc_type = file_get_contents($ACC_SETING);

		$key_file = "$WEB_DIR/API/alpaca.KEY"; // I was running the code on localhost, and hence the path!
		$key_secret = "$WEB_DIR/API/alpaca.SECRET"; // I was running the code on localhost, and hence the path!
	$api_key = file_get_contents($key_file);
	$api_secret = file_get_contents($key_secret);

$mode = $_GET['save'];
if ($mode == "do"){
		$secret = $_POST['secret'];
		$SET_ACC_type = $_POST['type'];
		file_put_contents($ACC_SETING, $SET_ACC_type);
	file_put_contents($key_secret, $secret);
	$current = $_POST['key'];
	file_put_contents($key_file, $current);
	$api_key = file_get_contents($key_file);
	$api_secret = file_get_contents($key_secret);
	$api_acc_type = file_get_contents($ACC_SETING);

if the key was incorrect there would be no trades right??

also note there is no JNLC

@kris I’ll be the first person to say “anything can happen”, however the fetching accounts and submitting orders APIs are very solid. There are literally millions of accounts using those APIs every day without an issue. If you can recreate a specific issue it may be easier to debug.

ill give it a try tomorrow

ill re set this account


same time tomorrow and ill post the result.

1 Like

@kris One thing which you are probably aware but I do want to reiterate. Resetting an account creates a completely new account (which is why new API keys are required).

Additionally, when resetting an account, to the system it looks like the account was just opened (exactly as in live trading). The first day an account is opened it will not have any day trading buying power. This is because day trade buying power is calculated from the previous end of day equity. Since the previous end of day equity was $0 the day trade buying power will be $0.

status update: untested ill keep you posted

ill be running the test today, ill keep you posted est 9 33 - 9 34

update: unrelated to alpaca

@kris Glad you seemed to have gotten it resolved!

Update the same account reset at 9 30 am was re set last night at 11:30 pm and today at 7AM account balance information looks to be incorrect at the moment


it was reset just last night

@kris The first issue to get straightened out is the screenshot is for account PA3W92QHU6G5 however the account data is for account PA3E2SDQZ79Y. Could that be the discrepancy you are seeing?

no its 2 issues
1 the api key seems to change twice after it is reset but access to the old one still gives wright access to send orders but wont send account info in the api i get null for bp and null for e this only happens some times as the api keys are set up on the server after the balance has been reset not sure why

2 when the buying power is set the account resets itsleff to $0.00 again not sure why

@kris You stated “the api key seems to change twice after it is reset”. What are you observing which makes you feel that is the case. Immediately when a paper account is reset, the new account api keys are null. They only get set if and when the user regenerates them from the dashboard.

Not sure what you mean by “when the buying power is set”. Do you mean when resetting an account to a specific initial equity? If that’s the case, then after resetting an account, as mentioned above, the first day an account is opened it will not have any day trading buying power. This is because day trade buying power is calculated from the previous end of day equity. Since the previous end of day equity was $0 the day trade buying power will be $0. Is that the question?

oh my god yes I’ve been trying to finger this out

now the thing is i reset the equity to i think to 2500 but it reset it self again after this morning back to $0 om not sure why

i had to reset it after to get it working

this might have to do with when the previous end of day equity is calculated and when the account is reset
some times im doing this at 1 am (resetting the account)

@kris If you see equity in a paper account drop to $0 it is most likely that you are looking at an ‘old’ account. When resetting an account, the original “old” account may still exist for awhile though ultimately one will get a “forbidden” error as old accounts are deleted. Ensure you are using the most up to date keys for the most recent reset of the account.

@Dan_Whitnable_Alpaca look at the image, i would think that the keys dont change after i reset then click the generate keys button, therefore it cant be related to me.

also on keys that get a response from alpaca of forbidden some how alpaca is taking (buy / sell) orders with the keys if you look above

trust me id rather the bug be on my end so i can fix it…

no i test on more then one account at the moment i was testing on 2 different ones

i try to ignore back handed comments like this, but think about it for a moment, im only asking for help.