AlpacaZorroPlugin v1.0.6 Released

Posted By: kzhao

AlpacaZorroPlugin v1.0.6 Released - 08/30/21 13:19

https://github.com/kzhdev/alpaca_zorro_plugin/releases/tag/v1.0.6
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 08/30/21 15:32

Thanks kzhao!

Did you see the notice a few days ago about an upcoming "API Breaking Change..."?
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 08/30/21 19:18

Yes, I saw the notice. I will make corresponding changes. Thanks for bring this up.
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/16/21 17:46

Hi @kzhao,

I've been trying to follow this part of your docs:

Code
Generate AssetList file through custom borkerCommand

brokerCommand(2001, char *symbols);

symbols - One or more symbols separated by comma. If symbols = 0, all symbols will be included. An AssetAlpaca.csv file will be generated in the Log diredtory.

Exemple:
// GenerateAlpacaAssetList.c
function main() {
  brokerCommand(2001, "SPY,AAPL,MSFT,TSLA");  // Generate AssetsAlpaca.csv contains SPY, AAPL, MSFT, TSLA symbols
}


The example works, but only when using Websocket. It doesn't work over REST - is it supposed to work over REST too?

Also, I can't get "symbols = 0" to return anything. "brokerCommand(2001, 0);" just returns the header.

And, what exactly will "all symbols" be? What's in AssetsFix.csv? Everything known to Alpaca?! laugh

Thanks!
Posted By: Lapsa

Re: AlpacaZorroPlugin v1.0.6 Released - 09/16/21 18:56

I can't read that README.md. Triggering typos.

gj anyhow

