Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New exchange mappings and fallback. #25

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/intrinio/realtime/options/Exchange.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,37 @@ public enum Exchange {
ISE((byte)'I'),
MERCURY((byte)'J'),
MIAMI((byte)'M'),
NYSE_ARCA((byte)'N'),
MIAMI_PEARL((byte)'O'),
NYSE_ARCA((byte)'P'),
NASDAQ((byte)'Q'),
MIAX_SAPPHIRE((byte)'S'),
NASDAQ_BX((byte)'T'),
MEMX((byte)'U'),
CBOE_C2((byte)'W'),
PHLX((byte)'X'),
BATS_BZX((byte)'Z');
BATS_BZX((byte)'Z'),
UNKNOWN((byte)'?');

private static final HashMap<Byte,Exchange> exchangeCodeMap = new HashMap<Byte,Exchange>();

static {
for (Exchange e: values()) {
exchangeCodeMap.put(e.code, e);
byte lower = (byte)(Character.toLowerCase((char)e.code));
exchangeCodeMap.put(lower, e);
}
exchangeCodeMap.put((byte)'P', Exchange.NYSE_ARCA); //Two chars mapped to same exchange. This one is depreciated
exchangeCodeMap.put((byte)'p', Exchange.NYSE_ARCA); //Two chars mapped to same exchange. This one is depreciated
}

public final byte code;
private Exchange(byte code) {
this.code = code;
}

public static Exchange valueOfCode(byte code) {
return exchangeCodeMap.get(code);
public static Exchange valueOfCode(byte code)
{
return exchangeCodeMap.getOrDefault(code, Exchange.UNKNOWN);
}

}
Loading