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
import asyncio | |
from aiomql import Account | |
async def main(): | |
# since our login details are defined in aiomql.json | |
# we can just call Account() without any arguments | |
async with Account() as acc: | |
print(acc.balance) |
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
import logging | |
from aiomql import ForexSymbol, Bot, Sessions, FingerTrap | |
logging.basicConfig(level=logging.WARNING) | |
def run_bot(): | |
bot = Bot() | |
symbols = ['EURUSD', 'GBPUSD', 'USDJPY', 'USDCHF', 'USDCAD', 'AUDUSD', 'NZDUSD', 'EURGBP', 'EURJPY', 'GBPJPY'] | |
strategies = [FingerTrap(symbol=ForexSymbol(name=symbol)) for symbol in symbols] |
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 aiomql import Config, Account | |
config = Config() | |
print(config.path, config.login, config.password) | |
# load the config from a file different file. | |
# remember to pass reload=True to reload the config file | |
Config(filename='config.json', reload=True) |
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
import re | |
def validate_email(email_address): | |
email_address = email_address.split() | |
# email address can start with any alphanumeric character. | |
# username part i.e the part before the @ symbol cannot be more than 64 characters | |
# domain part i.e the part after the @ symbol cannot be more than 251 characters | |
# domain part can end with any of the following top level domain name (.com, .org, .net) | |
pattern = re.compile(r"(?P<username>^[a-z0-9][\w.]{,63})@(?P<domain>[\w]{1,247}(.com|.net|.org)$)", flags=re.IGNORECASE|re.ASCII) | |
if not pattern.match(email_address): |
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
import asyncio | |
from logging import getLogger | |
from aiomql import Trader, ForexSymbol, RAM, OrderType, Account | |
logger = getLogger(__name__) | |
class SimpleTrader(Trader): |
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
import asyncio | |
from datetime import datetime | |
from aiomql import Symbol, TimeFrame, Account | |
async def main(): | |
# Assume account details are in the config file | |
async with Account(): | |
sym = Symbol(name="BTCUSD") | |
res = await sym.init() |
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
import asyncio | |
from datetime import datetime | |
from pytz import timezone | |
from aiomql import ForexSymbol, Account, Positions, History, Order, OrderType, RAM, TradeAction | |
async def main(): | |
async with Account(): | |
# get start time using local timezone |
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
import asyncio | |
from aiomql import Account, OrderType, TradeAction, Order, ForexSymbol | |
async def main(): | |
async with Account(): | |
# create a symbol | |
sym = ForexSymbol(name="BTCUSD") |
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
import asyncio | |
from aiomql import Symbol, TimeFrame, Account | |
async def main(): | |
async with Account(): | |
# create a symbol | |
sym = Symbol(name="EURUSD") | |
# initialize the symbol | |
res = await sym.init() |
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, File, UploadFile, Depends | |
from filestore import LocalStorage, Result | |
app = FastAPI() | |
# local storage instance for single file upload | |
loc = LocalStorage(name='book', required=True) | |
# local storage instance for multiple file upload with a maximum of 2 files from a single field | |
loc2 = LocalStorage(name='book', required=True, count=2) |
NewerOlder