symbol positionAmt entryPrice markPrice unRealizedProfit liquidationPrice leverage maxNotionalValue marginType isolatedMargin isAutoAddMargin positionSide notional isolatedWallet updateTime
...
132 FTTBUSD 0.0 0.0 0.00000000 0.00000000 0 20 0 cross 0.00000000 false BOTH 0 0 0
133 ETHUSDT 0.003 1912.07 1919.29000000 0.02166000 0 20 15000000 cross 0.00000000 false BOTH 5.75787000 0 1689840029568
134 ALPHAUSDT 0 0.0 0.00000000 0.00000000 0 20 25000 cross 0.00000000 false BOTH 0 0 0
...
symbol positionAmt
0 ETHUSDT 0.003
import csv
with open('data/train.csv') as f:
reader = csv.DictReader(f)
user_id = 1
while user_id < 20000:
user_cart = []
user_order = []
user_cart_quantity = {} # {user_cart: user_order}
for row in reader:
if row['user_id'] == str(user_id):
# список со всеми категориями с повтором
user_cart.append(row['cart'])
# список уникальных дат заказов
if row['order_completed_at'] not in user_order:
user_order.append(row['order_completed_at'])
# получение словаря key - категория, value - количество заказов
for i in user_cart:
if i not in user_cart_quantity:
if user_cart.count(i) > len(user_order) / 2: # заказов > 50%
user_cart_quantity.update({f'{i}': user_cart.count(i)})
with open('data/tesr.txt', 'a') as fw:
fw.write(f'{user_id};{i}, 1\n')
user_id += 1
f.seek(0)
def extract(cls, date):
temp = str(date).split('-')
day, month, year = int(temp[0]), int(temp[1]), int(temp[2])
return day, month, year