added flask

This commit is contained in:
Giulio De Pasquale 2020-12-07 21:52:47 +00:00
parent dcd91eaab8
commit f694f81b1b
2 changed files with 33 additions and 16 deletions

42
main.py
View File

@ -494,25 +494,35 @@ from bfxbot.currency import Symbol
from bfxbot.models import PositionState from bfxbot.models import PositionState
from strategy import TrailingStopStrategy from strategy import TrailingStopStrategy
dotenv.load_dotenv() from flask import Flask, render_template
API_KEY = os.getenv("API_KEY") app = Flask(__name__)
API_SECRET = os.getenv("API_SECRET")
bot = BfxBot(api_key=API_KEY, api_secret=API_SECRET)
strategy = TrailingStopStrategy()
bot.set_strategy(Symbol.BTC, strategy)
eh = bot.event_handler(Symbol.BTC)
@eh.on_state(PositionState.PROFIT) @app.route('/')
def on_min_profit(ss, pw): def entry():
print("Minimum profit!") return render_template('index.html')
async def main(): # dotenv.load_dotenv()
await bot.start()
while True: # API_KEY = os.getenv("API_KEY")
await bot.update() # API_SECRET = os.getenv("API_SECRET")
# bot = BfxBot(api_key=API_KEY, api_secret=API_SECRET)
# strategy = TrailingStopStrategy()
# bot.set_strategy(Symbol.BTC, strategy)
# eh = bot.event_handler(Symbol.BTC)
# @eh.on_state(PositionState.PROFIT)
# def on_min_profit(ss, pw):
# print("Minimum profit!")
# async def main():
# await bot.start()
# while True:
# await bot.update()
if __name__ == '__main__': if __name__ == '__main__':
asyncio.run(main()) # asyncio.run(main())
app.run()

7
templates/index.html Normal file
View File

@ -0,0 +1,7 @@
<!doctype html>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/bootstrap.min.css') }}">
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
<title>Hello world!</title>
<h1>Rustico - Approved Salento Bot</h1>