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

Implement aliases for assets on specific exchanges #140

Closed
macanudo527 opened this issue Apr 5, 2023 · 12 comments · Fixed by #146
Closed

Implement aliases for assets on specific exchanges #140

macanudo527 opened this issue Apr 5, 2023 · 12 comments · Fixed by #146

Comments

@macanudo527
Copy link
Collaborator

macanudo527 commented Apr 5, 2023

Some exchanges use ISO tickers for crypto assets. For example, Kraken (and Bitmex) uses XBT for BTC in some places. More details on XBT vs BTC

Other exchanges use 'micro' tickers for certain assets to denote fractions of a crypto asset. For example, Pionex uses mBTC to refer to 0.001 BTC.

In order to price these appropriately, we need to implement an alias system that will create a vector between the appropriate asset the alias represents and have a locked spot_price of 1 if they are a true alias or a fraction if they represent a micro asset. These will then be added to the Djikstra graph with 0 weight.

This helps address #133 and issues that came up with #114

@kiates
Copy link
Contributor

kiates commented Apr 7, 2023

Note that a mBTC in Pionex is 1/1000 of a BTC, not a Satoshi, and there is a similar "coin" for ETH called mETH.

@macanudo527
Copy link
Collaborator Author

#146 helped pave the way for this one, but we aren't quite there yet.

@macanudo527 macanudo527 reopened this Jul 10, 2023
@macanudo527
Copy link
Collaborator Author

I'm wondering about how to implement this. I think the best way is to implement a fake exchange that reports the aliases as markets then let the djikstra algo do its thing.

I'm wondering whether the fake exchange should take overrides in the form of a config file or csv file. They could also be declared in the ini file under the CCXT pair converter header. The overrides would be a market (e.g. MBTC/BTC) and a locked price (e.g. 0.0001). Known aliases would be added in of course, but this would allow users to add in aliases without having to commit a PR.

I can't see a way to dynamically build these. They will have to be hardwired somewhere.

@eprbell
Copy link
Owner

eprbell commented Jul 12, 2023

Let me ask a few of questions that will help brainstorm this:

  1. is an alias defined as follows: ([original_asset], [aliased_asset], [factor])? E.g. (BTC, mBTC, 0.001)
  2. is the alias list exchange-specific? E.g. mBTC is defined on Pionex but not elsewere. I assume the answer to this is yes.
  3. Is the per-exchange list of aliases available anywhere or do we have to compile it manually? From what you're saying I understand it's not available and must be compiled manually by us or the user, correct?

I'm not sure I understand the fake exchange concept: where would it be defined and would it need its own plugin?

@macanudo527
Copy link
Collaborator Author

  • is an alias defined as follows: ([original_asset], [aliased_asset], [factor])? E.g. (BTC, mBTC, 0.001)

We will need to implement ([original_asset], [aliased_asset], [factor], [exchange(optional)]) in order to avoid conflicts. I think we will have about a 50/50 split of aliases that need to be universal (for all exchanges) like LUNA -> LUNC. Others, for data security, should be limited to a particular exchange, like mBTC -> BTC * 0.0001 on Pionex. I don't think there is a conflicting ISO for mBTC right now, but you never know with crypto.

  • is the alias list exchange-specific? E.g. mBTC is defined on Pionex but not elsewere. I assume the answer to this is yes.

Some will need to be universal, others exchange-specific

  • Is the per-exchange list of aliases available anywhere or do we have to compile it manually? From what you're saying I understand it's not available and must be compiled manually by us or the user, correct?

I haven't been able to find one anywhere. Different exchanges will have different policies. CCXT has aliases built into its classes, but if we use a different exchange to price an asset the aliases won't match up. For instance, the Pionex API is not implemented by CCXT, yet, so we will need to use another exchange to price assets. mBTC doesn't exist on other exchanges so we will need to build a thin fake Pionex exchange that only has aliases that link up to other exchanges.

So the list will need to be compiled and maintained by us or the user. We can, of course, create a base and users can then override it in a pinch until we get a PR through.

Thinking on this more, we almost need the ability to manually define edges in the graph universally for all exchanges and another option to define the edge for a specific exchange.

@eprbell
Copy link
Owner

eprbell commented Jul 13, 2023

That makes sense.

Thinking on this more, we almost need the ability to manually define edges in the graph universally for all exchanges and another option to define the edge for a specific exchange.

Yes, I think that's exactly it. I don't think we need fake exchanges, we just need the ability to add markets (graph edges) to existing exchanges. Also I agree that we can define a base and the user can extend it if they need to (probably via the config file).

@macanudo527
Copy link
Collaborator Author

Yeah, the config file is the best route for overrides. And the base file is a csv? or hard code it into the MappedGraph class file? I think CSV would be easier to look at.

I'll build this into the MappedGraph class. It's getting pretty beefy. It's currently weighing in at 87 lines. I think it's best we extract it. I don't think it's a trivial data class anymore.

@eprbell
Copy link
Owner

eprbell commented Jul 14, 2023

Ok to separate out the MappedGraph class. I think the base can be hardcoded somewhere in the codebase. The reason I wouldn't use a CSV file is that it invites the idea that it can be modified by the end user.

@macanudo527
Copy link
Collaborator Author

Ok, I was thinking you might say that. I should be able to get something out soon then.

FYI: I did get a part-time programming job with the potential to go full-time, so I might not be as available as I have been.

@eprbell
Copy link
Owner

eprbell commented Jul 14, 2023

Congrats, happy for you!

@macanudo527
Copy link
Collaborator Author

@kiates Is the ticker symbol reported as "MBTC" (all caps) or "mBTC" (lower case m)?

@macanudo527
Copy link
Collaborator Author

I'm closing this for now since it seems like it has been resolved. If anyone has further issues with aliases, let's open another issue on that specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants