New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GMO コイン用の DataStore を一部実装する #74
Conversation
自分がシストレで利用したいデータについて実装したものですので、現状 Public WebSocket の 「最新レート」「取引履歴」は未実装です。こちらは時間が取れた際に実装する気持ちはありますが、いつになるかわからないためひとまず現状できている部分で Pull Request を立てました。 |
注文情報についてPrivate WebSocket の注文情報通知チャンネルではなぜか注文がキャンセルされたことは検知できても約定したことは検知できない仕様になっているため(なぜそんな仕様に…?)、約定情報通知チャンネルのデータも用いて注文情報の更新・削除を行っています。 |
素晴らしい完成度のコードですね。本当にありがとうございます。 |
クラス設計の理解
|
MessageHelper の static メソッドは本当は各データ型自身( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@supermomonga
確認・テストを行いました。
いくつかSuggestionを出していますが、動かない箇所もあったので修正コードを書いてあります。
Suggestion内容に問題なければ修正コードをこちらでコミットしようかと思います。(Decimalの修正量が多かったので)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
もう一点追記します。
テストコード import asyncio
import pybotters
from rich.console import Console
console = Console()
async def main():
async with pybotters.Client(base_url='https://api.coin.z.com') as client:
# test for public websocket(板情報を1度表示する)
store = pybotters.GMOCoinDataStore()
console.rule('public')
wstask = await client.ws_connect(
'wss://api.coin.z.com/ws/public/v1',
send_json={'command': 'subscribe', 'channel': 'orderbooks', 'symbol': 'XRP_JPY'},
hdlr_json=store.onmessage,
)
while not len(store.orderbooks):
await store.orderbooks.wait()
console.print(store.orderbooks.sorted())
# test for initialize
store = pybotters.GMOCoinDataStore()
await store.initialize(
client.get('/private/v1/latestExecutions?symbol=XRP_JPY'),
client.get('/private/v1/activeOrders?symbol=XRP_JPY'),
client.get('/private/v1/openPositions?symbol=XRP_JPY'),
client.get('/private/v1/positionSummary?symbol=XRP_JPY'),
)
console.rule('initialize')
console.print(
{
'executions': store.executions.find(),
'orders': store.orders.find(),
'positions': store.positions.find(),
'position_summary': store.position_summary.find(),
}
)
# test for private websocket(無限ループ、Web画面で取引して確認する)
console.rule('private')
r = await client.post('/private/v1/ws-auth')
data = await r.json()
token = data['data']
wstask = await client.ws_connect(
f'wss://api.coin.z.com/ws/private/v1/{token}',
send_json=[
{'command': 'subscribe', 'channel': 'executionEvents'},
{'command': 'subscribe', 'channel': 'orderEvents'},
{'command': 'subscribe', 'channel': 'positionEvents'},
{'command': 'subscribe', 'channel': 'positionSummaryEvents'},
],
hdlr_json=store.onmessage,
)
while True:
console.print(
{
'executions': store.executions.find(),
'orders': store.orders.find(),
'positions': store.positions.find(),
'position_summary': store.position_summary.find(),
}
)
await store.wait()
try:
asyncio.run(main())
except KeyboardInterrupt:
pass |
レビューありがとうございます! |
また、 |
直接コミットしました。 しっかり動作してますね! |
あ、すみません通知見落としてました。大丈夫だと思います! |
✨v0.6.0リリース ## Issues ✅ 対応取引所の追加(Phemex、Coincheck) #52 ✅ GMO コインの DataStore を実装する #60 ✅ リリース表記をPreview版にする #73 ✅ FTXDataStore の orders チャネルにおける close されたオーダーの取り扱いについて #75 ✅ DataStoreInterfaceのクラス名を変更する #79 ## Pull requests ✅ GMO コイン用の DataStore を一部実装する #74 ✅ DataStore のレコード削除メソッドのサンプル実装 #76 ✅ DataStore の wait メソッドが変更されたデータを返す実装 #77 ✅ Sphinxのドキュメントを追加 #78
related: #60
TypedDict
として実装してあります。独自クラスではなくTypedDict
型を採用した理由は、現状データストアが取り扱うデータの型がDict[str, Any]
であるItem
であるため、既存データストアの実装を変更せずに互換性を持たせられるためです。(データの出し入れ時にItem
型とのcast
をしています)Optional
型になっています。