1

I'm working on a project that allows the user to pull out information from both SEC and on the company's traded Stock using the company's stock-ticker.

Now, in order for me to be able to retrieve information from the SEC using the stock ticker ONLY, I must first query the gem stock_quotes for the company's Name to then retrieve the company's CIK-code. However, EDGAR is a well and true disaster when it comes to querying businesses based on their name, it does a much better job of querying based on CIK only, but currently, there's no other way to get the CIK from the Ticker only as in the query sequence of TICKER => CIK only the sequence TICKER => COMPANY_NAME => CIK works.

Now, since Edgar is old, and does not understand well, this means that for some companies, finding the CIK code using the format "COMPANY, INC" works perfectly. For some companies, that doesn't work, and I must remove the "INC" for Edgar to understand. And some companies have special characters in their names that Edgar doesn't know what to do with, so he throws errors left and right.

Now, here's an example:

@sec = SecQuery::Entity.find("#{@stock.name}".gsub("INC", "").gsub("COM", "").gsub("USD0.0001", "").gsub("USD0.001", 
    "").gsub("USD0.01", "").gsub("USD0.1", "").gsub("USD1.0", ""))

Now, I have reached a point to where I've realized that some companies actually do not have "inc" included in their written company name. This means I must add "INC" to that company name for edgar to understand which company I'm looking for.

But I'm unable to ADD things to the @stock.name - Could someone help me figure out how?

Ive tried different variations of

 @sec = SecQuery::Entity.find("#{@stock.name}".insert(-1, "INC")

 @sec = SecQuery::Entity.find("#{@stock.name}".concat(" INC")

 @sec = SecQuery::Entity.find("#{@stock.name}".gsub(/$/, ' INC')

Any help would be extremely useful.

micstr
  • 5,080
  • 8
  • 48
  • 76
Crashtor
  • 1,249
  • 1
  • 13
  • 21

1 Answers1

1

You could just do...

@sec = SecQuery::Entity.find("#{@stock.name}" + (" INC"))

SteveTurczyn
  • 36,057
  • 6
  • 41
  • 53