Skip to content
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

Redesign GMOCoin DataStore #249

Merged
merged 5 commits into from Jan 8, 2024
Merged

Redesign GMOCoin DataStore #249

merged 5 commits into from Jan 8, 2024

Conversation

MtkN1
Copy link
Member

@MtkN1 MtkN1 commented Jan 8, 2024

Summary

GMO コインのデータストアは #74 のコントリビュートによって実装されました。

しかし、ストア内のデータが他と違って型付きの Python クラスベースで定義されています。 単純に JSON をパースしたデータと比べて型が有効などのメリットもありますが、GMO コインの銘柄が追加された際にそれに追随するのに pybotters のアップデートが必要だったり、ユーザーの使い勝手が異なるなどの問題が生じていました。

この PR では従来版 GMOCoinDataStore クラスをインポートパスから削除して、従来の設計方針で実装したクラスを pybotters.GMOCoinDataStore に置き換えます。

Changes

  • 🚨 Breaking changes: pybotters.GMOCoinDataStore はストア内のデータ型がクラスベースから JSON ベースになり、キー名がスネークケースに変換されていたものから GMO コインドキュメントに記載されている文字列をそのままの値で格納されます
    • ティッカーストアの例: (データ型の変更)
      # legacy
      {
          'ask': Decimal('6484170'),
          'bid': Decimal('6481482'),
          'high': Decimal('6535603'),
          'last': Decimal('6481889'),
          'low': Decimal('6256694'),
          'symbol': <Symbol.BTC_JPY: 24>,
          'timestamp': datetime.datetime(2024, 1, 8, 13, 49, 0, 31000),
          'volume': Decimal('1877.89')
      }
      # new
      {
          'channel': 'ticker',
          'ask': '6492347',
          'bid': '6489767',
          'high': '6535603',
          'last': '6490200',
          'low': '6256694',
          'symbol': 'BTC_JPY',
          'timestamp': '2024-01-08T13:47:46.410Z',
          'volume': '1875.45'
      }
    • ポジションサマリーストアの例: (スネークケース -> キャメルケースの変更)
      # legacy
      {
          'symbol': <Symbol.XRP_JPY: 28>,
          'side': <OrderSide.BUY: 1>,
          'average_position_rate': Decimal('81.535'),
          'position_loss_gain': Decimal('-1'),
          'sum_order_quantity': Decimal('0'),
          'sum_position_quantity': Decimal('10'),
          'timestamp': datetime.datetime(2024, 1, 8, 13, 54, 31, 243000)
      }
      # new
      {
          'averagePositionRate': '81.535',
          'channel': 'positionSummaryEvents',
          'msgType': 'INIT',
          'positionLossGain': '-1',
          'side': 'BUY',
          'sumOrderQuantity': '0',
          'sumPositionQuantity': '10',
          'symbol': 'XRP_JPY',
          'timestamp': '2024-01-08T13:56:31.348Z'
      }
  • GMOCoinDataStore の API (メソッド名などのこと) の変更はありせん
  • 非推奨となる GMOCoinDataStore はトップレベルのインポートパスから削除され pybotters.models.legacy.gmocoin にモジュールが移動されます
    # レガシー版のインポート方法
    from pybotters.models.legacy.gmocoin import GMOCoinDataStore

@MtkN1 MtkN1 self-assigned this Jan 8, 2024
@MtkN1 MtkN1 merged commit dbf025b into main Jan 8, 2024
11 checks passed
@MtkN1 MtkN1 deleted the redesign-gmocoin-datastore branch January 8, 2024 14:11
@MtkN1 MtkN1 mentioned this pull request Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant