У нас есть этот код:
import pandas as pd
depth = {"lastUpdateId":{"0":121305065,"1":121305065,"2":121305065,"3":121305065,"4":121305065,"5":121305065,"6":121305065,"7":121305065,"8":121305065,"9":121305065},"bids":{"0":["0.00152230","8.12000000",[]],"1":["0.00152220","15.74000000",[]],"2":["0.00152210","102.00000000",[]],"3":["0.00152200","59.61000000",[]],"4":["0.00152110","4.44000000",[]],"5":["0.00152100","7.00000000",[]],"6":["0.00152090","165.20000000",[]],"7":["0.00152060","1.92000000",[]],"8":["0.00152030","0.72000000",[]],"9":["0.00152020","267.36000000",[]]},"asks":{"0":["0.00152330","9.86000000",[]],"1":["0.00152460","13.73000000",[]],"2":["0.00152470","109.14000000",[]],"3":["0.00152480","55.54000000",[]],"4":["0.00152500","5.24000000",[]],"5":["0.00152520","5.00000000",[]],"6":["0.00152530","137.45000000",[]],"7":["0.00152550","20.63000000",[]],"8":["0.00152770","892.00000000",[]],"9":["0.00152780","267.36000000",[]]}}
depthdf = pd.DataFrame(depth)
depthdf["CummBidsUSD"] = "??"
depthdf["CummAsksUSD"] = "??"
USDprice = 7000
print(depthdf)
Возвращая это:
lastUpdateId bids asks CummBidsUSD CummAsksUSD
0 121305065 [0.00152230, 8.12000000, []] [0.00152330, 9.86000000, []] ?? ??
1 121305065 [0.00152220, 15.74000000, []] [0.00152460, 13.73000000, []] ?? ??
2 121305065 [0.00152210, 102.00000000, []] [0.00152470, 109.14000000, []] ?? ??
3 121305065 [0.00152200, 59.61000000, []] [0.00152480, 55.54000000, []] ?? ??
4 121305065 [0.00152110, 4.44000000, []] [0.00152500, 5.24000000, []] ?? ??
5 121305065 [0.00152100, 7.00000000, []] [0.00152520, 5.00000000, []] ?? ??
6 121305065 [0.00152090, 165.20000000, []] [0.00152530, 137.45000000, []] ?? ??
7 121305065 [0.00152060, 1.92000000, []] [0.00152550, 20.63000000, []] ?? ??
8 121305065 [0.00152030, 0.72000000, []] [0.00152770, 892.00000000, []] ?? ??
9 121305065 [0.00152020, 267.36000000, []] [0.00152780, 267.36000000, []] ?? ??
Мы хотим добавить совокупные заявки и ставки в долларах США.
Для этого нам нужно сначала умножить: assetprice * qty * USDprice
Пример предложений в строке 0: 0,00152230 * 8.12000000 *7000* 1011 *
А затем добавьте накопительный.
Как нам это сделать?