-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
51 additions
and
21 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
defmodule Tai.VenueAdapters.Bitmex.ProductType do | ||
@type type :: Tai.Venues.Product.type() | ||
|
||
@doc """ | ||
Maps Bitmex product types to Tai product types. | ||
https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_get | ||
Perpetual Contracts - FFWCSX | ||
Perpetual Contracts (FX underliers) - FFWCSF | ||
Spot - IFXXXP | ||
Futures - FFCCSX | ||
BitMEX Basket Index - MRBXXX | ||
BitMEX Crypto Index - MRCXXX | ||
BitMEX FX Index - MRFXXX | ||
BitMEX Lending/Premium Index - MRRXXX | ||
BitMEX Volatility Index - MRIXXX | ||
## Examples | ||
iex> Tai.VenueAdapters.Bitmex.ProductType.normalize("FFWCSX") | ||
:swap | ||
""" | ||
|
||
@spec normalize(bitmex_product_type :: String.t()) :: type | ||
def normalize("FFWCS" <> _), do: :swap # FFWCSX, FFWCSF | ||
def normalize("FFCCS" <> _), do: :future # FFCCSX | ||
def normalize("IF" <> _), do: :spot # IFXXXP | ||
def normalize(_), do: :future | ||
end |
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
13 changes: 13 additions & 0 deletions
13
apps/tai/test/tai/venue_adapters/bitmex/product_type_test.exs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule Tai.VenueAdapters.Bitmex.ProductTypeTest do | ||
use ExUnit.Case, async: true | ||
alias Tai.VenueAdapters.Bitmex | ||
|
||
test ".normalize/1 converts product type" do | ||
assert Bitmex.ProductType.normalize("FFWCSX") == :swap | ||
assert Bitmex.ProductType.normalize("FFWCSF") == :swap | ||
assert Bitmex.ProductType.normalize("IFXXXP") == :spot | ||
assert Bitmex.ProductType.normalize("FFCCSX") == :future | ||
|
||
assert Bitmex.ProductType.normalize("XXXXXX") == :future, "fallback to future" | ||
end | ||
end |
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