kzhdev / alpaca_zorro_plugin

A Zorro Plugin for Alpaca Trade API.
https://zorro-project.com/
MIT License
14 stars 5 forks source link

Alpaca Adjusted Prices #11

Open Algo-Mike opened 2 months ago

Algo-Mike commented 2 months ago

Hi Kun,

Thanks for creating this very useful plugin!

Currently, the Zorro Trader Download.c script, in conjunction with your Alpaca plugin, downloads unadjusted 1 minute prices. Stock splits look like huge drops in price which create all kinds of issues with backtesting. Alpaca does offer adjusted prices, as per this Python script, run on my paper account:

def get_bars(symbol, start, end, limit=1000, timeframe='1Min', adjustment = 'raw'): base_url = f'https://data.alpaca.markets/v2/stocks/{symbol}/bars' request_headers = {'APCA-API-KEY-ID': 'Paper-account-key', 'APCA-API-SECRET-KEY' : 'Paper-account-secret'} request_params = {'start' : start, 'end' : end, 'limit' : limit, 'timeframe' : timeframe, 'adjustment' : adjustment} return requests.get(base_url, params=request_params, headers=request_headers).json()

bars = get_bars('AAPL', '2020-08-27', '2020-09-01', adjustment='raw')['bars'] print(bars) bars = get_bars('AAPL', '2020-08-27', '2020-09-01', adjustment='all')['bars'] print(bars)

The result for a stock split, on split day (AAPL): Apple UNADJUSTED: [{'c': 507, 'h': 507, 'l': 506.1, 'n': 71, 'o': 506.1, 't': '2020-08-24T08:00:00Z', 'v': 5941, 'vw': 506.505578}, ... {'c': 506.1, 'h': 506.1, 'l': 505.74, 'n': 145, 'o': 505.75, 't': '2020-08-24T23:59:00Z', 'v': 9248, 'vw': 505.959286}]

Apple ADJUSTED: [{'c': 124.01, 'h': 124.01, 'l': 123.79, 'n': 71, 'o': 123.79, 't': '2020-08-24T08:00:00Z', 'v': 23764, 'vw': 123.89}, ... {'c': 123.79, 'h': 123.79, 'l': 123.7, 'n': 145, 'o': 123.7, 't': '2020-08-24T23:59:00Z', 'v': 36992, 'vw': 123.75}]

What did the trick here is to add the adjustment parameter and set it to 'all' (adjustment for splits and dividends).

How can I do the same with your Alpaca Zorro plugin? I tried adding brokerCommand(SET_ORDERTEXT, "adjustment = 'all"); to the Download.c script, with no luck. I guess it only works with orders, not downloading data. The log message was "2024-04-28 16:58:21 | DEBUG | Unhandled command: 47 0."

Please advise.

Thank you in advance, Algo Mike

kzhdev commented 1 month ago

@Algo-Mike Sorry, I just saw this issue. I don't know why I didn't get any notification. I do have a version that downloads adjusted market data by default. I can create a new release shortly.

Algo-Mike commented 1 month ago

That would be great, thank you!

kzhdev commented 1 month ago

1.3.0 is released. By default, the adjustment is set to all. You can change the adjustment via brokerCommand as following:

  #include <AlpacaBrokerCommands.h>
  ....
  brokerCommand(SET_ADJUSTMENT, ADJUSTMENT_RAW);

  // Valid Adjustment values are
  //  ADJUSTMENT_RAW      - 0
  //  ADJUSTMENT_SPLIT    - 1
  //  ADJUSTMENT_DEVEDEND - 2
  //  ADJUSTMENT_ALL      - 3
Algo-Mike commented 1 month ago

Hi Kun, and thank you for the very fast resolution! I downloaded v1.3.0 but unfortunately it does not work for me. Here's what I am getting when running the Zorro Trader Download.c script:

Download compiling............ ok