Code
LOG_DEBUG("BorkerHisotry


Not to make fun in case you dyslexic.

I just find it extremely distracting.
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/16/21 21:35

Hi @kzhao,

In addition to the above, I am not able to download prices via the Download script. Using REST, I get a "forbidden" error. Using Websockets, I get "NoData!"...
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 02:01

@DdiV

I verified that the generate asset list brokerCommand works over both REST and WebSocket. The command is not using WebSocket. Do you see Zorro prints the Asset in the log window like the following?

Code
GenAssetList compiling..........
Login 0 Alpaca..
!Use Alpaca market data
!Account ********** at UTC 09-17 01:45 ok

!Generating Asset List...
!Asset PH.
!Asset SO
!Asset SUI
!Asset WEC
Logout.. ok


If you add
Quote
AlpacaLogLevel = 5
in Zorro.ini then run the script, do you see any error in the Alpaca log file?

To get all symbols, use
Code
brokerCommand(2001, 0);

All symbols mean all tradeable symbols returned from https://api.alpaca.markets/v2/asssets endpoint.
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 02:25

Thanks @kzhao.

No. Zorro only prints the first 4 lines and the last Logout. It does not print the Generating nor Asset lines.

LogLevel=5 shows error "Failed to open ./Log/AssetsAlpaca file". Which is interesting because AssetsAlpaca.csv is there, but empty.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 03:03

@DdlV

The plugin is unable to open the AssetsAlpaca.csv file. Is the file opened by another application? Please close Zorro, make sure there are no other Zorro instances running in the Task Window, and make sure the file is not opened by another application. Or you can delete the AssetsAlpaca.csv file. Then give it another try.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 03:13

@DdlV

For the "API Breaking Change...", I don't know what is the null return looks like exactly. I asked in Alpaca's Slack channel but never get a reply. It seems it is a rare situation. I will keep an eye on it and will address it properly when it happens.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 03:16

@Lapsa Sorry, for my poor English. I will go over the README and fix typos. Feel free to create a pull request or an issue in Github. Thanks
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 03:31

Thanks @kzhao.

OK, after (lots) more testing:

- The plugin seems to always fail login on the 1st try with "access key not found"
- Rerunning the script without changing anything login succeeds.
- But the generate fails and a Zorro Alert pops up that says "BrokerCommand 2001 61868921 at <time>". After this the file remains locked by Zorro/plugin (Notepad won't open it) even though the script is no longer running.
- A 3rd run gives the "Failed to open" message as above.
- If I delete the file and run the script again (4th try), it starts to finally work (yay!)
- I used your assets above, and PH works, but the other 3 all report "!forbidden." and do not appear in the file
- (Minor bug) As in your example above, PH is followed by a period (.), whereas none of the other assets is

Next step?

Thanks!
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 03:45

@DdlV

For the Download script, change LogLevel=6 do you see any errors? What is the response from Alpaca?
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 03:48

@DdlV Which version of Zorro do you use? It seems an exception occurred and the file is not closed.
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 03:59

@kzhao:

With LogLevel=6, tried Download SPY and got many lines like

Code
2021-09-17 03:51:55 | DEBUG | BorkerHisotry SPY start: 1609459200 end: 1631850714 nTickMinutes: 1 nTicks: 300
2021-09-17 03:51:55 | INFO | Alpaca Basic Plan. Adjust end to 1631849815
2021-09-17 03:51:55 | DEBUG | BorkerHisotry SPY start: 2021-01-01T00:00:00Z(1609459200) end: 2021-09-17T03:36:55Z(1631849815) nTickMinutes: 1 nTicks: 300


After a while the INFO lines stop and only the DEBUG lines show. No SPY file created.

Zorro version is 1.96.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 13:36

@ DdlV

1.96 might be too old. Could you try Zorro 2.35 and above?

For those symbols which returned "!forbidden", could you try

Code
curl -X GET \
    -H "APCA-API-KEY-ID: <YOUR_ALPACA_KEY>" \
    -H "APCA-API-SECRET-KEY:<YOUR_ALPACA_SECRETE>"\
    https://data.alpaca.markets/v2/stocks/SO/snapshot


SO is one of them, replace it with other symbols if you want to. What is the response from Alpaca?

BTW, the "." after the PH is not a bug. It was added by Zorro for indicating the progress of the operation.
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 14:25

Thanks @kzhao.

I don't have curl installed, but using wget the test works - a snapshot file containing data is created

Since the first asset (PH) did not return an error, I tried putting a different asset first. The first asset again did not return an error, but all the others returned "forbidden", as before. So, something goes wrong in the processing of the 1st asset.

The LogLevel=6 shows the first asset's data is in fact returned, but I looked a little closer and see that no PH file was created, indicating an error occurs that is not being reported.

It will take a while longer to download, install, and try 2.35 or 2.40...

Thanks.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 15:36

@DdlV

To be clear, "no PH file was created" - you mean the PH is not written to the AssetsAlpaca.csv file or you are talking about the Download script did not create the PH history file?

When I run the GenAssetList script, I got the following in the Alpaca log:
Quote

2021-09-17 15:23:57 | DEBUG | --> https://data.alpaca.markets/v2/stocks/AEP/snapshot
2021-09-17 15:23:57 | TRACE2 | <-- {"symbol":"AEP","latestTrade":{"t":"2021-09-17T15:23:58.113971199Z","x":"U","p":84.94,"s":100,"c":["@","F"],"i":928,"z":"C"},"latestQuote":{"t":"2021-09-17T15:23:58.114431539Z","ax":"Q","ap":84.95,"as":2,"bx":"U","bp":84.94,"bs":1,"c":["R"],"z":"C"},"minuteBar":{"t":"2021-09-17T15:22:00Z","o":84.9581,"h":84.97,"l":84.9581,"c":84.9675,"v":2211,"n":56,"vw":84.964057},"dailyBar":{"t":"2021-09-17T04:00:00Z","o":85.98,"h":86.13,"l":84.92,"c":84.9675,"v":2132757,"n":15223,"vw":85.736417},"prevDailyBar":{"t":"2021-09-16T04:00:00Z","o":87.04,"h":87.605,"l":85.8,"c":85.98,"v":3648954,"n":48814,"vw":86.274489}}
2021-09-17 15:23:57 | DEBUG | --> https://data.alpaca.markets/v2/stocks/BRX/snapshot
2021-09-17 15:23:57 | TRACE2 | <-- {"symbol":"BRX","latestTrade":{"t":"2021-09-17T15:23:38.693Z","x":"D","p":23.635,"s":300,"c":[" "],"i":79372106414168,"z":"A"},"latestQuote":{"t":"2021-09-17T15:23:58.11787264Z","ax":"N","ap":23.64,"as":7,"bx":"K","bp":23.63,"bs":7,"c":["R"],"z":"A"},"minuteBar":{"t":"2021-09-17T15:22:00Z","o":23.635,"h":23.635,"l":23.63,"c":23.635,"v":1157,"n":14,"vw":23.634632},"dailyBar":{"t":"2021-09-17T04:00:00Z","o":23.7,"h":23.79,"l":23.5,"c":23.635,"v":606627,"n":3250,"vw":23.623893},"prevDailyBar":{"t":"2021-09-16T04:00:00Z","o":23.48,"h":23.81,"l":23.38,"c":23.63,"v":1916339,"n":11894,"vw":23.632988}}
2021-09-17 15:23:57 | DEBUG | --> https://data.alpaca.markets/v2/stocks/CFG/snapshot
2021-09-17 15:23:58 | TRACE2 | <-- {"symbol":"CFG","latestTrade":{"t":"2021-09-17T15:23:57.385924747Z","x":"H","p":44.07,"s":100,"c":[" ","F"],"i":52984217424189,"z":"A"},"latestQuote":{"t":"2021-09-17T15:23:58.123406848Z","ax":"N","ap":44.07,"as":11,"bx":"N","bp":44.06,"bs":3,"c":["R"],"z":"A"},"minuteBar":{"t":"2021-09-17T15:22:00Z","o":44.0802,"h":44.1,"l":44.07,"c":44.08,"v":26951,"n":96,"vw":44.079047},"dailyBar":{"t":"2021-09-17T04:00:00Z","o":43.55,"h":44.2401,"l":43.53,"c":44.08,"v":1364132,"n":10455,"vw":43.815531},"prevDailyBar":{"t":"2021-09-16T04:00:00Z","o":44.03,"h":44.3,"l":43.6,"c":43.72,"v":4073907,"n":34659,"vw":43.878355}}
2021-09-17 15:23:58 | DEBUG | --> https://data.alpaca.markets/v2/stocks/CMS/snapshot
2021-09-17 15:23:58 | TRACE2 | <-- {"symbol":"CMS","latestTrade":{"t":"2021-09-17T15:23:54.435002624Z","x":"N","p":62.28,"s":100,"c":[" "],"i":52983542271799,"z":"A"},"latestQuote":{"t":"2021-09-17T15:23:55.46624155Z","ax":"T","ap":62.29,"as":1,"bx":"N","bp":62.27,"bs":3,"c":["R"],"z":"A"},"minuteBar":{"t":"2021-09-17T15:22:00Z","o":62.3,"h":62.3153,"l":62.3,"c":62.3153,"v":1156,"n":33,"vw":62.305444},"dailyBar":{"t":"2021-09-17T04:00:00Z","o":62.33,"h":62.62,"l":62.11,"c":62.3153,"v":874822,"n":4409,"vw":62.339674},"prevDailyBar":{"t":"2021-09-16T04:00:00Z","o":62.8,"h":63.18,"l":62.39,"c":62.48,"v":1240504,"n":13493,"vw":62.627855}}
2021-09-17 15:23:58 | DEBUG | --> https://data.alpaca.markets/v2/stocks/CUBE/snapshot
2021-09-17 15:23:58 | TRACE2 | <-- {"symbol":"CUBE","latestTrade":{"t":"2021-09-17T15:23:59.423Z","x":"D","p":52.27,"s":300,"c":[" "],"i":71679970988629,"z":"A"},"latestQuote":{"t":"2021-09-17T15:23:59.474206848Z","ax":"N","ap":52.29,"as":3,"bx":"T","bp":52.27,"bs":1,"c":["R"],"z":"A"},"minuteBar":{"t":"2021-09-17T15:22:00Z","o":52.31,"h":52.33,"l":52.3,"c":52.33,"v":3511,"n":60,"vw":52.308776},"dailyBar":{"t":"2021-09-17T04:00:00Z","o":52.67,"h":52.78,"l":52.14,"c":52.33,"v":190342,"n":2107,"vw":52.483831},"prevDailyBar":{"t":"2021-09-16T04:00:00Z","o":52.81,"h":53.04,"l":52.41,"c":52.58,"v":635574,"n":8179,"vw":52.604212}}
2021-09-17 15:23:58 | DEBUG | close file


Do you see "!forbidden" in the log? Do all other assets, except the first, send a snapshot request and get a response?
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 16:28

@kzhao:

Sorry for the confusion! You're right - I have been mixing things...

GenAssetList: Using "brokerCommand(2001, "PH, SO, SUI, WEC");":

- AssetsAlpaca.csv contains only a PH row
- Log contains:
Code
2021-09-17 16:16:55 | DEBUG | --> https://data.alpaca.markets/v2/stocks/PH/snapshot
2021-09-17 16:16:57 | TRACE2 | <-- {"symbol":"PH","latestTrade":{"t":"2021-09-17T16:15:52.08019227Z","x":"V","p":287.6,"s":100,"c":[" "],"i":54333202192483,"z":"A"},"latestQuote":{"t":"2021-09-17T16:16:42.976071272Z","ax":"V","ap":0,"as":0,"bx":"V","bp":0,"bs":0,"c":["R"],"z":"A"},"minuteBar":{"t":"2021-09-17T16:15:00Z","o":287.58,"h":287.6,"l":287.58,"c":287.6,"v":244,"n":7,"vw":287.587295},"dailyBar":{"t":"2021-09-17T04:00:00Z","o":293.855,"h":293.855,"l":285.27,"c":287.6,"v":23473,"n":749,"vw":287.506828},"prevDailyBar":{"t":"2021-09-16T04:00:00Z","o":289.37,"h":291.375,"l":287.26,"c":289.71,"v":74303,"n":1079,"vw":289.392517}}
2021-09-17 16:16:57 | DEBUG | --> https://data.alpaca.markets/v2/stocks/ SO/snapshot
2021-09-17 16:16:58 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 16:16:58 | DEBUG | --> https://data.alpaca.markets/v2/stocks/ SUI/snapshot
2021-09-17 16:16:59 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 16:16:59 | DEBUG | --> https://data.alpaca.markets/v2/stocks/ WEC/snapshot
2021-09-17 16:17:01 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 16:17:01 | DEBUG | close file


Download: Entering PH and 2021:

- No PH file is created
- Log contains:
Code
2021-09-17 16:12:50 | DEBUG | --> https://data.alpaca.markets/v2/stocks/PH/snapshot
2021-09-17 16:12:51 | TRACE2 | <-- {"symbol":"PH","latestTrade":{"t":"2021-09-17T16:12:44.106958939Z","x":"V","p":288.02,"s":100,"c":[" "],"i":54328437011028,"z":"A"},"latestQuote":{"t":"2021-09-17T16:12:40.09506449Z","ax":"V","ap":0,"as":0,"bx":"V","bp":0,"bs":0,"c":["R"],"z":"A"},"minuteBar":{"t":"2021-09-17T16:08:00Z","o":287.85,"h":287.85,"l":287.84,"c":287.84,"v":237,"n":9,"vw":287.849916},"dailyBar":{"t":"2021-09-17T04:00:00Z","o":293.855,"h":293.855,"l":285.27,"c":287.84,"v":22757,"n":721,"vw":287.49602},"prevDailyBar":{"t":"2021-09-16T04:00:00Z","o":289.37,"h":291.375,"l":287.26,"c":289.71,"v":74303,"n":1079,"vw":289.392517}}
2021-09-17 16:12:51 | DEBUG | BorkerHisotry PH start: 1609459200 end: 1631895171 nTickMinutes: 1440 nTicks: 1000
2021-09-17 16:12:51 | INFO | Alpaca Basic Plan. Adjust end to 1631894271
2021-09-17 16:12:51 | DEBUG | BorkerHisotry PH start: 2021-01-01T00:00:00Z(1609459200) end: 2021-09-17T15:57:51Z(1631894271) nTickMinutes: 1440 nTicks: 1000
2021-09-17 16:12:51 | DEBUG | --> https://data.alpaca.markets/v2/stocks/PH/bars?start=2021-01-01T00:00:00Z&end=2021-09-17T15:57:51Z&limit=5000&timeframe=1D
2021-09-17 16:12:53 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 16:12:53 | DEBUG | BorkerHisotry PH start: 1609459200 end: 1631808771 nTickMinutes: 1440 nTicks: 1000
2021-09-17 16:12:53 | DEBUG | BorkerHisotry PH start: 2021-01-01T00:00:00Z(1609459200) end: 2021-09-16T16:12:51Z(1631808771) nTickMinutes: 1440 nTicks: 1000
2021-09-17 16:12:53 | DEBUG | --> https://data.alpaca.markets/v2/stocks/PH/bars?start=2021-01-01T00:00:00Z&end=2021-09-16T16:12:51Z&limit=5000&timeframe=1D
2021-09-17 16:12:54 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 16:12:54 | DEBUG | BorkerHisotry PH start: 1609459200 end: 1631722371 nTickMinutes: 1440 nTicks: 1000
2021-09-17 16:12:54 | DEBUG | BorkerHisotry PH start: 2021-01-01T00:00:00Z(1609459200) end: 2021-09-15T16:12:51Z(1631722371) nTickMinutes: 1440 nTicks: 1000
2021-09-17 16:12:54 | DEBUG | --> https://data.alpaca.markets/v2/stocks/PH/bars?start=2021-01-01T00:00:00Z&end=2021-09-15T16:12:51Z&limit=5000&timeframe=1D
2021-09-17 16:12:56 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 16:12:56 | DEBUG | BorkerHisotry PH start: 1609459200 end: 1631635971 nTickMinutes: 1440 nTicks: 1000
2021-09-17 16:12:56 | DEBUG | BorkerHisotry PH start: 2021-01-01T00:00:00Z(1609459200) end: 2021-09-14T16:12:51Z(1631635971) nTickMinutes: 1440 nTicks: 1000
2021-09-17 16:12:56 | DEBUG | --> https://data.alpaca.markets/v2/stocks/PH/bars?start=2021-01-01T00:00:00Z&end=2021-09-14T16:12:51Z&limit=5000&timeframe=1D
2021-09-17 16:12:57 | TRACE2 | <-- {"message": "forbidden."}


Note: In this case there is no "close file" in the log.

Hope that is clearer.

Thanks.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 16:50

@DdlV

In the Order and Position API, {"message": "forbidden."} implies that you don't have permission. I don't know why Alpaca returns the "forbidden" on the MarketData endpoint. It might be related to your account. I posted a question on Alpaca's dev-all Slack channel. If you use a Paper account, try to reset your account to see if that helps.
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 18:58

@kzhao,

Regenerated the API key - same forbidden error.

Which only happens after the 1st asset - if asset 1 works, why don't assets 2+?

Is there a further LogLevel greater than 6 that will show the complete interaction with Alpaca?

Thanks.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 21:02

@DdlV

I have no idea why assets 2+ are forbidden. That is Alpaca's response. At this point, I'd contact Alpaca to find out what is the reason.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 21:07

@DdlV

Aha, the get snapshot returns forbidden is because there is a space before the symbol. Please make sure the assets are separated with a comma without any spaces.


Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 21:29

Thanks @kzhao, but that's not it. Same result without spaces:

Code
2021-09-17 21:15:55 | DEBUG | --> https://data.alpaca.markets/v2/stocks/SO/snapshot
2021-09-17 21:15:56 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 21:15:57 | DEBUG | --> https://data.alpaca.markets/v2/stocks/SUI/snapshot
2021-09-17 21:15:58 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 21:15:58 | DEBUG | --> https://data.alpaca.markets/v2/stocks/WEC/snapshot
2021-09-17 21:15:59 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 21:15:59 | DEBUG | close file


And if I break it into 4 separate brokerCommand's:

Code
2021-09-17 21:23:02 | DEBUG | --> https://data.alpaca.markets/v2/stocks/PH/snapshot
2021-09-17 21:23:03 | TRACE2 | <-- {"symbol":"PH","latestTrade":{"t":"2021-09-17T19:59:23.438575225Z","x":"V","p":287.85,"s":100,"c":[" "],"i":56480353247027,"z":"A"},"latestQuote":{"t":"2021-09-17T19:59:59.68236824Z","ax":"V","ap":0,"as":0,"bx":"V","bp":0,"bs":0,"c":["R"],"z":"A"},"minuteBar":{"t":"2021-09-17T19:59:00Z","o":287.85,"h":287.85,"l":287.85,"c":287.85,"v":862,"n":22,"vw":287.785162},"dailyBar":{"t":"2021-09-17T04:00:00Z","o":293.855,"h":293.855,"l":285.27,"c":287.85,"v":59433,"n":2556,"vw":287.336592},"prevDailyBar":{"t":"2021-09-16T04:00:00Z","o":289.37,"h":291.375,"l":287.26,"c":289.71,"v":74303,"n":1079,"vw":289.392517}}
2021-09-17 21:23:03 | DEBUG | close file
2021-09-17 21:23:03 | DEBUG | --> https://data.alpaca.markets/v2/stocks/SO/snapshot
2021-09-17 21:23:05 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 21:23:05 | DEBUG | close file
2021-09-17 21:23:05 | DEBUG | --> https://data.alpaca.markets/v2/stocks/SUI/snapshot
2021-09-17 21:23:06 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 21:23:06 | DEBUG | close file
2021-09-17 21:23:06 | DEBUG | --> https://data.alpaca.markets/v2/stocks/WEC/snapshot
2021-09-17 21:23:07 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 21:23:07 | DEBUG | close file


And if I put WEC first, again no error on the first asset, only the following ones:

Code
2021-09-17 21:26:44 | DEBUG | --> https://data.alpaca.markets/v2/stocks/WEC/snapshot
2021-09-17 21:26:46 | TRACE2 | <-- {"symbol":"WEC","latestTrade":{"t":"2021-09-17T19:59:48.717084597Z","x":"V","p":90.73,"s":100,"c":[" "],"i":56485083113038,"z":"A"},"latestQuote":{"t":"2021-09-17T19:59:57.170214559Z","ax":"V","ap":0,"as":0,"bx":"V","bp":0,"bs":0,"c":["R"],"z":"A"},"minuteBar":{"t":"2021-09-17T19:59:00Z","o":90.81,"h":90.815,"l":90.73,"c":90.73,"v":1543,"n":23,"vw":90.77581},"dailyBar":{"t":"2021-09-17T04:00:00Z","o":91.13,"h":91.67,"l":90.72,"c":90.73,"v":41329,"n":886,"vw":91.123337},"prevDailyBar":{"t":"2021-09-16T04:00:00Z","o":92.55,"h":92.55,"l":91.17,"c":91.54,"v":27346,"n":606,"vw":91.715505}}
2021-09-17 21:26:46 | DEBUG | close file
2021-09-17 21:26:46 | DEBUG | --> https://data.alpaca.markets/v2/stocks/PH/snapshot
2021-09-17 21:26:47 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 21:26:47 | DEBUG | close file
2021-09-17 21:26:47 | DEBUG | --> https://data.alpaca.markets/v2/stocks/SO/snapshot
2021-09-17 21:26:48 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 21:26:48 | DEBUG | close file
2021-09-17 21:26:48 | DEBUG | --> https://data.alpaca.markets/v2/stocks/SUI/snapshot
2021-09-17 21:26:50 | TRACE2 | <-- {"message": "forbidden."}

2021-09-17 21:26:50 | DEBUG | close file


So I don't think it's the account?

Thanks.
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 21:43

@kzhao,

Is there a LogLevel or some other way to show the full commands being sent to Alpaca?

Thanks.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 21:48

@DdIV

For the Download, it seems that Alpaca changed the timeframe from 1D to 1Day. When I tried the download, I got "invalid timeframe". Not sure if Alpaca had just changed the response message. Anyway, I will fix both of the issues this weekend. Thanks
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 21:55

No - Thank YOU!
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 22:34

@DdIV

That is really strange. I have no idea why other snapshot requests are forbidden. If you launch Zorro from a terminal by "Zorro.exe -d", then run the script, you will see debug logging in the strategy's log (not the Alpacal log)
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 22:39

@DdIV

I got the response from Alpaca in the Slack:
Quote

It appears you haven’t signed up for the “unlimited” data plan? or are using keys from an account that isn’t associated with that plan. Notice in your debugging the line
Alpaca Basic Plan. Adjust end to 1631894271
That implies the API thinks you only have the basic data plan which restricts access to the most recent 15 minutes of data.
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/17/21 23:05

Thanks @kzhao!

Hmmm... It's true I haven't signed up for unlimited. But... I think we should separate the issues:

GenAssetList: What does the data plan have to do with this?! Even if it's only 15 mins, why does that impact subsequent assets?

Download: I'm trying to download EOD data, for which a 15 min limit makes no sense...

Thanks.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/18/21 00:00

@DdIV

Agree, Alpaca's response does not convince me either, because I have adjusted the end time to 15 minutes before the request time, and the first snapshot returned data. I'd expect that all the requests returned forbidden. I have asked a follow-up question.
Posted By: kzhao

Re: AlpacaZorroPlugin v1.0.6 Released - 09/20/21 14:43

@DdIV

I tried the Basic plan in a paper account, I didn't get the "forbidden" response from Alpaca. I'm not sure if you see the "forbidden" in the live account. Please try the new v1.1.0 release. If Alpaca still responses with "forbidden", you probably should contact Alpaca support to figure out what is the reason.
Posted By: DdlV

Re: AlpacaZorroPlugin v1.0.6 Released - 09/20/21 21:59

@kzhao,

The bottom line is that the plugin is NOT compatible with 1.96. It (so far) works fine with 2.40.9 - no more "forbidden" errors; and with v1.1.0 the EOD Download also works.

If I run into any other issues, I will post them in the v1.1.0 thread.

Many thanks!
© 2024 lite-C Forums