-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneww.js
34 lines (30 loc) · 815 Bytes
/
neww.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Alpaca from '@alpacahq/alpaca-trade-api';
import WebSocket from 'ws';
const API_KEY = process.env.ALPACA_API_KEY;
const API_SECRET = process.env.ALPACA_API_SECRET;
const USE_POLYGON = false;
const alpaca = new Alpaca({
keyId: API_KEY,
secretKey: API_SECRET,
paper: true,
usePolygon: USE_POLYGON
});
import { default as mongodb } from 'mongodb';
let MongoClient = mongodb.MongoClient;
function hello() {
var ws = new WebSocket('wss://data.alpaca.markets/stream');
var dummy = {
"action": "authenticate",
"data": {
"key_id": API_KEY,
"secret_key": API_SECRET
}
};
ws.on('connection', function open() {
ws.send(dummy);
});
ws.on('message', function incoming(data) {
console.log(data);
});
}
hello();