Download... Login 0 Alpaca.. !Use Alpaca Basic Market Data.. !auth failed (402). !Websocket disconnected !Unable to open Alpaca websocket. Prices will be pulled from REST API. !Account PA3FUH6WLTO3 at UTC 05-20 00:17 !NVDA 12-31 23:01:00 to 12-31 23:59:59 failed !NVDA 12-31 23:01:00 to 12-31 23:58:59 failed Error 035: NVDA download 5 errors.

Now, please note the account that is being used: PA3FUH6WLTO3 This is NOT my paper trading account. I tried reset the API account and key 3 times, but it still does not work. It keeps using this PA3FUH6WLTO3 account no matter what I put into the Zorro Trader Login/password fields.

Please advise. Thanks!

kzhdev commented 1 month ago

PA3FUH6WLTO3 is your account number, it's not the API key. You should see the number on the Alpaca website. !Account PA3FUH6WLTO3 at UTC 05-20 00:17 means you are successfully logged in.

Although the WebSocket failed to connect, it switched to the RESI API.

Error 035: NVDA download 5 errors. The error is due to there is no bars in the time range.

Please try to delete the NVDA .t6 file in your Historical folder then try again.

Algo-Mike commented 1 month ago

You are correct about the account number, I thought it was the key. Anyway, I reset the paper account again and now, with the new Key and Secret, it seems to work. I am currently downloading some historical prices. Will circle back here if there are any more issues. Thanks!

kzhdev commented 1 month ago

Okay, the sandbox WebSocket (wss://stream.data.sandbox.alpaca.markets/{version}/{feed}) does not work. That's why the authentication failed.

I rolled back the change. Please use v1.3.1.

Algo-Mike commented 1 month ago

Excellent, thank you! BTW, I did NOT use the account number as the Key :-) It appeared in the error message, though, so I thought it may be relevant. Also, two observations. v1.2.1 was downloading unadjusted prices delayed 15-30 mins (I think) so I could get all historical data until "today" during evening hours. v1.3.0 does download adjusted prices indeed, but does not download anything past 2023. I will try v1.3.1 and my python scripts tomorrow and circle back here with the results.

Thank you very much for your help!

kzhdev commented 1 month ago

Need to set the feed to IEX specifically for the Free market data plan. Please try 1.3.2.

Algo-Mike commented 1 month ago

I tried both 1.3.1 and 1.3.2. Here's what I got:

With 1.3.1 you can only download historical data from 2016 to 2023. 2024 won't download. With 1.3.2 you can only download historical data from 2020 to yesterday, but nothing past 2020.

My python script (above) downloads everything from 2016 to yesterday. This is the behavior I would like to see. Also, I glanced over the alpaca_market_data.h source file. For downloading historical data, can you just use this url: https://data.alpaca.markets/v2/stocks/{symbol}/bars ? Please note that this does not require to specify IEX data.

Thank you!

kzhdev commented 1 month ago

Hmm, when I tried downloading 2024 data on the Free plan this morning, the feed prevented me from doing so.

2024-05-20 09:56:04 | TRACE | --> https://data.alpaca.markets/v2/stocks/NVDA/bars?start=2024-01-01T00:00:00Z&end=2024-05-20T14:56:04Z&limit=10000&timeframe=1Min&sort=desc&adjustment=all 2024-05-20 09:56:04 | TRACE | <-- {"message":"subscription does not permit querying recent SIP data"}

However, it is OK to download data from the early years without setting the feed to IEX.

I can run more tests tomorrow. It might be because the recent 15-minute data is not available on the Free plan.

kzhdev commented 1 month ago

I removed the IEX feed and adjusted the end time for the free plan.

Please try: https://github.com/kzhdev/alpaca_zorro_plugin/releases/download/v1.3.3/AlpacaZorroPlugin_v1.3.3.zip

Algo-Mike commented 1 month ago

I'm getting a "Not found" error.

kzhdev commented 1 month ago

AlpacaZorroPlugin_v1.3.3.zip

Algo-Mike commented 1 month ago

