0
Follow
2
Followers
Ich habe fast 2 Monate mit FMZ gearbeitet, habe einige Strategien geführt, die gut sind, und ich habe das Gefühl, dass es notwendig ist, etwas für die Gemeinschaft zu leisten, wenn ich mir die Beispiele von Websocket anschaue.
Die Schnittstelle reagiert schneller als die von Rest in Strategien zur Absicherung von Arbitrage in mehreren Währungen, und wenn mehrere Währungen gleichzeitig gehandelt werden, ist der Unterschied groß.
python
#websocket 更新 行情
# {
# "e":"bookTicker", // 事件类型
# "u":400900217, // 更新ID
# "E": 1568014460893, // 事件推送时间
# "T": 1568014460891, // 撮合时间
# "s":"BNBUSDT", // 交易对
# "b":"25.35190000", // 买单最优挂单价格
# "B":"31.21000000", // 买单最优挂单数量
# "a":"25.36520000", // 卖单最优挂单价格
# "A":"40.66000000" // 卖单最优挂单数量
# }
def on_msg(msg) : #更新行情
if msg is not None and len(msg)>0:
bookTicker = json.loads(msg)
else:
# Log('book tick msg is none')
return
Log(bookTicker)
def main():
SetErrorFilter("502:|503:|tcp|character|unexpected|network|timeout|WSARecv|Connect|GetAddr|no such|reset|http|received|EOF|reused|Unknown")
trade_symbols = 'TRX,ZEC,DENT,BLZ,ENJ,ZIL,MANA,ONT,XMR,ICX,SC,THETA,CVC,BAT,STMX,VET,IOST,NEO,MTL,DASH,KNC,ZRX,IOTA'.split(',')
ary_symbol_streams = []
for i in range(len(trade_symbols)):
symbol = trade_symbols[i].lower()
stream_client = Dial(f"wss://fstream.binance.com/ws/{symbol}usdt@bookTicker|reconnect=true")
ary_symbol_streams.append(stream_client)
while (true):
for item in ary_symbol_streams:
#-2读取最新数据
msg = item.read(-2)
on_msg(msg)
Related Recommendations
How to Specify Different Versions of Data for the Rented Strategy by Its Rental Code MetadataAdvanced Tutorial for FMZ Quant platform Strategy WritingElementary Tutorial for FMZ Quant platform Strategy WritingGet Started with FMZ Quant PlatformSECURITY BUGI keep getting error: Exchange_GetAccount: Invalid ContractTypeWe have an incredibly profitable market making algorithm for sideways markets on Bitmex - but need expert to help eliminate wait times during downward volatility in the marketError with deribitLimitations of the backtesting engineHow to install ta-lib on linux docker?
Comment
All comments (4)
Dial("wss://stream.binance.com:9443/stream?streams=btcusdt@aggTrade/ethusdt@aggTrade/axsusdt@aggTrade/ltcusdt@aggTrade/dogeusdt@aggTrade|reconnect=true");
5 years ago
- 1

