[Feature request] support to record "Market price" or "index" in bitmex
seems they are terribly out of line when things get funny
message: {'table': 'instrument', 'action': 'partial', 'keys': ['symbol'], 'types': {'symbol': 'symbol', 'rootSymbol': 'symbol', 'state': 'symbol', 'typ': 'symbol', 'listing': 'timestamp', 'front': 'timestamp', 'expiry': 'timestamp', 'settle': 'timestamp', 'relistInterval': 'timespan', 'inverseLeg': 'symbol', 'sellLeg': 'symbol', 'buyLeg': 'symbol', 'optionStrikePcnt': 'float', 'optionStrikeRound': 'float', 'optionStrikePrice': 'float', 'optionMultiplier': 'float', 'positionCurrency': 'symbol', 'underlying': 'symbol', 'quoteCurrency': 'symbol', 'underlyingSymbol': 'symbol', 'reference': 'symbol', 'referenceSymbol': 'symbol', 'calcInterval': 'timespan', 'publishInterval': 'timespan', 'publishTime': 'timespan', 'maxOrderQty': 'long', 'maxPrice': 'float', 'lotSize': 'long', 'tickSize': 'float', 'multiplier': 'long', 'settlCurrency': 'symbol', 'underlyingToPositionMultiplier': 'long', 'underlyingToSettleMultiplier': 'long', 'quoteToSettleMultiplier': 'long', 'isQuanto': 'boolean', 'isInverse': 'boolean', 'initMargin': 'float', 'maintMargin': 'float', 'riskLimit': 'long', 'riskStep': 'long', 'limit': 'float', 'capped': 'boolean', 'taxed': 'boolean', 'deleverage': 'boolean', 'makerFee': 'float', 'takerFee': 'float', 'settlementFee': 'float', 'insuranceFee': 'float', 'fundingBaseSymbol': 'symbol', 'fundingQuoteSymbol': 'symbol', 'fundingPremiumSymbol': 'symbol', 'fundingTimestamp': 'timestamp', 'fundingInterval': 'timespan', 'fundingRate': 'float', 'indicativeFundingRate': 'float', 'rebalanceTimestamp': 'timestamp', 'rebalanceInterval': 'timespan', 'openingTimestamp': 'timestamp', 'closingTimestamp': 'timestamp', 'sessionInterval': 'timespan', 'prevClosePrice': 'float', 'limitDownPrice': 'float', 'limitUpPrice': 'float', 'bankruptLimitDownPrice': 'float', 'bankruptLimitUpPrice': 'float', 'prevTotalVolume': 'long', 'totalVolume': 'long', 'volume': 'long', 'volume24h': 'long', 'prevTotalTurnover': 'long', 'totalTurnover': 'long', 'turnover': 'long', 'turnover24h': 'long', 'homeNotional24h': 'float', 'foreignNotional24h': 'float', 'prevPrice24h': 'float', 'vwap': 'float', 'highPrice': 'float', 'lowPrice': 'float', 'lastPrice': 'float', 'lastPriceProtected': 'float', 'lastTickDirection': 'symbol', 'lastChangePcnt': 'float', 'bidPrice': 'float', 'midPrice': 'float', 'askPrice': 'float', 'impactBidPrice': 'float', 'impactMidPrice': 'float', 'impactAskPrice': 'float', 'hasLiquidity': 'boolean', 'openInterest': 'long', 'openValue': 'long', 'fairMethod': 'symbol', 'fairBasisRate': 'float', 'fairBasis': 'float', 'fairPrice': 'float', 'markMethod': 'symbol', 'markPrice': 'float', 'indicativeTaxRate': 'float', 'indicativeSettlePrice': 'float', 'optionUnderlyingPrice': 'float', 'settledPrice': 'float', 'timestamp': 'timestamp'}, 'foreignKeys': {'inverseLeg': 'instrument', 'sellLeg': 'instrument', 'buyLeg': 'instrument'}, 'attributes': {'symbol': 'unique'}, 'filter': {'symbol': '.BXBT'}, 'data': [{'symbol': '.BXBT', 'rootSymbol': 'XBT', 'state': 'Unlisted', 'typ': 'MRCXXX', 'listing': None, 'front': None, 'expiry': None, 'settle': None, 'relistInterval': None, 'inverseLeg': '', 'sellLeg': '', 'buyLeg': '', 'optionStrikePcnt': None, 'optionStrikeRound': None, 'optionStrikePrice': None, 'optionMultiplier': None, 'positionCurrency': '', 'underlying': 'XBT', 'quoteCurrency': 'USD', 'underlyingSymbol': 'XBT=', 'reference': 'BMI', 'referenceSymbol': '.BXBT', 'calcInterval': None, 'publishInterval': '2000-01-01T00:01:00.000Z', 'publishTime': None, 'maxOrderQty': None, 'maxPrice': None, 'lotSize': None, 'tickSize': 0.01, 'multiplier': None, 'settlCurrency': '', 'underlyingToPositionMultiplier': None, 'underlyingToSettleMultiplier': None, 'quoteToSettleMultiplier': None, 'isQuanto': False, 'isInverse': False, 'initMargin': None, 'maintMargin': None, 'riskLimit': None, 'riskStep': None, 'limit': None, 'capped': False, 'taxed': False, 'deleverage': False, 'makerFee': None, 'takerFee': None, 'settlementFee': None, 'insuranceFee': None, 'fundingBaseSymbol': '', 'fundingQuoteSymbol': '', 'fundingPremiumSymbol': '', 'fundingTimestamp': None, 'fundingInterval': None, 'fundingRate': None, 'indicativeFundingRate': None, 'rebalanceTimestamp': None, 'rebalanceInterval': None, 'openingTimestamp': None, 'closingTimestamp': None, 'sessionInterval': None, 'prevClosePrice': None, 'limitDownPrice': None, 'limitUpPrice': None, 'bankruptLimitDownPrice': None, 'bankruptLimitUpPrice': None, 'prevTotalVolume': None, 'totalVolume': None, 'volume': None, 'volume24h': None, 'prevTotalTurnover': None, 'totalTurnover': None, 'turnover': None, 'turnover24h': None, 'homeNotional24h': None, 'foreignNotional24h': None, 'prevPrice24h': 7375.39, 'vwap': None, 'highPrice': None, 'lowPrice': None, 'lastPrice': 5495.4, 'lastPriceProtected': None, 'lastTickDirection': 'PlusTick', 'lastChangePcnt': -0.2549, 'bidPrice': None, 'midPrice': None, 'askPrice': None, 'impactBidPrice': None, 'impactMidPrice': None, 'impactAskPrice': None, 'hasLiquidity': False, 'openInterest': None, 'openValue': 0, 'fairMethod': '', 'fairBasisRate': None, 'fairBasis': None, 'fairPrice': None, 'markMethod': 'LastPrice', 'markPrice': 5495.4, 'indicativeTaxRate': None, 'indicativeSettlePrice': None, 'optionUnderlyingPrice': None, 'settledPrice': None, 'timestamp': '2020-03-13T08:01:35.000Z'}]}
message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5496.61, 'lastChangePcnt': -0.2547, 'markPrice': 5496.61, 'timestamp': '2020-03-13T08:01:40.000Z'}]}
message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5508.47, 'lastChangePcnt': -0.2531, 'markPrice': 5508.47, 'timestamp': '2020-03-13T08:01:50.000Z'}]}
message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5504.58, 'lastChangePcnt': -0.2537, 'markPrice': 5504.58, 'timestamp': '2020-03-13T08:01:55.000Z'}]}
message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5509.93, 'lastChangePcnt': -0.2529, 'markPrice': 5509.93, 'timestamp': '2020-03-13T08:02:00.000Z'}]}
message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'prevPrice24h': 7370.21, 'lastChangePcnt': -0.2524, 'timestamp': '2020-03-13T08:02:00.000Z'}]}
message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5525.08, 'lastChangePcnt': -0.2503, 'markPrice': 5525.08, 'timestamp': '2020-03-13T08:02:05.000Z'}]}
How did you get .BXBT through Crytpofeed?
I'm still not able to get this data through cryptofeed
How did you get .BXBT through Crytpofeed?
You can get the .BXBT stream through the TRADES channel (obviously pushed every 1 minute):
f.add_feed(Bitmex(channels=[TRADES], pairs=['.BXBT'], callbacks={TRADES: TradeCallback(trade)}))
If you want the mark price check the implementation for open_interest. It's the same instrument/ endpoint.
How did you get .BXBT through Crytpofeed?
You can get the .BXBT stream through the trades feed (obviously pushed every 1 minute):
f.add_feed(Bitmex(channels=[TRADES], pairs=['.BXBT'], callbacks={TRADES: TradeCallback(trade)}))If you want the mark price check the implementation for open_interest. It's the same instrument/ endpoint.
I imagine that's the terminal command to modify the config file? I'll try it out, thanks! I haven't been able to find the open_interest implementation either, would you be so kind to provide a link or a screenshot? Thank you!
This should be the whole code to print .BXBT stream to the console
from cryptofeed.callback import TradeCallback
from cryptofeed import FeedHandler
from cryptofeed.exchanges import Bitmex
from cryptofeed.defines import TRADES
async def index(feed, pair, side, amount, price, order_id, timestamp, receipt_timestamp):
print(feed, pair, side, amount, price, order_id, timestamp, receipt_timestamp)
def main():
f = FeedHandler()
f.add_feed(Bitmex(channels=[TRADES], pairs=['.BXBT'], callbacks={TRADES: TradeCallback(index)}))
f.run()
if __name__ == '__main__':
main()
Sorry I was referring to this line https://github.com/bmoscon/cryptofeed/blob/fa87eeed37c751ae77b8578cebaa15684cde001e/cryptofeed/exchange/bitmex.py#L438
In the 2nd post above you can see a lot of information, currently only the 'openInterest' key is used in the code. Adding 'markPrice', 'volume' etc. should be straight forward.
message: {'table': 'instrument', 'action': 'partial', 'keys': ['symbol'], 'types': {'symbol': 'symbol', 'rootSymbol': 'symbol', 'state': 'symbol', 'typ': 'symbol', 'listing': 'timestamp', 'front': 'timestamp', 'expiry': 'timestamp', 'settle': 'timestamp', 'relistInterval': 'timespan', 'inverseLeg': 'symbol', 'sellLeg': 'symbol', 'buyLeg': 'symbol', 'optionStrikePcnt': 'float', 'optionStrikeRound': 'float', 'optionStrikePrice': 'float', 'optionMultiplier': 'float', 'positionCurrency': 'symbol', 'underlying': 'symbol', 'quoteCurrency': 'symbol', 'underlyingSymbol': 'symbol', 'reference': 'symbol', 'referenceSymbol': 'symbol', 'calcInterval': 'timespan', 'publishInterval': 'timespan', 'publishTime': 'timespan', 'maxOrderQty': 'long', 'maxPrice': 'float', 'lotSize': 'long', 'tickSize': 'float', 'multiplier': 'long', 'settlCurrency': 'symbol', 'underlyingToPositionMultiplier': 'long', 'underlyingToSettleMultiplier': 'long', 'quoteToSettleMultiplier': 'long', 'isQuanto': 'boolean', 'isInverse': 'boolean', 'initMargin': 'float', 'maintMargin': 'float', 'riskLimit': 'long', 'riskStep': 'long', 'limit': 'float', 'capped': 'boolean', 'taxed': 'boolean', 'deleverage': 'boolean', 'makerFee': 'float', 'takerFee': 'float', 'settlementFee': 'float', 'insuranceFee': 'float', 'fundingBaseSymbol': 'symbol', 'fundingQuoteSymbol': 'symbol', 'fundingPremiumSymbol': 'symbol', 'fundingTimestamp': 'timestamp', 'fundingInterval': 'timespan', 'fundingRate': 'float', 'indicativeFundingRate': 'float', 'rebalanceTimestamp': 'timestamp', 'rebalanceInterval': 'timespan', 'openingTimestamp': 'timestamp', 'closingTimestamp': 'timestamp', 'sessionInterval': 'timespan', 'prevClosePrice': 'float', 'limitDownPrice': 'float', 'limitUpPrice': 'float', 'bankruptLimitDownPrice': 'float', 'bankruptLimitUpPrice': 'float', 'prevTotalVolume': 'long', 'totalVolume': 'long', 'volume': 'long', 'volume24h': 'long', 'prevTotalTurnover': 'long', 'totalTurnover': 'long', 'turnover': 'long', 'turnover24h': 'long', 'homeNotional24h': 'float', 'foreignNotional24h': 'float', 'prevPrice24h': 'float', 'vwap': 'float', 'highPrice': 'float', 'lowPrice': 'float', 'lastPrice': 'float', 'lastPriceProtected': 'float', 'lastTickDirection': 'symbol', 'lastChangePcnt': 'float', 'bidPrice': 'float', 'midPrice': 'float', 'askPrice': 'float', 'impactBidPrice': 'float', 'impactMidPrice': 'float', 'impactAskPrice': 'float', 'hasLiquidity': 'boolean', 'openInterest': 'long', 'openValue': 'long', 'fairMethod': 'symbol', 'fairBasisRate': 'float', 'fairBasis': 'float', 'fairPrice': 'float', 'markMethod': 'symbol', 'markPrice': 'float', 'indicativeTaxRate': 'float', 'indicativeSettlePrice': 'float', 'optionUnderlyingPrice': 'float', 'settledPrice': 'float', 'timestamp': 'timestamp'}, 'foreignKeys': {'inverseLeg': 'instrument', 'sellLeg': 'instrument', 'buyLeg': 'instrument'}, 'attributes': {'symbol': 'unique'}, 'filter': {'symbol': '.BXBT'}, 'data': [{'symbol': '.BXBT', 'rootSymbol': 'XBT', 'state': 'Unlisted', 'typ': 'MRCXXX', 'listing': None, 'front': None, 'expiry': None, 'settle': None, 'relistInterval': None, 'inverseLeg': '', 'sellLeg': '', 'buyLeg': '', 'optionStrikePcnt': None, 'optionStrikeRound': None, 'optionStrikePrice': None, 'optionMultiplier': None, 'positionCurrency': '', 'underlying': 'XBT', 'quoteCurrency': 'USD', 'underlyingSymbol': 'XBT=', 'reference': 'BMI', 'referenceSymbol': '.BXBT', 'calcInterval': None, 'publishInterval': '2000-01-01T00:01:00.000Z', 'publishTime': None, 'maxOrderQty': None, 'maxPrice': None, 'lotSize': None, 'tickSize': 0.01, 'multiplier': None, 'settlCurrency': '', 'underlyingToPositionMultiplier': None, 'underlyingToSettleMultiplier': None, 'quoteToSettleMultiplier': None, 'isQuanto': False, 'isInverse': False, 'initMargin': None, 'maintMargin': None, 'riskLimit': None, 'riskStep': None, 'limit': None, 'capped': False, 'taxed': False, 'deleverage': False, 'makerFee': None, 'takerFee': None, 'settlementFee': None, 'insuranceFee': None, 'fundingBaseSymbol': '', 'fundingQuoteSymbol': '', 'fundingPremiumSymbol': '', 'fundingTimestamp': None, 'fundingInterval': None, 'fundingRate': None, 'indicativeFundingRate': None, 'rebalanceTimestamp': None, 'rebalanceInterval': None, 'openingTimestamp': None, 'closingTimestamp': None, 'sessionInterval': None, 'prevClosePrice': None, 'limitDownPrice': None, 'limitUpPrice': None, 'bankruptLimitDownPrice': None, 'bankruptLimitUpPrice': None, 'prevTotalVolume': None, 'totalVolume': None, 'volume': None, 'volume24h': None, 'prevTotalTurnover': None, 'totalTurnover': None, 'turnover': None, 'turnover24h': None, 'homeNotional24h': None, 'foreignNotional24h': None, 'prevPrice24h': 7375.39, 'vwap': None, 'highPrice': None, 'lowPrice': None, 'lastPrice': 5495.4, 'lastPriceProtected': None, 'lastTickDirection': 'PlusTick', 'lastChangePcnt': -0.2549, 'bidPrice': None, 'midPrice': None, 'askPrice': None, 'impactBidPrice': None, 'impactMidPrice': None, 'impactAskPrice': None, 'hasLiquidity': False, 'openInterest': None, 'openValue': 0, 'fairMethod': '', 'fairBasisRate': None, 'fairBasis': None, 'fairPrice': None, 'markMethod': 'LastPrice', 'markPrice': 5495.4, 'indicativeTaxRate': None, 'indicativeSettlePrice': None, 'optionUnderlyingPrice': None, 'settledPrice': None, 'timestamp': '2020-03-13T08:01:35.000Z'}]} message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5496.61, 'lastChangePcnt': -0.2547, 'markPrice': 5496.61, 'timestamp': '2020-03-13T08:01:40.000Z'}]} message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5508.47, 'lastChangePcnt': -0.2531, 'markPrice': 5508.47, 'timestamp': '2020-03-13T08:01:50.000Z'}]} message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5504.58, 'lastChangePcnt': -0.2537, 'markPrice': 5504.58, 'timestamp': '2020-03-13T08:01:55.000Z'}]} message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5509.93, 'lastChangePcnt': -0.2529, 'markPrice': 5509.93, 'timestamp': '2020-03-13T08:02:00.000Z'}]} message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'prevPrice24h': 7370.21, 'lastChangePcnt': -0.2524, 'timestamp': '2020-03-13T08:02:00.000Z'}]} message: {'table': 'instrument', 'action': 'update', 'data': [{'symbol': '.BXBT', 'lastPrice': 5525.08, 'lastChangePcnt': -0.2503, 'markPrice': 5525.08, 'timestamp': '2020-03-13T08:02:05.000Z'}]}
Thank you!