Thank you very much! Downloading historical data works fine, with websockets disabled. The data is adjusted, and I am able to download from 2016 to yesterday. Tomorrow during market hours I will play with the websocket functionality.

Much appreciated!

Algo-Mike commented 1 month ago

Hi Kun,

Unfortunately, I am having major issues with live trading in the paper account. When I hit the "Trade" button, I am getting mostly messages like these:

!Failed to subscribe SPY from Websocket. Price will be polled from REST API. Load SPY prices.. 3520 min, gap 16 min !Subscribe DIA. !Failed to subscribe DIA from Websocket. Price will be polled from REST API. !Failed to subscribe DIA from Websocket. Price will be polled from REST API. Load DIA prices.. 3140 min, gap 16 min

And after a ton of those messages, Zorro crashes:

Warning 033: no ADI data in INITRUN Error 111: Crash in run: run() at bar 129 Logout.. ok

At every run, for at least a few symbols, there is no data coming from Alpaca. I tried running the script at least 50 times, and only ONCE it worked correctly, placed a few trades, etc. So the trading script works, but it appears the websocket is unstable, or maybe Alpaca has some issues. Please advise. Thanks!

Algo-Mike commented 1 month ago

Here's another kind of error message I'm getting:

!Subscribe ANET Error 054: ANET invalid asset price

as well as:

!Subscribe ADBE Load ADBE prices.. !Failed to get bars. end should not be before start 2615 min, gap 19 min

kzhdev commented 1 month ago

Can you enable logging by adding the following in the ZorroFix.ini file and send me the Alpaca log tomorrow?

AlpacaLogLevel = 5 AlpacaLogType = 88

kzhdev commented 1 month ago

Please use the WebSocketProxy from the 1.3.3 release.

kzhdev commented 1 month ago

A correction, please use AlpacaLogType = 96.

Algo-Mike commented 1 month ago

All right, I ran this according to your instructions several times today. The result was the same every time. Here's what Zorro Trader displays:

!Subscribe ADBE. !Subscribe ADI !Subscribe ADP. !Subscribe ANET. !Subscribe ATHM. !Subscribe CALM !Subscribe COR !Subscribe CTVA. !Subscribe FNV. !Failed to subscribe FNV from Websocket. Price will be polled from REST API. Error 042: no FNV parameters !Subscribe FSLR. !Failed to subscribe FSLR from Websocket. Price will be polled from REST API. Error 042: no FSLR parameters !Subscribe MNST. !Failed to subscribe MNST from Websocket. Price will be polled from REST API... !Subscribe MRNA. !Failed to subscribe MRNA from Websocket. Price will be polled from REST API... !Subscribe MRO !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests.. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests. !Failed to get lastQuotes for A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA error: too many requests.

I am attaching the logfiles as well. Alpaca_2024-05-23_135519.log WebsocketProxy.log

kzhdev commented 1 month ago

@Algo-Mike Thanks for the logging.

2024-05-23 12:57:31 | TRACE | [{"T":"error","code":405,"msg":"symbol limit exceeded"}]

Unfortunately, the Free plan has a 30-symbol limit. That is the reason for the WebSocket subscription failure. Please refer to doc: https://alpaca.markets/deprecated/docs/api-documentation/api-v2/market-data/alpaca-data-api-v2/real-time/

Please disable the WebSocket by adding AlpacaUseWebsocket = 0 in the ZorroFix.ini file.

Another issue is that the request rate exceeded Alpaca's 200-per-second limit for the Free plan. I set the GET_MAXREQUESTS for the Free plan in the plugin to 200, but Zorro doesn't control the request rate accordingly. What is your BarPeriod? Consider lowering it or adding MaxRequests = 100; to reduce the request rate in your Zorro script.

Algo-Mike commented 1 month ago

The number of symbols in my Assets list is 29, precisely because the limit is 30. My BarPeriod = 10 min, I cannot lower it or the script won't work. Not sure why the script would send 200 requests per second, as there are only 29 symbols. Even if it queries every minute, it doesn't add up. I will try disabling the websocket and using MaxRequests =100; tomorrow, and also play with a python script that will subscribe the 29 symbols via alpaca-api. Thank you!

kzhdev commented 1 month ago

image

The subscription failed after successfully subscribing to 15 symbols. It appears that the 30-symbol limit includes both quotes and trades.

Algo-Mike commented 1 month ago

I did a little Python testing today. Here's the code:

import time from alpaca.data.live import StockDataStream

stream = StockDataStream("KEY", "SECRET")

async def handle_bars(data): print(data) print("BARS") time.sleep(1)

async def handle_quotes(data): print(data) print("QUOTES")

stream.subscribe_bars(handle_bars, "AAPL", "MSFT","NVDA","TSLA", "MSFT", "AMZN", "GOOGL", "FB", "BRK.B", "JPM", "JNJ", "V", "WMT", "PG", "UNH", "HD", "BAC", "VZ", "CVX", "KO", "DIS", "MCD", "INTC", "PEP", "ABT","ABBV","ACN","ADBE","ADI","ADP") #,"ADSK")

stream.subscribe_quotes(handle_quotes, "AAPL", "MSFT","NVDA","TSLA", "MSFT", "AMZN", "GOOGL", "FB", "BRK.B", "JPM", "JNJ", "V", "WMT", "PG", "UNH", "HD", "BAC", "VZ", "CVX", "KO", "DIS", "MCD", "INTC", "PEP", "ABT","ABBV","ACN","ADBE","ADI","ADP") #,"ADSK")

stream.run()

We are receiving both bars and quotes for 30 assets with no issues. Adding the #commented_out asset at the end triggers a limit error. This script ran for about an hour with no issues, and I stopped it to try the next one.

Algo-Mike commented 1 month ago

Python code for getting quotes and trades:

import time from alpaca.data.live import StockDataStream

stream = StockDataStream("KEY", "SECRET")

async def handle_quotes(data): print(data) print("QUOTES")

async def handle_trades(data): print(data) print("TRADES") time.sleep(1)

stream.subscribe_quotes(handle_quotes, "AAPL", "MSFT","NVDA","TSLA", "MSFT", "AMZN", "GOOGL", "FB", "BRK.B", "JPM", "JNJ", "V", "WMT", "PG", "UNH")#, "HD", "BAC", "VZ", "CVX", "KO", "DIS", "MCD", "INTC", "PEP", "ABT","ABBV","ACN","ADBE","ADI","ADP") #,"ADSK")

stream.subscribe_trades(handle_trades, "AAPL", "MSFT","NVDA","TSLA", "MSFT", "AMZN", "GOOGL", "FB", "BRK.B", "JPM", "JNJ", "V", "WMT", "PG", "UNH")#, "HD", "BAC", "VZ", "CVX", "KO", "DIS", "MCD", "INTC", "PEP", "ABT","ABBV","ACN","ADBE","ADI","ADP") #,"ADSK")

stream.run()

This does not allow 30 assets, but only 15 for quotes and 15 for trades. I think this is the effect you mentioned. But with 15 stocks, the python script ran with no issues for about one hour.

So I presume the plugin gets both quotes and trades, and that's why the limit is 15. But why do we need both? Can we just make do with the quotes? Or maybe I'm getting this completely wrong?

Algo-Mike commented 1 month ago

I tested with Zorro Trader with 14 assets in AssetFix.csv, which is less than 15 (above). Reducing the number of assets eliminates the !Subscribe issue. Setting MaxRequest = 0.1 (minimum) seems to make a difference.

However, there are still many other errors. like:

!Subscribe FNV Error 42: no FNV parameters

Lookback 400 bars, 2024-05-24..(NaD) Warning 033: no FSLR data in INITRUN Warning 033: no MRO data in INITRUN Warning 033: no NUE data in INITRUN Warning 033: no NXT data in INITRUN...... Warning 035: FSLR gap at #16 (NaD) 0->0.00000 Warning 035: FSLR gap at #16 (NaD) 0->0.00000 Warning 035: FSLR gap at #16 (NaD) 0->0.00000. Warning 035: MRO gap at #16 (NaD) 0->0.00000.........

