import asyncio

from async_v20 import OandaClient

client = OandaClient()

# This
coroutine_1 = client.create_order('AUD_USD', 10)

# Is the same as this
from async_v20 import InstrumentName, DecimalNumber

coroutine_2 = client.create_order(InstrumentName('AUD_USD'), DecimalNumber(10))

# Is the same as this
from async_v20 import OrderRequest

coroutine_3 = client.post_order(
    order_request=OrderRequest(instrument='AUD_USD', units=10, type='MARKET'))

loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.gather(coroutine_1, coroutine_2, coroutine_3))
Esempio n. 2
0
import asyncio

from async_v20 import OandaClient

client = OandaClient()

# This
coroutine_1 = client.create_order('AUD_USD', 10)

# Is the same as this
from async_v20 import InstrumentName, Unit

coroutine_2 = client.create_order(
    InstrumentName('AUD_USD'), Unit(10)
)

# Is the same as this
from async_v20 import OrderRequest

coroutine_3 = client.post_order(
    order_request=OrderRequest(
        instrument='AUD_USD', units=10
    )
)

loop = asyncio.get_event_loop()
loop.run_until_complete(
    asyncio.gather(
        coroutine_1,
        coroutine_2,
        coroutine_3
Esempio n. 3
0
    client.account_changes(),
    client.get_candles('AUD_USD',
                       price='BMA',
                       count=10,
                       granularity='S5',
                       daily_alignment=0,
                       include_first_query=False),
    client.get_candles('AUD_USD', from_time=time() - (60 * 10)),
    client.get_order_book('AUD_USD'),
    client.get_position_book('AUD_USD'),
)

for i in rsp:
    print(i.json())

rsp = run(*[client.create_order('AUD_USD', -11) for _ in range(10)])
for i in rsp:
    print(i.json())

rsp = run(client.list_open_trades())

for i in rsp:
    print(i.json())

rsp = run(client.close_position('AUD_USD', long_units='ALL'))

for i in rsp:
    print(i.json())

rsp = run(*[client.create_order('AUD_USD', 1) for _ in range(10)])