Comments (6)
range(10)は0〜9なので問題ないはずです
from arbitrage_crypto.
#!/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.
あっ、そうですね。10である意味も特にないので9にしときましょう
from arbitrage_crypto.
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.
こちらの方がスマートですね。しばらく動作確認してみて更新します。ありがとうございます。
from arbitrage_crypto.
コードを更新しました(あと出力をわかりやすいものにしました)。ご指摘ありがとうございます。
from arbitrage_crypto.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arbitrage_crypto.