Giter Club home page Giter Club logo

Comments (6)

algori11 avatar algori11 commented on September 15, 2024

range(10)は0〜9なので問題ないはずです

from arbitrage_crypto.

octaltree avatar octaltree commented on September 15, 2024
#!/usr/bin/env python
idx = [0, 0, 0]
arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] # 長さ10の任意のリスト
for i in range(10):
    idx[0] += 1
    print(arr[idx[0]])
b
c
d
e
f
g
h
i
j
Traceback (most recent call last):
  File "foo.py", line 6, in <module>
    print(arr[idx[0]])
IndexError: list index out of range

こうなりませんか?

from arbitrage_crypto.

algori11 avatar algori11 commented on September 15, 2024

あっ、そうですね。10である意味も特にないので9にしときましょう

from arbitrage_crypto.

octaltree avatar octaltree commented on September 15, 2024

9にするのでも良いのですが,
初期化では無い処理をループに入れたこの形のが私は好きです.
雑に変えたので間違ってるかもしれません. 参考程度に

idx = np.zeros(3).astype(int)

amount1 = np.cumsum(ask1[:, 1] * ask2[-1][0])
amount2 = np.cumsum(ask2[:, 1])
amount3 = np.cumsum(bid3[:, 1])

ratio = 0
value = 0

for i in range(10):
    new_ratio = (
        bid3[:, 0][idx[2]] / (ask1[:, 0][idx[0]] * ask2[:, 0][idx[1]]))
    if new_ratio < threshold:
        break
    ratio = new_ratio
    value = np.min([amount1[idx[0]], amount2[idx[1]], amount3[idx[2]]])
    idx[np.argmin([
        amount1[idx[0]], amount2[idx[1]], amount3[idx[2]]])] += 1
return (ratio, value)

from arbitrage_crypto.

algori11 avatar algori11 commented on September 15, 2024

こちらの方がスマートですね。しばらく動作確認してみて更新します。ありがとうございます。

from arbitrage_crypto.

algori11 avatar algori11 commented on September 15, 2024

コードを更新しました(あと出力をわかりやすいものにしました)。ご指摘ありがとうございます。

from arbitrage_crypto.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.