How to use the data-forge.fromCSV function in data-forge

To help you get started, we’ve selected a few data-forge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ashleydavis / alpha-vantage-cli / index.ts View on Github external
"&symbol=" + symbol + 
            "&apikey=" + this.apiKey + 
            "&datatype=csv" +
            "&outputsize=" + this.outputDataSize
            ;
            
        if (this.verbose) {
            console.log('<< ' + url);
        }

        var response = await request(url);
        if (response.indexOf("Error Message") >= 0) {
            throw new Error(JSON.parse(response)["Error Message"]);
        }

        return dataForge
            .fromCSV(response, { skipEmptyLines: true })
            .parseDates("timestamp", "YYYY-MM-DD")
            .parseFloats(["open", "high", "low", "close", "adjusted_close", "volume", "dividend_amount" , "split_coefficient"])
            .renameSeries({
                timestamp: "Timestamp",
                open: "Open",
                high: "High",
                low: "Low",
                close: "Close",
                adjusted_close: "AdjClose",
                volume: "Volume",
                dividend_amount: "DividendAmount",
                split_coefficient: "SplitCoefficient",
            })
            .bake();
    }
github ashleydavis / alpha-vantage-cli / index.ts View on Github external
"&apikey=" + this.apiKey + 
            "&datatype=csv" +
            "&outputsize=" + this.outputDataSize  +
            "&interval=" + interval            
            ;

        if (this.verbose) {
            console.log('<< ' + url);
        }

        var response = await request(url);
        if (response.indexOf("Error Message") >= 0) {
            throw new Error(JSON.parse(response)["Error Message"]);
        }

        return dataForge
            .fromCSV(response, { skipEmptyLines: true })
            .parseDates("timestamp", "YYYY-MM-DD HH:mm:ss")
            .parseFloats(["open", "high", "low", "close", "volume"])
            .renameSeries({
                timestamp: "Timestamp",
                open: "Open",
                high: "High",
                low: "Low",
                close: "Close",
                volume: "Volume",
            })
            .bake();
    }
github ashleydavis / alpha-vantage-cli / build / index.js View on Github external
"?function=TIME_SERIES_INTRADAY" +
                            "&symbol=" + symbol +
                            "&apikey=" + this.apiKey +
                            "&datatype=csv" +
                            "&outputsize=" + this.outputDataSize +
                            "&interval=" + interval;
                        if (this.verbose) {
                            console.log('<< ' + url);
                        }
                        return [4 /*yield*/, request(url)];
                    case 1:
                        response = _a.sent();
                        if (response.indexOf("Error Message") >= 0) {
                            throw new Error(JSON.parse(response)["Error Message"]);
                        }
                        return [2 /*return*/, dataForge
                                .fromCSV(response, { skipEmptyLines: true })
                                .parseDates("timestamp", "YYYY-MM-DD HH:mm:ss")
                                .parseFloats(["open", "high", "low", "close", "volume"])
                                .renameSeries({
                                timestamp: "Timestamp",
                                open: "Open",
                                high: "High",
                                low: "Low",
                                close: "Close",
                                volume: "Volume",
                            })
                                .bake()];
                }
            });
        });

data-forge

JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ.

MIT
Latest version published 8 months ago

Package Health Score

64 / 100
Full package analysis