Closed sf52crypto closed 4 years ago
@sf52crypto
In the older versions, I had the tickers being fetched onMount (you can see the change here)
The main reasons this has been changed is because:
TickerSwitch
function which would subscribe and unsubscribe from the ticker, so that only 1 subscription is live at the time.
In the future releases, I want to make a global .env
file where you could choose tickers to subscribe to. I haven't thought of the solution yet, since I don't want to eject from create-react-app
.
Aside from switching, I was referring to the logic for the math regarding contracts. For example, in client/src/redux/selectors/index.ts, lines 86-88:
// 1 contract of ETH is for 0.01 mXBT which is 1e-6 XBT
if (orderList.stop["symbol"] === "ETHUSD")
quantity *= 1e-6 * averageEntry ** 2;
To implement XRPUSD, similar math would have to be added.
Where ETHUSD is 0.001 mXBT per 1 USD XRPUSD is 0.0002 XBT per 1 USD
And 0.0002 XBT = 0.2 mXBT
I was thinking that just the calculation was the only thing that would be needed, in addition to referencing the instrument name as an option.
@sf52crypto
I was thinking that just the calculation was the only thing that would be needed, in addition to referencing the instrument name as an option.
Yes, all you need to do is to update some lines.
If you want, you can try to implement that yourself. If I am correct, you will need to change these things:
client/src/redux/selectors/index.ts, lines 86-88:
This is just for showing the average price. I'd recommend starting from those 2 main points above and then updating the selector.
I realize how poorly documented and structured some of my code is. It may be hard for someone new to try to understand it.
You can see that BitMEX API provides tickSize
for every ticker.
The best would be to fetch tickers on component mount and do averaging/rounding based on that.
The rounding is throwing me a bit.
XRPUSD is always 0.XXXX. I guess the real need for rounding is so that the UI can send a valid value in.
So if I have 0.2886 I want it to stay that way. But if I entered 0.28865, I'd need it to round to 0.2887 to be valid. In that case, the increment needs to be 10000.
Math.round(0.28865 * 10000) / 10000 = 0.2887
I think I understand what it's doing now. For ETHUSD, the decimal can be .n or .n5. Using the 20 in that formula makes it so that the hundreds position is rounded to 5 or 0 (and then truncated). Not what I was expecting. 289.13 will round the 3 to 5, and give 289.15 as expected. But 289.16 also returns 289.15. I expected it to round up to 289.2.
I tried changing it up, but it didn't work. Have to figure out the language syntax.
Wow, I actually got it to work once I got past compilation errors due to the syntax. I just noticed though that the avg price calculation is wrong. But I just successfully submitted 4 orders to scale into a buy on XRPUSD! :)
The risk and average price are not working yet, and will take some time to figure out.
Thanks for the pointers on getting XRP added. I still have oddities of the script language to figure out.
I will release v1.7.0 tomorrow with average price and risk using XRPUSD ticker. Don't worry about that.
Added XRPUSD ticker in v1.7.0
What would be involved to add XRPUSD to the list of available instruments?
I had looked at the code briefly, and it looks like the calculations are coded in, so any new instruments would require new calculations.