You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -99,7 +103,7 @@ Runs a function when establishing the connection. When backtesting, you will usu
99
103
#### Example
100
104
```JavaScript
101
105
client.onConnect(() => {
102
-
client.subscribe(['AM.SPY']);
106
+
client.subscribe(['alpacadatav1/AM.SPY']);
103
107
});
104
108
```
105
109
@@ -114,22 +118,20 @@ client.onDisconnect(() => {
114
118
```
115
119
116
120
### Websocket#onStockAggMin
117
-
This runs your function when a simulated minute occurrs and returns the relevant data. This is where your trading will likely take place
121
+
This runs your function when a simulated minute occurrs and returns the relevant data. This is where your trading will likely take place. Subject will look something like `AM.SPY` and data will look like a standard bar data.
118
122
119
123
#### Example
120
124
```JavaScript
121
125
client.onStockAggMin((subject, data) => {
122
-
constpriceArray=JSON.parse(data);
123
-
124
-
if (priceArray[0].closePrice<500) {
126
+
if (data.closePrice<500) {
125
127
backtest.createOrder({
126
128
symbol:'SPY',
127
129
qty:300,
128
130
side:'buy',
129
131
type:'market',
130
132
time_in_force:'day'
131
133
});
132
-
134
+
133
135
console.log('Bought SPY');
134
136
}
135
137
});
@@ -141,6 +143,6 @@ Subscribes to the channels listed. Currently, only aggregate minute channels are
0 commit comments