<commit_before>var protobuf = require('protobufjs');
var bytebuffer = require('byte');
var tls = require('tls');
var chalk = require('chalk');

var API_HOST = 'sandbox-tradeapi.spotware.com';
var API_PORT = 5032;
var CLIENT_ID = '7_5az7pj935owsss8kgokcco84wc8osk0g0gksow0ow4s4ocwwgc';
var CLIENT_SECRET = '<KEY>';
var ACCOUNT_ID = 62002;
var ACCOUNT_TOKEN = '<PASSWORD>';

// Proto Message Builds
var commonBuilder = protobuf.loadProtoFile('proto/CommonMessages.proto');
var openApiBuilder = protobuf.loadProtoFile('proto/OpenApiMessages.proto');


// Buffers
var PingBuf = commonBuilder.build('ProtoPingReq');
var OAuthBuf = openApiBuilder.build('ProtoOAAuthReq');
var SpotsBuf = openApiBuilder.build('ProtoOASubscribeForSpotsReq');
var ProtoMessageBuf = commonBuilder.build('ProtoMessage');



var pingInterval;
var start = Math.floor(new Date() / 1000);

var socket = tls.connect(API_PORT, API_HOST, function() {
    console.log('Connected');
    // Sending pings in a loop
    pingInterval = setInterval(function() {
        var pingBuf = new PingBuf({
            payloadType: 'PING_REQ',
            timestamp: Math.floor(new Date())
        });
        //console.log('Sending ping...');
        var msg = wrapMessage(pingBuf);
        socket.write(getLength(msg));
        socket.write(msg);
    }, 1000);
    // Authenticating
    var oAuthBuf = new OAuthBuf({
        payloadType: 'OA_AUTH_REQ',
        clientId: CLIENT_ID,
        clientSecret: CLIENT_SECRET
    });
    console.log('Sending auth Request...');
    var msg = wrapMessage(oAuthBuf);
    socket.write(getLength(msg));
    socket.write(msg);
});

