Alpaca status code
Alpaca status code: HTTP 504
What does HTTP 504 mean on the Alpaca API?
Gateway timeout, listed among the replies of GET /v2/account/portfolio/history.
Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.
Independent and unofficialdocs.alpaca.marketschecked
How do I fix HTTP 504?
Ask for a shorter period or a coarser timeframe and retry.