I am attaching the log files as well. Hope this helps! Alpaca_2024-05-24_143332.log

WebsocketProxy.log

Algo-Mike commented 1 month ago

I also tried using MaxRequests = 0.1 and disabling the web socket. What I get is something like this:

Load MSFT prices... Error 035: MSFT download 5 errors 30800+490 min, gap 15 min !Subscribe NUE !Subscribe NVDA Load NVDA prices... Error 035: NVDA download 5 errors 30800+655 min, gap 16 min !Subscribe NXT !Subscribe SGML Load SGML prices... Error 035: SGML download 5 errors 30800+335 min, gap 16 min !Subscribe TSLA Copied to Clipboard! Load TSLA prices... Error 035: TSLA download 5 errors 30800+650 min, gap 16 min !Subscribe WPM Load WPM prices... Error 035: WPM download 5 errors 30800+335 min, gap 16 min

It seems to be working though. I will do some more testing on Monday. Thanks!

kzhdev commented 1 month ago

Thanks for doing the Python test. The plugin subscribes to trades in case the script sets the PRICE_TYPE to trade. I can change it to subscribe to trades after the script sets the PRICE_TYPE to trade.

The log you attached still has "too many requests" errors. I can add throttle to the request.

Algo-Mike commented 1 month ago

It would be great if we could use the 30 symbols limit, and throttle the requests. Thank you!

kzhdev commented 1 month ago

Please try this AlpacaZorroPlugin_v.zip

Algo-Mike commented 1 month ago

Unfortunately, it's not much better. Lots of invalid asset price errors:

!Subscribe NXT Error 054: NXT invalid asset price !Subscribe SGML Error 054: SGML invalid asset price

and too many requests:

Error 054: NXT invalid asset price !Failed to get lastQuotes for FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA,A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,GOOG,FIS error: too many requests. !Failed to get lastQuotes for FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA,A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,GOOG,FIS error: too many requests. Error 054: AAP invalid asset price !Failed to get lastQuotes for FNV,FSLR,MNST,MRNA,MRO,MSFT,NUE,NVDA,NXT,SGML,TSLA,WPM,SPY,DIA,A,ABBV,AAL,AAP,AAPL,ACGL,ACN,ADBE,ADI,ADP,ANET,ATHM,CALM,COR,CTVA,GOOG,FIS error: too many requests.

The too many requests issue is resolved by using MaxRequests = 0.1;

However, the rest of the errors remain. I am attaching the logs. Thanks! Alpaca_2024-05-28_135354.log WebsocketProxy.log

Algo-Mike commented 1 month ago

Also, it never gets data for the symbol FNV. I checked, Alpaca has it. The entry in the Assets.csv is also incorrect for FNV.

kzhdev commented 1 month ago

Some of your symbols are illiquid, such as FSLR, SGML, NXT, FNV, etc. NXT had only 1 quote through WebSocket, and the others didn't have any quote updates from WebSocket at all. No quote update from WebSocket caused the plugin to keep getting from the REST API, which breached the request rate limit.

We can change it to query the REST API only once and rely on WebSoket for the new quote update.

kzhdev commented 1 month ago

I believe "Error 054: NXT invalid asset price" is due to the ASK price being 0. I have asked Zorro support for this.

kzhdev commented 1 month ago

Please try this one. I added the fix to prevent the plugin from continuously fetching quotes from the REST AIP and implemented a robust global throttle.

AlpacaZorroPlugin_v.zip

kzhdev commented 1 month ago

AlpacaZorroPlugin_v.zip

According to Zorro's suggestion, the price and spread should not be set if the ASK price is 0. This should get rid of the 054 error.

Algo-Mike commented 1 month ago

Works great! 054 is gone, as are most the other errors. The only one that pops every now and the is:

!Subscribe AAP Load AAP prices.. Error 035: AAP download 5 errors 30800+890 min, gap 19 min

Other than this kind of error, nothing else to report. I will keep testing tomorrow, and circle back with the results.

Thank you very much!

kzhdev commented 1 month ago

I contacted Zorro support about the 035 error. Here is what I get from Zorro:

we believe that you are right, and error 035 should not be raised when the missing data covers only a few days. This can be the case at the very end of the download period. We will forward a notice to the developers to modify this in the next beta version.

kzhdev commented 1 month ago

AlpacaZorroPlugin_v.zip Please try this tomorrow. I adjusted the throttle limit. If everything works fine, I will make an official release.

Algo-Mike commented 1 month ago

I just tried to download some data with the Download.c script. Worked fine with the previous version. Now it does not work. I am attaching the logs.

WebsocketProxy.log Alpaca_2024-05-29_204724.log

Algo-Mike commented 1 month ago

Download compiling............ ok

Download... Login 0 Alpaca.. !Use Alpaca Basic Market Data.. !Account PA3FUH6WLTO3 at UTC 05-30 00:47.......... !Failed to get bars. Brokerprogress returned zero. Aborting... !A 05-30 00:01:00 to 05-30 00:47:36 failed. Logout.. ok Time 00:02:12

kzhdev commented 1 month ago

AlpacaZorroPlugin_v.zip Fixed the issue.

Algo-Mike commented 1 month ago

After two full days of algo trading during market hours and downloading historical data outside of market hours, it appears everything is running smoothly. I will do some more historical data downloads during the week-end and circle back here. Thank you for updating the plugin!

kzhdev commented 1 month ago

Thank you for helping to test the plugin. I added a minor fix. I will keep testing the plugin for a day or two.

Algo-Mike commented 1 month ago

I had some issues today. Here's the Zorro output:

!order not found for ZORRO_415500013 !order not found for ZORRO_415500013 !order not found for ZORRO_415500013 !order not found for ZORRO_415500004 !order not found for ZORRO_415500004 !order not found for ZORRO_415500006. !order not found for ZORRO_415500009 !order not found for ZORRO_415500013 !order not found for ZORRO_415500009 !order not found for ZORRO_415500012 !order not found for ZORRO_415500006 !order not found for ZORRO_415500013

I am attaching the Alpaca log. Can't upload the websocket log as the file is huge. Alpaca_2024-06-05_102659.zip

Algo-Mike commented 1 month ago

Also, I would like to test the version you are currently testing, but you didn't post the link. Please advise. Thank you for your effort!

Algo-Mike commented 1 month ago

I managed to get uploadable logs for the "order not found" issue:

Alpaca_2024-06-05_143133.log WebsocketProxy.log

Hope this helps. The problem keeps happening, and no orders are being placed.

Algo-Mike commented 1 month ago

Well, it seems an order got through, but still lots of errors:

!order not found for ZORRO_415500013 !order not found for ZORRO_415500009 !order not found for ZORRO_415500006

[Wed 24-06-05 20:00] 30006 +22.10 5/5 (75.98) [ADBE::L00007] Trail 1@455.66 Stop 420.18 !order not found for ZORRO_415500006 !order not found for ZORRO_415500009 !order not found for ZORRO_415500009....................................................

[Wed 24-06-05 20:10] 30006 +22.19 5/5 (75.98). [ADBE::L00007] Trail 1@455.66 Stop 424.19.

kzhdev commented 1 month ago

This error is not related to websocket at all.

Please run following in the terminal/cmd, search for "client_order_id":"ZORRO_4115000xx" in the return. Do you find those orders?

curl -X GET -H "APCA-API-KEY-ID: xxxx" -H "APCA-API-SECRET-KEY:xxxx" https://api.alpaca.markets/v2/orders?status=all

Here is the version I'm testing: AlpacaZorroPlugin_v.zip