Comments (13)
@egabosh No problem let us know if anything!
from ccxt.
Hello @egabosh,
Thanks for reporting it.
Just to make sure I understood, are you saying that if you made a buy
that impacted the short position (reducing it for instance), then the trade should contain sell
as the side?
from ccxt.
Moin @carlosmiei,
not quite. Sorry, I'll try to describe it again in more detail:
If I invest in a short position (buy), then Phemex sets “side”: “2”, which is interpreted by CCXT as “sell”.
However, Phemex also sets the variable “posSide”: “2”, which is set to 1 for a long trade.
Short is basically an inverse long. This therefore makes sense in terms of Phemex logic.
This does not seem to be taken into account in the CCXT processed output.
Therefore, in my opinion, it would be necessary in CCXT either to specify whether it is a long or short trade, which as far as I know is evident from “posSide”, or to switch sides in the case of a short trade.
Depending on what fits better in CCXT.
It would only be important for me to be able to recognize in the CCXT output whether it is a short or long trade, as otherwise misinterpretations would occur.
So currently the output of CCXT is incorrect because it is incomplete.
from ccxt.
@egabosh This is confusing me a bit
If I invest in a short position (buy)
Upon trading futures, we don't say we bought a short, we say you sold/shorted X amount of the Y contract, so usually we don't mix buy+short terminology
from ccxt.
The posSide in that case can be used for inferring if the trade increased/reduced the exposure of the position, but the side should still be sell
from ccxt.
The posSide in that case can be used for inferring if the trade increased/reduced the exposure of the position, but the side should still be
sell
Yes, exactly. It would only be important to know whether the trade is a short or a long trade.
fetchMyTrades() outputs all short and long trades and it is not clear from the CCXT output whether the trade in question is a short or long position.
This information is only available in the variable posSide (not to be confused with Side) provided by Phemex.
from ccxt.
@egabosh I'm afraid that information does not belong to trade
, a trade is a execution report and should state if that particular trade bought or sold some X amount of contracts, regardless of the position impacted.
from ccxt.
Without this information, I cannot recognize from the CCXT output whether I have opened a short or long position in the trade.
So whether I clicked on “Open Long” or “Open Short”.
See screenshot:
In the json output of phemex this is indicated by posSide.
So I need this information about the CCXT output.
from ccxt.
@egabosh That information should be available as you intend inside the Order
structure, but not in the Trade
from ccxt.
@carlosmiei OK. but then should the the side in CCXT be switched from "buy" to "sell" and "sell" to "buy" if Phemex posSide is 2 I think.
from ccxt.
@egabosh Now that I'm thinking, not sure if even in Order
we should apply that logic, because one buy
order can be used to shrink a short
position and one sell
order to shrink a buy
but the order was indeed a buy/sell
. I think you would have to use the Position
+ Order
to determine the impact the order had on your current position.
Besides that, upon placing the order, depending on the positionMode you know in advance if the order will impact the short/long leg, if you're in the one-way mode you can use things like reduceOnly
to ensure that the order produces the desired effect.
from ccxt.
@carlosmiei Ah. I'll give it some more thought but the more I think about it, I think you're right.
Sorry for the confusion.
from ccxt.
@egabosh That information should be available as you intend inside the
Order
structure, but not in theTrade
@carlosmiei: Didn't find the Information in any order got by fetch_orders() interpreted by CCXT too (only information is posSide from Phemex. Example:
"info": {
"createdAt": "1715818144087",
"symbol": "BTCUSDT",
"orderQtyRq": "0.01",
"side": "1",
"posSide": "2",
"priceRp": "75326.2",
"execQtyRq": "0.01",
"leavesQtyRq": "0",
"execPriceRp": "66573.7",
"orderValueRv": "665.737",
"leavesValueRv": "0",
"cumValueRv": "665.737",
"stopDirection": "1",
"stopPxRp": "66500",
"trigger": "1",
"actionBy": "4",
"execFeeRv": "0.36615535",
"ordType": "3",
"ordStatus": "7",
"clOrdId": "XXXXXXXXXXXXXXXX",
"orderId": "XXXXXXXXXXXXXXXX",
"execStatus": "7",
"bizError": "0",
"totalPnlRv": null,
"avgTransactPriceRp": null,
"orderDetailsVos": null,
"tradeType": "1",
"updatedAt": "1715818144091"
},
"id": "XXXXXXXXXXXXXXXX",
"clientOrderId": "XXXXXXXXXXXXXXXX",
"datetime": "2024-05-16T00:09:04.087Z",
"timestamp": 1715818144087,
"lastTradeTimestamp": null,
"symbol": "BTC/USDT:USDT",
"type": null,
"timeInForce": null,
"postOnly": false,
"reduceOnly": null,
"side": "buy",
"price": 75326.2,
"stopPrice": 66500,
"triggerPrice": 66500,
"takeProfitPrice": null,
"stopLossPrice": null,
"amount": 0.01,
"filled": 0.01,
"remaining": 0,
"cost": 665.737,
"average": 66573.7,
"status": "closed",
"fee": null,
"trades": [],
"fees": [],
"lastUpdateTimestamp": null
from ccxt.
Related Issues (20)
- Hyperliquid - Couple of issues with fetch_(orders?|closed_orders|open_orders) HOT 7
- [Indodax] Cannot post limit order since 4.3.86 HOT 1
- fetchLedger Returning 404 Error on Bybit Subaccount (Standard Account, Not UTA) HOT 9
- OKX swap order uses currency size instead of contract size HOT 1
- how to disable account status check for kucoin hf trade HOT 4
- binance new unsub method forgets to decrease numSubscriptions HOT 3
- Hyperliquid - Incorrect symbol in fetch_my_trades() HOT 3
- Kraken - fetch_open_orders returns [] HOT 10
- Issue with OKX and Bitget MATIC futures HOT 4
- binance: fetch_funding_rate_history return [] value HOT 4
- Gateio futures does not work with CCXT Pro HOT 8
- Bybit bad symbol `NEIROETHUSDT` HOT 2
- crypto.com access denied HOT 5
- hyperliquid unable to use/debug "set_margin_mode" and "set_leverage" HOT 9
- GateIO Futures - Time/bid/ask is not saved in watch_tickers (also bid, ask). HOT 2
- New Exchange: Biconomy CEX - https://www.biconomy.com/en
- New Exchange: KoinBX CEX - https://koinbx.com/ HOT 1
- bitget .markets doesn't include margin markets HOT 1
- Error: self is not defined in Deno HOT 4
- Bitmart bid or ask getting stuck
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ccxt.