Forex API
メジャー、マイナー、エキゾチックを含む 50+ の通貨ペアに Tick レベルの相場情報を提供します。
1 つの WebSocket・REST API で、Tick レベルの Forex、Crypto、Stock、Commodity、Index データを配信します。営業担当との通話なしで、数秒で無料キーを取得できます。
| シンボル | 資産クラス | 価格 | 直近変動 |
|---|---|---|---|
| EUR/USD 外国為替ユーロ / 米ドル | 外国為替 | - | - |
| BTC/USDT 暗号資産ビットコイン | 暗号資産 | - | - |
| ETH/USDT 暗号資産イーサリアム | 暗号資産 | - | - |
| AAPL 株式Apple Inc. | 株式 | - | - |
| XAU/USD コモディティ金スポット | コモディティ | - | - |
| USD/JPY 外国為替米ドル / 円 | 外国為替 | - | - |
| NVDA 株式NVIDIA Corp. | 株式 | - | - |
| SPX 指数S&P 500 指数 | 指数 | - | - |
AllTick がカバーするすべての市場を、同じ統一 REST と WebSocket インターフェースから利用できます。
メジャー、マイナー、エキゾチックを含む 50+ の通貨ペアに Tick レベルの相場情報を提供します。
リアルタイムの現物・デリバティブデータを、1 つの配信に正規化します。
米国、香港、中国本土市場の株式について、約定と相場情報を提供します。
貴金属とエネルギーのリアルタイム価格を提供します。
主要なグローバル指数のベンチマーク値と構成銘柄を提供します。
AllTick の各市場について、対応範囲、レイテンシー、データ種別を比較します。
製品を見るAllTick と一般的な従来型市場データベンダーを比較します。
| 機能 | AllTick | 一般的な従来型ベンダー |
|---|---|---|
| WebSocket レイテンシー中央値 | 約 150ms | 400–800ms |
| 1 つの API に含まれる資産クラス | 5(FX、Crypto、Stock、Commodities、Indices) | 1–2 |
| 稼働率 SLA | 99.95% | 99.5% またはなし |
| 無料枠 | あり — API キーを即時発行 | 営業担当との通話が必要 |
| WebSocket ストリーミング | ネイティブ | ポーリング / 制限あり |
WebSocket に接続し、あらゆる市場の任意のシンボルを購読できます。
# AllTick realtime financial data API
# forex crypto stock commodities indices
import asyncio, json, uuid
import websockets
subscribe = {
"cmd_id": 22004,
"seq_id": 1,
"trace": str(uuid.uuid4()),
"data": {"symbol_list": [{"code": "EURUSD"}]},
}
heartbeat = {"cmd_id": 22000, "seq_id": 1, "trace": "heartbeat", "data": {}}
async def stream():
uri = "wss://quote.alltick.co/quote-b-ws-api?token=YOUR_API_KEY"
async with websockets.connect(uri) as socket:
await socket.send(json.dumps(subscribe))
async def keep_alive():
while True:
await asyncio.sleep(10)
await socket.send(json.dumps(heartbeat))
asyncio.create_task(keep_alive())
async for message in socket:
print(json.loads(message))
asyncio.run(stream())Crypto の対応範囲を広げながら、市場データコストを 60% 削減。
“AllTick への移行により、3 社のベンダーを 1 つの WebSocket 配信に統合し、取引アプリを 1 四半期早くリリースできました。”導入事例を読む
200ms 未満の相場情報更新で 4 万人の同時接続ユーザーに対応。
“99.95% SLA と安定したレイテンシーは、当社のリテールブローカーがグローバル展開するためにまさに必要なものでした。”導入事例を読む
5 資産クラスにわたる 12 年分の Tick データをバックテスト。
“1 つの正規化 API から履歴データとリアルタイムデータを取得でき、数週間分のデータエンジニアリング作業が不要になりました。”導入事例を読む
市場データエンジニアリング、ストリーミング API、低遅延金融アプリケーション構築に関する実践的な記事です。
この記事では、Pythonを使用して事前パッケージ化された高頻度データAPIを呼び出す方法を紹介します。ここでは、Alltickのティックデータインターフェースを例として使用します。以下はサンプルコードの一部です。
import time
import requests
import json
# Extra headers
test_headers = {
'Content-Type':'application/json'
}
'''
github:https://github.com/alltick/realtime-forex-crypto-stock-tick-finance-websocket-api
{"trace":"python_http_test1","data":{"code":"AAPL.US","kline_type":1,"kline_timestamp_end":0,"query_kline_num":2,"adjust_type":0}}
'''
test_url1 = 'https://quote.alltick.io/quote-stock-b-api/kline?token=e945d7d9-9e6e-4721-922a-7251a9d311d0-1678159756806&query=%7B%22trace%22%3A%22python_http_test1%22%2C%22data%22%3A%7B%22code%22%3A%22AAPL.US%22%2C%22kline_type%22%3A1%2C%22kline_timestamp_end%22%3A0%2C%22query_kline_num%22%3A2%2C%22adjust_type%22%3A0%7D%7D'
resp1 = requests.get(url=test_url1, headers=test_headers)
# Decoded text returned by the request
text1 = resp1.text
print(text1)
上記のコードでは、Apple株(AAPL.US)を例にして、1分単位のKラインデータをリクエストしています。他のKラインタイプをリクエストする場合は、kline_typeに以下の値を渡します:
1 – 1分、2 – 5分、3 – 15分、4 – 30分、
5 – 1時間、6 – 2時間、7 – 4時間、8 – 日次、
9 – 週次、10 – 月次。
import time
import requests
import json
# Extra headers
test_headers = {
'Content-Type':'application/json'
}
'''
github:https://github.com/alltick/realtime-forex-crypto-stock-tick-finance-websocket-api
{"trace":"python_http_test2","data":{"symbol_list":[{"code": "700.HK"},{"code": "UNH.US"},{"code": "600416.SH"}]}}
'''
test_url1 = 'https://quote.alltick.io/quote-stock-b-api/trade-tick?token=e945d7d9-9e6e-4721-922a-7251a9d311d0-1678159756806&query=%7B%22trace%22%3A%22python_http_test2%22%2C%22data%22%3A%7B%22symbol_list%22%3A%5B%7B%22code%22%3A%20%22700.HK%22%7D%2C%7B%22code%22%3A%20%22UNH.US%22%7D%2C%7B%22code%22%3A%20%22600416.SH%22%7D%5D%7D%7D'
resp1 = requests.get(url=test_url1, headers=test_headers)
# Decoded text returned by the request
text1 = resp1.text
print(text1)
この例では、symbol_listには複数のシンボルを含めることができ、異なる市場の製品も含めることができます。
import time
import requests
import json
# Extra headers
test_headers = {
'Content-Type':'application/json'
}
'''
github:https://github.com/alltick/realtime-forex-crypto-stock-tick-finance-websocket-api
{"trace":"python_http_test2","data":{"symbol_list":[{"code": "700.HK"},{"code": "UNH.US"},{"code": "600416.SH"}]}}
'''
test_url1 = 'https://quote.alltick.io/quote-stock-b-api/depth-tick?token=e945d7d9-9e6e-4721-922a-7251a9d311d0-1678159756806&query=%7B%22trace%22%3A%22python_http_test2%22%2C%22data%22%3A%7B%22symbol_list%22%3A%5B%7B%22code%22%3A%20%22700.HK%22%7D%2C%7B%22code%22%3A%20%22UNH.US%22%7D%2C%7B%22code%22%3A%20%22600416.SH%22%7D%5D%7D%7D'
resp1 = requests.get(url=test_url1, headers=test_headers)
# Decoded text returned by the request
text1 = resp1.text
print(text1)
同様に、symbol_listは複数のエントリをサポートしています。
import json
import websocket # pip install websocket-client
class Feed(object):
def __init__(self):
self.url = 'wss://quote.alltick.io/quote-stock-b-ws-api?token=e945d7d9-9e6e-4721-922a-7251a9d311d0-1678159756806'
self.ws = None
def on_open(self, ws):
"""
Callback object which is called at opening websocket.
1 argument:
@ ws: the WebSocketApp object
"""
print('A new WebSocketApp is opened!')
sub_param = {
"cmd_id": 22002,
"seq_id": 123,
"trace":"3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
"data":{
"symbol_list":[
{
"code": "700.HK",
"depth_level": 5,
},
{
"code": "UNH.US",
"depth_level": 5,
},
{
"code": "600416.SH",
"depth_level": 5,
}
]
}
}
sub_str = json.dumps(sub_param)
ws.send(sub_str)
print("depth quote are subscribed!")
def on_data(self, ws, string, type, continue_flag):
"""
4 argument.
The 1st argument is this class object.
The 2nd argument is utf-8 string which we get from the server.
The 3rd argument is data type. ABNF.OPCODE_TEXT or ABNF.OPCODE_BINARY will be came.
The 4th argument is continue flag. If 0, the data continue
"""
def on_message(self, ws, message):
"""
Callback object which is called when received data.
2 arguments:
@ ws: the WebSocketApp object
@ message: utf-8 data received from the server
"""
result = eval(message)
print(result)
def on_error(self, ws, error):
"""
Callback object which is called when got an error.
2 arguments:
@ ws: the WebSocketApp object
@ error: exception object """ print(error) def on_close(self, ws, close_status_code, close_msg): """ Callback object which is called when the connection is closed. 2 arguments: @ ws: the WebSocketApp object @ close_status_code @ close_msg """ print('The connection is closed!') def start(self): self.ws = websocket.WebSocketApp( self.url, on_open=self.on_open, on_message=self.on_message, on_data=self.on_data, on_error=self.on_error, on_close=self.on_close, ) self.ws.run_forever() if __name__ == "__main__": feed = Feed() feed.start()