Created
October 5, 2021 19:46
-
-
Save JoshuaJakowlew/11e49c027213a9c6f29b856f8bb015e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI, APIRouter, Request | |
from fastapi.staticfiles import StaticFiles | |
from fastapi.responses import JSONResponse, HTMLResponse | |
from fastapi.templating import Jinja2Templates | |
import json | |
from datetime import datetime | |
import MetaTrader5 as mt | |
from bars import Rates | |
app = FastAPI() | |
rates = Rates() | |
app.mount("/static", StaticFiles(directory="static"), name="static") | |
templates = Jinja2Templates(directory="templates") | |
@app.get("/") | |
async def home(request: Request): | |
return templates.TemplateResponse("chart.html", {"request": request}) | |
@app.get("/updates/init") | |
async def updates_init(count: int = 10): | |
data = rates.copy_from_pos(count, "EURUSD") | |
return data | |
@app.get("/updates") | |
async def updates(date_from: float): | |
date_from = datetime.fromtimestamp(date_from) | |
date_to = datetime.now() | |
data = rates.copy_rates_range(date_from, date_to, "EURUSD") | |
return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment