Skip to content

Instantly share code, notes, and snippets.

@clintonyeb
Created May 19, 2020 03:05
Show Gist options
  • Select an option

  • Save clintonyeb/26c2e0dafd49faddb3a375ad0e0fde09 to your computer and use it in GitHub Desktop.

Select an option

Save clintonyeb/26c2e0dafd49faddb3a375ad0e0fde09 to your computer and use it in GitHub Desktop.

Revisions

  1. @clintonyeboah clintonyeboah created this gist May 19, 2020.
    43 changes: 43 additions & 0 deletions app.component.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    import { Component, OnInit } from '@angular/core';
    import { AppService } from './app.service';

    @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss'],
    })
    export class AppComponent implements OnInit {
    currency = '';
    currencies;
    tickCount = 0;
    pipDiff = 0;
    buyOrSell = '';
    ticker = 0;
    movavg = 0;
    webSocket;
    averages;

    constructor(private appService: AppService) {}

    ngOnInit(): void {
    this.appService.getCcyPair().subscribe((data: Array<any>) => {
    this.currencies = data.map((d) => d['currency_name']);
    this.currency = this.currencies[0];
    });
    }

    handleSubmit() {
    this.wsSend({
    currencyPair: this.currency,
    });
    }

    wsSend(message) {
    if (this.webSocket) {
    this.webSocket.close();
    }
    this.averages = [];
    const messageValue = JSON.stringify(message);
    this.webSocket = this.initializeWS(messageValue);
    }
    }