Skip to content

Commit

Permalink
Added creating_dataframe and creating_orders to ./perftests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamespeterschinner committed Jan 11, 2018
1 parent 073d766 commit 27792c9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
13 changes: 13 additions & 0 deletions perftests/creating_dataframe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import asyncio
from perftests.helpers import Time, client


print('Running creating_dataframes benchmark with async_v20 version', client.version)
loop = asyncio.get_event_loop()

rsp = loop.run_until_complete(client.get_candles('AUD_USD'))


with Time() as t:
for _ in range(1000):
df = rsp.candles.dataframe()
25 changes: 25 additions & 0 deletions perftests/creating_orders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import asyncio
from perftests.helpers import Time, client


print('Running creating_dataframe benchmark with async_v20 version', client.version)
loop = asyncio.get_event_loop()

# This will test the speed of the _formatting_order_requests helper function
client.format_order_requests = True

async def place_orders(count):
await asyncio.gather(*[
client.create_order(
'AUD_USD',
units=0,
stop_loss_on_fill=0,
take_profit_on_fill=0,
trailing_stop_loss_on_fill=0,
)
for _ in range(count)])


with Time() as t:
for _ in range(10):
loop.run_until_complete(place_orders(500))
5 changes: 4 additions & 1 deletion perftests/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ async def handler(request):
json = response
if not isinstance(json, str):
json = next(response)
status = 200
if method == 'POST':
status = 201
return web.Response(body=gzip.compress(bytes(json, encoding='utf8')), headers=rest_headers,
status=200)
status=status)
async def main(loop):
await loop.create_server(web.Server(handler), "127.0.0.1", 8080)
print("======= Serving on http://127.0.0.1:8080/ ======")
Expand Down

0 comments on commit 27792c9

Please sign in to comment.