INNER CODE UNIT · Python

get_profit

5ymph0en1x/SyDOM · sydom.py:195

def get_profit(instr_bmex):
    naming = str(instr_bmex) + '_position.csv'
    try:
        open(naming)
    except Exception as e:
        return None
    df = pd.read_csv(naming)
    base = df['price'].iloc[0]
    if df['direction'].iloc[0] == 'long':
        profit = df['size'].iloc[0] * (1/base - 1/get_bid(0)) * get_bid(0)
        return profit
    elif df['direction'].iloc[0] == 'short':
        profit = df['size'].iloc[0] * (1/base - 1/get_ask(0)) * get_ask(0)
        return profit
    else:
        return 0


View source record →

📰 Research Paper
Loading…
⏳ Fetching content…