All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tecacet.finance.io.parser.NasdaqAssetParser Maven / Gradle / Ivy

package com.tecacet.finance.io.parser;

import com.tecacet.finance.model.Asset;
import com.tecacet.finance.model.AssetType;
import com.tecacet.finance.model.Exchange;
import com.tecacet.jflat.CSVReader;
import org.apache.commons.csv.CSVFormat;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;


public class NasdaqAssetParser {

    private final CSVReader reader = CSVReader.
            readerWithHeaderMapping(Asset.class, new String[]{"Symbol", "Security Name", "Round Lot Size"},
                    new String[]{"symbol", "name", "roundLotSize"})
            .withFormat(CSVFormat.DEFAULT.withFirstRecordAsHeader().withDelimiter('|'));

    public List parse(InputStream is) throws IOException {
        List assets =
                reader.readAllWithCallback(is, (row, asset) ->
                        asset.toBuilder()
                                .assetType(AssetType.STOCK)
                                .exchange(Exchange.NASDAQ)
                                .build());


        // The last one is a footer
        assets.remove(assets.size() - 1);
        return assets;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy