Created
June 21, 2013 00:48
-
-
Save masaakif/5828063 to your computer and use it in GitHub Desktop.
MarketID、ExchangeID、SEDOLコードの表と、MarketID、ExchangeID、BLPExchCodeの表から、Bloombergのコードを生成する。たとえば、caequ, XTSX, 2000075というデータと、caequ,XTSX,CN の場合は、2000075 CN Equity と出力する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'set' | |
exs = Hash.new | |
open("exchlist.txt").each do |line| | |
next if line[0] == '0' | |
exl = line.chomp.split("\t") | |
exs["#{exl[1]}.#{exl[2]}"] = exl[3] | |
end | |
blps = Set.new | |
excs = Hash.new | |
["sedol.1","sedol.2","sedol.3"].each do |fn| | |
l = 0 | |
open(fn).each do |line| | |
l = l + 1 | |
next if l < 5 | |
break if line[0] == '+' and l > 10 | |
exc = exs["#{line[2..6]}.#{line[13..16]}"] | |
excs[exc] ||=0 | |
excs[exc] += 1 | |
next if excs[exc] > 20 | |
sedol = line[26..32] | |
blps.add "#{sedol} Equity SEDOL1" | |
blps.add "#{sedol} #{exc} Equity" | |
end | |
end | |
blps.sort.each do |blp| | |
puts blp | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment