Skip to content

Commit

Permalink
Removed debug print statement
Browse files Browse the repository at this point in the history
updated invalid OrderRequest error msg
  • Loading branch information
jamespeterschinner committed Jan 11, 2018
1 parent 6f8104f commit 8a3b5ea
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 59 deletions.
2 changes: 1 addition & 1 deletion async_v20/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def sleep(s=0.0):
await asyncio.sleep(s)


__version__ = '6.2.1b0'
__version__ = '6.2.1b1'


class OandaClient(AccountInterface, InstrumentInterface, OrderInterface, PositionInterface,
Expand Down
1 change: 0 additions & 1 deletion async_v20/definitions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ def _construct_indexes(self):
if key is not None:
instrument_index.setdefault(key, []).append(index)
except AttributeError:
print('ERROR')
break

return dict(_id_index=id_index, _instrument_index=instrument_index)
Expand Down
30 changes: 15 additions & 15 deletions async_v20/definitions/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AccountID(str, Primitive):
"""

# Correct syntax of value
format_syntax = '“-“-delimited string with format {siteID}-{divisionID}-{userID}-{accountNumber}'
format_syntax = '"-"-delimited string with format "{siteID}-{divisionID}-{userID}-{accountNumber}"'
# Example of correct format
example = '001-011-5838423-001'

Expand Down Expand Up @@ -261,7 +261,7 @@ class OrderSpecifier(str, Primitive, Specifier):

# Correct syntax of value
format_syntax = 'Either the Order’s OANDA-assigned OrderID or the Order’s client-provided ' \
'ClientID prefixed by the “@” symbol'
'ClientID prefixed by the "@" symbol'
# Example of correct format
example = '1523'

Expand Down Expand Up @@ -320,9 +320,9 @@ class OrderTriggerCondition(str, Primitive):

# Valid values
values = {
'DEFAULT': 'Trigger an Order the natural way: '
'DEFAULT': 'Trigger an Order the "natural" way: '
'compare its price to the ask for long Orders and bid for short Orders.',
'INVERSE': 'Trigger an Order the opposite of the natural way: '
'INVERSE': 'Trigger an Order the opposite of the "natural" way: '
'compare its price the bid for long Orders and ask for short Orders.',
'BID': 'Trigger an Order by comparing its price to the bid regardless of whether it is long or short.',
'ASK': 'Trigger an Order by comparing its price to the ask regardless of whether it is long or short.',
Expand Down Expand Up @@ -361,11 +361,11 @@ class TimeInForce(str, Primitive):

# Valid values
values = {
'GTC': 'The Order is Good unTil Cancelled',
'GTD': 'The Order is Good unTil Date and will be cancelled at the provided time',
'GFD': 'The Order is Good For Day and will be cancelled at 5pm New York time',
'FOK': 'The Order must be immediately Filled Or Killed',
'IOC': 'The Order must be Immediatedly paritally filled Or Cancelled'
'GTC': 'The Order is "Good unTil Cancelled"',
'GTD': 'The Order is "Good unTil Date" and will be cancelled at the provided time',
'GFD': 'The Order is "Good For Day" and will be cancelled at 5pm New York time',
'FOK': 'The Order must be immediately "Filled Or Killed"',
'IOC': 'The Order must be "Immediatedly paritally filled Or Cancelled"'
}

def __new__(cls, value):
Expand Down Expand Up @@ -433,10 +433,10 @@ class AcceptDatetimeFormat(str, Primitive):

# Valid values
values = {
'UNIX': 'If UNIX is specified DateTime fields will be specified or '
'returned in the 12345678.000000123 format.',
'RFC3339': 'If RFC3339 is specified DateTime will be specified or '
'returned in YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ format.'
'UNIX': 'If "UNIX" is specified DateTime fields will be specified or '
'returned in the "12345678.000000123" format.',
'RFC3339': 'If "RFC3339" is specified DateTime will be specified or '
'returned in "YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ" format.'
}

def __new__(cls, value):
Expand Down Expand Up @@ -529,7 +529,7 @@ class InstrumentName(str, Primitive):
"""

# Correct syntax of value
format_syntax = 'A string containing the base currency and quote currency delimited by a “_”.'
format_syntax = 'A string containing the base currency and quote currency delimited by a "_".'

def __new__(cls, value):
return super().__new__(cls, value)
Expand Down Expand Up @@ -557,7 +557,7 @@ class TradeSpecifier(str, Primitive, Specifier):

# Correct syntax of value
format_syntax = 'Either the Trade’s OANDA-assigned TradeID or the Trade’s client-provided ' \
'ClientID prefixed by the “@” symbol'
'ClientID prefixed by the "@" symbol'
# Example of correct format
example = '@my_trade_id'

Expand Down
6 changes: 3 additions & 3 deletions async_v20/endpoints/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Ids(str):

class LongUnits(str):
"""Indication of how much of the long Position to closeout. Either the
string ALL, the string NONE, or a DecimalNumber representing how many
string "ALL", the string "NONE", or a DecimalNumber representing how many
units of the long position to close using a PositionCloseout MarketOrder.
The units specified must always be positive.
"""
Expand All @@ -102,7 +102,7 @@ def __new__(cls, value='ALL'):

class ShortUnits(str):
""" Indication of how much of the short Position to closeout. Either the
string ALL, the string NONE, or a DecimalNumber representing how many
string "ALL", the string "NONE", or a DecimalNumber representing how many
units of the short position to close using a PositionCloseout
MarketOrder. The units specified must always be positive.
"""
Expand Down Expand Up @@ -165,7 +165,7 @@ class ShortClientExtensions(ClientExtensions):


class Units(str):
"""Indication of how much of the Trade to close. Either the string ALL
"""Indication of how much of the Trade to close. Either the string "ALL"
(indicating that all of the Trade should be closed), or a DecimalNumber
representing the number of units of the open Trade to Close using a
TradeClose MarketOrder. The units specified must always be positive, and
Expand Down
12 changes: 6 additions & 6 deletions async_v20/endpoints/other_responses.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
string = str
error_response = {'errorCode': string, 'errorMessage': string}
other_responses = {
# A 400 Bad Request” reponse may be returned from the v20 REST API when the client has
# A "400 Bad Request" response may be returned from the v20 REST API when the client has
# provided invalid data to be processed.
400: error_response,
# A 401 Unauthorized” reponse may be returned from the v20 REST API when the endpoint being
# A "401 Unauthorized" response may be returned from the v20 REST API when the endpoint being
# accessed requires the client to be authenticated however the authentication token is invalid
# or has not been provided.
401: error_response,
# A 403 Forbidden response may be returned from the v20 REST API when the client has provided
# A "403 Forbidden" response may be returned from the v20 REST API when the client has provided
# a token that does not authorize them to perform the action implemented by the API endpoint.
403: error_response,
# A 404 Not Found response may be returned from the v20 REST API when the client is attempting
# A "404 Not Found" response may be returned from the v20 REST API when the client is attempting
# to refer to an entity (Account, Trade, Order, Position, etc.) that does not exist.
404: error_response,
# A 405 Method Not Allowed response may be returned from the v20 REST API when the client is
# A "405 Method Not Allowed" response may be returned from the v20 REST API when the client is
# attempting to access an API endpoint with an HTTP method that is not supported.
405: error_response,
# A 416 Range Not Satisfiable response may be returned from the v20 REST API when the client
# A "416 Range Not Satisfiable" response may be returned from the v20 REST API when the client
# has specified a range (time range or Transaction range) that is invalid or cannot be processed.
416: error_response,
# Excess requests will receive HTTP 429 error.
Expand Down
4 changes: 2 additions & 2 deletions async_v20/interface/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def _format_order_request(order_request, instrument, clip=False):
units=order_request.units.format(
instrument.trade_units_precision))
else:
msg = f'OrderRequest units {order_request.units} ' \
f'are less than the minimum trade size {instrument.minimum_trade_size}'
msg = f'OrderRequest units {order_request.units} {instrument.name} specified range ' \
f'{instrument.minimum_trade_size} - {instrument.maximum_order_units}'
logger.error(msg)
raise InvalidOrderRequest(msg)

Expand Down
7 changes: 7 additions & 0 deletions bin/preload.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

from async_v20 import *
import asyncio
import logging

logger = logging.getLogger('async_v20')
handler = logging.StreamHandler()
logger.addHandler(handler)
logger.setLevel(logging.INFO)

client = OandaClient(rest_timeout=40)
loop = asyncio.get_event_loop()
run = loop.run_until_complete
2 changes: 1 addition & 1 deletion doc/build/html/_sources/glossary.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
pandas

a Python package providing fast, flexible, and expressive data structures
designed to make working with relational or labeled data both easy and intuitive
designed to make working with "relational" or "labeled" data both easy and intuitive

http://pandas.pydata.org/

Expand Down

0 comments on commit 8a3b5ea

Please sign in to comment.