Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, Nymphodora, Quad, TipmyPip, Imhotep), 852 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
AlpacaPlugin 1.0.0 released #482665
03/15/21 04:15
03/15/21 04:15
Joined: Sep 2019
Posts: 63
Naperville
K
kzhao Offline OP
Junior Member
kzhao  Offline OP
Junior Member
K

Joined: Sep 2019
Posts: 63
Naperville
AlpacaZorroPlugin v1.0.0 released.

https://github.com/kzhdev/alpaca_zorro_plugin


- Introduced ZorroWebsocketProxy so that multiple ZorroS instances can share one Websocket connection
**NOTE** ZorroWebsocketProxy adopts a lock-free design which spins on one CPU core. High CPU usage is normal and expected.

- Added Alpaca MarketData V2 Websocket support
- Las trade and last quote are directly from WebSocket stream. This is dramatically reduced Zorro API query.
- if last trade or last quote update have not received yet, the plugin will pull last trade and quote from V1 endpoint.

- Added Alpaca plugin specific setting to Zorro.ini or ZorroFix.ini file.
- AlpacaDataSource = 1 // 0 = Alpaca, 1 = Polygon
- AlpacaPaidDataPlan = 1 // 0 = False, 1 = True
- AlpacaLogLevel = 0 // 0 = OFF, 1 = ERROR, 2 = WARNING, 3 = INFO, 4 = DEBUG, 5 = TRACE
- PolygonApiKey = "*************" // Polygon ApiKey
please refer to the README.md for details.

- Historical bars are still retrieved from V1 endpoint because V2 Historical Bars are not ready yet.

- Polygon MarketData is still supported, but the ApiKey has moved into Zorro config file.
NOTE: Polygon free plan can't be used as alternative market data source due to lack of last trade and last quote data.

Re: AlpacaPlugin 1.0.0 released [Re: kzhao] #482668
03/15/21 12:50
03/15/21 12:50
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Originally Posted by kzhao
- Introduced ZorroWebsocketProxy so that multiple ZorroS instances can share one Websocket connection
**NOTE** ZorroWebsocketProxy adopts a lock-free design which spins on one CPU core. High CPU usage is normal and expected.
Why is high CPU usage normal and expected? What is using up the CPU?

Re: AlpacaPlugin 1.0.0 released [Re: kzhao] #482669
03/15/21 13:53
03/15/21 13:53
Joined: Sep 2019
Posts: 63
Naperville
K
kzhao Offline OP
Junior Member
kzhao  Offline OP
Junior Member
K

Joined: Sep 2019
Posts: 63
Naperville
The websocket proxy server/client spins a CPU core by doing busy wait. It keeps the CPU busy to wait messages or sending heartbeat between the server and clients. It is not doing hard spin though, the CPU will not totally locked up. If there is no job to do, it yields the thread so that other thread can be executed. I have been running at least 2 Zorro S instances on a single core VM, everything works fine.

Re: AlpacaPlugin 1.0.0 released [Re: kzhao] #482694
03/17/21 20:05
03/17/21 20:05
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
@kzhao, I am trying v1.0.0. I have not added any settings into Zorro[Fix].ini - presumably that means defaulting to Alpaca Market Data and no logging. I am running this on Linux in a VM under Wine, testing with Z8/9.

- Most of the time Trade gives "!Unable to open Alpaca websocket". So far this happens always on the first Trade after Zorro starts, and sometimes again later.

- After the initial prices download, the Server goes Offline and the connection box goes red.

- After that I get "BrokerLogin: No Data!", and the strategy appears to hang.

- If I Stop Trading, zorro_websocket continues to loop until I close Zorro. Shouldn't it be stopped when the strategy stops?

- zorro_websocket is using all cores.

Re: AlpacaPlugin 1.0.0 released [Re: kzhao] #482709
03/18/21 20:22
03/18/21 20:22
Joined: Sep 2019
Posts: 63
Naperville
K
kzhao Offline OP
Junior Member
kzhao  Offline OP
Junior Member
K

Joined: Sep 2019
Posts: 63
Naperville
I did not run Zorro under Wine. I do found an issue where sometimes when starting a strategy the very first time, the proxy server heartbeat timed out. If you launch the strategy again, it should be fine. I already have a fix. I will try running zorro under Wine to see what happens.

The WebSocket proxy server keeps running after you stop trading because it can serve multiple Zorro instances. I can add an option so the server can shutdown after all connected clients are disconnected

How many cores does your VM have? The WebSocket proxy will keep the CPU busy, but most of the time it checks if there is an event and yields the CPU to other threads.

Last edited by kzhao; 03/18/21 20:35.
Re: AlpacaPlugin 1.0.0 released [Re: kzhao] #482710
03/18/21 20:38
03/18/21 20:38
Joined: Jun 2013
Posts: 1,609
D
DdlV Offline
Serious User
DdlV  Offline
Serious User
D

Joined: Jun 2013
Posts: 1,609
Thanks kzhao. VM has 2 cores & websocket seems to use both...

Re: AlpacaPlugin 1.0.0 released [Re: kzhao] #482711
03/18/21 20:40
03/18/21 20:40
Joined: Sep 2019
Posts: 63
Naperville
K
kzhao Offline OP
Junior Member
kzhao  Offline OP
Junior Member
K

Joined: Sep 2019
Posts: 63
Naperville
I am developing and testing the plugin on a single-core VM. Yes, you will see high CPU usage, but everything works fine.

Re: AlpacaPlugin 1.0.0 released [Re: kzhao] #482712
03/18/21 21:07
03/18/21 21:07
Joined: Sep 2019
Posts: 63
Naperville
K
kzhao Offline OP
Junior Member
kzhao  Offline OP
Junior Member
K

Joined: Sep 2019
Posts: 63
Naperville
In your case, the WebSocket server and the client spin on two separate CPU cores.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1