| from typing import List |
| from fastapi import FastAPI |
| from pydantic import BaseModel |
| from pyngrok import ngrok |
|
|
| app = FastAPI() |
| app = FastAPI() |
| auth="2aZeouhaHuJSXZQ9WatZC3LQieO_6ckrQG71twNRutGxaLh3H" |
| ngrok.set_auth_token(auth) |
| |
| ngrok_tunnel = ngrok.connect(8000) |
| print('Public URL:', ngrok_tunnel.public_url) |
|
|
|
|
| class Item(BaseModel): |
| data: List[List[float]] = [] |
| ratio: int |
|
|
| @app.get("/") |
| def hello(): |
| return {"Error 404"} |
|
|
| @app.post("/pattern1/") |
| async def create_item(item: Item): |
| data = item.data |
| ratio = item.ratio |
| |
| |
| if data[2][0] > data[2][1] > data[2][2] < data[2][3] < data[2][4] and data[2][3] < data[2][0]: |
| |
| position="long" |
| |
| st_price = min(data[1][:4]) |
| |
| close_price = data[2][4] |
| |
| points = close_price - st_price |
| |
| target_price = close_price + (points*ratio) |
| target_price = round(target_price,2) |
| |
| perc_change_st = -(((st_price - close_price) / close_price) * 100) |
| |
| return [position,st_price,close_price,target_price,perc_change_st] |
| |
| |
| elif data[2][0] < data[2][1] < data[2][2] > data[2][3] > data[2][4] and data[2][3] > data[2][0]: |
| |
| position="short" |
| |
| st_price = max(data[0][:4]) |
| |
| close_price = data[2][4] |
| |
| points = st_price - close_price |
| |
| target_price = (close_price - (points*ratio)) |
| target_price = round(target_price,2) |
| |
| perc_change_st = (((st_price - close_price) / close_price) * 100) |
| |
| return [position,st_price,close_price,target_price,perc_change_st] |
| |
| else: |
| return None |
|
|