INNER CODE UNIT · Python

launch_paper_order

5ymph0en1x/SyDOM · sydom.py:188

def launch_paper_order(instr_bmex, direction, size, price):
    df = pd.DataFrame(columns=['direction', 'size', 'price'])
    df.loc[0] = pd.Series({'direction': direction, 'size': size, 'price': price})
    naming = str(instr_bmex) + '_order.csv'
    df.to_csv(naming, index=False)


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

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…