socket.on('readable', function() {
    var length = new Buffer(socket.read(4)).readInt32BE(0);
    var data = socket.read(length);

    data = ProtoMessageBuf.decode(data);
    var payloadType = data.payloadType;
    if (payloadType == openApiBuilder.build('ProtoOAPayloadType').OA_AUTH_RES) {
        console.log('Received auth response');
        // Subscribing for EURUSD spots
        
        var spotsBuf = new SpotsBuf({
            payloadType: 'OA_SUBSCRIBE_FOR_SPOTS_REQ',
            accountId: ACCOUNT_ID,
            accessToken: ACCOUNT_TOKEN,
            symblolName: 'EURUSD'
        });
        console.log('Sending subscribe event...');
        var msg = wrapMessage(spotsBuf);
        socket.write(getLength(msg));
        socket.write(msg);
    } else if (payloadType == commonBuilder.build('ProtoPayloadType').PING_RES) {
        //console.log('Received ping response');
    } else if (payloadType == openApiBuilder.build('ProtoOAPayloadType').OA_SUBSCRIBE_FOR_SPOTS_RES) {
        console.log(chalk.blue('Received subscribe response'));
    } else if (payloadType == openApiBuilder.build('ProtoOAPayloadType').OA_SPOT_EVENT) {
        var SpotBuf = openApiBuilder.build('ProtoOASpotEvent');
        var msg = SpotBuf.decode(data.payload);
        console.log(chalk.blue('Bid price: ' + msg.bidPrice + ', ask price: ' + msg.askPrice));
    } else if (payloadType == commonBuilder.build('ProtoPayloadType').ERROR_RES) {
        var ErrorBuf = commonBuilder.build('ProtoErrorRes');
        var msg = ErrorBuf.decode(data.payload);
        console.log(chalk.red('Received error response'));
        console.log(chalk.red(msg.description));
    } else {
        console.log('Received misc payloadType: ' + payloadType);
    }<commit_msg>chang of comparison operator from == to ===<commit_after>var protobuf = require('protobufjs');
var bytebuffer = require('byte');
var tls = require('tls');
var chalk = require('chalk');

var API_HOST = 'sandbox-tradeapi.spotware.com';
var API_PORT = 5032;
var CLIENT_ID = '7_5az7pj935owsss8kgokcco84wc8osk0g0gksow0ow4s4ocwwgc';
var CLIENT_SECRET = '<KEY>';
var ACCOUNT_ID = 62002;
var ACCOUNT_TOKEN = '<PASSWORD>';

// Proto Message Builds
var commonBuilder = protobuf.loadProtoFile('proto/CommonMessages.proto');
var openApiBuilder = protobuf.loadProtoFile('proto/OpenApiMessages.proto');


// Buffers
var PingBuf = commonBuilder.build('ProtoPingReq');
var OAuthBuf = openApiBuilder.build('ProtoOAAuthReq');
var SpotsBuf = openApiBuilder.build('ProtoOASubscribeForSpotsReq');
var ProtoMessageBuf = commonBuilder.build('ProtoMessage');



var pingInterval;
var start = Math.floor(new Date() / 1000);

var socket = tls.connect(API_PORT, API_HOST, function() {
    console.log('Connected');
    // Sending pings in a loop
    pingInterval = setInterval(function() {
        var pingBuf = new PingBuf({
            payloadType: 'PING_REQ',
            timestamp: Math.floor(new Date())
        });
        //console.log('Sending ping...');
        var msg = wrapMessage(pingBuf);
        socket.write(getLength(msg));
        socket.write(msg);
    }, 1000);
    // Authenticating
    var oAuthBuf = new OAuthBuf({
        payloadType: 'OA_AUTH_REQ',
        clientId: CLIENT_ID,
        clientSecret: CLIENT_SECRET
    });
    console.log('Sending auth Request...');
    var msg = wrapMessage(oAuthBuf);
    socket.write(getLength(msg));
    socket.write(msg);
});

socket.on('readable', function() {
    var length = new Buffer(socket.read(4)).readInt32BE(0);
    var data = socket.read(length);

    data = ProtoMessageBuf.decode(data);
    var payloadType = data.payloadType;
    if (payloadType === openApiBuilder.build('ProtoOAPayloadType').OA_AUTH_RES) {
        console.log('Received auth response');
        // Subscribing for EURUSD spots
        
        var spotsBuf = new SpotsBuf({
            payloadType: 'OA_SUBSCRIBE_FOR_SPOTS_REQ',
            accountId: ACCOUNT_ID,
            accessToken: ACCOUNT_TOKEN,
            symblolName: 'EURUSD'
        });
        console.log('Sending subscribe event...');
        var msg = wrapMessage(spotsBuf);
        socket.write(getLength(msg));
        socket.write(msg);
    } else if (payloadType === commonBuilder.build('ProtoPayloadType').PING_RES) {
        //console.log('Received ping response');
    } else if (payloadType === openApiBuilder.build('ProtoOAPayloadType').OA_SUBSCRIBE_FOR_SPOTS_RES) {
        console.log(chalk.blue('Received subscribe response'));
    } else if (payloadType === openApiBuilder.build('ProtoOAPayloadType').OA_SPOT_EVENT) {
        var SpotBuf = openApiBuilder.build('ProtoOASpotEvent');
        var msg = SpotBuf.decode(data.payload);
        console.log(chalk.blue('Bid price: ' + msg.bidPrice + ', ask price: ' + msg.askPrice));
    } else if (payloadType === commonBuilder.build('ProtoPayloadType').ERROR_RES) {
        var ErrorBuf = commonBuilder.build('ProtoErrorRes');
        var msg = ErrorBuf.decode(data.payload);
        console.log(chalk.red('Received error response'));
        console.log(chalk.red(msg.description));
    } else {
        console.log('Received misc payloadType: ' + payloadType);
    }
{'fraction_non_alphanumeric': 0.1335298452468681, 'fraction_numerical': 0.010611643330876934, 'mean_word_length': 3.4821664464993396, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5458329', 'n_tokens_mistral': 2189, 'n_tokens_neox': 2091, 'n_words': 408}