/* Generated by Cython 0.29.23 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [],
        "language": "c++",
        "name": "trapeza.account.fx_account",
        "sources": [
            "trapeza/account/fx_account.pyx"
        ]
    },
    "module_name": "trapeza.account.fx_account"
}
END: Cython Metadata */

#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_23"
#define CYTHON_HEX_VERSION 0x001D17F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #ifndef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef __cplusplus
  #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
#endif
#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #else
    #define CYTHON_INLINE inline
  #endif
#endif
template<typename T>
void __Pyx_call_destructor(T& x) {
    x.~T();
}
template<typename T>
class __Pyx_FakeReference {
  public:
    __Pyx_FakeReference() : ptr(NULL) { }
    __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
    T *operator->() { return ptr; }
    T *operator&() { return ptr; }
    operator T&() { return *ptr; }
    template<typename U> bool operator ==(U other) { return *ptr == other; }
    template<typename U> bool operator !=(U other) { return *ptr != other; }
  private:
    T *ptr;
};

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__trapeza__account__fx_account
#define __PYX_HAVE_API__trapeza__account__fx_account
/* Early includes */
#include <string.h>
#include "ios"
#include "new"
#include "stdexcept"
#include "typeinfo"
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "trapeza\\account\\fx_account.pyx",
  "trapeza\\account\\fx_account.pxd",
  "stringsource",
  "trapeza\\account\\execution_heap.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap;
struct __pyx_obj_7trapeza_7account_14execution_heap_DictKeysToVec;
struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount;
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot;
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr;
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee;
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr;
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates;
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr;
struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct;
struct __pyx_t_7trapeza_7account_14execution_heap_currency_pair_struct;
struct __pyx_ctuple_bool__and_bool__and_double__and_double;
typedef struct __pyx_ctuple_bool__and_bool__and_double__and_double __pyx_ctuple_bool__and_bool__and_double__and_double;

/* "trapeza/account/execution_heap.pxd":9
 * 
 * 
 * cdef struct fx_heap_element_struct:             # <<<<<<<<<<<<<<
 *     long time
 *     string action_func
 */
struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct {
  long time;
  std::string action_func;
  double volume;
  std::string currency;
  std::string coverage;
};

/* "trapeza/account/execution_heap.pxd":17
 * 
 * 
 * cdef struct currency_pair_struct:             # <<<<<<<<<<<<<<
 *     string currency_a
 *     string currency_b
 */
struct __pyx_t_7trapeza_7account_14execution_heap_currency_pair_struct {
  std::string currency_a;
  std::string currency_b;
  double rate;
};

/* "trapeza/account/execution_heap.pxd":42
 * cdef class DictKeysToVec:
 *     cdef vector[currency_pair_struct] currency_pairs
 *     cdef (bool_t, bool_t, double, double) is_tuple_key_in_tuple_vec(self, string key_a, string key_b)             # <<<<<<<<<<<<<<
 */
struct __pyx_ctuple_bool__and_bool__and_double__and_double {
  bool f0;
  bool f1;
  double f2;
  double f3;
};

/* "trapeza/arithmetics/arithmetics.pxd":1
 * ctypedef double (*c_precision_t)(double, double)             # <<<<<<<<<<<<<<
 * cdef c_precision_t c_precision_add
 * cdef c_precision_t c_precision_subtract
 */
typedef double (*__pyx_t_7trapeza_11arithmetics_11arithmetics_c_precision_t)(double, double);
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee;
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage;
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_sell;
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_buy;
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_transfer;
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_collect;
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_deposit;
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw;

/* "trapeza/account/fx_account.pxd":26
 *     cdef short _c_issue_corruption_warning(self) except -1
 *     cdef short _c_confirmation(self, long processing_duration) except -1
 *     cdef short _c_fill_fee(self, double fee_volume, string fee_currency, long fee_exec_duration,             # <<<<<<<<<<<<<<
 *                            string forward_coverage=*) except -1
 *     cdef short _execute_heap(self) except -1
 */
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee {
  int __pyx_n;
  std::string forward_coverage;
};

/* "trapeza/account/fx_account.pxd":36
 *                           bool_t ignore_type_checking) except *
 *     cpdef short _c_reset(self) except -1
 *     cpdef double _c_check_coverage(self, double debit_amount, string currency, long time_step,             # <<<<<<<<<<<<<<
 *                                    double virtual_deposit=*) except -1
 *     cpdef short _c_isin_depot(self, string currency) except -1
 */
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage {
  int __pyx_n;
  double virtual_deposit;
};

/* "trapeza/account/fx_account.pxd":39
 *                                    double virtual_deposit=*) except -1
 *     cpdef short _c_isin_depot(self, string currency) except -1
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=*,             # <<<<<<<<<<<<<<
 *                      string fee_currency=*, long fee_exec_duration=*, long processing_duration=*,
 *                      string coverage=*, bool_t instant_withdrawal=*,
 */
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_sell {
  int __pyx_n;
  double fee_volume;
  std::string fee_currency;
  long fee_exec_duration;
  long processing_duration;
  std::string coverage;
  bool instant_withdrawal;
  bool instant_float_fee;
};

/* "trapeza/account/fx_account.pxd":43
 *                      string coverage=*, bool_t instant_withdrawal=*,
 *                      bool_t instant_float_fee=*) except -9999
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=*,             # <<<<<<<<<<<<<<
 *                     string fee_currency=*, long fee_exec_duration=*, long processing_duration=*,
 *                     string coverage=*, bool_t instant_withdrawal=*,
 */
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_buy {
  int __pyx_n;
  double fee_volume;
  std::string fee_currency;
  long fee_exec_duration;
  long processing_duration;
  std::string coverage;
  bool instant_withdrawal;
  bool instant_float_fee;
};

/* "trapeza/account/fx_account.pxd":47
 *                     string coverage=*, bool_t instant_withdrawal=*,
 *                     bool_t instant_float_fee=*) except -9999
 *     cpdef short c_transfer(self, double volume, string currency,             # <<<<<<<<<<<<<<
 *                          double payer_fee_volume=*, string payer_fee_currency=*,
 *                          long payer_fee_exec_duration=*, long payer_processing_duration=*) except -9999
 */
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_transfer {
  int __pyx_n;
  double payer_fee_volume;
  std::string payer_fee_currency;
  long payer_fee_exec_duration;
  long payer_processing_duration;
};

/* "trapeza/account/fx_account.pxd":50
 *                          double payer_fee_volume=*, string payer_fee_currency=*,
 *                          long payer_fee_exec_duration=*, long payer_processing_duration=*) except -9999
 *     cpdef short c_collect(self, double volume, string currency,             # <<<<<<<<<<<<<<
 *                         double payee_fee_volume=*, string payee_fee_currency=*, long payee_fee_exec_duration=*,
 *                         long payee_processing_duration=*) except -9999
 */
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_collect {
  int __pyx_n;
  double payee_fee_volume;
  std::string payee_fee_currency;
  long payee_fee_exec_duration;
  long payee_processing_duration;
};

/* "trapeza/account/fx_account.pxd":53
 *                         double payee_fee_volume=*, string payee_fee_currency=*, long payee_fee_exec_duration=*,
 *                         long payee_processing_duration=*) except -9999
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=*,             # <<<<<<<<<<<<<<
 *                         string fee_currency=*, long fee_exec_duration=*,
 *                         string coverage=*, bool_t instant_float_fee=*) except -9999
 */
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_deposit {
  int __pyx_n;
  double fee_volume;
  std::string fee_currency;
  long fee_exec_duration;
  std::string coverage;
  bool instant_float_fee;
};

/* "trapeza/account/fx_account.pxd":56
 *                         string fee_currency=*, long fee_exec_duration=*,
 *                         string coverage=*, bool_t instant_float_fee=*) except -9999
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=*, double fee_volume=*,             # <<<<<<<<<<<<<<
 *                          string fee_currency=*, long fee_exec_duration=*,
 *                          string coverage=*, bool_t instant_float_fee=*) except -9999
 */
struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw {
  int __pyx_n;
  long processing_duration;
  double fee_volume;
  std::string fee_currency;
  long fee_exec_duration;
  std::string coverage;
  bool instant_float_fee;
};

/* "trapeza/account/execution_heap.pxd":23
 * 
 * # noinspection PyPep8Naming
 * cdef class cFXWrapperVectorHeap:             # <<<<<<<<<<<<<<
 *     cdef vector[fx_heap_element_struct] vector_heap
 *     cdef string std_cover_at_exec_exception
 */
struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap {
  PyObject_HEAD
  struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *__pyx_vtab;
  std::vector<struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct>  vector_heap;
  std::string std_cover_at_exec_exception;
};


/* "trapeza/account/execution_heap.pxd":40
 * 
 * 
 * cdef class DictKeysToVec:             # <<<<<<<<<<<<<<
 *     cdef vector[currency_pair_struct] currency_pairs
 *     cdef (bool_t, bool_t, double, double) is_tuple_key_in_tuple_vec(self, string key_a, string key_b)
 */
struct __pyx_obj_7trapeza_7account_14execution_heap_DictKeysToVec {
  PyObject_HEAD
  struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_DictKeysToVec *__pyx_vtab;
  std::vector<struct __pyx_t_7trapeza_7account_14execution_heap_currency_pair_struct>  currency_pairs;
};


/* "trapeza/account/fx_account.pxd":8
 * 
 * # noinspection PyPep8Naming
 * cdef class cFXAccount:             # <<<<<<<<<<<<<<
 *     # class attributes
 *     cdef public bool_t _c_is_heap
 */
struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount {
  PyObject_HEAD
  struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *__pyx_vtab;
  bool _c_is_heap;
  bool _c_is_exchange_rate_updated;
  bool _c_prohibit_debiting;
  std::string _c_reference_currency;
  PyObject *_c_depot;
  PyObject *_c_fee;
  PyObject *_c_exchange_rates;
  bool _c_ignore_type_checking;
  long _c_clock;
  short _c_check_marked_coverage;
  struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *vec_heap;
};


/* "trapeza/account/fx_account.pyx":1291
 * 
 *     @property
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current depot and it's positions. Returned dict is not manipulable/ mutable. Use setter method instead.
 */
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot {
  PyObject_HEAD
  PyObject *__pyx_v_self;
};


/* "trapeza/account/fx_account.pyx":1296
 *         :return: dict, keys: str:currency, value: float:position_size
 *         """
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_depot.items())             # <<<<<<<<<<<<<<
 *     @depot.setter
 *     def depot(self, inp):
 */
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *__pyx_outer_scope;
  PyObject *__pyx_v_k;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
};


/* "trapeza/account/fx_account.pyx":1312
 * 
 *     @property
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current set fees. Returned dict is not manipulable/ mutable. Use setter method instead.
 */
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee {
  PyObject_HEAD
  PyObject *__pyx_v_self;
};


/* "trapeza/account/fx_account.pyx":1317
 *         :return: dict, keys:{'sell', 'buy', 'withdraw', 'deposit'}, values: function
 *         """
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_fee.items())             # <<<<<<<<<<<<<<
 *     @_fee.setter
 *     def _fee(self, inp):
 */
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr {
  PyObject_HEAD
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *__pyx_outer_scope;
  PyObject *__pyx_v_k;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
};


/* "trapeza/account/fx_account.pyx":1355
 * 
 *     @property
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns current exchange rates (which was previously provided by self.tick(...), self.update_exchange_rate(...)
 */
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates {
  PyObject_HEAD
  PyObject *__pyx_v_self;
};


/* "trapeza/account/fx_account.pyx":1361
 *         :return: dict with keys:tuple of str:currency (currency pair) and values:float
 *         """
 *         return ProtectedDict(((k[0].decode(), k[1].decode()), v) for k, v in self._c_exchange_rates.items())             # <<<<<<<<<<<<<<
 *     @exchange_rates.setter
 *     def exchange_rates(self, inp):
 */
struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr {
  PyObject_HEAD
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *__pyx_outer_scope;
  PyObject *__pyx_v_k;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
};



/* "trapeza/account/execution_heap.pxd":23
 * 
 * # noinspection PyPep8Naming
 * cdef class cFXWrapperVectorHeap:             # <<<<<<<<<<<<<<
 *     cdef vector[fx_heap_element_struct] vector_heap
 *     cdef string std_cover_at_exec_exception
 */

struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap {
  long (*size)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *);
  double (*cum_sum_heap)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *, std::string, std::string, long, long, int __pyx_skip_dispatch);
  double (*cum_sum_marked_fund)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *, std::string, long, long, int __pyx_skip_dispatch);
  double (*cum_sum_marked_debit)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *, std::string, long, long, int __pyx_skip_dispatch);
  struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct (*heappop)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *);
  struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct (*encode_tostruct)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct (*tostruct)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *, PyObject *, int __pyx_skip_dispatch);
  void (*heappush_struct)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *, struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct);
  void (*heappush)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *, PyObject *);
  PyObject *(*tolist)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *, int __pyx_skip_dispatch);
  long (*max_time_step)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *);
  long (*py_max_time_step)(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *__pyx_vtabptr_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap;


/* "trapeza/account/execution_heap.pxd":40
 * 
 * 
 * cdef class DictKeysToVec:             # <<<<<<<<<<<<<<
 *     cdef vector[currency_pair_struct] currency_pairs
 *     cdef (bool_t, bool_t, double, double) is_tuple_key_in_tuple_vec(self, string key_a, string key_b)
 */

struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_DictKeysToVec {
  __pyx_ctuple_bool__and_bool__and_double__and_double (*is_tuple_key_in_tuple_vec)(struct __pyx_obj_7trapeza_7account_14execution_heap_DictKeysToVec *, std::string, std::string);
};
static struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_DictKeysToVec *__pyx_vtabptr_7trapeza_7account_14execution_heap_DictKeysToVec;


/* "trapeza/account/fx_account.pyx":32
 * 
 * # noinspection PyAbstractClass,PyPep8Naming,PyUnresolvedReferences,PyAttributeOutsideInit,PyTypeChecker
 * cdef class cFXAccount:             # <<<<<<<<<<<<<<
 *     """
 *     This is a C++ implementation via cython and gets wrapped by FXAccount class. This class tries to stay in C++ space
 */

struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount {
  short (*_c_check_debiting)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *);
  short (*_c_issue_corruption_warning)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *);
  short (*_c_confirmation)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, long);
  short (*_c_fill_fee)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, long, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee *__pyx_optional_args);
  short (*_execute_heap)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *);
  short (*_c_isin_depot_quiet)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, std::string);
  void (*_c__init__)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, std::string, PyObject *, PyObject *, PyObject *, long, PyObject *, short, bool, bool, int __pyx_skip_dispatch);
  short (*_c_reset)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, int __pyx_skip_dispatch);
  double (*_c_check_coverage)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, long, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage *__pyx_optional_args);
  short (*_c_isin_depot)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, std::string, int __pyx_skip_dispatch);
  short (*c_sell)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, double, std::string, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_sell *__pyx_optional_args);
  short (*c_buy)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, double, std::string, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_buy *__pyx_optional_args);
  short (*c_transfer)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_transfer *__pyx_optional_args);
  short (*c_collect)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_collect *__pyx_optional_args);
  short (*c_deposit)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, long, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_deposit *__pyx_optional_args);
  short (*c_withdraw)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw *__pyx_optional_args);
  long (*c_tick)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, long, int __pyx_skip_dispatch);
  short (*c_update_exchange_rate)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, std::string, int __pyx_skip_dispatch);
  short (*c_batch_update_exchange_rates)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  double (*c_total_balance)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, PyObject *, std::string, int __pyx_skip_dispatch);
  double (*c_position)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, std::string, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *__pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* IncludeCppStringH.proto */
#include <string>

/* decode_c_string_utf16.proto */
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 0;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = -1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}

/* decode_c_bytes.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

/* decode_cpp_string.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_cpp_string(
         std::string cppstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    return __Pyx_decode_c_bytes(
        cppstring.data(), cppstring.size(), start, stop, encoding, errors, decode_func);
}

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* UnpackTupleError.proto */
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);

/* UnpackTuple2.proto */
#define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
    (likely(is_tuple || PyTuple_Check(tuple)) ?\
        (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
            __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
            (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
        __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
    PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
static int __Pyx_unpack_tuple2_generic(
    PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);

/* dict_iter.proto */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* py_dict_keys.proto */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d);

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod0.proto */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    (likely((cfunc)->func) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
            (PY_VERSION_HEX >= 0x030700A0 ?\
                (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
                (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
          (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
            (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
            (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
               ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) :\
               __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* PyIntCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* IncludeStringH.proto */
#include <string.h>

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* PyIntCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* CallableCheck.proto */
#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3
#define __Pyx_PyCallable_Check(obj)   ((obj)->ob_type->tp_call != NULL)
#else
#define __Pyx_PyCallable_Check(obj)   PyCallable_Check(obj)
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* SetItemInt.proto */
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_SubtractCObj(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* GetVTable.proto */
static void* __Pyx_GetVtable(PyObject *dict);

/* CalculateMetaclass.proto */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* CythonFunctionShared.proto */
#define __Pyx_CyFunction_USED 1
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    size_t defaults_size;  // used by FusedFunction for copying defaults
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_Check(obj)  (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

/* CythonFunction.proto */
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *closure,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);

/* SetNameInClass.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
#elif CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
#else
#define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
#endif

/* Py3ClassCreate.proto */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc);
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);

/* CyFunctionClassCell.proto */
static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* None.proto */
#include <new>

/* GCCDiagnostics.proto */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif

struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct;
static PyObject* __pyx_convert__to_py_struct____pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct(struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct s);
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_short(short value);

/* CIntFromPy.proto */
static CYTHON_INLINE short __Pyx_PyInt_As_short(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_ExcInfoStruct  _PyErr_StackItem
#else
typedef struct {
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
} __Pyx_ExcInfoStruct;
#endif
typedef struct {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    __Pyx_ExcInfoStruct gi_exc_state;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    PyObject *gi_name;
    PyObject *gi_qualname;
    PyObject *gi_modulename;
    PyObject *gi_code;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
    PyObject *name, PyObject *qualname, PyObject *module_name);
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
static int __Pyx_Coroutine_clear(PyObject *self);
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Coroutine_Close(PyObject *self);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_Coroutine_SwapException(self)
#define __Pyx_Coroutine_ResetAndClearException(self)  __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
#else
#define __Pyx_Coroutine_SwapException(self) {\
    __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
    __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
    }
#define __Pyx_Coroutine_ResetAndClearException(self) {\
    __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
    (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
    }
#endif
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);

/* PatchModuleWithCoroutine.proto */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

/* PatchGeneratorABC.proto */
static int __Pyx_patch_abc(void);

/* Generator.proto */
#define __Pyx_Generator_USED
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* FunctionExport.proto */
static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);

/* VoidPtrImport.proto */
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static void __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c__init__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_reference_currency, PyObject *__pyx_v_depot, PyObject *__pyx_v_fee_dict, PyObject *__pyx_v_exec_heap, long __pyx_v_clock, PyObject *__pyx_v_exchange_rates, short __pyx_v_check_marked_coverage, bool __pyx_v_prohibit_debiting, bool __pyx_v_ignore_type_checking, int __pyx_skip_dispatch); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_reset(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_debit_amount, std::string __pyx_v_currency, long __pyx_v_time_step, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage *__pyx_optional_args); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_check_debiting(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_isin_depot(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency, int __pyx_skip_dispatch); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_isin_depot_quiet(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_issue_corruption_warning(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_confirmation(CYTHON_UNUSED struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, long __pyx_v_processing_duration); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee *__pyx_optional_args); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__execute_heap(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_sell(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, double __pyx_v_bid_price, std::string __pyx_v_base, std::string __pyx_v_quote, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_sell *__pyx_optional_args); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_buy(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, double __pyx_v_ask_price, std::string __pyx_v_base, std::string __pyx_v_quote, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_buy *__pyx_optional_args); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_transfer(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_transfer *__pyx_optional_args); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_collect(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_collect *__pyx_optional_args); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_deposit(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, long __pyx_v_processing_duration, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_deposit *__pyx_optional_args); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw *__pyx_optional_args); /* proto*/
static long __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_tick(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, long __pyx_v_clock, int __pyx_skip_dispatch); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_update_exchange_rate(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_rate, std::string __pyx_v_base, std::string __pyx_v_quote, int __pyx_skip_dispatch); /* proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_batch_update_exchange_rates(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_list_rates, PyObject *__pyx_v_list_base_quote_pair, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_total_balance(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_exchange_rates, std::string __pyx_v_reference_currency, int __pyx_skip_dispatch); /* proto*/
static double __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_position(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency, int __pyx_skip_dispatch); /* proto*/

/* Module declarations from 'libc.string' */

/* Module declarations from 'libcpp.string' */

/* Module declarations from 'libcpp' */

/* Module declarations from 'libcpp.vector' */

/* Module declarations from 'libcpp.algorithm' */

/* Module declarations from 'trapeza.account.execution_heap' */
static PyTypeObject *__pyx_ptype_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap = 0;
static PyTypeObject *__pyx_ptype_7trapeza_7account_14execution_heap_DictKeysToVec = 0;

/* Module declarations from 'cython' */

/* Module declarations from 'libc.math' */

/* Module declarations from 'trapeza.arithmetics.arithmetics' */
static __pyx_t_7trapeza_11arithmetics_11arithmetics_c_precision_t *__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_add = 0;
#define __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add (*__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_add)
static __pyx_t_7trapeza_11arithmetics_11arithmetics_c_precision_t *__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_subtract = 0;
#define __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_subtract (*__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_subtract)
static __pyx_t_7trapeza_11arithmetics_11arithmetics_c_precision_t *__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_multiply = 0;
#define __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_multiply (*__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_multiply)
static __pyx_t_7trapeza_11arithmetics_11arithmetics_c_precision_t *__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_divide = 0;
#define __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_divide (*__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_divide)

/* Module declarations from 'trapeza.account.fx_account' */
static PyTypeObject *__pyx_ptype_7trapeza_7account_10fx_account_cFXAccount = 0;
static PyTypeObject *__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct__depot = 0;
static PyTypeObject *__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr = 0;
static PyTypeObject *__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee = 0;
static PyTypeObject *__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr = 0;
static PyTypeObject *__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates = 0;
static PyTypeObject *__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr = 0;
static PyObject *__pyx_f_7trapeza_7account_10fx_account_fx_null_fee(double, double, PyObject *, PyObject *, long, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_7trapeza_7account_10fx_account___pyx_unpickle_cFXAccount__set_state(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/
static std::string __pyx_convert_string_from_py_std__in_string(PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "trapeza.account.fx_account"
extern int __pyx_module_is_main_trapeza__account__fx_account;
int __pyx_module_is_main_trapeza__account__fx_account = 0;

/* Implementation of 'trapeza.account.fx_account' */
static PyObject *__pyx_builtin_property;
static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_NameError;
static const char __pyx_k_X[] = "X";
static const char __pyx_k_Y[] = "Y";
static const char __pyx_k_c[] = "c_";
static const char __pyx_k_e[] = "e";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_k[] = "k";
static const char __pyx_k_v[] = "v";
static const char __pyx_k__19[] = "";
static const char __pyx_k__93[] = "_";
static const char __pyx_k_buy[] = "buy";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_fee[] = "_fee";
static const char __pyx_k_inp[] = "inp";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_base[] = "base";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_func[] = "func";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_keys[] = "keys";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_rate[] = "rate";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_sell[] = "sell";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_tick[] = "tick";
static const char __pyx_k_time[] = "time";
static const char __pyx_k_warn[] = "warn";
static const char __pyx_k_c_buy[] = "c_buy";
static const char __pyx_k_c_fee[] = "_c_fee";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_clock[] = "clock";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_debit[] = "debit";
static const char __pyx_k_depot[] = "depot";
static const char __pyx_k_f_key[] = "_f_key";
static const char __pyx_k_fee_2[] = "fee";
static const char __pyx_k_heapq[] = "heapq";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_price[] = "price";
static const char __pyx_k_quote[] = "quote";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_reset[] = "_reset";
static const char __pyx_k_super[] = "super";
static const char __pyx_k_throw[] = "throw";
static const char __pyx_k_c_sell[] = "c_sell";
static const char __pyx_k_c_tick[] = "c_tick";
static const char __pyx_k_decode[] = "decode";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_except[] = "except";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_ignore[] = "ignore";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_result[] = "result";
static const char __pyx_k_setter[] = "setter";
static const char __pyx_k_tolist[] = "tolist";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_volume[] = "volume";
static const char __pyx_k_alt_fee[] = "alt_fee";
static const char __pyx_k_buy_fee[] = "buy_fee";
static const char __pyx_k_c__init[] = "_c__init__";
static const char __pyx_k_c_clock[] = "_c_clock";
static const char __pyx_k_c_depot[] = "_c_depot";
static const char __pyx_k_c_reset[] = "_c_reset";
static const char __pyx_k_collect[] = "collect";
static const char __pyx_k_default[] = "default";
static const char __pyx_k_deleter[] = "deleter";
static const char __pyx_k_deposit[] = "deposit";
static const char __pyx_k_element[] = "element";
static const char __pyx_k_fee_buy[] = "fee_buy";
static const char __pyx_k_genexpr[] = "genexpr";
static const char __pyx_k_heapify[] = "heapify";
static const char __pyx_k_partial[] = "partial";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_trapeza[] = "trapeza";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_callable[] = "callable";
static const char __pyx_k_coverage[] = "coverage";
static const char __pyx_k_currency[] = "currency";
static const char __pyx_k_eval_fee[] = "_eval_fee";
static const char __pyx_k_fee_dict[] = "fee_dict";
static const char __pyx_k_fee_keys[] = "_fee_keys";
static const char __pyx_k_fee_sell[] = "fee_sell";
static const char __pyx_k_fill_fee[] = "_fill_fee";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_has_warn[] = "has_warn";
static const char __pyx_k_issubset[] = "issubset";
static const char __pyx_k_position[] = "position";
static const char __pyx_k_property[] = "property";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_sell_fee[] = "sell_fee";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_transfer[] = "transfer";
static const char __pyx_k_vec_heap[] = "vec_heap";
static const char __pyx_k_warnings[] = "warnings";
static const char __pyx_k_withdraw[] = "withdraw";
static const char __pyx_k_FXAccount[] = "FXAccount";
static const char __pyx_k_NameError[] = "NameError";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_ask_price[] = "ask_price";
static const char __pyx_k_bid_price[] = "bid_price";
static const char __pyx_k_c_collect[] = "c_collect";
static const char __pyx_k_c_deposit[] = "c_deposit";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_exception[] = "exception";
static const char __pyx_k_exec_heap[] = "exec_heap";
static const char __pyx_k_has_risen[] = "has_risen";
static const char __pyx_k_heap_time[] = "heap_time";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_payee_fee[] = "payee_fee";
static const char __pyx_k_payer_fee[] = "payer_fee";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_time_step[] = "time_step";
static const char __pyx_k_IndexError[] = "IndexError";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_cFXAccount[] = "cFXAccount";
static const char __pyx_k_c_position[] = "c_position";
static const char __pyx_k_c_transfer[] = "c_transfer";
static const char __pyx_k_c_withdraw[] = "c_withdraw";
static const char __pyx_k_fee_amount[] = "fee_amount";
static const char __pyx_k_fee_volume[] = "fee_volume";
static const char __pyx_k_full_reset[] = "_full_reset";
static const char __pyx_k_list_rates[] = "list_rates";
static const char __pyx_k_parse_fees[] = "_parse_fees";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_sample_key[] = "sample_key";
static const char __pyx_k_BaseAccount[] = "BaseAccount";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_action_func[] = "action_func";
static const char __pyx_k_action_type[] = "action_type";
static const char __pyx_k_check_types[] = "check_types";
static const char __pyx_k_deposit_fee[] = "deposit_fee";
static const char __pyx_k_fee_deposit[] = "fee_deposit";
static const char __pyx_k_fx_null_fee[] = "fx_null_fee";
static const char __pyx_k_heap_volume[] = "heap_volume";
static const char __pyx_k_max_forward[] = "max_forward";
static const char __pyx_k_parse_depot[] = "_parse_depot";
static const char __pyx_k_volume_base[] = "volume_base";
static const char __pyx_k_AccountError[] = "AccountError";
static const char __pyx_k_c_isin_depot[] = "_c_isin_depot";
static const char __pyx_k_cum_sum_heap[] = "cum_sum_heap";
static const char __pyx_k_current_rate[] = "current_rate";
static const char __pyx_k_debit_amount[] = "debit_amount";
static const char __pyx_k_depot_setter[] = "depot_setter";
static const char __pyx_k_fee_currency[] = "fee_currency";
static const char __pyx_k_fee_tmp_dict[] = "_fee_tmp_dict";
static const char __pyx_k_fee_withdraw[] = "fee_withdraw";
static const char __pyx_k_min_backward[] = "min_backward";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_staticmethod[] = "staticmethod";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_CoverageError[] = "CoverageError";
static const char __pyx_k_FXAccount_buy[] = "FXAccount.buy";
static const char __pyx_k_ProtectedDict[] = "ProtectedDict";
static const char __pyx_k_base_currency[] = "base_currency";
static const char __pyx_k_check_alt_fee[] = "_check_alt_fee";
static const char __pyx_k_heap_coverage[] = "heap_coverage";
static const char __pyx_k_heap_currency[] = "heap_currency";
static const char __pyx_k_payee_account[] = "payee_account";
static const char __pyx_k_payer_account[] = "payer_account";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_total_balance[] = "total_balance";
static const char __pyx_k_tpz_exception[] = "tpz_exception";
static const char __pyx_k_trapeza_utils[] = "trapeza.utils";
static const char __pyx_k_FXAccount__fee[] = "FXAccount._fee";
static const char __pyx_k_FXAccount_sell[] = "FXAccount.sell";
static const char __pyx_k_FXAccount_tick[] = "FXAccount.tick";
static const char __pyx_k_OperatingError[] = "OperatingError";
static const char __pyx_k_check_coverage[] = "_check_coverage";
static const char __pyx_k_cum_sum_heap_2[] = "_cum_sum_heap";
static const char __pyx_k_exchange_rates[] = "exchange_rates";
static const char __pyx_k_withdrawal_fee[] = "withdrawal_fee";
static const char __pyx_k_FXAccount_clock[] = "FXAccount.clock";
static const char __pyx_k_FXAccount_depot[] = "FXAccount.depot";
static const char __pyx_k_PositionNAError[] = "PositionNAError";
static const char __pyx_k_c_total_balance[] = "c_total_balance";
static const char __pyx_k_marked_coverage[] = "marked_coverage";
static const char __pyx_k_parse_exec_heap[] = "_parse_exec_heap";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_virtual_deposit[] = "virtual_deposit";
static const char __pyx_k_FXAccount___init[] = "FXAccount.__init__";
static const char __pyx_k_FXAccount__reset[] = "FXAccount._reset";
static const char __pyx_k_action_func_type[] = "action_func_type";
static const char __pyx_k_c_check_coverage[] = "_c_check_coverage";
static const char __pyx_k_c_exchange_rates[] = "_c_exchange_rates";
static const char __pyx_k_forward_coverage[] = "forward_coverage";
static const char __pyx_k_heap_action_type[] = "heap_action_type";
static const char __pyx_k_payee_fee_volume[] = "payee_fee_volume";
static const char __pyx_k_payer_fee_volume[] = "payer_fee_volume";
static const char __pyx_k_FXAccount_collect[] = "FXAccount.collect";
static const char __pyx_k_FXAccount_deposit[] = "FXAccount.deposit";
static const char __pyx_k_ProtectedExecHeap[] = "ProtectedExecHeap";
static const char __pyx_k_alt_fee_error_msg[] = "alt_fee_error_msg";
static const char __pyx_k_currency_in_depot[] = "currency in depot";
static const char __pyx_k_fee_exec_duration[] = "fee_exec_duration";
static const char __pyx_k_instant_float_fee[] = "instant_float_fee";
static const char __pyx_k_prohibit_debiting[] = "prohibit_debiting";
static const char __pyx_k_Buy_volume_in_is_0[] = "Buy volume in {} is < 0.";
static const char __pyx_k_FXAccount_position[] = "FXAccount.position";
static const char __pyx_k_FXAccount_transfer[] = "FXAccount.transfer";
static const char __pyx_k_FXAccount_withdraw[] = "FXAccount.withdraw";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_float_fee_currency[] = "float_fee_currency";
static const char __pyx_k_instant_withdrawal[] = "instant_withdrawal";
static const char __pyx_k_payee_fee_currency[] = "payee_fee_currency";
static const char __pyx_k_payer_fee_currency[] = "payer_fee_currency";
static const char __pyx_k_reference_currency[] = "reference_currency";
static const char __pyx_k_FXAccount__eval_fee[] = "FXAccount._eval_fee";
static const char __pyx_k_FXAccount__fill_fee[] = "FXAccount._fill_fee";
static const char __pyx_k_FXAccount_exec_heap[] = "FXAccount.exec_heap";
static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
static const char __pyx_k_Sell_volume_in_is_0[] = "Sell volume in {} is < 0.";
static const char __pyx_k_c_prohibit_debiting[] = "_c_prohibit_debiting";
static const char __pyx_k_cum_sum_marked_fund[] = "cum_sum_marked_fund";
static const char __pyx_k_exchange_rate_value[] = "exchange_rate_value";
static const char __pyx_k_exchange_rates_dict[] = "exchange_rates dict";
static const char __pyx_k_parsed_fee_currency[] = "parsed_fee_currency";
static const char __pyx_k_processing_duration[] = "processing_duration";
static const char __pyx_k_c_reference_currency[] = "_c_reference_currency";
static const char __pyx_k_cum_sum_marked_debit[] = "cum_sum_marked_debit";
static const char __pyx_k_ignore_type_checking[] = "ignore_type_checking";
static const char __pyx_k_list_base_quote_pair[] = "list_base_quote_pair";
static const char __pyx_k_parse_exchange_rates[] = "_parse_exchange_rates";
static const char __pyx_k_update_exchange_rate[] = "update_exchange_rate";
static const char __pyx_k_FXAccount__full_reset[] = "FXAccount._full_reset";
static const char __pyx_k_FXAccount__parse_fees[] = "FXAccount._parse_fees";
static const char __pyx_k_check_marked_coverage[] = "check_marked_coverage";
static const char __pyx_k_clock_has_to_be_int_0[] = "clock has to be int >= 0.";
static const char __pyx_k_cum_sum_marked_fund_2[] = "_cum_sum_marked_fund";
static const char __pyx_k_exchange_rates_setter[] = "exchange_rates_setter";
static const char __pyx_k_list_base_quote_pairs[] = "list_base_quote_pairs";
static const char __pyx_k_FXAccount__parse_depot[] = "FXAccount._parse_depot";
static const char __pyx_k_c_ignore_type_checking[] = "_c_ignore_type_checking";
static const char __pyx_k_c_update_exchange_rate[] = "c_update_exchange_rate";
static const char __pyx_k_cum_sum_marked_debit_2[] = "_cum_sum_marked_debit";
static const char __pyx_k_default_float_currency[] = "default_float_currency";
static const char __pyx_k_exchange_rate_currency[] = "exchange_rate_currency";
static const char __pyx_k_ignore_type_checking_2[] = "_ignore_type_checking";
static const char __pyx_k_FXAccount__cum_sum_heap[] = "FXAccount._cum_sum_heap";
static const char __pyx_k_FXAccount_total_balance[] = "FXAccount.total_balance";
static const char __pyx_k_c_check_marked_coverage[] = "_c_check_marked_coverage";
static const char __pyx_k_check_is_valid_fee_func[] = "_check_is_valid_fee_func";
static const char __pyx_k_exchange_rate_key_tuple[] = "exchange_rate_key_tuple";
static const char __pyx_k_fee_processing_duration[] = "fee_processing_duration";
static const char __pyx_k_payee_fee_exec_duration[] = "payee_fee_exec_duration";
static const char __pyx_k_payer_fee_exec_duration[] = "payer_fee_exec_duration";
static const char __pyx_k_pyx_unpickle_cFXAccount[] = "__pyx_unpickle_cFXAccount";
static const char __pyx_k_FXAccount__check_alt_fee[] = "FXAccount._check_alt_fee";
static const char __pyx_k_FXAccount_exchange_rates[] = "FXAccount.exchange_rates";
static const char __pyx_k_currency_volume_in_depot[] = "currency volume in depot";
static const char __pyx_k_is_exchange_rate_updated[] = "is_exchange_rate_updated";
static const char __pyx_k_prohibit_debiting_setter[] = "prohibit_debiting_setter";
static const char __pyx_k_FXAccount__check_coverage[] = "FXAccount._check_coverage";
static const char __pyx_k_payee_processing_duration[] = "payee_processing_duration";
static const char __pyx_k_payer_processing_duration[] = "payer_processing_duration";
static const char __pyx_k_FXAccount__parse_exec_heap[] = "FXAccount._parse_exec_heap";
static const char __pyx_k_c_is_exchange_rate_updated[] = "_c_is_exchange_rate_updated";
static const char __pyx_k_trapeza_account_fx_account[] = "trapeza.account.fx_account";
static const char __pyx_k_FXAccount_prohibit_debiting[] = "FXAccount.prohibit_debiting";
static const char __pyx_k_Lists_must_have_same_length[] = "Lists must have same length.";
static const char __pyx_k_batch_update_exchange_rates[] = "batch_update_exchange_rates";
static const char __pyx_k_FXAccount_reference_currency[] = "FXAccount.reference_currency";
static const char __pyx_k_trapeza_account_base_account[] = "trapeza.account.base_account";
static const char __pyx_k_volume_must_be_grater_than_0[] = "volume must be grater than 0.";
static const char __pyx_k_FXAccount__fee_locals_genexpr[] = "FXAccount._fee.<locals>.genexpr";
static const char __pyx_k_c_batch_update_exchange_rates[] = "c_batch_update_exchange_rates";
static const char __pyx_k_coverage_must_be_except_debit[] = "coverage must be {\"except\", \"debit\"}.";
static const char __pyx_k_FXAccount__cum_sum_marked_fund[] = "FXAccount._cum_sum_marked_fund";
static const char __pyx_k_FXAccount_depot_locals_genexpr[] = "FXAccount.depot.<locals>.genexpr";
static const char __pyx_k_FXAccount_update_exchange_rate[] = "FXAccount.update_exchange_rate";
static const char __pyx_k_trapeza_account_fx_account_pyx[] = "trapeza\\account\\fx_account.pyx";
static const char __pyx_k_Derived_from_BaseAccount_This_i[] = "\n    Derived from BaseAccount. This implementation is meant to model transactions and mechanisms specific to the\n    foreign exchange market. Nevertheless the implementation can also be used to model e.g. transactions of stocks\n    (with minor adaption such as rounding stocks down to whole).\n    Special emphasis is placed on providing a flexible interface to model a variety of situations.\n\n    The package 'trapeza' uses the following FX specific notation for currency pairs (direct quotation notation):\n        A currency pair is denoted by base|quote, e.g. \342\202\254|$.\n        The exchange rate of the base|quote pair defines that x volume in quote currency is exchanged for one unit of\n        base currency.\n        In mathematical terms, the exchange rate of base|quote has the unit of [quote/base], e.g. the exchange rate\n        of the \342\202\254|$-pair has the mathematical unit of [$/\342\202\254].\n        Multiplying the exchange rate by a volume in base currency is equivalent to the exchange direction 'from base\n        to quote'. Dividing a volume in quote currency by the exchange rate is equivalent to 'from quote to base'.\n        We use 'w' as symbol for the exchange rate of base|quote pair, v_base and v_quote for volumes in base and\n        quote currencies.\n\n        Multiplication: v_base * w = v_quote -> [base] * [quote/base] = [quote]  (from base to quote)\n        Division:       v_quote / w = v_base -> [quote] * [base/quote] = [base]  (from quote to base)\n\n        This also referred to as 'direct quotation' (versus volume quotation)\n\n    In context of the above defined notation, sell and buy transactions are defined as follows:\n        Buy: Buy the base currency and sell the quote currency.\n             (in other words: receive units in base currency in exchange for quote currency)\n             In market context, buy transactions are performed at the ask price\n        Sell: Sell the base currency and buy the quote currency.""\n              (in other words: receive units in quote currency in exchange for base currency)\n              Sell transactions are performed at the bid price\n        Ask price: price offered to buyer side (from seller)\n        Bid price: price offered to seller side (from buyer)\n        Normally following relation holds true: aks price > bid price\n\n    FXAccount class tries to model a normal bank depot/ account with all its transaction types. Following transaction\n    types are implemented:\n        - deposit: deposit money (or assets) onto the account's depot\n        - withdraw: withdraw money (or assets) from the account's depot\n        - buy: buy a base|quote currency; base can either be an other currency or any asset (e.g. stock)\n        - sell: sell a base|quote currency; base can either be an other currency or any asset (e.g. stock)\n        - transfer: transfer money (or assets) from own account onto an other account (which at least must be derived\n                    from trapeza.account.base_account.BaseAccount abstract class)\n        - collect: collect money (or assets) from an other account (which at least must be derived\n                   from trapeza.account.base_account.BaseAccount abstract class) onto own account\n    For sell and buy transactions you have to supply the respective market data, e.g. the current exchange rate.\n    Thereby it does not matter if the user is selling/buying a currency pair or stocks (which is just\n    a stock|currency pair) or anything else like options. Goal of this library is not simulate market data e.g. option\n    prices, but to model transaction types. By supplying appropriate market data, the user is free to model transactions\n    regarding currency pairs, stocks, options, etc.\n\n    FXAccount is also able to model processing times of a transaction's fulfillment, e.g. if a transaction is not\n    executed immediately but needs some time to be filled (transmission time of message, broker execution, ""etc.).\n    This is achieved by implementing a stack automaton alike logic which executes at discrete time steps.\n    FXAccount contains an internal clock, which is counted up by calling FXAccount.tick() by  one time step.\n    If processing duration of a transaction is set to 0 (default), the respective transaction is filled immediately.\n    If processing duration is set to something else than 0, then the respective transaction is filled when the internal\n    clock of FXAccount reaches the time step of 'processing duration + time at instructing transaction', e.g.:\n        time step 0: instruct sell transaction with processing duration of 2\n        time step 1: nothing happens\n        time step 2: sell transaction is/ will be conducted\n    The time unit can be anything the user wants to choose, e.g. seconds, working days etc.\n    Internally, this structure is represented by a stack, which in this case is a heap data structure (we'll call it\n    heap from here on). Transactions with larger processing times than 0 will be put onto the heap. At each call to\n    FXAccount.tick() the heap will be checked if any delayed transactions are due.\n\n    FXAccount also performs a coverage check, e.g. if a withdraw transaction would lead to a negative account balance.\n    This check is also applied to transactions delayed by processing durations at the time of instructing them in order\n    to ensure that transactions filled at future time steps will not lead to coverage violations.\n    For this kind of coverage check, three possible checks are available:\n        1. False or None: omits coverage analysis\n        2. 'min_backward': Current clock time and processing duration are added up to the execution time step of\n                           respective order. Coverage is checked up to this execution time step. This ensures, that\n                           the transaction is conductible at the time due, but does not ensure, that transaction\n                      ""     might lead to coverage violations beyond the execution time step.\n        3. 'max_forward': The maximum execution time step on the internal heap is taken as reference time step\n                          (therefore called max forward). Coverage check is performed up to this reference time step.\n                          This ensures, that coverage is given at any time in the future.\n    A coverage violation throws an trapeza.exception.CoverageException. See docstring of transaction types on how to\n    control exception behavior.\n    If checking of marked but not yet billed transactions (self.check_marked_coverage set at __init__) is turned off\n    (set to False), then unexpected behavior raises in case a coverage exception occurs (either when trying to perform\n    a transaction or during execution of transactions stacked on internal heap (delayed transactions by processing\n    times)).\n\n    Furthermore, FXAccount can define transaction fees. Those transaction fees can either be defined by arguments\n    passed to the different transaction calls, or can be defined globally, e.g. at __init__ as functions which are then\n    automatically applied to the different transactions. Globally defined fees must be functions.\n    If fees are defined as functions, they must implement the following call signature:\n        (fee_amount, fee_currency, fee_exec_time) = fee(volume, price, base, quote, processing_duration)\n            volume: float, given in base (see parameter:base)\n            price: float, given in base|quote direct notation (see above for notation convention)\n            base: python string, base currency\n            quote: python string, quote currency\n            processing_duration: int, processing time needed to fill transaction/ until transaction takes effect\n                                 on account\n    The arguments volume, price, base, quote and processing_duration are the same arguments as used in the call to\n    the transaction,"" e.g. FXAccount.sell(...). They are just passed through to the fee function.\n    See docstring of class methods for further details.\n    Fee functions can also be set via overwriting class attributes. FXAccount._fee contains a dict:\n        FXAccount._fee = {'sell': func, 'buy': func, 'withdraw': func, 'deposit': func}\n    If the user wants to overwrite the fee functions, an entire dict has to be provided! Single key-values can not be\n    overwritten separately (e.g. FXAccount._fee['sell'] = ... will throw an exception)!\n    Collect() and transfer() do not have dedicated fee functions, but invoke those of withdrawal and depositing. Extra\n    fees can be submitted via the argument list (in this case fees of depositing and withdrawal are temporarily\n    suspended once for this transaction). In general, passing fees via argument list of method calls will take those\n    fees into consideration and will temporarily suspend global fees once for the respective transaction.\n    Default is not applying any fees.\n    The above defined function signature for defining custom fees always takes volume referenced in base currency\n    (both are arguments of custom defined fee function) and always takes python strings as inputs (no encoding etc.\n    needed).\n\n    FXAccount keeps track of all positions in its depot. FXAccount.position(currency) returns the current position size\n    of currency (or any other asset).\n    FXAccount.total_balance returns the total value of the account's depot expressed in the reference currency\n    (set at __init__).\n    FXAccount.total_balance can be called directly when passing exchange rates to it (keys: tuple of strings\n    expressing base and quote, value: float). Otherwise self.batch_update_exchange_rates (or self.update_exchange_rate,\n    which is not recommended) has to be called beforehand (if self.total_balance shall be called without any\n    arguments).\n    FXAccount.position does not need any updating beforehand.\n    .""update_exchange_rate and .batch_update_exchange_rates do not affect internal heap of delayed transactions or the\n    internal clock.\n    FXAccount.position and FXAccount.total_balance are just (so to speak) snapshots at the current internal clock time.\n    Do not forget to call FXAccount.tick() to proceed in time and to execute transactions delayed by processing times.\n\n    FXAccount also has the option of type checking, which can be set at __init__. If set to False, each class method\n    checks if the arguments passed to it are of the right data type. This adds some safety by additional checks but\n    costs performance. If set to True, type checking will be ignored. Default is type checking being active.\n\n    Quickstart:\n    >> acc = FXAccount('EUR')   # reference currency is in EUR\n    >> acc.deposit(100, 'EUR')  # deposit 100 EUR onto account\n    >> acc.tick()               # proceed one time step, nothing's gonna happen here...\n    >> acc.sell(10, 1, 'EUR', 'TPZ')    # exchange 10 EUR against fictive currency TPZ\n    >> print(acc.total_balance({('EUR', 'TPZ'): 1}\n    >> >> 100\n    >> acc.sell(10, 1, 'EUR', 'TPZ', fee= 1, processing_duration=1)     # transaction is delayed, fee in base\n    >> print(acc.total_balance({('EUR', 'TPZ'): 1}\n    >> >> 100\n    >> acc.tick()       # this will lead to filling delayed transaction\n    >> print(acc.depot)\n    >> >> {'EUR': 79, 'TPZ': 20}    # 1 EUR fee is subtracted\n    ";
static const char __pyx_k_FXAccount__cum_sum_marked_debit[] = "FXAccount._cum_sum_marked_debit";
static const char __pyx_k_FXAccount__ignore_type_checking[] = "FXAccount._ignore_type_checking";
static const char __pyx_k_FXAccount__parse_exchange_rates[] = "FXAccount._parse_exchange_rates";
static const char __pyx_k_FXAccount_batch_update_exchange[] = "FXAccount.batch_update_exchange_rates";
static const char __pyx_k_FXAccount_check_marked_coverage[] = "FXAccount.check_marked_coverage";
static const char __pyx_k_FXAccount_exchange_rates_locals[] = "FXAccount.exchange_rates.<locals>.genexpr";
static const char __pyx_k_Internal_clock_must_be_set_to_0[] = "Internal clock must be set to >=0.";
static const char __pyx_k_When_setting_exec_heap_manually[] = "When setting exec_heap manually, method argument must either be a list or tuple of single entries or a single entry itself as list or tuple of the following elements: [int:time, str:action_func, float:volume, str:currency, str:coverage]. action_func must be either \"withdraw\" or \"deposit\", got {}";
static const char __pyx_k_coverage_must_be_except_partial[] = "coverage must be {\"except\", \"partial\", \"debit\"}.";
static const char __pyx_k_exchange_rates_does_not_include[] = "exchange_rates does not include all currencies listed in account depot. Currencies in current depot: {}. Currencies given by exchange_rates: {}";
static const char __pyx_k_fee_setter_argument_must_be_dic[] = "_fee setter argument must be dict with fee[\"buy\"], fee[\"sell\"], fee[\"deposit\"] and fee[\"withdraw\"]. See docstring of FXAccount for further information about fee handling.";
static const char __pyx_k_is_exchange_rate_updated_setter[] = "is_exchange_rate_updated_setter";
static const char __pyx_k_must_be_of_type_None_bool_float[] = "{} must be of type None, bool, float or func and not of type {}";
static const char __pyx_k_or_are_not_included_in_exchange[] = "{}|{} or {}|{} are not included in exchange_rates.";
static const char __pyx_k_parse_fee_and_transaction_param[] = "_parse_fee_and_transaction_params";
static const char __pyx_k_Auto_converting_withdraw_and_dep[] = "Auto-converting \"withdraw\" and \"deposit\" to \"c_withdraw\" and \"c_deposit\" (to match up cython-implemented exec_heap of cFXAccount, which wrapped is by FXAccount).";
static const char __pyx_k_Checking_of_marked_but_not_yet_b[] = "Checking of marked but not yet billed transactions was turned off. Account depot as well as internal execution heap of delayed/ future transactions may be irrecoverably corrupted. CoverageError.";
static const char __pyx_k_Debiting_into_negative_positions[] = "Debiting into negative positions not allowed by parameter \"prohibit_debiting\" at init.";
static const char __pyx_k_Exchange_rates_contain_empty_dic[] = "Exchange rates contain empty dict.";
static const char __pyx_k_Exchange_rates_have_not_been_upd[] = "Exchange rates have not been updated before calling. Please call self.batch_update_exchange_rates beforehand.";
static const char __pyx_k_Exchange_rates_of_base_quote_and[] = "Exchange rates of base|quote and 1/quote|base do not match up.";
static const char __pyx_k_FXAccount__check_is_valid_fee_fu[] = "FXAccount._check_is_valid_fee_func";
static const char __pyx_k_FXAccount__parse_fee_and_transac[] = "FXAccount._parse_fee_and_transaction_params";
static const char __pyx_k_FXAccount_is_exchange_rate_updat[] = "FXAccount.is_exchange_rate_updated";
static const char __pyx_k_Incompatible_checksums_s_vs_0xf1[] = "Incompatible checksums (%s vs 0xf142c4f = (_c_check_marked_coverage, _c_clock, _c_depot, _c_exchange_rates, _c_fee, _c_ignore_type_checking, _c_is_exchange_rate_updated, _c_is_heap, _c_prohibit_debiting, _c_reference_currency, vec_heap))";
static const char __pyx_k_Internal_logic_error_Value_in_un[] = "Internal logic error. Value in underlying c-implementation (cython) is set to an invalid value.";
static const char __pyx_k_Negative_depot_position_detected[] = "Negative depot position detected, even though debiting was not allowed. Account depot as well as internal execution heap of delayed/ future transactions may be irrecoverably corrupted. CoverageError.";
static const char __pyx_k_Only_integers_for_setting_intern[] = "Only integers for setting internal clock.";
static const char __pyx_k_Single_entry_to_exec_heap_consis[] = "Single entry to exec_heap consists of: [int:time, str:action_func, float:volume, str:currency, str:coverage]. Only {} elements were given as single entry to exec_heap. Either a single entry or a list of single entries can be used to set exec_heap manually.";
static const char __pyx_k_Transaction_not_feasible_even_th[] = "Transaction not feasible even though coverage set to partial. Fees not covered.";
static const char __pyx_k_action_func_type_must_be_c_withd[] = "action_func_type must be \"c_withdraw\", \"c_deposit\". \"withdraw\", \"deposit\" (auto-converting to \"withdraw\" and \"deposit\" to \"c_...\"), got {}";
static const char __pyx_k_alt_fee_must_be_in_None_False_fu[] = "alt_fee must be in {None, False, func, Float";
  static const char __pyx_k_check_marked_coverage_must_be_in[] = "check_marked_coverage must be in {None, False, \"max_forward\", \"min_backward\"}.";
  static const char __pyx_k_coverage_must_be_in_except_parti[] = "coverage must be in [\"except\", \"partial\", \"debit\", \"ignore\"]";
  static const char __pyx_k_exec_heap_must_be_either_list_of[] = "exec_heap must be either list of list, tuples of lists, tuple of a single entryto exec_heap or list of single entry to exec_heap. Single entry to exec_heapconsists of: [int:time, str:action_func, float:volume, str:currency, str:coverage]";
  static const char __pyx_k_list_base_quote_pairs_must_conta[] = "list_base_quote_pairs must contain tuples";
  static const char __pyx_k_list_rates_must_contain_floats_o[] = "list_rates must contain floats or ints";
  static const char __pyx_k_payee_account_has_no_implementat[] = "payee_account has no implementation payee_account.deposit(volume, currency, payee_fee, payee_processing_duration)";
  static const char __pyx_k_payer_account_has_no_implementat[] = "payer_account has no implementation payer_account.withdraw(volume, currency, payer_fee, payer_processing_duration)";
  static const char __pyx_k_Transaction_not_feasible_even_th_2[] = "Transaction not feasible even though coverage set to partial. Fees not covered";
  static PyObject *__pyx_n_s_AccountError;
  static PyObject *__pyx_kp_u_Auto_converting_withdraw_and_dep;
  static PyObject *__pyx_n_s_BaseAccount;
  static PyObject *__pyx_kp_u_Buy_volume_in_is_0;
  static PyObject *__pyx_kp_u_Checking_of_marked_but_not_yet_b;
  static PyObject *__pyx_n_s_CoverageError;
  static PyObject *__pyx_kp_u_Debiting_into_negative_positions;
  static PyObject *__pyx_kp_s_Derived_from_BaseAccount_This_i;
  static PyObject *__pyx_kp_u_Exchange_rates_contain_empty_dic;
  static PyObject *__pyx_kp_u_Exchange_rates_have_not_been_upd;
  static PyObject *__pyx_kp_u_Exchange_rates_of_base_quote_and;
  static PyObject *__pyx_n_s_FXAccount;
  static PyObject *__pyx_n_s_FXAccount___init;
  static PyObject *__pyx_n_s_FXAccount__check_alt_fee;
  static PyObject *__pyx_n_s_FXAccount__check_coverage;
  static PyObject *__pyx_n_s_FXAccount__check_is_valid_fee_fu;
  static PyObject *__pyx_n_s_FXAccount__cum_sum_heap;
  static PyObject *__pyx_n_s_FXAccount__cum_sum_marked_debit;
  static PyObject *__pyx_n_s_FXAccount__cum_sum_marked_fund;
  static PyObject *__pyx_n_s_FXAccount__eval_fee;
  static PyObject *__pyx_n_s_FXAccount__fee;
  static PyObject *__pyx_n_s_FXAccount__fee_locals_genexpr;
  static PyObject *__pyx_n_s_FXAccount__fill_fee;
  static PyObject *__pyx_n_s_FXAccount__full_reset;
  static PyObject *__pyx_n_s_FXAccount__ignore_type_checking;
  static PyObject *__pyx_n_s_FXAccount__parse_depot;
  static PyObject *__pyx_n_s_FXAccount__parse_exchange_rates;
  static PyObject *__pyx_n_s_FXAccount__parse_exec_heap;
  static PyObject *__pyx_n_s_FXAccount__parse_fee_and_transac;
  static PyObject *__pyx_n_s_FXAccount__parse_fees;
  static PyObject *__pyx_n_s_FXAccount__reset;
  static PyObject *__pyx_n_s_FXAccount_batch_update_exchange;
  static PyObject *__pyx_n_s_FXAccount_buy;
  static PyObject *__pyx_n_s_FXAccount_check_marked_coverage;
  static PyObject *__pyx_n_s_FXAccount_clock;
  static PyObject *__pyx_n_s_FXAccount_collect;
  static PyObject *__pyx_n_s_FXAccount_deposit;
  static PyObject *__pyx_n_s_FXAccount_depot;
  static PyObject *__pyx_n_s_FXAccount_depot_locals_genexpr;
  static PyObject *__pyx_n_s_FXAccount_exchange_rates;
  static PyObject *__pyx_n_s_FXAccount_exchange_rates_locals;
  static PyObject *__pyx_n_s_FXAccount_exec_heap;
  static PyObject *__pyx_n_s_FXAccount_is_exchange_rate_updat;
  static PyObject *__pyx_n_s_FXAccount_position;
  static PyObject *__pyx_n_s_FXAccount_prohibit_debiting;
  static PyObject *__pyx_n_s_FXAccount_reference_currency;
  static PyObject *__pyx_n_s_FXAccount_sell;
  static PyObject *__pyx_n_s_FXAccount_tick;
  static PyObject *__pyx_n_s_FXAccount_total_balance;
  static PyObject *__pyx_n_s_FXAccount_transfer;
  static PyObject *__pyx_n_s_FXAccount_update_exchange_rate;
  static PyObject *__pyx_n_s_FXAccount_withdraw;
  static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xf1;
  static PyObject *__pyx_n_s_IndexError;
  static PyObject *__pyx_kp_u_Internal_clock_must_be_set_to_0;
  static PyObject *__pyx_kp_u_Internal_logic_error_Value_in_un;
  static PyObject *__pyx_n_s_KeyError;
  static PyObject *__pyx_kp_u_Lists_must_have_same_length;
  static PyObject *__pyx_n_s_NameError;
  static PyObject *__pyx_kp_u_Negative_depot_position_detected;
  static PyObject *__pyx_n_s_NotImplementedError;
  static PyObject *__pyx_kp_u_Only_integers_for_setting_intern;
  static PyObject *__pyx_n_s_OperatingError;
  static PyObject *__pyx_n_s_PickleError;
  static PyObject *__pyx_n_s_PositionNAError;
  static PyObject *__pyx_n_s_ProtectedDict;
  static PyObject *__pyx_n_s_ProtectedExecHeap;
  static PyObject *__pyx_kp_u_Sell_volume_in_is_0;
  static PyObject *__pyx_kp_u_Single_entry_to_exec_heap_consis;
  static PyObject *__pyx_kp_u_Transaction_not_feasible_even_th;
  static PyObject *__pyx_kp_u_Transaction_not_feasible_even_th_2;
  static PyObject *__pyx_n_s_TypeError;
  static PyObject *__pyx_n_s_ValueError;
  static PyObject *__pyx_kp_u_When_setting_exec_heap_manually;
  static PyObject *__pyx_n_u_X;
  static PyObject *__pyx_n_u_Y;
  static PyObject *__pyx_kp_u__19;
  static PyObject *__pyx_n_s__93;
  static PyObject *__pyx_n_s_action_func;
  static PyObject *__pyx_n_s_action_func_type;
  static PyObject *__pyx_kp_u_action_func_type_must_be_c_withd;
  static PyObject *__pyx_n_s_action_type;
  static PyObject *__pyx_n_s_alt_fee;
  static PyObject *__pyx_n_s_alt_fee_error_msg;
  static PyObject *__pyx_kp_u_alt_fee_must_be_in_None_False_fu;
  static PyObject *__pyx_n_s_args;
  static PyObject *__pyx_n_s_ask_price;
  static PyObject *__pyx_n_u_ask_price;
  static PyObject *__pyx_n_s_base;
  static PyObject *__pyx_n_u_base;
  static PyObject *__pyx_n_u_base_currency;
  static PyObject *__pyx_n_s_batch_update_exchange_rates;
  static PyObject *__pyx_n_s_bid_price;
  static PyObject *__pyx_n_u_bid_price;
  static PyObject *__pyx_n_b_buy;
  static PyObject *__pyx_n_s_buy;
  static PyObject *__pyx_n_u_buy;
  static PyObject *__pyx_n_u_buy_fee;
  static PyObject *__pyx_n_u_c;
  static PyObject *__pyx_n_s_cFXAccount;
  static PyObject *__pyx_n_s_c__init;
  static PyObject *__pyx_n_s_c_batch_update_exchange_rates;
  static PyObject *__pyx_n_s_c_buy;
  static PyObject *__pyx_n_s_c_check_coverage;
  static PyObject *__pyx_n_s_c_check_marked_coverage;
  static PyObject *__pyx_n_s_c_clock;
  static PyObject *__pyx_n_s_c_collect;
  static PyObject *__pyx_n_b_c_deposit;
  static PyObject *__pyx_n_s_c_deposit;
  static PyObject *__pyx_n_u_c_deposit;
  static PyObject *__pyx_n_s_c_depot;
  static PyObject *__pyx_n_s_c_exchange_rates;
  static PyObject *__pyx_n_s_c_fee;
  static PyObject *__pyx_n_s_c_ignore_type_checking;
  static PyObject *__pyx_n_s_c_is_exchange_rate_updated;
  static PyObject *__pyx_n_s_c_isin_depot;
  static PyObject *__pyx_n_s_c_position;
  static PyObject *__pyx_n_s_c_prohibit_debiting;
  static PyObject *__pyx_n_s_c_reference_currency;
  static PyObject *__pyx_n_s_c_reset;
  static PyObject *__pyx_n_s_c_sell;
  static PyObject *__pyx_n_s_c_tick;
  static PyObject *__pyx_n_s_c_total_balance;
  static PyObject *__pyx_n_s_c_transfer;
  static PyObject *__pyx_n_s_c_update_exchange_rate;
  static PyObject *__pyx_n_b_c_withdraw;
  static PyObject *__pyx_n_s_c_withdraw;
  static PyObject *__pyx_n_u_c_withdraw;
  static PyObject *__pyx_n_s_callable;
  static PyObject *__pyx_n_s_check_alt_fee;
  static PyObject *__pyx_n_s_check_coverage;
  static PyObject *__pyx_n_s_check_is_valid_fee_func;
  static PyObject *__pyx_n_s_check_marked_coverage;
  static PyObject *__pyx_kp_u_check_marked_coverage_must_be_in;
  static PyObject *__pyx_n_s_check_types;
  static PyObject *__pyx_n_s_class;
  static PyObject *__pyx_n_s_cline_in_traceback;
  static PyObject *__pyx_n_s_clock;
  static PyObject *__pyx_n_u_clock;
  static PyObject *__pyx_kp_u_clock_has_to_be_int_0;
  static PyObject *__pyx_n_s_close;
  static PyObject *__pyx_n_s_collect;
  static PyObject *__pyx_n_s_coverage;
  static PyObject *__pyx_n_u_coverage;
  static PyObject *__pyx_kp_u_coverage_must_be_except_debit;
  static PyObject *__pyx_kp_u_coverage_must_be_except_partial;
  static PyObject *__pyx_kp_u_coverage_must_be_in_except_parti;
  static PyObject *__pyx_n_s_cum_sum_heap;
  static PyObject *__pyx_n_s_cum_sum_heap_2;
  static PyObject *__pyx_n_s_cum_sum_marked_debit;
  static PyObject *__pyx_n_s_cum_sum_marked_debit_2;
  static PyObject *__pyx_n_s_cum_sum_marked_fund;
  static PyObject *__pyx_n_s_cum_sum_marked_fund_2;
  static PyObject *__pyx_n_s_currency;
  static PyObject *__pyx_n_u_currency;
  static PyObject *__pyx_kp_u_currency_in_depot;
  static PyObject *__pyx_kp_u_currency_volume_in_depot;
  static PyObject *__pyx_n_s_current_rate;
  static PyObject *__pyx_n_b_debit;
  static PyObject *__pyx_n_u_debit;
  static PyObject *__pyx_n_s_debit_amount;
  static PyObject *__pyx_n_s_decode;
  static PyObject *__pyx_n_b_default;
  static PyObject *__pyx_n_s_default_float_currency;
  static PyObject *__pyx_n_s_deleter;
  static PyObject *__pyx_n_b_deposit;
  static PyObject *__pyx_n_s_deposit;
  static PyObject *__pyx_n_u_deposit;
  static PyObject *__pyx_n_u_deposit_fee;
  static PyObject *__pyx_n_s_depot;
  static PyObject *__pyx_n_u_depot;
  static PyObject *__pyx_n_u_depot_setter;
  static PyObject *__pyx_n_s_dict;
  static PyObject *__pyx_n_s_doc;
  static PyObject *__pyx_n_s_e;
  static PyObject *__pyx_n_s_element;
  static PyObject *__pyx_n_s_encode;
  static PyObject *__pyx_n_s_enumerate;
  static PyObject *__pyx_n_s_eval_fee;
  static PyObject *__pyx_n_b_except;
  static PyObject *__pyx_n_u_except;
  static PyObject *__pyx_n_s_exception;
  static PyObject *__pyx_n_u_exchange_rate_currency;
  static PyObject *__pyx_n_u_exchange_rate_key_tuple;
  static PyObject *__pyx_n_u_exchange_rate_value;
  static PyObject *__pyx_n_s_exchange_rates;
  static PyObject *__pyx_n_u_exchange_rates;
  static PyObject *__pyx_kp_u_exchange_rates_dict;
  static PyObject *__pyx_kp_u_exchange_rates_does_not_include;
  static PyObject *__pyx_n_u_exchange_rates_setter;
  static PyObject *__pyx_n_s_exec_heap;
  static PyObject *__pyx_n_u_exec_heap;
  static PyObject *__pyx_kp_u_exec_heap_must_be_either_list_of;
  static PyObject *__pyx_n_s_f_key;
  static PyObject *__pyx_n_s_fee;
  static PyObject *__pyx_n_s_fee_2;
  static PyObject *__pyx_n_s_fee_amount;
  static PyObject *__pyx_n_u_fee_amount;
  static PyObject *__pyx_n_s_fee_buy;
  static PyObject *__pyx_n_u_fee_buy;
  static PyObject *__pyx_n_s_fee_currency;
  static PyObject *__pyx_n_u_fee_currency;
  static PyObject *__pyx_n_s_fee_deposit;
  static PyObject *__pyx_n_u_fee_deposit;
  static PyObject *__pyx_n_s_fee_dict;
  static PyObject *__pyx_n_u_fee_dict;
  static PyObject *__pyx_n_s_fee_exec_duration;
  static PyObject *__pyx_n_s_fee_keys;
  static PyObject *__pyx_n_u_fee_processing_duration;
  static PyObject *__pyx_n_s_fee_sell;
  static PyObject *__pyx_n_u_fee_sell;
  static PyObject *__pyx_kp_u_fee_setter_argument_must_be_dic;
  static PyObject *__pyx_n_s_fee_tmp_dict;
  static PyObject *__pyx_n_s_fee_volume;
  static PyObject *__pyx_n_s_fee_withdraw;
  static PyObject *__pyx_n_u_fee_withdraw;
  static PyObject *__pyx_n_s_fill_fee;
  static PyObject *__pyx_n_s_float_fee_currency;
  static PyObject *__pyx_n_u_float_fee_currency;
  static PyObject *__pyx_n_s_format;
  static PyObject *__pyx_n_s_forward_coverage;
  static PyObject *__pyx_n_s_full_reset;
  static PyObject *__pyx_n_s_func;
  static PyObject *__pyx_n_s_fx_null_fee;
  static PyObject *__pyx_n_s_genexpr;
  static PyObject *__pyx_n_s_getstate;
  static PyObject *__pyx_n_s_has_risen;
  static PyObject *__pyx_n_s_has_warn;
  static PyObject *__pyx_n_u_heap_action_type;
  static PyObject *__pyx_n_u_heap_coverage;
  static PyObject *__pyx_n_u_heap_currency;
  static PyObject *__pyx_n_u_heap_time;
  static PyObject *__pyx_n_u_heap_volume;
  static PyObject *__pyx_n_s_heapify;
  static PyObject *__pyx_n_s_heapq;
  static PyObject *__pyx_n_s_i;
  static PyObject *__pyx_n_u_ignore;
  static PyObject *__pyx_n_s_ignore_type_checking;
  static PyObject *__pyx_n_u_ignore_type_checking;
  static PyObject *__pyx_n_s_ignore_type_checking_2;
  static PyObject *__pyx_n_s_import;
  static PyObject *__pyx_n_s_init;
  static PyObject *__pyx_n_s_inp;
  static PyObject *__pyx_n_u_inp;
  static PyObject *__pyx_n_s_instant_float_fee;
  static PyObject *__pyx_n_u_instant_float_fee;
  static PyObject *__pyx_n_s_instant_withdrawal;
  static PyObject *__pyx_n_u_instant_withdrawal;
  static PyObject *__pyx_n_s_is_exchange_rate_updated;
  static PyObject *__pyx_n_u_is_exchange_rate_updated_setter;
  static PyObject *__pyx_n_s_issubset;
  static PyObject *__pyx_n_s_items;
  static PyObject *__pyx_n_s_k;
  static PyObject *__pyx_n_s_keys;
  static PyObject *__pyx_n_s_list_base_quote_pair;
  static PyObject *__pyx_n_s_list_base_quote_pairs;
  static PyObject *__pyx_kp_u_list_base_quote_pairs_must_conta;
  static PyObject *__pyx_n_s_list_rates;
  static PyObject *__pyx_kp_u_list_rates_must_contain_floats_o;
  static PyObject *__pyx_n_s_main;
  static PyObject *__pyx_n_s_marked_coverage;
  static PyObject *__pyx_n_u_max_forward;
  static PyObject *__pyx_n_s_metaclass;
  static PyObject *__pyx_n_u_min_backward;
  static PyObject *__pyx_n_s_module;
  static PyObject *__pyx_kp_u_must_be_of_type_None_bool_float;
  static PyObject *__pyx_n_s_name;
  static PyObject *__pyx_n_s_new;
  static PyObject *__pyx_kp_u_or_are_not_included_in_exchange;
  static PyObject *__pyx_n_s_parse_depot;
  static PyObject *__pyx_n_s_parse_exchange_rates;
  static PyObject *__pyx_n_s_parse_exec_heap;
  static PyObject *__pyx_n_s_parse_fee_and_transaction_param;
  static PyObject *__pyx_n_s_parse_fees;
  static PyObject *__pyx_n_s_parsed_fee_currency;
  static PyObject *__pyx_n_u_partial;
  static PyObject *__pyx_n_s_payee_account;
  static PyObject *__pyx_kp_u_payee_account_has_no_implementat;
  static PyObject *__pyx_n_s_payee_fee;
  static PyObject *__pyx_n_s_payee_fee_currency;
  static PyObject *__pyx_n_s_payee_fee_exec_duration;
  static PyObject *__pyx_n_s_payee_fee_volume;
  static PyObject *__pyx_n_s_payee_processing_duration;
  static PyObject *__pyx_n_u_payee_processing_duration;
  static PyObject *__pyx_n_s_payer_account;
  static PyObject *__pyx_kp_u_payer_account_has_no_implementat;
  static PyObject *__pyx_n_s_payer_fee;
  static PyObject *__pyx_n_u_payer_fee;
  static PyObject *__pyx_n_s_payer_fee_currency;
  static PyObject *__pyx_n_s_payer_fee_exec_duration;
  static PyObject *__pyx_n_s_payer_fee_volume;
  static PyObject *__pyx_n_s_payer_processing_duration;
  static PyObject *__pyx_n_u_payer_processing_duration;
  static PyObject *__pyx_n_s_pickle;
  static PyObject *__pyx_n_s_position;
  static PyObject *__pyx_n_s_prepare;
  static PyObject *__pyx_n_s_price;
  static PyObject *__pyx_n_s_processing_duration;
  static PyObject *__pyx_n_u_processing_duration;
  static PyObject *__pyx_n_s_prohibit_debiting;
  static PyObject *__pyx_n_u_prohibit_debiting;
  static PyObject *__pyx_n_u_prohibit_debiting_setter;
  static PyObject *__pyx_n_s_property;
  static PyObject *__pyx_n_s_pyx_PickleError;
  static PyObject *__pyx_n_s_pyx_checksum;
  static PyObject *__pyx_n_s_pyx_result;
  static PyObject *__pyx_n_s_pyx_state;
  static PyObject *__pyx_n_s_pyx_type;
  static PyObject *__pyx_n_s_pyx_unpickle_cFXAccount;
  static PyObject *__pyx_n_s_pyx_vtable;
  static PyObject *__pyx_n_s_qualname;
  static PyObject *__pyx_n_s_quote;
  static PyObject *__pyx_n_u_quote;
  static PyObject *__pyx_n_s_range;
  static PyObject *__pyx_n_s_rate;
  static PyObject *__pyx_n_u_rate;
  static PyObject *__pyx_n_s_reduce;
  static PyObject *__pyx_n_s_reduce_cython;
  static PyObject *__pyx_n_s_reduce_ex;
  static PyObject *__pyx_n_s_reference_currency;
  static PyObject *__pyx_n_u_reference_currency;
  static PyObject *__pyx_n_s_reset;
  static PyObject *__pyx_n_s_result;
  static PyObject *__pyx_n_s_sample_key;
  static PyObject *__pyx_n_s_self;
  static PyObject *__pyx_n_b_sell;
  static PyObject *__pyx_n_s_sell;
  static PyObject *__pyx_n_u_sell;
  static PyObject *__pyx_n_u_sell_fee;
  static PyObject *__pyx_n_s_send;
  static PyObject *__pyx_n_s_setstate;
  static PyObject *__pyx_n_s_setstate_cython;
  static PyObject *__pyx_n_s_setter;
  static PyObject *__pyx_n_s_staticmethod;
  static PyObject *__pyx_kp_s_stringsource;
  static PyObject *__pyx_n_s_super;
  static PyObject *__pyx_n_s_test;
  static PyObject *__pyx_n_s_throw;
  static PyObject *__pyx_n_s_tick;
  static PyObject *__pyx_n_s_time;
  static PyObject *__pyx_n_s_time_step;
  static PyObject *__pyx_n_s_tolist;
  static PyObject *__pyx_n_s_total_balance;
  static PyObject *__pyx_n_s_tpz_exception;
  static PyObject *__pyx_n_s_transfer;
  static PyObject *__pyx_n_s_trapeza;
  static PyObject *__pyx_n_s_trapeza_account_base_account;
  static PyObject *__pyx_n_s_trapeza_account_fx_account;
  static PyObject *__pyx_kp_s_trapeza_account_fx_account_pyx;
  static PyObject *__pyx_n_s_trapeza_utils;
  static PyObject *__pyx_n_s_update;
  static PyObject *__pyx_n_s_update_exchange_rate;
  static PyObject *__pyx_n_s_v;
  static PyObject *__pyx_n_s_vec_heap;
  static PyObject *__pyx_n_s_virtual_deposit;
  static PyObject *__pyx_n_s_volume;
  static PyObject *__pyx_n_u_volume;
  static PyObject *__pyx_n_s_volume_base;
  static PyObject *__pyx_kp_u_volume_must_be_grater_than_0;
  static PyObject *__pyx_n_s_warn;
  static PyObject *__pyx_n_s_warnings;
  static PyObject *__pyx_n_b_withdraw;
  static PyObject *__pyx_n_s_withdraw;
  static PyObject *__pyx_n_u_withdraw;
  static PyObject *__pyx_n_u_withdrawal_fee;
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_fx_null_fee(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_volume, double __pyx_v_price, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, long __pyx_v_processing_duration); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount___init__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_reference_currency, PyObject *__pyx_v_depot, PyObject *__pyx_v_fee_dict, PyObject *__pyx_v_exec_heap, long __pyx_v_clock, PyObject *__pyx_v_exchange_rates, short __pyx_v_check_marked_coverage, bool __pyx_v_prohibit_debiting, bool __pyx_v_ignore_type_checking); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_2_c__init__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_reference_currency, PyObject *__pyx_v_depot, PyObject *__pyx_v_fee_dict, PyObject *__pyx_v_exec_heap, long __pyx_v_clock, PyObject *__pyx_v_exchange_rates, short __pyx_v_check_marked_coverage, bool __pyx_v_prohibit_debiting, bool __pyx_v_ignore_type_checking); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_4_c_reset(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_check_coverage(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_debit_amount, std::string __pyx_v_currency, long __pyx_v_time_step, double __pyx_v_virtual_deposit); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_isin_depot(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_10c_sell(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, double __pyx_v_bid_price, std::string __pyx_v_base, std::string __pyx_v_quote, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, long __pyx_v_processing_duration, std::string __pyx_v_coverage, bool __pyx_v_instant_withdrawal, bool __pyx_v_instant_float_fee); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_12c_buy(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, double __pyx_v_ask_price, std::string __pyx_v_base, std::string __pyx_v_quote, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, long __pyx_v_processing_duration, std::string __pyx_v_coverage, bool __pyx_v_instant_withdrawal, bool __pyx_v_instant_float_fee); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_14c_transfer(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, double __pyx_v_payer_fee_volume, std::string __pyx_v_payer_fee_currency, long __pyx_v_payer_fee_exec_duration, long __pyx_v_payer_processing_duration); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_16c_collect(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, double __pyx_v_payee_fee_volume, std::string __pyx_v_payee_fee_currency, long __pyx_v_payee_fee_exec_duration, long __pyx_v_payee_processing_duration); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_18c_deposit(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, long __pyx_v_processing_duration, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, std::string __pyx_v_coverage, bool __pyx_v_instant_float_fee); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_20c_withdraw(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, long __pyx_v_processing_duration, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, std::string __pyx_v_coverage, bool __pyx_v_instant_float_fee); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_22c_tick(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, long __pyx_v_clock); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_24c_update_exchange_rate(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_rate, std::string __pyx_v_base, std::string __pyx_v_quote); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_26c_batch_update_exchange_rates(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_list_rates, PyObject *__pyx_v_list_base_quote_pair); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_28c_total_balance(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_exchange_rates, std::string __pyx_v_reference_currency); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_30c_position(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_4__del__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_4__del__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_4__del__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_23_c_ignore_type_checking___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_4__del__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_32__reduce_cython__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_34__setstate_cython__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_exec_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_2exec_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_4exec_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_6check_marked_coverage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_8check_marked_coverage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_10check_marked_coverage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_12clock(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_14clock(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_16clock(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_18_ignore_type_checking(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_5depot_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_20depot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_22depot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_24depot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_4_fee_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_26_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_28_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_30_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_14exchange_rates_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_32exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_34exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_36exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_38reference_currency(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_40reference_currency(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_42reference_currency(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_44is_exchange_rate_updated(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_46is_exchange_rate_updated(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_48is_exchange_rate_updated(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_50prohibit_debiting(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_52prohibit_debiting(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_54prohibit_debiting(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_56__init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_reference_currency, PyObject *__pyx_v_depot, PyObject *__pyx_v_fee_buy, PyObject *__pyx_v_fee_sell, PyObject *__pyx_v_fee_deposit, PyObject *__pyx_v_fee_withdraw, PyObject *__pyx_v_exec_heap, long __pyx_v_clock, PyObject *__pyx_v_exchange_rates, PyObject *__pyx_v_marked_coverage, PyObject *__pyx_v_prohibit_debiting, PyObject *__pyx_v_ignore_type_checking); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_58_full_reset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_60_reset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_62_check_is_valid_fee_func(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_func); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_64_parse_depot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_depot, PyObject *__pyx_v_ignore_type_checking); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_66_parse_exec_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_exec_heap, PyObject *__pyx_v_ignore_type_checking); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_68_parse_fees(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fee_buy, PyObject *__pyx_v_fee_sell, PyObject *__pyx_v_fee_deposit, PyObject *__pyx_v_fee_withdraw, PyObject *__pyx_v_ignore_type_checking); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_70_parse_exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_exchange_rates, PyObject *__pyx_v_ignore_type_checking); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_72_check_alt_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_alt_fee, PyObject *__pyx_v_alt_fee_error_msg); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_74_parse_fee_and_transaction_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_float_fee_currency, PyObject *__pyx_v_default_float_currency, PyObject *__pyx_v_alt_fee, PyObject *__pyx_v_alt_fee_error_msg, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_processing_duration); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_76_check_coverage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_debit_amount, PyObject *__pyx_v_currency, PyObject *__pyx_v_time_step); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_78_eval_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_action_type, PyObject *__pyx_v_alt_fee, double __pyx_v_volume, double __pyx_v_current_rate, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, PyObject *__pyx_v_processing_duration); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_80_cum_sum_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_currency, PyObject *__pyx_v_action_func_type, long __pyx_v_time_step); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_82_cum_sum_marked_fund(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_currency, long __pyx_v_time_step); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_84_cum_sum_marked_debit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_currency, PyObject *__pyx_v_time_step); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_86_fill_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_action_type, PyObject *__pyx_v_alt_fee, PyObject *__pyx_v_volume, PyObject *__pyx_v_price, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_forward_coverage); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_88withdraw(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_volume, PyObject *__pyx_v_currency, PyObject *__pyx_v_fee, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_coverage, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_float_fee_currency); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_90deposit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_volume, PyObject *__pyx_v_currency, PyObject *__pyx_v_fee, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_coverage, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_float_fee_currency); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_92collect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_payer_account, double __pyx_v_volume, PyObject *__pyx_v_currency, PyObject *__pyx_v_payee_fee, PyObject *__pyx_v_payer_fee, PyObject *__pyx_v_payee_processing_duration, PyObject *__pyx_v_payer_processing_duration); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_94transfer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_payee_account, double __pyx_v_volume, PyObject *__pyx_v_currency, PyObject *__pyx_v_payee_fee, PyObject *__pyx_v_payer_fee, PyObject *__pyx_v_payee_processing_duration, PyObject *__pyx_v_payer_processing_duration); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_96buy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_volume_base, double __pyx_v_ask_price, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, PyObject *__pyx_v_fee, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_coverage, PyObject *__pyx_v_instant_withdrawal, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_float_fee_currency); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_98sell(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_volume_base, double __pyx_v_bid_price, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, PyObject *__pyx_v_fee, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_coverage, PyObject *__pyx_v_instant_withdrawal, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_float_fee_currency); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_100tick(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_clock); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_102update_exchange_rate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_rate, PyObject *__pyx_v_base, PyObject *__pyx_v_quote); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_104batch_update_exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_list_rates, PyObject *__pyx_v_list_base_quote_pairs); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_106total_balance(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_exchange_rates, PyObject *__pyx_v_reference_currency); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_108position(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_currency); /* proto */
static PyObject *__pyx_pf_7trapeza_7account_10fx_account_2__pyx_unpickle_cFXAccount(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account_cFXAccount(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct__depot(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_keys = {0, &__pyx_n_s_keys, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PySet_Type_issubset = {0, &__pyx_n_s_issubset, 0, 0, 0};
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_252980303;
static std::string __pyx_k_;
static std::string __pyx_k__2;
static std::string __pyx_k__3;
static std::string __pyx_k__4;
static std::string __pyx_k__5;
static std::string __pyx_k__6;
static std::string __pyx_k__7;
static std::string __pyx_k__8;
static std::string __pyx_k__9;
static std::string __pyx_k__10;
static std::string __pyx_k__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__61;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__69;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__75;
static PyObject *__pyx_tuple__77;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__102;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__108;
static PyObject *__pyx_tuple__110;
static PyObject *__pyx_tuple__112;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_tuple__116;
static PyObject *__pyx_tuple__117;
static PyObject *__pyx_tuple__119;
static PyObject *__pyx_tuple__120;
static PyObject *__pyx_tuple__122;
static PyObject *__pyx_tuple__123;
static PyObject *__pyx_tuple__125;
static PyObject *__pyx_tuple__126;
static PyObject *__pyx_tuple__128;
static PyObject *__pyx_tuple__129;
static PyObject *__pyx_tuple__131;
static PyObject *__pyx_tuple__132;
static PyObject *__pyx_tuple__134;
static PyObject *__pyx_tuple__135;
static PyObject *__pyx_tuple__137;
static PyObject *__pyx_tuple__138;
static PyObject *__pyx_tuple__140;
static PyObject *__pyx_tuple__142;
static PyObject *__pyx_tuple__144;
static PyObject *__pyx_tuple__145;
static PyObject *__pyx_tuple__147;
static PyObject *__pyx_codeobj__28;
static PyObject *__pyx_codeobj__30;
static PyObject *__pyx_codeobj__32;
static PyObject *__pyx_codeobj__34;
static PyObject *__pyx_codeobj__36;
static PyObject *__pyx_codeobj__38;
static PyObject *__pyx_codeobj__40;
static PyObject *__pyx_codeobj__42;
static PyObject *__pyx_codeobj__44;
static PyObject *__pyx_codeobj__46;
static PyObject *__pyx_codeobj__48;
static PyObject *__pyx_codeobj__50;
static PyObject *__pyx_codeobj__52;
static PyObject *__pyx_codeobj__54;
static PyObject *__pyx_codeobj__56;
static PyObject *__pyx_codeobj__58;
static PyObject *__pyx_codeobj__60;
static PyObject *__pyx_codeobj__62;
static PyObject *__pyx_codeobj__64;
static PyObject *__pyx_codeobj__66;
static PyObject *__pyx_codeobj__68;
static PyObject *__pyx_codeobj__70;
static PyObject *__pyx_codeobj__72;
static PyObject *__pyx_codeobj__74;
static PyObject *__pyx_codeobj__76;
static PyObject *__pyx_codeobj__78;
static PyObject *__pyx_codeobj__80;
static PyObject *__pyx_codeobj__82;
static PyObject *__pyx_codeobj__84;
static PyObject *__pyx_codeobj__86;
static PyObject *__pyx_codeobj__88;
static PyObject *__pyx_codeobj__90;
static PyObject *__pyx_codeobj__92;
static PyObject *__pyx_codeobj__95;
static PyObject *__pyx_codeobj__97;
static PyObject *__pyx_codeobj__99;
static PyObject *__pyx_codeobj__101;
static PyObject *__pyx_codeobj__103;
static PyObject *__pyx_codeobj__105;
static PyObject *__pyx_codeobj__107;
static PyObject *__pyx_codeobj__109;
static PyObject *__pyx_codeobj__111;
static PyObject *__pyx_codeobj__113;
static PyObject *__pyx_codeobj__115;
static PyObject *__pyx_codeobj__118;
static PyObject *__pyx_codeobj__121;
static PyObject *__pyx_codeobj__124;
static PyObject *__pyx_codeobj__127;
static PyObject *__pyx_codeobj__130;
static PyObject *__pyx_codeobj__133;
static PyObject *__pyx_codeobj__136;
static PyObject *__pyx_codeobj__139;
static PyObject *__pyx_codeobj__141;
static PyObject *__pyx_codeobj__143;
static PyObject *__pyx_codeobj__146;
static PyObject *__pyx_codeobj__148;
/* Late includes */

/* "trapeza/account/fx_account.pyx":18
 * 
 * 
 * cpdef tuple fx_null_fee(double volume, double price, base, quote, long processing_duration):             # <<<<<<<<<<<<<<
 *     """
 *     Standard fee rule for FXAccount, equal to not applying any fees.
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_1fx_null_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_7trapeza_7account_10fx_account_fx_null_fee(CYTHON_UNUSED double __pyx_v_volume, CYTHON_UNUSED double __pyx_v_price, PyObject *__pyx_v_base, CYTHON_UNUSED PyObject *__pyx_v_quote, CYTHON_UNUSED long __pyx_v_processing_duration, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fx_null_fee", 0);

  /* "trapeza/account/fx_account.pyx":29
 *     :return: 0, base, 0
 *     """
 *     return 0, base, 0             # <<<<<<<<<<<<<<
 * 
 * # noinspection PyAbstractClass,PyPep8Naming,PyUnresolvedReferences,PyAttributeOutsideInit,PyTypeChecker
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
  __Pyx_INCREF(__pyx_v_base);
  __Pyx_GIVEREF(__pyx_v_base);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_base);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_0);
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":18
 * 
 * 
 * cpdef tuple fx_null_fee(double volume, double price, base, quote, long processing_duration):             # <<<<<<<<<<<<<<
 *     """
 *     Standard fee rule for FXAccount, equal to not applying any fees.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.fx_null_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_1fx_null_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_fx_null_fee[] = "\n    Standard fee rule for FXAccount, equal to not applying any fees.\n\n    :param volume: double, transaction volume in base currency\n    :param price: double, price in base|quote FX direct notation\n    :param base: python str, base currency in FX direct notation (see docstring of class description FXAccount)\n    :param quote: python str, quote currency in FX direct notation (see docstring of class description FXAccount)\n    :param processing_duration: long, processing time of FXAccount transaction (e.g. sell() or buy())\n    :return: 0, base, 0\n    ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_1fx_null_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_volume;
  double __pyx_v_price;
  PyObject *__pyx_v_base = 0;
  PyObject *__pyx_v_quote = 0;
  long __pyx_v_processing_duration;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fx_null_fee (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_volume,&__pyx_n_s_price,&__pyx_n_s_base,&__pyx_n_s_quote,&__pyx_n_s_processing_duration,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_price)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fx_null_fee", 1, 5, 5, 1); __PYX_ERR(0, 18, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fx_null_fee", 1, 5, 5, 2); __PYX_ERR(0, 18, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quote)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fx_null_fee", 1, 5, 5, 3); __PYX_ERR(0, 18, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fx_null_fee", 1, 5, 5, 4); __PYX_ERR(0, 18, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fx_null_fee") < 0)) __PYX_ERR(0, 18, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 18, __pyx_L3_error)
    __pyx_v_price = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 18, __pyx_L3_error)
    __pyx_v_base = values[2];
    __pyx_v_quote = values[3];
    __pyx_v_processing_duration = __Pyx_PyInt_As_long(values[4]); if (unlikely((__pyx_v_processing_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 18, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fx_null_fee", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 18, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.fx_null_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_fx_null_fee(__pyx_self, __pyx_v_volume, __pyx_v_price, __pyx_v_base, __pyx_v_quote, __pyx_v_processing_duration);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_fx_null_fee(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_volume, double __pyx_v_price, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, long __pyx_v_processing_duration) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fx_null_fee", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7trapeza_7account_10fx_account_fx_null_fee(__pyx_v_volume, __pyx_v_price, __pyx_v_base, __pyx_v_quote, __pyx_v_processing_duration, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.fx_null_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":45
 *     """
 * 
 *     def __init__(self, string reference_currency, dict depot, dict fee_dict, list exec_heap, long clock,             # <<<<<<<<<<<<<<
 *                  dict exchange_rates, short check_marked_coverage, bool_t prohibit_debiting,
 *                  bool_t ignore_type_checking):
 */

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount___init__[] = "\n        Calls self._c__init__. See self._c__init__ for further docstring information.\n        :param reference_currency: std:string\n        :param depot: dict\n        :param fee_dict: dict\n        :param exec_heap: list of lists\n        :param clock: long\n        :param exchange_rates: dict\n        :param check_marked_coverage: short\n        :param prohibit_debiting: std:bool\n        :param ignore_type_checking: std:bool\n        :return None\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_7trapeza_7account_10fx_account_10cFXAccount___init__;
#endif
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  std::string __pyx_v_reference_currency;
  PyObject *__pyx_v_depot = 0;
  PyObject *__pyx_v_fee_dict = 0;
  PyObject *__pyx_v_exec_heap = 0;
  long __pyx_v_clock;
  PyObject *__pyx_v_exchange_rates = 0;
  short __pyx_v_check_marked_coverage;
  bool __pyx_v_prohibit_debiting;
  bool __pyx_v_ignore_type_checking;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_reference_currency,&__pyx_n_s_depot,&__pyx_n_s_fee_dict,&__pyx_n_s_exec_heap,&__pyx_n_s_clock,&__pyx_n_s_exchange_rates,&__pyx_n_s_check_marked_coverage,&__pyx_n_s_prohibit_debiting,&__pyx_n_s_ignore_type_checking,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reference_currency)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_depot)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 1); __PYX_ERR(0, 45, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_dict)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 2); __PYX_ERR(0, 45, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exec_heap)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 3); __PYX_ERR(0, 45, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_clock)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 4); __PYX_ERR(0, 45, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exchange_rates)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 5); __PYX_ERR(0, 45, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_check_marked_coverage)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 6); __PYX_ERR(0, 45, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_prohibit_debiting)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 7); __PYX_ERR(0, 45, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ignore_type_checking)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 8); __PYX_ERR(0, 45, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 45, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
    }
    __pyx_v_reference_currency = __pyx_convert_string_from_py_std__in_string(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
    __pyx_v_depot = ((PyObject*)values[1]);
    __pyx_v_fee_dict = ((PyObject*)values[2]);
    __pyx_v_exec_heap = ((PyObject*)values[3]);
    __pyx_v_clock = __Pyx_PyInt_As_long(values[4]); if (unlikely((__pyx_v_clock == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
    __pyx_v_exchange_rates = ((PyObject*)values[5]);
    __pyx_v_check_marked_coverage = __Pyx_PyInt_As_short(values[6]); if (unlikely((__pyx_v_check_marked_coverage == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L3_error)
    __pyx_v_prohibit_debiting = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_prohibit_debiting == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L3_error)
    __pyx_v_ignore_type_checking = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_ignore_type_checking == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 45, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_depot), (&PyDict_Type), 1, "depot", 1))) __PYX_ERR(0, 45, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fee_dict), (&PyDict_Type), 1, "fee_dict", 1))) __PYX_ERR(0, 45, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_exec_heap), (&PyList_Type), 1, "exec_heap", 1))) __PYX_ERR(0, 45, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_exchange_rates), (&PyDict_Type), 1, "exchange_rates", 1))) __PYX_ERR(0, 46, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount___init__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_reference_currency, __pyx_v_depot, __pyx_v_fee_dict, __pyx_v_exec_heap, __pyx_v_clock, __pyx_v_exchange_rates, __pyx_v_check_marked_coverage, __pyx_v_prohibit_debiting, __pyx_v_ignore_type_checking);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount___init__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_reference_currency, PyObject *__pyx_v_depot, PyObject *__pyx_v_fee_dict, PyObject *__pyx_v_exec_heap, long __pyx_v_clock, PyObject *__pyx_v_exchange_rates, short __pyx_v_check_marked_coverage, bool __pyx_v_prohibit_debiting, bool __pyx_v_ignore_type_checking) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "trapeza/account/fx_account.pyx":61
 *         :return None
 *         """
 *         self._c__init__(reference_currency, depot, fee_dict, exec_heap, clock,exchange_rates, check_marked_coverage,             # <<<<<<<<<<<<<<
 *                      prohibit_debiting, ignore_type_checking)
 * 
 */
  ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c__init__(__pyx_v_self, __pyx_v_reference_currency, __pyx_v_depot, __pyx_v_fee_dict, __pyx_v_exec_heap, __pyx_v_clock, __pyx_v_exchange_rates, __pyx_v_check_marked_coverage, __pyx_v_prohibit_debiting, __pyx_v_ignore_type_checking, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":45
 *     """
 * 
 *     def __init__(self, string reference_currency, dict depot, dict fee_dict, list exec_heap, long clock,             # <<<<<<<<<<<<<<
 *                  dict exchange_rates, short check_marked_coverage, bool_t prohibit_debiting,
 *                  bool_t ignore_type_checking):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":66
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cpdef void _c__init__(self, string reference_currency, dict depot, dict fee_dict, list exec_heap, long clock,             # <<<<<<<<<<<<<<
 *                  dict exchange_rates, short check_marked_coverage, bool_t prohibit_debiting,
 *                  bool_t ignore_type_checking) except*:
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_3_c__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static void __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c__init__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_reference_currency, PyObject *__pyx_v_depot, PyObject *__pyx_v_fee_dict, PyObject *__pyx_v_exec_heap, long __pyx_v_clock, PyObject *__pyx_v_exchange_rates, short __pyx_v_check_marked_coverage, bool __pyx_v_prohibit_debiting, bool __pyx_v_ignore_type_checking, int __pyx_skip_dispatch) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c__init__", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c__init); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_3_c__init__)) {
        __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_reference_currency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_clock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyInt_From_short(__pyx_v_check_marked_coverage); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 66, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_prohibit_debiting); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 66, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_ignore_type_checking); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 66, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_8 = __pyx_t_1; __pyx_t_9 = NULL;
        __pyx_t_10 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
            __pyx_t_10 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[10] = {__pyx_t_9, __pyx_t_3, __pyx_v_depot, __pyx_v_fee_dict, __pyx_v_exec_heap, __pyx_t_4, __pyx_v_exchange_rates, __pyx_t_5, __pyx_t_6, __pyx_t_7};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 9+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[10] = {__pyx_t_9, __pyx_t_3, __pyx_v_depot, __pyx_v_fee_dict, __pyx_v_exec_heap, __pyx_t_4, __pyx_v_exchange_rates, __pyx_t_5, __pyx_t_6, __pyx_t_7};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 9+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(9+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 66, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__pyx_t_9) {
            __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_depot);
          __Pyx_GIVEREF(__pyx_v_depot);
          PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_v_depot);
          __Pyx_INCREF(__pyx_v_fee_dict);
          __Pyx_GIVEREF(__pyx_v_fee_dict);
          PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_v_fee_dict);
          __Pyx_INCREF(__pyx_v_exec_heap);
          __Pyx_GIVEREF(__pyx_v_exec_heap);
          PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_v_exec_heap);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_10, __pyx_t_4);
          __Pyx_INCREF(__pyx_v_exchange_rates);
          __Pyx_GIVEREF(__pyx_v_exchange_rates);
          PyTuple_SET_ITEM(__pyx_t_11, 5+__pyx_t_10, __pyx_v_exchange_rates);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_11, 6+__pyx_t_10, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_11, 7+__pyx_t_10, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_11, 8+__pyx_t_10, __pyx_t_7);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_6 = 0;
          __pyx_t_7 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":92
 *         """
 *         # >>>set whether internal type checking is omitted (performance increase vs. safer code)
 *         self._c_ignore_type_checking = ignore_type_checking             # <<<<<<<<<<<<<<
 * 
 *         # >>>base_currency
 */
  __pyx_v_self->_c_ignore_type_checking = __pyx_v_ignore_type_checking;

  /* "trapeza/account/fx_account.pyx":95
 * 
 *         # >>>base_currency
 *         self._c_reference_currency = reference_currency             # <<<<<<<<<<<<<<
 * 
 *         # >>>depot: key: currency, value: volume
 */
  __pyx_v_self->_c_reference_currency = __pyx_v_reference_currency;

  /* "trapeza/account/fx_account.pyx":98
 * 
 *         # >>>depot: key: currency, value: volume
 *         self._c_depot = depot             # <<<<<<<<<<<<<<
 * 
 *         # >>>switch checking of coverage of marked transaction on or off
 */
  __Pyx_INCREF(__pyx_v_depot);
  __Pyx_GIVEREF(__pyx_v_depot);
  __Pyx_GOTREF(__pyx_v_self->_c_depot);
  __Pyx_DECREF(__pyx_v_self->_c_depot);
  __pyx_v_self->_c_depot = __pyx_v_depot;

  /* "trapeza/account/fx_account.pyx":102
 *         # >>>switch checking of coverage of marked transaction on or off
 *         # 0: False/ None, 1: min_backward, 2: max_forward
 *         self._c_check_marked_coverage = check_marked_coverage             # <<<<<<<<<<<<<<
 * 
 *         # >>>internal state which checks if self.update_exchange_rate() or self.batch_update_exchange_rates() was called
 */
  __pyx_v_self->_c_check_marked_coverage = __pyx_v_check_marked_coverage;

  /* "trapeza/account/fx_account.pyx":106
 *         # >>>internal state which checks if self.update_exchange_rate() or self.batch_update_exchange_rates() was called
 *         #    before calling self.total_balance()
 *         self._c_is_exchange_rate_updated = False             # <<<<<<<<<<<<<<
 * 
 *         # >>>internal state for processing marked transactions within coverage checking (recursion handling)
 */
  __pyx_v_self->_c_is_exchange_rate_updated = 0;

  /* "trapeza/account/fx_account.pyx":109
 * 
 *         # >>>internal state for processing marked transactions within coverage checking (recursion handling)
 *         self._c_is_heap = False             # <<<<<<<<<<<<<<
 * 
 *         # >>>heap: (time, action_func, volume, currency, **kwargs)
 */
  __pyx_v_self->_c_is_heap = 0;

  /* "trapeza/account/fx_account.pyx":112
 * 
 *         # >>>heap: (time, action_func, volume, currency, **kwargs)
 *         self.vec_heap = cFXWrapperVectorHeap(exec_heap)             # <<<<<<<<<<<<<<
 * 
 *         # >>>parse fees
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap), __pyx_v_exec_heap); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec_heap);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec_heap));
  __pyx_v_self->vec_heap = ((struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":115
 * 
 *         # >>>parse fees
 *         self._c_fee = fee_dict             # <<<<<<<<<<<<<<
 * 
 *         # >>>exchange rates
 */
  __Pyx_INCREF(__pyx_v_fee_dict);
  __Pyx_GIVEREF(__pyx_v_fee_dict);
  __Pyx_GOTREF(__pyx_v_self->_c_fee);
  __Pyx_DECREF(__pyx_v_self->_c_fee);
  __pyx_v_self->_c_fee = __pyx_v_fee_dict;

  /* "trapeza/account/fx_account.pyx":118
 * 
 *         # >>>exchange rates
 *         self._c_exchange_rates = exchange_rates             # <<<<<<<<<<<<<<
 * 
 *         # >>>allow debiting
 */
  __Pyx_INCREF(__pyx_v_exchange_rates);
  __Pyx_GIVEREF(__pyx_v_exchange_rates);
  __Pyx_GOTREF(__pyx_v_self->_c_exchange_rates);
  __Pyx_DECREF(__pyx_v_self->_c_exchange_rates);
  __pyx_v_self->_c_exchange_rates = __pyx_v_exchange_rates;

  /* "trapeza/account/fx_account.pyx":121
 * 
 *         # >>>allow debiting
 *         self._c_prohibit_debiting = prohibit_debiting             # <<<<<<<<<<<<<<
 * 
 *         # >>>clock
 */
  __pyx_v_self->_c_prohibit_debiting = __pyx_v_prohibit_debiting;

  /* "trapeza/account/fx_account.pyx":124
 * 
 *         # >>>clock
 *         self._c_clock = clock  # internal clock in time base units for oder execution             # <<<<<<<<<<<<<<
 * 
 *         #>>>init depot in reference currency
 */
  __pyx_v_self->_c_clock = __pyx_v_clock;

  /* "trapeza/account/fx_account.pyx":66
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cpdef void _c__init__(self, string reference_currency, dict depot, dict fee_dict, list exec_heap, long clock,             # <<<<<<<<<<<<<<
 *                  dict exchange_rates, short check_marked_coverage, bool_t prohibit_debiting,
 *                  bool_t ignore_type_checking) except*:
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_3_c__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_2_c__init__[] = "\n        This methods gets wrapped by __init__ and serves as method to be called from _c_reset() and _c_full_reset(), \n        which is useful when __init__ gets overwritten during subclassing.\n        :param reference_currency: std:string, reference currency for account\n        :param depot: dict, {b'currency': double:current_position_size}\n        :param fee_dict: dict, {b'buy': func, b'sell': func, b'withdraw': func, b'deposit': func}\n        :param exec_heap: list os lists, list of [int:time, py_str:action_func, float:volume, py_str:currency,\n                                                  py_str:coverage]\n                          this gets translated to self.vec_heap (C++ heap vector)\n                          action_func: {'c_withdraw', 'c_deposit'} ('withdraw' and 'deposit' are not auto-parsed at \n                                       this point)\n                          coverage: see FXAccount docstring regarding sell, buy, withdraw and deposit\n        :param clock: long, internal clock\n        :param exchange_rates: dict, {(b'currency', b'currency'): double:current_exchange_rate}\n        :param check_marked_coverage: short, 0: False/ None, 1: min_backward, 2: max_forward\n                                      see FXAccount for further details\n        :param prohibit_debiting: std:bool\n                                  see FXAccount for further details\n        :param ignore_type_checking: std:bool\n                                     see FXAccount for further details\n        :return: None\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_3_c__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  std::string __pyx_v_reference_currency;
  PyObject *__pyx_v_depot = 0;
  PyObject *__pyx_v_fee_dict = 0;
  PyObject *__pyx_v_exec_heap = 0;
  long __pyx_v_clock;
  PyObject *__pyx_v_exchange_rates = 0;
  short __pyx_v_check_marked_coverage;
  bool __pyx_v_prohibit_debiting;
  bool __pyx_v_ignore_type_checking;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_c__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_reference_currency,&__pyx_n_s_depot,&__pyx_n_s_fee_dict,&__pyx_n_s_exec_heap,&__pyx_n_s_clock,&__pyx_n_s_exchange_rates,&__pyx_n_s_check_marked_coverage,&__pyx_n_s_prohibit_debiting,&__pyx_n_s_ignore_type_checking,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reference_currency)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_depot)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c__init__", 1, 9, 9, 1); __PYX_ERR(0, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_dict)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c__init__", 1, 9, 9, 2); __PYX_ERR(0, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exec_heap)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c__init__", 1, 9, 9, 3); __PYX_ERR(0, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_clock)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c__init__", 1, 9, 9, 4); __PYX_ERR(0, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exchange_rates)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c__init__", 1, 9, 9, 5); __PYX_ERR(0, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_check_marked_coverage)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c__init__", 1, 9, 9, 6); __PYX_ERR(0, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_prohibit_debiting)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c__init__", 1, 9, 9, 7); __PYX_ERR(0, 66, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ignore_type_checking)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c__init__", 1, 9, 9, 8); __PYX_ERR(0, 66, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_c__init__") < 0)) __PYX_ERR(0, 66, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
    }
    __pyx_v_reference_currency = __pyx_convert_string_from_py_std__in_string(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L3_error)
    __pyx_v_depot = ((PyObject*)values[1]);
    __pyx_v_fee_dict = ((PyObject*)values[2]);
    __pyx_v_exec_heap = ((PyObject*)values[3]);
    __pyx_v_clock = __Pyx_PyInt_As_long(values[4]); if (unlikely((__pyx_v_clock == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L3_error)
    __pyx_v_exchange_rates = ((PyObject*)values[5]);
    __pyx_v_check_marked_coverage = __Pyx_PyInt_As_short(values[6]); if (unlikely((__pyx_v_check_marked_coverage == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 67, __pyx_L3_error)
    __pyx_v_prohibit_debiting = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_prohibit_debiting == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 67, __pyx_L3_error)
    __pyx_v_ignore_type_checking = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_ignore_type_checking == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 68, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_c__init__", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 66, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_depot), (&PyDict_Type), 1, "depot", 1))) __PYX_ERR(0, 66, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fee_dict), (&PyDict_Type), 1, "fee_dict", 1))) __PYX_ERR(0, 66, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_exec_heap), (&PyList_Type), 1, "exec_heap", 1))) __PYX_ERR(0, 66, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_exchange_rates), (&PyDict_Type), 1, "exchange_rates", 1))) __PYX_ERR(0, 67, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_2_c__init__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_reference_currency, __pyx_v_depot, __pyx_v_fee_dict, __pyx_v_exec_heap, __pyx_v_clock, __pyx_v_exchange_rates, __pyx_v_check_marked_coverage, __pyx_v_prohibit_debiting, __pyx_v_ignore_type_checking);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_2_c__init__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_reference_currency, PyObject *__pyx_v_depot, PyObject *__pyx_v_fee_dict, PyObject *__pyx_v_exec_heap, long __pyx_v_clock, PyObject *__pyx_v_exchange_rates, short __pyx_v_check_marked_coverage, bool __pyx_v_prohibit_debiting, bool __pyx_v_ignore_type_checking) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c__init__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c__init__(__pyx_v_self, __pyx_v_reference_currency, __pyx_v_depot, __pyx_v_fee_dict, __pyx_v_exec_heap, __pyx_v_clock, __pyx_v_exchange_rates, __pyx_v_check_marked_coverage, __pyx_v_prohibit_debiting, __pyx_v_ignore_type_checking, 1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L1_error)
  __pyx_t_1 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":131
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cpdef short _c_reset(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         See FXAccount for docstring information.
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_5_c_reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_reset(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, int __pyx_skip_dispatch) {
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  short __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_reset", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_reset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_5_c_reset)) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_5 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_5 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_5;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":136
 *         :return: 1
 *         """
 *         self._c__init__(self._c_reference_currency, dict(), self._c_fee, [], 0, dict(), self._c_check_marked_coverage,             # <<<<<<<<<<<<<<
 *                         self._c_prohibit_debiting, self._c_ignore_type_checking)
 *         return 1
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_self->_c_fee;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "trapeza/account/fx_account.pyx":137
 *         """
 *         self._c__init__(self._c_reference_currency, dict(), self._c_fee, [], 0, dict(), self._c_check_marked_coverage,
 *                         self._c_prohibit_debiting, self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c__init__(__pyx_v_self, __pyx_v_self->_c_reference_currency, ((PyObject*)__pyx_t_1), ((PyObject*)__pyx_t_2), ((PyObject*)__pyx_t_3), 0, ((PyObject*)__pyx_t_4), __pyx_v_self->_c_check_marked_coverage, __pyx_v_self->_c_prohibit_debiting, __pyx_v_self->_c_ignore_type_checking, 0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 136, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "trapeza/account/fx_account.pyx":138
 *         self._c__init__(self._c_reference_currency, dict(), self._c_fee, [], 0, dict(), self._c_check_marked_coverage,
 *                         self._c_prohibit_debiting, self._c_ignore_type_checking)
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     @cython.wraparound(False)
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":131
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cpdef short _c_reset(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         See FXAccount for docstring information.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_5_c_reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_4_c_reset[] = "\n        See FXAccount for docstring information.\n        :return: 1\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_5_c_reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_c_reset (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_4_c_reset(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_4_c_reset(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_reset", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_reset(__pyx_v_self, 1); if (unlikely(__pyx_t_1 == ((short)-1))) __PYX_ERR(0, 131, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":141
 * 
 *     @cython.wraparound(False)
 *     cpdef double _c_check_coverage(self, double debit_amount, string currency, long time_step,             # <<<<<<<<<<<<<<
 *                                    double virtual_deposit=0) except -1:
 *         """
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_7_c_check_coverage(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_debit_amount, std::string __pyx_v_currency, long __pyx_v_time_step, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage *__pyx_optional_args) {
  double __pyx_v_virtual_deposit = ((double)0.0);
  double __pyx_v_marked_debit_amount;
  double __pyx_v_marked_funds;
  double __pyx_v_coverage;
  double __pyx_v_currency_position;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  double __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  long __pyx_t_14;
  short __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_check_coverage", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_virtual_deposit = __pyx_optional_args->virtual_deposit;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_check_coverage); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_7_c_check_coverage)) {
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_debit_amount); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_time_step); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = PyFloat_FromDouble(__pyx_v_virtual_deposit); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 141, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_7 = __pyx_t_1; __pyx_t_8 = NULL;
        __pyx_t_9 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
            __pyx_t_9 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 141, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          if (__pyx_t_8) {
            __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_t_6);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_6 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_11;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":157
 *                  double or math.inf (if self.check_marked_coverage=False)
 *         """
 *         if self._c_check_marked_coverage == 0:             # <<<<<<<<<<<<<<
 *             return INFINITY
 * 
 */
  __pyx_t_12 = ((__pyx_v_self->_c_check_marked_coverage == 0) != 0);
  if (__pyx_t_12) {

    /* "trapeza/account/fx_account.pyx":158
 *         """
 *         if self._c_check_marked_coverage == 0:
 *             return INFINITY             # <<<<<<<<<<<<<<
 * 
 *         if self._c_check_marked_coverage == 2 and  self.vec_heap.size() != 0:
 */
    __pyx_r = INFINITY;
    goto __pyx_L0;

    /* "trapeza/account/fx_account.pyx":157
 *                  double or math.inf (if self.check_marked_coverage=False)
 *         """
 *         if self._c_check_marked_coverage == 0:             # <<<<<<<<<<<<<<
 *             return INFINITY
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":160
 *             return INFINITY
 * 
 *         if self._c_check_marked_coverage == 2 and  self.vec_heap.size() != 0:             # <<<<<<<<<<<<<<
 *                 time_step = self.vec_heap.max_time_step()
 * 
 */
  __pyx_t_13 = ((__pyx_v_self->_c_check_marked_coverage == 2) != 0);
  if (__pyx_t_13) {
  } else {
    __pyx_t_12 = __pyx_t_13;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_13 = ((((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->size(__pyx_v_self->vec_heap) != 0) != 0);
  __pyx_t_12 = __pyx_t_13;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_12) {

    /* "trapeza/account/fx_account.pyx":161
 * 
 *         if self._c_check_marked_coverage == 2 and  self.vec_heap.size() != 0:
 *                 time_step = self.vec_heap.max_time_step()             # <<<<<<<<<<<<<<
 * 
 *         # >>>avoid double accounting when debit volume is already in heap
 */
    __pyx_t_14 = ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->max_time_step(__pyx_v_self->vec_heap); if (unlikely(__pyx_t_14 == ((long)-9223372036854775807L) && PyErr_Occurred())) __PYX_ERR(0, 161, __pyx_L1_error)
    __pyx_v_time_step = __pyx_t_14;

    /* "trapeza/account/fx_account.pyx":160
 *             return INFINITY
 * 
 *         if self._c_check_marked_coverage == 2 and  self.vec_heap.size() != 0:             # <<<<<<<<<<<<<<
 *                 time_step = self.vec_heap.max_time_step()
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":164
 * 
 *         # >>>avoid double accounting when debit volume is already in heap
 *         if self._c_is_heap:             # <<<<<<<<<<<<<<
 *             debit_amount = 0
 * 
 */
  __pyx_t_12 = (__pyx_v_self->_c_is_heap != 0);
  if (__pyx_t_12) {

    /* "trapeza/account/fx_account.pyx":165
 *         # >>>avoid double accounting when debit volume is already in heap
 *         if self._c_is_heap:
 *             debit_amount = 0             # <<<<<<<<<<<<<<
 * 
 *         self._c_isin_depot(currency)
 */
    __pyx_v_debit_amount = 0.0;

    /* "trapeza/account/fx_account.pyx":164
 * 
 *         # >>>avoid double accounting when debit volume is already in heap
 *         if self._c_is_heap:             # <<<<<<<<<<<<<<
 *             debit_amount = 0
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":167
 *             debit_amount = 0
 * 
 *         self._c_isin_depot(currency)             # <<<<<<<<<<<<<<
 * 
 *         cdef double marked_debit_amount
 */
  __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_isin_depot(__pyx_v_self, __pyx_v_currency, 0); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 167, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":173
 *         cdef double coverage
 *         cdef double currency_position
 *         marked_debit_amount = self.vec_heap.cum_sum_marked_debit(currency, time_step, self._c_clock)             # <<<<<<<<<<<<<<
 *         if virtual_deposit != 0:
 *             marked_funds = c_precision_add(self.vec_heap.cum_sum_marked_fund(currency, time_step, self._c_clock),
 */
  __pyx_v_marked_debit_amount = ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->cum_sum_marked_debit(__pyx_v_self->vec_heap, __pyx_v_currency, __pyx_v_time_step, __pyx_v_self->_c_clock, 0);

  /* "trapeza/account/fx_account.pyx":174
 *         cdef double currency_position
 *         marked_debit_amount = self.vec_heap.cum_sum_marked_debit(currency, time_step, self._c_clock)
 *         if virtual_deposit != 0:             # <<<<<<<<<<<<<<
 *             marked_funds = c_precision_add(self.vec_heap.cum_sum_marked_fund(currency, time_step, self._c_clock),
 *                                            virtual_deposit)
 */
  __pyx_t_12 = ((__pyx_v_virtual_deposit != 0.0) != 0);
  if (__pyx_t_12) {

    /* "trapeza/account/fx_account.pyx":175
 *         marked_debit_amount = self.vec_heap.cum_sum_marked_debit(currency, time_step, self._c_clock)
 *         if virtual_deposit != 0:
 *             marked_funds = c_precision_add(self.vec_heap.cum_sum_marked_fund(currency, time_step, self._c_clock),             # <<<<<<<<<<<<<<
 *                                            virtual_deposit)
 *         else:
 */
    __pyx_v_marked_funds = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->cum_sum_marked_fund(__pyx_v_self->vec_heap, __pyx_v_currency, __pyx_v_time_step, __pyx_v_self->_c_clock, 0), __pyx_v_virtual_deposit);

    /* "trapeza/account/fx_account.pyx":174
 *         cdef double currency_position
 *         marked_debit_amount = self.vec_heap.cum_sum_marked_debit(currency, time_step, self._c_clock)
 *         if virtual_deposit != 0:             # <<<<<<<<<<<<<<
 *             marked_funds = c_precision_add(self.vec_heap.cum_sum_marked_fund(currency, time_step, self._c_clock),
 *                                            virtual_deposit)
 */
    goto __pyx_L8;
  }

  /* "trapeza/account/fx_account.pyx":178
 *                                            virtual_deposit)
 *         else:
 *             marked_funds = self.vec_heap.cum_sum_marked_fund(currency, time_step, self._c_clock)             # <<<<<<<<<<<<<<
 * 
 *         # noinspection PyUnresolvedReferences
 */
  /*else*/ {
    __pyx_v_marked_funds = ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->cum_sum_marked_fund(__pyx_v_self->vec_heap, __pyx_v_currency, __pyx_v_time_step, __pyx_v_self->_c_clock, 0);
  }
  __pyx_L8:;

  /* "trapeza/account/fx_account.pyx":181
 * 
 *         # noinspection PyUnresolvedReferences
 *         currency_position = self._c_depot[currency]             # <<<<<<<<<<<<<<
 *         coverage = c_precision_add(currency_position,
 *                                    c_precision_add(marked_funds,
 */
  if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 181, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_currency_position = __pyx_t_11;

  /* "trapeza/account/fx_account.pyx":182
 *         # noinspection PyUnresolvedReferences
 *         currency_position = self._c_depot[currency]
 *         coverage = c_precision_add(currency_position,             # <<<<<<<<<<<<<<
 *                                    c_precision_add(marked_funds,
 *                                                    c_precision_add(-marked_debit_amount, -debit_amount)))
 */
  __pyx_v_coverage = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_currency_position, __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_marked_funds, __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add((-__pyx_v_marked_debit_amount), (-__pyx_v_debit_amount))));

  /* "trapeza/account/fx_account.pyx":186
 *                                                    c_precision_add(-marked_debit_amount, -debit_amount)))
 * 
 *         if coverage < 0:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.CoverageError(coverage, currency.decode())
 *         return coverage
 */
  __pyx_t_12 = ((__pyx_v_coverage < 0.0) != 0);
  if (unlikely(__pyx_t_12)) {

    /* "trapeza/account/fx_account.pyx":187
 * 
 *         if coverage < 0:
 *             raise tpz_exception.CoverageError(coverage, currency.decode())             # <<<<<<<<<<<<<<
 *         return coverage
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 187, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_coverage); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_decode_cpp_string(__pyx_v_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 187, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_1, __pyx_t_10};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_1, __pyx_t_10};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 187, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_10);
      __pyx_t_1 = 0;
      __pyx_t_10 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 187, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":186
 *                                                    c_precision_add(-marked_debit_amount, -debit_amount)))
 * 
 *         if coverage < 0:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.CoverageError(coverage, currency.decode())
 *         return coverage
 */
  }

  /* "trapeza/account/fx_account.pyx":188
 *         if coverage < 0:
 *             raise tpz_exception.CoverageError(coverage, currency.decode())
 *         return coverage             # <<<<<<<<<<<<<<
 * 
 *     # noinspection PyUnresolvedReferences
 */
  __pyx_r = __pyx_v_coverage;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":141
 * 
 *     @cython.wraparound(False)
 *     cpdef double _c_check_coverage(self, double debit_amount, string currency, long time_step,             # <<<<<<<<<<<<<<
 *                                    double virtual_deposit=0) except -1:
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_check_coverage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1.0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_7_c_check_coverage(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_6_c_check_coverage[] = "\n        See FXAccount for docstring information.\n        \n        virtual_deposit is used for intermediary calculations of fictive (what-if) funds which have not been executed\n        or marked on heap yet.\n        \n        :param debit_amount: double\n        :param currency: std:string\n        :param time_step: long\n        :param virtual_deposit: double, virtual but not effectively executed/ billed fund, which is added on top for\n                                coverage calculation (but not billed at depot or internal heap, so takes no real effect)\n        :return: coverage (i.e. cum_sum_funds - cum_sum_debits - debit_amount) in given currency up to given time step, \n                 double or math.inf (if self.check_marked_coverage=False)\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_7_c_check_coverage(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_debit_amount;
  std::string __pyx_v_currency;
  long __pyx_v_time_step;
  double __pyx_v_virtual_deposit;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_c_check_coverage (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_debit_amount,&__pyx_n_s_currency,&__pyx_n_s_time_step,&__pyx_n_s_virtual_deposit,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_debit_amount)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c_check_coverage", 0, 3, 4, 1); __PYX_ERR(0, 141, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_time_step)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_c_check_coverage", 0, 3, 4, 2); __PYX_ERR(0, 141, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_virtual_deposit);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_c_check_coverage") < 0)) __PYX_ERR(0, 141, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_debit_amount = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_debit_amount == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error)
    __pyx_v_currency = __pyx_convert_string_from_py_std__in_string(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error)
    __pyx_v_time_step = __Pyx_PyInt_As_long(values[2]); if (unlikely((__pyx_v_time_step == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error)
    if (values[3]) {
      __pyx_v_virtual_deposit = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_virtual_deposit == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error)
    } else {
      __pyx_v_virtual_deposit = ((double)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_c_check_coverage", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 141, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_check_coverage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_check_coverage(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_debit_amount, __pyx_v_currency, __pyx_v_time_step, __pyx_v_virtual_deposit);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_check_coverage(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_debit_amount, std::string __pyx_v_currency, long __pyx_v_time_step, double __pyx_v_virtual_deposit) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_check_coverage", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.virtual_deposit = __pyx_v_virtual_deposit;
  __pyx_t_1 = __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount->_c_check_coverage(__pyx_v_self, __pyx_v_debit_amount, __pyx_v_currency, __pyx_v_time_step, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((double)-1.0))) __PYX_ERR(0, 141, __pyx_L1_error)
  __pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_check_coverage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":193
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef short _c_check_debiting(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Checks if any positions in self.depot are negative, given that self._c_prohibit_debiting is True (else this
 */

static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_check_debiting(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  std::string __pyx_v_key;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  std::string __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  short __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_check_debiting", 0);

  /* "trapeza/account/fx_account.pyx":204
 *         """
 *         cdef string key
 *         if self._c_prohibit_debiting is False:             # <<<<<<<<<<<<<<
 *             return 1
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->_c_prohibit_debiting == 0) != 0);
  if (__pyx_t_1) {

    /* "trapeza/account/fx_account.pyx":205
 *         cdef string key
 *         if self._c_prohibit_debiting is False:
 *             return 1             # <<<<<<<<<<<<<<
 *         else:
 *             for key in self._c_depot.keys():
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "trapeza/account/fx_account.pyx":204
 *         """
 *         cdef string key
 *         if self._c_prohibit_debiting is False:             # <<<<<<<<<<<<<<
 *             return 1
 *         else:
 */
  }

  /* "trapeza/account/fx_account.pyx":207
 *             return 1
 *         else:
 *             for key in self._c_depot.keys():             # <<<<<<<<<<<<<<
 *                 if self._c_depot[key] < 0:
 *                     warnings.warn('Negative depot position detected, even though debiting was not allowed. '
 */
  /*else*/ {
    __pyx_t_3 = 0;
    if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "keys");
      __PYX_ERR(0, 207, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_dict_iterator(__pyx_v_self->_c_depot, 1, __pyx_n_s_keys, (&__pyx_t_4), (&__pyx_t_5)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 207, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_6;
    __pyx_t_6 = 0;
    while (1) {
      __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_4, &__pyx_t_3, &__pyx_t_6, NULL, NULL, __pyx_t_5);
      if (unlikely(__pyx_t_7 == 0)) break;
      if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 207, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 207, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_key = __pyx_t_8;

      /* "trapeza/account/fx_account.pyx":208
 *         else:
 *             for key in self._c_depot.keys():
 *                 if self._c_depot[key] < 0:             # <<<<<<<<<<<<<<
 *                     warnings.warn('Negative depot position detected, even though debiting was not allowed. '
 *                                   'Account depot as well as internal execution heap of delayed/ future transactions '
 */
      if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 208, __pyx_L1_error)
      }
      __pyx_t_6 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_key); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 208, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 208, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_RichCompare(__pyx_t_9, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 208, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 208, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__pyx_t_1)) {

        /* "trapeza/account/fx_account.pyx":209
 *             for key in self._c_depot.keys():
 *                 if self._c_depot[key] < 0:
 *                     warnings.warn('Negative depot position detected, even though debiting was not allowed. '             # <<<<<<<<<<<<<<
 *                                   'Account depot as well as internal execution heap of delayed/ future transactions '
 *                                   'may be irrecoverably corrupted. CoverageError.')
 */
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_warnings); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 209, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_warn); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 209, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_10, function);
          }
        }
        __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_9, __pyx_kp_u_Negative_depot_position_detected) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_kp_u_Negative_depot_position_detected);
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 209, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "trapeza/account/fx_account.pyx":212
 *                                   'Account depot as well as internal execution heap of delayed/ future transactions '
 *                                   'may be irrecoverably corrupted. CoverageError.')
 *                     self._c_issue_corruption_warning()             # <<<<<<<<<<<<<<
 *                     raise tpz_exception.CoverageError(self._c_depot[key], key.decode(),
 *                                                      'Debiting into negative positions not allowed by '
 */
        __pyx_t_11 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_issue_corruption_warning(__pyx_v_self); if (unlikely(__pyx_t_11 == ((short)-1))) __PYX_ERR(0, 212, __pyx_L1_error)

        /* "trapeza/account/fx_account.pyx":213
 *                                   'may be irrecoverably corrupted. CoverageError.')
 *                     self._c_issue_corruption_warning()
 *                     raise tpz_exception.CoverageError(self._c_depot[key], key.decode(),             # <<<<<<<<<<<<<<
 *                                                      'Debiting into negative positions not allowed by '
 *                                                      'parameter "prohibit_debiting" at init.')
 */
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 213, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 213, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 213, __pyx_L1_error)
        }
        __pyx_t_10 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_key); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 213, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_12 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 213, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_decode_cpp_string(__pyx_v_key, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 213, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_13 = NULL;
        __pyx_t_7 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
            __pyx_t_7 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_12, __pyx_t_10, __pyx_kp_u_Debiting_into_negative_positions};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 213, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_12, __pyx_t_10, __pyx_kp_u_Debiting_into_negative_positions};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 213, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        {
          __pyx_t_14 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 213, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          if (__pyx_t_13) {
            __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_7, __pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_7, __pyx_t_10);
          __Pyx_INCREF(__pyx_kp_u_Debiting_into_negative_positions);
          __Pyx_GIVEREF(__pyx_kp_u_Debiting_into_negative_positions);
          PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_7, __pyx_kp_u_Debiting_into_negative_positions);
          __pyx_t_12 = 0;
          __pyx_t_10 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 213, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __PYX_ERR(0, 213, __pyx_L1_error)

        /* "trapeza/account/fx_account.pyx":208
 *         else:
 *             for key in self._c_depot.keys():
 *                 if self._c_depot[key] < 0:             # <<<<<<<<<<<<<<
 *                     warnings.warn('Negative depot position detected, even though debiting was not allowed. '
 *                                   'Account depot as well as internal execution heap of delayed/ future transactions '
 */
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "trapeza/account/fx_account.pyx":216
 *                                                      'Debiting into negative positions not allowed by '
 *                                                      'parameter "prohibit_debiting" at init.')
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     @cython.wraparound(False)
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":193
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef short _c_check_debiting(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Checks if any positions in self.depot are negative, given that self._c_prohibit_debiting is True (else this
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_check_debiting", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":219
 * 
 *     @cython.wraparound(False)
 *     cpdef short _c_isin_depot(self, string currency) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Checks if param:currency is in self.depot.keys()
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_9_c_isin_depot(PyObject *__pyx_v_self, PyObject *__pyx_arg_currency); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_isin_depot(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency, int __pyx_skip_dispatch) {
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  short __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_isin_depot", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_isin_depot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_9_c_isin_depot)) {
        __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_6 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_6 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 219, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_6;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":226
 *         :raises: trapeza.exception.PositionNAError: if currency not in self.depot
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":228
 *         try:
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             raise tpz_exception.PositionNAError(currency.decode())
 */
      if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 228, __pyx_L3_error)
      }
      __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 228, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v__ = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "trapeza/account/fx_account.pyx":226
 *         :raises: trapeza.exception.PositionNAError: if currency not in self.depot
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]
 */
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "trapeza/account/fx_account.pyx":229
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.PositionNAError(currency.decode())
 *         return 1
 */
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_isin_depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 229, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "trapeza/account/fx_account.pyx":230
 *             _ = self._c_depot[currency]
 *         except KeyError:
 *             raise tpz_exception.PositionNAError(currency.decode())             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 230, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_PositionNAError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_decode_cpp_string(__pyx_v_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 230, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_3 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 230, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "trapeza/account/fx_account.pyx":226
 *         :raises: trapeza.exception.PositionNAError: if currency not in self.depot
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]
 */
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":231
 *         except KeyError:
 *             raise tpz_exception.PositionNAError(currency.decode())
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     @cython.wraparound(False)
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":219
 * 
 *     @cython.wraparound(False)
 *     cpdef short _c_isin_depot(self, string currency) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Checks if param:currency is in self.depot.keys()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_isin_depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_9_c_isin_depot(PyObject *__pyx_v_self, PyObject *__pyx_arg_currency); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_8_c_isin_depot[] = "\n        Checks if param:currency is in self.depot.keys()\n        :param currency: std:string\n        :return: 1\n        :raises: trapeza.exception.PositionNAError: if currency not in self.depot\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_9_c_isin_depot(PyObject *__pyx_v_self, PyObject *__pyx_arg_currency) {
  std::string __pyx_v_currency;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_c_isin_depot (wrapper)", 0);
  assert(__pyx_arg_currency); {
    __pyx_v_currency = __pyx_convert_string_from_py_std__in_string(__pyx_arg_currency); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 219, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_isin_depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_isin_depot(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((std::string)__pyx_v_currency));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_isin_depot(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_isin_depot", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_isin_depot(__pyx_v_self, __pyx_v_currency, 1); if (unlikely(__pyx_t_1 == ((short)-1))) __PYX_ERR(0, 219, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_isin_depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":234
 * 
 *     @cython.wraparound(False)
 *     cdef short _c_isin_depot_quiet(self, string currency) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Does exactly the same as self._c_isin_depot() but instead of throwing an exception, this function returns
 */

static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_isin_depot_quiet(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency) {
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_isin_depot_quiet", 0);

  /* "trapeza/account/fx_account.pyx":242
 *                  0: else
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":244
 *         try:
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return 0
 */
      if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 244, __pyx_L3_error)
      }
      __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 244, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 244, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v__ = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "trapeza/account/fx_account.pyx":242
 *                  0: else
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "trapeza/account/fx_account.pyx":245
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return 0
 *         return 1
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_isin_depot_quiet", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) __PYX_ERR(0, 245, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_7);

      /* "trapeza/account/fx_account.pyx":246
 *             _ = self._c_depot[currency]
 *         except KeyError:
 *             return 0             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
      __pyx_r = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "trapeza/account/fx_account.pyx":242
 *                  0: else
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # noinspection PyUnresolvedReferences
 *             _ = self._c_depot[currency]
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L8_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":247
 *         except KeyError:
 *             return 0
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":234
 * 
 *     @cython.wraparound(False)
 *     cdef short _c_isin_depot_quiet(self, string currency) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Does exactly the same as self._c_isin_depot() but instead of throwing an exception, this function returns
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_isin_depot_quiet", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":251
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef short _c_issue_corruption_warning(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Issues warning about corrupted heap and corrupted account depot if checking of marked but not yet booked
 */

static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_issue_corruption_warning(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_issue_corruption_warning", 0);

  /* "trapeza/account/fx_account.pyx":290
 *         :raises: warning
 *         """
 *         if self._c_check_marked_coverage == 0:             # <<<<<<<<<<<<<<
 *             warnings.warn('Checking of marked but not yet billed transactions was turned off. Account depot as '
 *                           'well as internal execution heap of delayed/ future transactions may be '
 */
  __pyx_t_1 = ((__pyx_v_self->_c_check_marked_coverage == 0) != 0);
  if (__pyx_t_1) {

    /* "trapeza/account/fx_account.pyx":291
 *         """
 *         if self._c_check_marked_coverage == 0:
 *             warnings.warn('Checking of marked but not yet billed transactions was turned off. Account depot as '             # <<<<<<<<<<<<<<
 *                           'well as internal execution heap of delayed/ future transactions may be '
 *                           'irrecoverably corrupted. CoverageError.')
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_warnings); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_warn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_kp_u_Checking_of_marked_but_not_yet_b) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_Checking_of_marked_but_not_yet_b);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "trapeza/account/fx_account.pyx":290
 *         :raises: warning
 *         """
 *         if self._c_check_marked_coverage == 0:             # <<<<<<<<<<<<<<
 *             warnings.warn('Checking of marked but not yet billed transactions was turned off. Account depot as '
 *                           'well as internal execution heap of delayed/ future transactions may be '
 */
  }

  /* "trapeza/account/fx_account.pyx":294
 *                           'well as internal execution heap of delayed/ future transactions may be '
 *                           'irrecoverably corrupted. CoverageError.')
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":251
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef short _c_issue_corruption_warning(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Issues warning about corrupted heap and corrupted account depot if checking of marked but not yet booked
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_issue_corruption_warning", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":298
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef short _c_confirmation(self, long processing_duration) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Return confirmation status depending on value of processing_duration
 */

static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_confirmation(CYTHON_UNUSED struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, long __pyx_v_processing_duration) {
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_c_confirmation", 0);

  /* "trapeza/account/fx_account.pyx":306
 *         """
 *         # if processing_duration is None or processing_duration <= 0:   # None not possible
 *         if processing_duration <= 0:             # <<<<<<<<<<<<<<
 *             return 1
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_processing_duration <= 0) != 0);
  if (__pyx_t_1) {

    /* "trapeza/account/fx_account.pyx":307
 *         # if processing_duration is None or processing_duration <= 0:   # None not possible
 *         if processing_duration <= 0:
 *             return 1             # <<<<<<<<<<<<<<
 *         else:
 *             return 0
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "trapeza/account/fx_account.pyx":306
 *         """
 *         # if processing_duration is None or processing_duration <= 0:   # None not possible
 *         if processing_duration <= 0:             # <<<<<<<<<<<<<<
 *             return 1
 *         else:
 */
  }

  /* "trapeza/account/fx_account.pyx":309
 *             return 1
 *         else:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *     @cython.wraparound(False)
 */
  /*else*/ {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "trapeza/account/fx_account.pyx":298
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef short _c_confirmation(self, long processing_duration) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Return confirmation status depending on value of processing_duration
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":312
 * 
 *     @cython.wraparound(False)
 *     cdef short _c_fill_fee(self, double fee_volume, string fee_currency, long fee_exec_duration,             # <<<<<<<<<<<<<<
 *                            string forward_coverage=b'except') except -1:
 *         """
 */

static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee *__pyx_optional_args) {
  std::string __pyx_v_forward_coverage = __pyx_k_;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_c_fill_fee", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_forward_coverage = __pyx_optional_args->forward_coverage;
    }
  }

  /* "trapeza/account/fx_account.pyx":328
 *         :return: 1
 *         """
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self.c_withdraw(fee_volume, fee_currency, fee_exec_duration, coverage=forward_coverage)
 *         return 1
 */
  __pyx_t_1 = ((__pyx_v_fee_volume > 0.0) != 0);
  if (__pyx_t_1) {

    /* "trapeza/account/fx_account.pyx":329
 *         """
 *         if fee_volume > 0:
 *             self.c_withdraw(fee_volume, fee_currency, fee_exec_duration, coverage=forward_coverage)             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_withdraw); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_fee_volume); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_fee_currency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_fee_exec_duration); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_forward_coverage); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_coverage, __pyx_t_4) < 0) __PYX_ERR(0, 329, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 329, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "trapeza/account/fx_account.pyx":328
 *         :return: 1
 *         """
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self.c_withdraw(fee_volume, fee_currency, fee_exec_duration, coverage=forward_coverage)
 *         return 1
 */
  }

  /* "trapeza/account/fx_account.pyx":330
 *         if fee_volume > 0:
 *             self.c_withdraw(fee_volume, fee_currency, fee_exec_duration, coverage=forward_coverage)
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     @cython.wraparound(False)
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":312
 * 
 *     @cython.wraparound(False)
 *     cdef short _c_fill_fee(self, double fee_volume, string fee_currency, long fee_exec_duration,             # <<<<<<<<<<<<<<
 *                            string forward_coverage=b'except') except -1:
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_fill_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":333
 * 
 *     @cython.wraparound(False)
 *     cdef short _execute_heap(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Processes and executes self.exec_heap (if transactions are delayed due to processing duration of fulfillment).
 */

static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount__execute_heap(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct __pyx_v_process;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  short __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_execute_heap", 0);

  /* "trapeza/account/fx_account.pyx":343
 * 
 *         # >>>avoid double accounting when processing heap
 *         self._c_is_heap = True             # <<<<<<<<<<<<<<
 * 
 *         # >>>loop through heap, which is sorted in ascending timestamps
 */
  __pyx_v_self->_c_is_heap = 1;

  /* "trapeza/account/fx_account.pyx":347
 *         # >>>loop through heap, which is sorted in ascending timestamps
 *         cdef fx_heap_element_struct process
 *         while True:             # <<<<<<<<<<<<<<
 *             # get first element with lowest timestamp
 *             if self.vec_heap.size() > 0:
 */
  while (1) {

    /* "trapeza/account/fx_account.pyx":349
 *         while True:
 *             # get first element with lowest timestamp
 *             if self.vec_heap.size() > 0:             # <<<<<<<<<<<<<<
 *                 process = self.vec_heap.heappop()
 *             else:
 */
    __pyx_t_1 = ((((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->size(__pyx_v_self->vec_heap) > 0) != 0);
    if (__pyx_t_1) {

      /* "trapeza/account/fx_account.pyx":350
 *             # get first element with lowest timestamp
 *             if self.vec_heap.size() > 0:
 *                 process = self.vec_heap.heappop()             # <<<<<<<<<<<<<<
 *             else:
 *                 self._c_is_heap = False
 */
      __pyx_v_process = ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->heappop(__pyx_v_self->vec_heap);

      /* "trapeza/account/fx_account.pyx":349
 *         while True:
 *             # get first element with lowest timestamp
 *             if self.vec_heap.size() > 0:             # <<<<<<<<<<<<<<
 *                 process = self.vec_heap.heappop()
 *             else:
 */
      goto __pyx_L5;
    }

    /* "trapeza/account/fx_account.pyx":352
 *                 process = self.vec_heap.heappop()
 *             else:
 *                 self._c_is_heap = False             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
    /*else*/ {
      __pyx_v_self->_c_is_heap = 0;

      /* "trapeza/account/fx_account.pyx":353
 *             else:
 *                 self._c_is_heap = False
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             # check if internal clock already reached execution time
 */
      goto __pyx_L4_break;
    }
    __pyx_L5:;

    /* "trapeza/account/fx_account.pyx":356
 * 
 *             # check if internal clock already reached execution time
 *             if self._c_clock >= process.time:             # <<<<<<<<<<<<<<
 *                 # execute
 *                 if len(process) == 5:
 */
    __pyx_t_1 = ((__pyx_v_self->_c_clock >= __pyx_v_process.time) != 0);
    if (__pyx_t_1) {

      /* "trapeza/account/fx_account.pyx":358
 *             if self._c_clock >= process.time:
 *                 # execute
 *                 if len(process) == 5:             # <<<<<<<<<<<<<<
 *                     # noinspection PyUnresolvedReferences
 *                     getattr(self, process.action_func.decode())\
 */
      __pyx_t_2 = __pyx_convert__to_py_struct____pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct(__pyx_v_process); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 358, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_1 = ((__pyx_t_3 == 5) != 0);
      if (__pyx_t_1) {

        /* "trapeza/account/fx_account.pyx":360
 *                 if len(process) == 5:
 *                     # noinspection PyUnresolvedReferences
 *                     getattr(self, process.action_func.decode())\             # <<<<<<<<<<<<<<
 *                         (process.volume, process.currency, 0,
 *                          coverage=process.coverage)
 */
        __pyx_t_2 = __Pyx_decode_cpp_string(__pyx_v_process.action_func, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_GetAttr(((PyObject *)__pyx_v_self), __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "trapeza/account/fx_account.pyx":361
 *                     # noinspection PyUnresolvedReferences
 *                     getattr(self, process.action_func.decode())\
 *                         (process.volume, process.currency, 0,             # <<<<<<<<<<<<<<
 *                          coverage=process.coverage)
 *                 else:
 */
        __pyx_t_2 = PyFloat_FromDouble(__pyx_v_process.volume); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_process.currency); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_0);
        __pyx_t_2 = 0;
        __pyx_t_5 = 0;

        /* "trapeza/account/fx_account.pyx":362
 *                     getattr(self, process.action_func.decode())\
 *                         (process.volume, process.currency, 0,
 *                          coverage=process.coverage)             # <<<<<<<<<<<<<<
 *                 else:
 *                     # noinspection PyUnresolvedReferences
 */
        __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 362, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_process.coverage); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_coverage, __pyx_t_2) < 0) __PYX_ERR(0, 362, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "trapeza/account/fx_account.pyx":361
 *                     # noinspection PyUnresolvedReferences
 *                     getattr(self, process.action_func.decode())\
 *                         (process.volume, process.currency, 0,             # <<<<<<<<<<<<<<
 *                          coverage=process.coverage)
 *                 else:
 */
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "trapeza/account/fx_account.pyx":358
 *             if self._c_clock >= process.time:
 *                 # execute
 *                 if len(process) == 5:             # <<<<<<<<<<<<<<
 *                     # noinspection PyUnresolvedReferences
 *                     getattr(self, process.action_func.decode())\
 */
        goto __pyx_L7;
      }

      /* "trapeza/account/fx_account.pyx":365
 *                 else:
 *                     # noinspection PyUnresolvedReferences
 *                     getattr(self, process.action_func.decode())(process.volume, process.currency.decode(), 0)             # <<<<<<<<<<<<<<
 *             else:
 *                 # internal clock did not reach execution time yet, so push back and exit
 */
      /*else*/ {
        __pyx_t_5 = __Pyx_decode_cpp_string(__pyx_v_process.action_func, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __Pyx_GetAttr(((PyObject *)__pyx_v_self), __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = PyFloat_FromDouble(__pyx_v_process.volume); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __Pyx_decode_cpp_string(__pyx_v_process.currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 365, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = NULL;
        __pyx_t_8 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
            __pyx_t_8 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_5, __pyx_t_4, __pyx_int_0};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_5, __pyx_t_4, __pyx_int_0};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 365, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          if (__pyx_t_7) {
            __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
          __Pyx_INCREF(__pyx_int_0);
          __Pyx_GIVEREF(__pyx_int_0);
          PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_int_0);
          __pyx_t_5 = 0;
          __pyx_t_4 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __pyx_L7:;

      /* "trapeza/account/fx_account.pyx":356
 * 
 *             # check if internal clock already reached execution time
 *             if self._c_clock >= process.time:             # <<<<<<<<<<<<<<
 *                 # execute
 *                 if len(process) == 5:
 */
      goto __pyx_L6;
    }

    /* "trapeza/account/fx_account.pyx":368
 *             else:
 *                 # internal clock did not reach execution time yet, so push back and exit
 *                 self.vec_heap.heappush_struct(process)             # <<<<<<<<<<<<<<
 *                 self._c_is_heap = False
 *                 break
 */
    /*else*/ {
      ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->heappush_struct(__pyx_v_self->vec_heap, __pyx_v_process);

      /* "trapeza/account/fx_account.pyx":369
 *                 # internal clock did not reach execution time yet, so push back and exit
 *                 self.vec_heap.heappush_struct(process)
 *                 self._c_is_heap = False             # <<<<<<<<<<<<<<
 *                 break
 *         self._c_check_debiting()
 */
      __pyx_v_self->_c_is_heap = 0;

      /* "trapeza/account/fx_account.pyx":370
 *                 self.vec_heap.heappush_struct(process)
 *                 self._c_is_heap = False
 *                 break             # <<<<<<<<<<<<<<
 *         self._c_check_debiting()
 *         return 1
 */
      goto __pyx_L4_break;
    }
    __pyx_L6:;
  }
  __pyx_L4_break:;

  /* "trapeza/account/fx_account.pyx":371
 *                 self._c_is_heap = False
 *                 break
 *         self._c_check_debiting()             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  __pyx_t_10 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_debiting(__pyx_v_self); if (unlikely(__pyx_t_10 == ((short)-1))) __PYX_ERR(0, 371, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":372
 *                 break
 *         self._c_check_debiting()
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":333
 * 
 *     @cython.wraparound(False)
 *     cdef short _execute_heap(self) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         Processes and executes self.exec_heap (if transactions are delayed due to processing duration of fulfillment).
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._execute_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":376
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_11c_sell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_sell(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, double __pyx_v_bid_price, std::string __pyx_v_base, std::string __pyx_v_quote, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_sell *__pyx_optional_args) {
  double __pyx_v_fee_volume = ((double)0.0);
  std::string __pyx_v_fee_currency = __pyx_k__2;
  long __pyx_v_fee_exec_duration = ((long)0);
  long __pyx_v_processing_duration = ((long)0);
  std::string __pyx_v_coverage = __pyx_k__3;

  /* "trapeza/account/fx_account.pyx":378
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,             # <<<<<<<<<<<<<<
 *                    bool_t instant_float_fee=False) except -9999:
 *         """
 */
  bool __pyx_v_instant_withdrawal = ((bool)0);

  /* "trapeza/account/fx_account.pyx":379
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,
 *                    bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.sell for further information.
 */
  bool __pyx_v_instant_float_fee = ((bool)0);
  short __pyx_v_current_check_marked_coverage;
  std::string __pyx_v_propagate_coverage;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  short __pyx_t_18;
  int __pyx_t_19;
  double __pyx_t_20;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage __pyx_t_21;
  std::string __pyx_t_22;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee __pyx_t_23;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_sell", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_fee_volume = __pyx_optional_args->fee_volume;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_fee_currency = __pyx_optional_args->fee_currency;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_fee_exec_duration = __pyx_optional_args->fee_exec_duration;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_processing_duration = __pyx_optional_args->processing_duration;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_coverage = __pyx_optional_args->coverage;
              if (__pyx_optional_args->__pyx_n > 5) {
                __pyx_v_instant_withdrawal = __pyx_optional_args->instant_withdrawal;
                if (__pyx_optional_args->__pyx_n > 6) {
                  __pyx_v_instant_float_fee = __pyx_optional_args->instant_float_fee;
                }
              }
            }
          }
        }
      }
    }
  }

  /* "trapeza/account/fx_account.pyx":376
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 376, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_11c_sell)) {
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyFloat_FromDouble(__pyx_v_bid_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_base); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_quote); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyFloat_FromDouble(__pyx_v_fee_volume); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_fee_currency); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyInt_From_long(__pyx_v_fee_exec_duration); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_v_processing_duration); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = __Pyx_PyBool_FromLong(__pyx_v_instant_withdrawal); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = __Pyx_PyBool_FromLong(__pyx_v_instant_float_fee); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_14 = __pyx_t_1; __pyx_t_15 = NULL;
        __pyx_t_16 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
          if (likely(__pyx_t_15)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_14, function);
            __pyx_t_16 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[12] = {__pyx_t_15, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_16, 11+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[12] = {__pyx_t_15, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_16, 11+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else
        #endif
        {
          __pyx_t_17 = PyTuple_New(11+__pyx_t_16); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 376, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__pyx_t_15) {
            __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_16, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_16, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_16, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_17, 3+__pyx_t_16, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_17, 4+__pyx_t_16, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_17, 5+__pyx_t_16, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_17, 6+__pyx_t_16, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_17, 7+__pyx_t_16, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_17, 8+__pyx_t_16, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_17, 9+__pyx_t_16, __pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_13);
          PyTuple_SET_ITEM(__pyx_t_17, 10+__pyx_t_16, __pyx_t_13);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_6 = 0;
          __pyx_t_7 = 0;
          __pyx_t_8 = 0;
          __pyx_t_9 = 0;
          __pyx_t_10 = 0;
          __pyx_t_11 = 0;
          __pyx_t_12 = 0;
          __pyx_t_13 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_18 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_18 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 376, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_18;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":402
 *         """
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             fee_currency = base
 * 
 */
  __pyx_t_19 = ((__pyx_v_fee_currency == ((char const *)"default")) != 0);
  if (__pyx_t_19) {

    /* "trapeza/account/fx_account.pyx":403
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':
 *             fee_currency = base             # <<<<<<<<<<<<<<
 * 
 *         # >>>store value for later restoring
 */
    __pyx_v_fee_currency = __pyx_v_base;

    /* "trapeza/account/fx_account.pyx":402
 *         """
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             fee_currency = base
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":407
 *         # >>>store value for later restoring
 *         cdef short current_check_marked_coverage
 *         current_check_marked_coverage = self._c_check_marked_coverage             # <<<<<<<<<<<<<<
 *         # >>>get fulfillment method depending on account coverage and fee structure
 *         if self._c_depot[base] < c_precision_add(volume, fee_volume * (fee_currency == base)):
 */
  __pyx_t_18 = __pyx_v_self->_c_check_marked_coverage;
  __pyx_v_current_check_marked_coverage = __pyx_t_18;

  /* "trapeza/account/fx_account.pyx":409
 *         current_check_marked_coverage = self._c_check_marked_coverage
 *         # >>>get fulfillment method depending on account coverage and fee structure
 *         if self._c_depot[base] < c_precision_add(volume, fee_volume * (fee_currency == base)):             # <<<<<<<<<<<<<<
 *             if coverage == b'except':
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == base)),
 */
  if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 409, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_base)))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (__pyx_t_19) {

    /* "trapeza/account/fx_account.pyx":410
 *         # >>>get fulfillment method depending on account coverage and fee structure
 *         if self._c_depot[base] < c_precision_add(volume, fee_volume * (fee_currency == base)):
 *             if coverage == b'except':             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == base)),
 *                                                   base.decode())
 */
    __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"except")) != 0);
    if (unlikely(__pyx_t_19)) {

      /* "trapeza/account/fx_account.pyx":411
 *         if self._c_depot[base] < c_precision_add(volume, fee_volume * (fee_currency == base)):
 *             if coverage == b'except':
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == base)),             # <<<<<<<<<<<<<<
 *                                                   base.decode())
 *             elif coverage == b'partial':
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_base)))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);

      /* "trapeza/account/fx_account.pyx":412
 *             if coverage == b'except':
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == base)),
 *                                                   base.decode())             # <<<<<<<<<<<<<<
 *             elif coverage == b'partial':
 *                 volume = c_precision_subtract(self._c_depot[base], fee_volume * (fee_currency == base))
 */
      __pyx_t_17 = __Pyx_decode_cpp_string(__pyx_v_base, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 412, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_13 = NULL;
      __pyx_t_16 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_16 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_1, __pyx_t_17};
        __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 411, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_1, __pyx_t_17};
        __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 411, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 411, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_13) {
          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_16, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_17);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_16, __pyx_t_17);
        __pyx_t_1 = 0;
        __pyx_t_17 = 0;
        __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 411, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_14, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __PYX_ERR(0, 411, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":410
 *         # >>>get fulfillment method depending on account coverage and fee structure
 *         if self._c_depot[base] < c_precision_add(volume, fee_volume * (fee_currency == base)):
 *             if coverage == b'except':             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == base)),
 *                                                   base.decode())
 */
    }

    /* "trapeza/account/fx_account.pyx":413
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == base)),
 *                                                   base.decode())
 *             elif coverage == b'partial':             # <<<<<<<<<<<<<<
 *                 volume = c_precision_subtract(self._c_depot[base], fee_volume * (fee_currency == base))
 *                 if volume < 0:
 */
    __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"partial")) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":414
 *                                                   base.decode())
 *             elif coverage == b'partial':
 *                 volume = c_precision_subtract(self._c_depot[base], fee_volume * (fee_currency == base))             # <<<<<<<<<<<<<<
 *                 if volume < 0:
 *                     raise tpz_exception.CoverageError(fee_volume, fee_currency.decode(),
 */
      if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 414, __pyx_L1_error)
      }
      __pyx_t_14 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_base); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_20 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_20 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_volume = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_subtract(__pyx_t_20, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_base)));

      /* "trapeza/account/fx_account.pyx":415
 *             elif coverage == b'partial':
 *                 volume = c_precision_subtract(self._c_depot[base], fee_volume * (fee_currency == base))
 *                 if volume < 0:             # <<<<<<<<<<<<<<
 *                     raise tpz_exception.CoverageError(fee_volume, fee_currency.decode(),
 *                                                      'Transaction not feasible even though coverage set '
 */
      __pyx_t_19 = ((__pyx_v_volume < 0.0) != 0);
      if (unlikely(__pyx_t_19)) {

        /* "trapeza/account/fx_account.pyx":416
 *                 volume = c_precision_subtract(self._c_depot[base], fee_volume * (fee_currency == base))
 *                 if volume < 0:
 *                     raise tpz_exception.CoverageError(fee_volume, fee_currency.decode(),             # <<<<<<<<<<<<<<
 *                                                      'Transaction not feasible even though coverage set '
 *                                                      'to partial. Fees not covered.')
 */
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 416, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 416, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = PyFloat_FromDouble(__pyx_v_fee_volume); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 416, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_17 = __Pyx_decode_cpp_string(__pyx_v_fee_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 416, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_1 = NULL;
        __pyx_t_16 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_12, function);
            __pyx_t_16 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_14, __pyx_t_17, __pyx_kp_u_Transaction_not_feasible_even_th};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_16, 3+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_14, __pyx_t_17, __pyx_kp_u_Transaction_not_feasible_even_th};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_16, 3+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(3+__pyx_t_16); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 416, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          if (__pyx_t_1) {
            __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); __pyx_t_1 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_14);
          PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_16, __pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_17);
          PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_16, __pyx_t_17);
          __Pyx_INCREF(__pyx_kp_u_Transaction_not_feasible_even_th);
          __Pyx_GIVEREF(__pyx_kp_u_Transaction_not_feasible_even_th);
          PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_16, __pyx_kp_u_Transaction_not_feasible_even_th);
          __pyx_t_14 = 0;
          __pyx_t_17 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(0, 416, __pyx_L1_error)

        /* "trapeza/account/fx_account.pyx":415
 *             elif coverage == b'partial':
 *                 volume = c_precision_subtract(self._c_depot[base], fee_volume * (fee_currency == base))
 *                 if volume < 0:             # <<<<<<<<<<<<<<
 *                     raise tpz_exception.CoverageError(fee_volume, fee_currency.decode(),
 *                                                      'Transaction not feasible even though coverage set '
 */
      }

      /* "trapeza/account/fx_account.pyx":413
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == base)),
 *                                                   base.decode())
 *             elif coverage == b'partial':             # <<<<<<<<<<<<<<
 *                 volume = c_precision_subtract(self._c_depot[base], fee_volume * (fee_currency == base))
 *                 if volume < 0:
 */
      goto __pyx_L5;
    }

    /* "trapeza/account/fx_account.pyx":419
 *                                                      'Transaction not feasible even though coverage set '
 *                                                      'to partial. Fees not covered.')
 *             elif coverage == b'ignore':             # <<<<<<<<<<<<<<
 *                 return -1
 *             elif coverage == b'debit':
 */
    __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"ignore")) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":420
 *                                                      'to partial. Fees not covered.')
 *             elif coverage == b'ignore':
 *                 return -1             # <<<<<<<<<<<<<<
 *             elif coverage == b'debit':
 *                 self._c_check_marked_coverage = 0
 */
      __pyx_r = -1;
      goto __pyx_L0;

      /* "trapeza/account/fx_account.pyx":419
 *                                                      'Transaction not feasible even though coverage set '
 *                                                      'to partial. Fees not covered.')
 *             elif coverage == b'ignore':             # <<<<<<<<<<<<<<
 *                 return -1
 *             elif coverage == b'debit':
 */
    }

    /* "trapeza/account/fx_account.pyx":421
 *             elif coverage == b'ignore':
 *                 return -1
 *             elif coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self._c_check_marked_coverage = 0
 * 
 */
    __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"debit")) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":422
 *                 return -1
 *             elif coverage == b'debit':
 *                 self._c_check_marked_coverage = 0             # <<<<<<<<<<<<<<
 * 
 *         # >>>check coverage before proceeding
 */
      __pyx_v_self->_c_check_marked_coverage = 0;

      /* "trapeza/account/fx_account.pyx":421
 *             elif coverage == b'ignore':
 *                 return -1
 *             elif coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self._c_check_marked_coverage = 0
 * 
 */
    }
    __pyx_L5:;

    /* "trapeza/account/fx_account.pyx":409
 *         current_check_marked_coverage = self._c_check_marked_coverage
 *         # >>>get fulfillment method depending on account coverage and fee structure
 *         if self._c_depot[base] < c_precision_add(volume, fee_volume * (fee_currency == base)):             # <<<<<<<<<<<<<<
 *             if coverage == b'except':
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == base)),
 */
  }

  /* "trapeza/account/fx_account.pyx":425
 * 
 *         # >>>check coverage before proceeding
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == base)), base,             # <<<<<<<<<<<<<<
 *                                self._c_clock + processing_duration * (1 - instant_withdrawal))
 *         if fee_volume > 0:
 */
  __pyx_t_20 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_base))), __pyx_v_base, (__pyx_v_self->_c_clock + (__pyx_v_processing_duration * (1 - __pyx_v_instant_withdrawal))), 0, NULL); if (unlikely(__pyx_t_20 == ((double)-1.0))) __PYX_ERR(0, 425, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":427
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == base)), base,
 *                                self._c_clock + processing_duration * (1 - instant_withdrawal))
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # if fee_volume is in base (or generally speaking not in quote),
 *             # we have to check that enough money is on depot
 */
  __pyx_t_19 = ((__pyx_v_fee_volume > 0.0) != 0);
  if (__pyx_t_19) {

    /* "trapeza/account/fx_account.pyx":430
 *             # if fee_volume is in base (or generally speaking not in quote),
 *             # we have to check that enough money is on depot
 *             if fee_currency != quote:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
    __pyx_t_19 = ((__pyx_v_fee_currency != __pyx_v_quote) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":431
 *             # we have to check that enough money is on depot
 *             if fee_currency != quote:
 *                 self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             # if fee_volume is in quote, we have to take processing times into account
 */
      __pyx_t_20 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, NULL); if (unlikely(__pyx_t_20 == ((double)-1.0))) __PYX_ERR(0, 431, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":430
 *             # if fee_volume is in base (or generally speaking not in quote),
 *             # we have to check that enough money is on depot
 *             if fee_currency != quote:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
      goto __pyx_L8;
    }

    /* "trapeza/account/fx_account.pyx":439
 *             #       when checking coverage
 *             #   - fee before depositing: check that enough money in fee_currency is on depot
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
    __pyx_t_19 = (((__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee)) < __pyx_v_processing_duration) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":440
 *             #   - fee before depositing: check that enough money in fee_currency is on depot
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:
 *                 self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             else:
 */
      __pyx_t_20 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, NULL); if (unlikely(__pyx_t_20 == ((double)-1.0))) __PYX_ERR(0, 440, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":439
 *             #       when checking coverage
 *             #   - fee before depositing: check that enough money in fee_currency is on depot
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
      goto __pyx_L8;
    }

    /* "trapeza/account/fx_account.pyx":443
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             else:
 *                 if self._c_isin_depot_quiet(fee_currency) == 0:             # <<<<<<<<<<<<<<
 *                     # this is done to prevent an exception if there is not yet an open position in fee_currency on
 *                     # account's depot
 */
    /*else*/ {
      __pyx_t_18 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_isin_depot_quiet(__pyx_v_self, __pyx_v_fee_currency); if (unlikely(__pyx_t_18 == ((short)-1))) __PYX_ERR(0, 443, __pyx_L1_error)
      __pyx_t_19 = ((__pyx_t_18 == 0) != 0);
      if (__pyx_t_19) {

        /* "trapeza/account/fx_account.pyx":446
 *                     # this is done to prevent an exception if there is not yet an open position in fee_currency on
 *                     # account's depot
 *                     self._c_depot[fee_currency] = 0             # <<<<<<<<<<<<<<
 *                 # volume given in base, bid_price in base|quote notation (unit: [quote/base])
 *                 # volume for offsetting fees must be in quote, so we have to multiply with bid_price
 */
        if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 446, __pyx_L1_error)
        }
        __pyx_t_2 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_fee_currency); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 446, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (unlikely(PyDict_SetItem(__pyx_v_self->_c_depot, __pyx_t_2, __pyx_int_0) < 0)) __PYX_ERR(0, 446, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "trapeza/account/fx_account.pyx":443
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             else:
 *                 if self._c_isin_depot_quiet(fee_currency) == 0:             # <<<<<<<<<<<<<<
 *                     # this is done to prevent an exception if there is not yet an open position in fee_currency on
 *                     # account's depot
 */
      }

      /* "trapeza/account/fx_account.pyx":449
 *                 # volume given in base, bid_price in base|quote notation (unit: [quote/base])
 *                 # volume for offsetting fees must be in quote, so we have to multiply with bid_price
 *                 self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee),
 *                                        c_precision_multiply(volume, bid_price))
 */
      __pyx_t_21.__pyx_n = 1;
      __pyx_t_21.virtual_deposit = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_multiply(__pyx_v_volume, __pyx_v_bid_price);
      __pyx_t_20 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, &__pyx_t_21); if (unlikely(__pyx_t_20 == ((double)-1.0))) __PYX_ERR(0, 449, __pyx_L1_error)
    }
    __pyx_L8:;

    /* "trapeza/account/fx_account.pyx":427
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == base)), base,
 *                                self._c_clock + processing_duration * (1 - instant_withdrawal))
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # if fee_volume is in base (or generally speaking not in quote),
 *             # we have to check that enough money is on depot
 */
  }

  /* "trapeza/account/fx_account.pyx":454
 * 
 *         # >>>process transactions according to withdrawal execution duration
 *         self.c_withdraw(volume, base, processing_duration=processing_duration * (1 - instant_withdrawal),             # <<<<<<<<<<<<<<
 *                         coverage=coverage)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_withdraw); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_base); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_13);
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_12 = __Pyx_PyInt_From_long((__pyx_v_processing_duration * (1 - __pyx_v_instant_withdrawal))); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_processing_duration, __pyx_t_12) < 0) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "trapeza/account/fx_account.pyx":455
 *         # >>>process transactions according to withdrawal execution duration
 *         self.c_withdraw(volume, base, processing_duration=processing_duration * (1 - instant_withdrawal),
 *                         coverage=coverage)             # <<<<<<<<<<<<<<
 * 
 *         # >>>deposit quote currency
 */
  __pyx_t_12 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_coverage, __pyx_t_12) < 0) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "trapeza/account/fx_account.pyx":454
 * 
 *         # >>>process transactions according to withdrawal execution duration
 *         self.c_withdraw(volume, base, processing_duration=processing_duration * (1 - instant_withdrawal),             # <<<<<<<<<<<<<<
 *                         coverage=coverage)
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_17, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "trapeza/account/fx_account.pyx":458
 * 
 *         # >>>deposit quote currency
 *         self.c_deposit(volume=c_precision_multiply(volume, bid_price), currency=quote,             # <<<<<<<<<<<<<<
 *                        processing_duration=processing_duration, coverage=coverage)
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_deposit); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_17 = PyFloat_FromDouble(__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_multiply(__pyx_v_volume, __pyx_v_bid_price)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_volume, __pyx_t_17) < 0) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_17 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_quote); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_currency, __pyx_t_17) < 0) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "trapeza/account/fx_account.pyx":459
 *         # >>>deposit quote currency
 *         self.c_deposit(volume=c_precision_multiply(volume, bid_price), currency=quote,
 *                        processing_duration=processing_duration, coverage=coverage)             # <<<<<<<<<<<<<<
 * 
 *         # >>>handle fees
 */
  __pyx_t_17 = __Pyx_PyInt_From_long(__pyx_v_processing_duration); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_processing_duration, __pyx_t_17) < 0) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_17 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_coverage, __pyx_t_17) < 0) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "trapeza/account/fx_account.pyx":458
 * 
 *         # >>>deposit quote currency
 *         self.c_deposit(volume=c_precision_multiply(volume, bid_price), currency=quote,             # <<<<<<<<<<<<<<
 *                        processing_duration=processing_duration, coverage=coverage)
 * 
 */
  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_empty_tuple, __pyx_t_13); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

  /* "trapeza/account/fx_account.pyx":463
 *         # >>>handle fees
 *         cdef string propagate_coverage
 *         if coverage == b'partial':             # <<<<<<<<<<<<<<
 *             propagate_coverage = b'except'
 *         else:
 */
  __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"partial")) != 0);
  if (__pyx_t_19) {

    /* "trapeza/account/fx_account.pyx":464
 *         cdef string propagate_coverage
 *         if coverage == b'partial':
 *             propagate_coverage = b'except'             # <<<<<<<<<<<<<<
 *         else:
 *             propagate_coverage = coverage
 */
    __pyx_t_22 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 464, __pyx_L1_error)
    __pyx_v_propagate_coverage = __pyx_t_22;

    /* "trapeza/account/fx_account.pyx":463
 *         # >>>handle fees
 *         cdef string propagate_coverage
 *         if coverage == b'partial':             # <<<<<<<<<<<<<<
 *             propagate_coverage = b'except'
 *         else:
 */
    goto __pyx_L10;
  }

  /* "trapeza/account/fx_account.pyx":466
 *             propagate_coverage = b'except'
 *         else:
 *             propagate_coverage = coverage             # <<<<<<<<<<<<<<
 *         self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,
 *                          fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 */
  /*else*/ {
    __pyx_v_propagate_coverage = __pyx_v_coverage;
  }
  __pyx_L10:;

  /* "trapeza/account/fx_account.pyx":467
 *         else:
 *             propagate_coverage = coverage
 *         self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,             # <<<<<<<<<<<<<<
 *                          fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 *                          forward_coverage=propagate_coverage)
 */
  __pyx_t_23.__pyx_n = 1;
  __pyx_t_23.forward_coverage = __pyx_v_propagate_coverage;
  __pyx_t_18 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_fill_fee(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee)), &__pyx_t_23); if (unlikely(__pyx_t_18 == ((short)-1))) __PYX_ERR(0, 467, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":472
 * 
 *         # >>>restore
 *         self._c_check_marked_coverage = current_check_marked_coverage             # <<<<<<<<<<<<<<
 * 
 *         # >>> return confirmation
 */
  __pyx_v_self->_c_check_marked_coverage = __pyx_v_current_check_marked_coverage;

  /* "trapeza/account/fx_account.pyx":475
 * 
 *         # >>> return confirmation
 *         return self._c_confirmation(processing_duration)             # <<<<<<<<<<<<<<
 * 
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 */
  __pyx_t_18 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_confirmation(__pyx_v_self, __pyx_v_processing_duration); if (unlikely(__pyx_t_18 == ((short)-1))) __PYX_ERR(0, 475, __pyx_L1_error)
  __pyx_r = __pyx_t_18;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":376
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_sell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -9999;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_11c_sell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_10c_sell[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.sell for further information.\n        \n        :param volume: double, in BASE currency\n        :param bid_price: double, current bid rate in base|quote notation\n        :param base: std:string, currency\n        :param quote: std:string, currency\n        :param fee_volume: double, volume in param:fee_currency\n        :param fee_currency: std:string, if b'default', then param:fee_currency defaults to param:base\n        :param fee_exec_duration: long, processing time (delay) in time base units of internal clock\n        :param processing_duration: long, processing time (delay) in time base units of internal clock\n        :param coverage: std:string {b'partial', b'except', b'ignore', b'debit'}, \n                         default=b'except'\n                         see FXAccount.sell for details\n        :param instant_withdrawal: std:bool, \n                                   see FXAccount.sell for details\n        :param instant_float_fee: std:bool, \n                                  see FXAccount.sell for details\n        :return: confirmation: short, \n                               confirmation states --> -1: ignored, 0: processing (processing_duration), 1: executed\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_11c_sell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_volume;
  double __pyx_v_bid_price;
  std::string __pyx_v_base;
  std::string __pyx_v_quote;
  double __pyx_v_fee_volume;
  std::string __pyx_v_fee_currency;
  long __pyx_v_fee_exec_duration;
  long __pyx_v_processing_duration;
  std::string __pyx_v_coverage;
  bool __pyx_v_instant_withdrawal;
  bool __pyx_v_instant_float_fee;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_sell (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_volume,&__pyx_n_s_bid_price,&__pyx_n_s_base,&__pyx_n_s_quote,&__pyx_n_s_fee_volume,&__pyx_n_s_fee_currency,&__pyx_n_s_fee_exec_duration,&__pyx_n_s_processing_duration,&__pyx_n_s_coverage,&__pyx_n_s_instant_withdrawal,&__pyx_n_s_instant_float_fee,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bid_price)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_sell", 0, 4, 11, 1); __PYX_ERR(0, 376, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_sell", 0, 4, 11, 2); __PYX_ERR(0, 376, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quote)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_sell", 0, 4, 11, 3); __PYX_ERR(0, 376, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_volume);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_currency);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_exec_duration);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coverage);
          if (value) { values[8] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_withdrawal);
          if (value) { values[9] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_float_fee);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "c_sell") < 0)) __PYX_ERR(0, 376, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 376, __pyx_L3_error)
    __pyx_v_bid_price = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_bid_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 376, __pyx_L3_error)
    __pyx_v_base = __pyx_convert_string_from_py_std__in_string(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 376, __pyx_L3_error)
    __pyx_v_quote = __pyx_convert_string_from_py_std__in_string(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 376, __pyx_L3_error)
    if (values[4]) {
      __pyx_v_fee_volume = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_fee_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 376, __pyx_L3_error)
    } else {
      __pyx_v_fee_volume = ((double)0.0);
    }
    if (values[5]) {
      __pyx_v_fee_currency = __pyx_convert_string_from_py_std__in_string(values[5]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 377, __pyx_L3_error)
    } else {
      __pyx_v_fee_currency = __pyx_k__2;
    }
    if (values[6]) {
      __pyx_v_fee_exec_duration = __Pyx_PyInt_As_long(values[6]); if (unlikely((__pyx_v_fee_exec_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 377, __pyx_L3_error)
    } else {
      __pyx_v_fee_exec_duration = ((long)0);
    }
    if (values[7]) {
      __pyx_v_processing_duration = __Pyx_PyInt_As_long(values[7]); if (unlikely((__pyx_v_processing_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 377, __pyx_L3_error)
    } else {
      __pyx_v_processing_duration = ((long)0);
    }
    if (values[8]) {
      __pyx_v_coverage = __pyx_convert_string_from_py_std__in_string(values[8]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L3_error)
    } else {
      __pyx_v_coverage = __pyx_k__3;
    }
    if (values[9]) {
      __pyx_v_instant_withdrawal = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_instant_withdrawal == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L3_error)
    } else {

      /* "trapeza/account/fx_account.pyx":378
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,             # <<<<<<<<<<<<<<
 *                    bool_t instant_float_fee=False) except -9999:
 *         """
 */
      __pyx_v_instant_withdrawal = ((bool)0);
    }
    if (values[10]) {
      __pyx_v_instant_float_fee = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_instant_float_fee == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 379, __pyx_L3_error)
    } else {

      /* "trapeza/account/fx_account.pyx":379
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,
 *                    bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.sell for further information.
 */
      __pyx_v_instant_float_fee = ((bool)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("c_sell", 0, 4, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 376, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_sell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_10c_sell(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_volume, __pyx_v_bid_price, __pyx_v_base, __pyx_v_quote, __pyx_v_fee_volume, __pyx_v_fee_currency, __pyx_v_fee_exec_duration, __pyx_v_processing_duration, __pyx_v_coverage, __pyx_v_instant_withdrawal, __pyx_v_instant_float_fee);

  /* "trapeza/account/fx_account.pyx":376
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_10c_sell(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, double __pyx_v_bid_price, std::string __pyx_v_base, std::string __pyx_v_quote, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, long __pyx_v_processing_duration, std::string __pyx_v_coverage, bool __pyx_v_instant_withdrawal, bool __pyx_v_instant_float_fee) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_sell __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_sell", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 7;
  __pyx_t_2.fee_volume = __pyx_v_fee_volume;
  __pyx_t_2.fee_currency = __pyx_v_fee_currency;
  __pyx_t_2.fee_exec_duration = __pyx_v_fee_exec_duration;
  __pyx_t_2.processing_duration = __pyx_v_processing_duration;
  __pyx_t_2.coverage = __pyx_v_coverage;
  __pyx_t_2.instant_withdrawal = __pyx_v_instant_withdrawal;
  __pyx_t_2.instant_float_fee = __pyx_v_instant_float_fee;
  __pyx_t_1 = __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount->c_sell(__pyx_v_self, __pyx_v_volume, __pyx_v_bid_price, __pyx_v_base, __pyx_v_quote, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((short)-9999))) __PYX_ERR(0, 376, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_sell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":479
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_13c_buy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_buy(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, double __pyx_v_ask_price, std::string __pyx_v_base, std::string __pyx_v_quote, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_buy *__pyx_optional_args) {
  double __pyx_v_fee_volume = ((double)0.0);
  std::string __pyx_v_fee_currency = __pyx_k__4;
  long __pyx_v_fee_exec_duration = ((long)0);
  long __pyx_v_processing_duration = ((long)0);
  std::string __pyx_v_coverage = __pyx_k__5;

  /* "trapeza/account/fx_account.pyx":481
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,             # <<<<<<<<<<<<<<
 *                       bool_t instant_float_fee=False) except -9999:
 *         """
 */
  bool __pyx_v_instant_withdrawal = ((bool)0);

  /* "trapeza/account/fx_account.pyx":482
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,
 *                       bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.buy for further information.
 */
  bool __pyx_v_instant_float_fee = ((bool)0);
  double __pyx_v_volume_quote;
  short __pyx_v_curr_check_marked_coverage;
  std::string __pyx_v_propagate_coverage;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  short __pyx_t_18;
  int __pyx_t_19;
  double __pyx_t_20;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage __pyx_t_21;
  std::string __pyx_t_22;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee __pyx_t_23;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_buy", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_fee_volume = __pyx_optional_args->fee_volume;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_fee_currency = __pyx_optional_args->fee_currency;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_fee_exec_duration = __pyx_optional_args->fee_exec_duration;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_processing_duration = __pyx_optional_args->processing_duration;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_coverage = __pyx_optional_args->coverage;
              if (__pyx_optional_args->__pyx_n > 5) {
                __pyx_v_instant_withdrawal = __pyx_optional_args->instant_withdrawal;
                if (__pyx_optional_args->__pyx_n > 6) {
                  __pyx_v_instant_float_fee = __pyx_optional_args->instant_float_fee;
                }
              }
            }
          }
        }
      }
    }
  }

  /* "trapeza/account/fx_account.pyx":479
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_buy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_13c_buy)) {
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyFloat_FromDouble(__pyx_v_ask_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_base); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_quote); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyFloat_FromDouble(__pyx_v_fee_volume); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_fee_currency); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyInt_From_long(__pyx_v_fee_exec_duration); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_v_processing_duration); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = __Pyx_PyBool_FromLong(__pyx_v_instant_withdrawal); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = __Pyx_PyBool_FromLong(__pyx_v_instant_float_fee); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_14 = __pyx_t_1; __pyx_t_15 = NULL;
        __pyx_t_16 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
          if (likely(__pyx_t_15)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_14, function);
            __pyx_t_16 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[12] = {__pyx_t_15, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_16, 11+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 479, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[12] = {__pyx_t_15, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_16, 11+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 479, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else
        #endif
        {
          __pyx_t_17 = PyTuple_New(11+__pyx_t_16); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 479, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__pyx_t_15) {
            __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_16, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_16, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_16, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_17, 3+__pyx_t_16, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_17, 4+__pyx_t_16, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_17, 5+__pyx_t_16, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_17, 6+__pyx_t_16, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_17, 7+__pyx_t_16, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_17, 8+__pyx_t_16, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_17, 9+__pyx_t_16, __pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_13);
          PyTuple_SET_ITEM(__pyx_t_17, 10+__pyx_t_16, __pyx_t_13);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_6 = 0;
          __pyx_t_7 = 0;
          __pyx_t_8 = 0;
          __pyx_t_9 = 0;
          __pyx_t_10 = 0;
          __pyx_t_11 = 0;
          __pyx_t_12 = 0;
          __pyx_t_13 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 479, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_18 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_18 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_18;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":507
 *         # easier to handle volume in quote currency.
 *         # >>>convert volume from base into quote
 *         cdef double volume_quote = c_precision_multiply(volume, ask_price)             # <<<<<<<<<<<<<<
 * 
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 */
  __pyx_v_volume_quote = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_multiply(__pyx_v_volume, __pyx_v_ask_price);

  /* "trapeza/account/fx_account.pyx":510
 * 
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             fee_currency = base
 * 
 */
  __pyx_t_19 = ((__pyx_v_fee_currency == ((char const *)"default")) != 0);
  if (__pyx_t_19) {

    /* "trapeza/account/fx_account.pyx":511
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':
 *             fee_currency = base             # <<<<<<<<<<<<<<
 * 
 *         # >>>store value for later restoring
 */
    __pyx_v_fee_currency = __pyx_v_base;

    /* "trapeza/account/fx_account.pyx":510
 * 
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             fee_currency = base
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":515
 *         # >>>store value for later restoring
 *         cdef short curr_check_marked_coverage
 *         curr_check_marked_coverage = self._c_check_marked_coverage             # <<<<<<<<<<<<<<
 *         # >>>get fulfillment method depending on account coverage and fee structure
 *         # volume is in quote currency
 */
  __pyx_t_18 = __pyx_v_self->_c_check_marked_coverage;
  __pyx_v_curr_check_marked_coverage = __pyx_t_18;

  /* "trapeza/account/fx_account.pyx":518
 *         # >>>get fulfillment method depending on account coverage and fee structure
 *         # volume is in quote currency
 *         if self._c_depot[quote] < c_precision_add(volume_quote, fee_volume * (fee_currency == quote)):             # <<<<<<<<<<<<<<
 *             if coverage == b'except':
 *                 raise tpz_exception.CoverageError(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)),
 */
  if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 518, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_quote); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume_quote, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_quote)))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (__pyx_t_19) {

    /* "trapeza/account/fx_account.pyx":519
 *         # volume is in quote currency
 *         if self._c_depot[quote] < c_precision_add(volume_quote, fee_volume * (fee_currency == quote)):
 *             if coverage == b'except':             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.CoverageError(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)),
 *                                                   quote.decode())
 */
    __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"except")) != 0);
    if (unlikely(__pyx_t_19)) {

      /* "trapeza/account/fx_account.pyx":520
 *         if self._c_depot[quote] < c_precision_add(volume_quote, fee_volume * (fee_currency == quote)):
 *             if coverage == b'except':
 *                 raise tpz_exception.CoverageError(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)),             # <<<<<<<<<<<<<<
 *                                                   quote.decode())
 *             elif coverage == b'partial':
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 520, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 520, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume_quote, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_quote)))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 520, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);

      /* "trapeza/account/fx_account.pyx":521
 *             if coverage == b'except':
 *                 raise tpz_exception.CoverageError(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)),
 *                                                   quote.decode())             # <<<<<<<<<<<<<<
 *             elif coverage == b'partial':
 *                 volume_quote = c_precision_subtract(self._c_depot[quote], fee_volume * (fee_currency == quote))  # in quote currency
 */
      __pyx_t_17 = __Pyx_decode_cpp_string(__pyx_v_quote, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 521, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_13 = NULL;
      __pyx_t_16 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_16 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_1, __pyx_t_17};
        __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 520, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_1, __pyx_t_17};
        __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 520, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 520, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_13) {
          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_16, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_17);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_16, __pyx_t_17);
        __pyx_t_1 = 0;
        __pyx_t_17 = 0;
        __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 520, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_14, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __PYX_ERR(0, 520, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":519
 *         # volume is in quote currency
 *         if self._c_depot[quote] < c_precision_add(volume_quote, fee_volume * (fee_currency == quote)):
 *             if coverage == b'except':             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.CoverageError(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)),
 *                                                   quote.decode())
 */
    }

    /* "trapeza/account/fx_account.pyx":522
 *                 raise tpz_exception.CoverageError(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)),
 *                                                   quote.decode())
 *             elif coverage == b'partial':             # <<<<<<<<<<<<<<
 *                 volume_quote = c_precision_subtract(self._c_depot[quote], fee_volume * (fee_currency == quote))  # in quote currency
 *                 if volume_quote < 0:
 */
    __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"partial")) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":523
 *                                                   quote.decode())
 *             elif coverage == b'partial':
 *                 volume_quote = c_precision_subtract(self._c_depot[quote], fee_volume * (fee_currency == quote))  # in quote currency             # <<<<<<<<<<<<<<
 *                 if volume_quote < 0:
 *                     raise tpz_exception.CoverageError(fee_volume, fee_currency.decode(),
 */
      if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 523, __pyx_L1_error)
      }
      __pyx_t_14 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_quote); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 523, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 523, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_20 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_20 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 523, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_volume_quote = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_subtract(__pyx_t_20, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_quote)));

      /* "trapeza/account/fx_account.pyx":524
 *             elif coverage == b'partial':
 *                 volume_quote = c_precision_subtract(self._c_depot[quote], fee_volume * (fee_currency == quote))  # in quote currency
 *                 if volume_quote < 0:             # <<<<<<<<<<<<<<
 *                     raise tpz_exception.CoverageError(fee_volume, fee_currency.decode(),
 *                                                      'Transaction not feasible even though coverage set '
 */
      __pyx_t_19 = ((__pyx_v_volume_quote < 0.0) != 0);
      if (unlikely(__pyx_t_19)) {

        /* "trapeza/account/fx_account.pyx":525
 *                 volume_quote = c_precision_subtract(self._c_depot[quote], fee_volume * (fee_currency == quote))  # in quote currency
 *                 if volume_quote < 0:
 *                     raise tpz_exception.CoverageError(fee_volume, fee_currency.decode(),             # <<<<<<<<<<<<<<
 *                                                      'Transaction not feasible even though coverage set '
 *                                                      'to partial. Fees not covered.')
 */
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 525, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 525, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = PyFloat_FromDouble(__pyx_v_fee_volume); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 525, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_17 = __Pyx_decode_cpp_string(__pyx_v_fee_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 525, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_1 = NULL;
        __pyx_t_16 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_12, function);
            __pyx_t_16 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_14, __pyx_t_17, __pyx_kp_u_Transaction_not_feasible_even_th};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_16, 3+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 525, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_14, __pyx_t_17, __pyx_kp_u_Transaction_not_feasible_even_th};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_16, 3+__pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 525, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(3+__pyx_t_16); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 525, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          if (__pyx_t_1) {
            __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); __pyx_t_1 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_14);
          PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_16, __pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_17);
          PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_16, __pyx_t_17);
          __Pyx_INCREF(__pyx_kp_u_Transaction_not_feasible_even_th);
          __Pyx_GIVEREF(__pyx_kp_u_Transaction_not_feasible_even_th);
          PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_16, __pyx_kp_u_Transaction_not_feasible_even_th);
          __pyx_t_14 = 0;
          __pyx_t_17 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 525, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(0, 525, __pyx_L1_error)

        /* "trapeza/account/fx_account.pyx":524
 *             elif coverage == b'partial':
 *                 volume_quote = c_precision_subtract(self._c_depot[quote], fee_volume * (fee_currency == quote))  # in quote currency
 *                 if volume_quote < 0:             # <<<<<<<<<<<<<<
 *                     raise tpz_exception.CoverageError(fee_volume, fee_currency.decode(),
 *                                                      'Transaction not feasible even though coverage set '
 */
      }

      /* "trapeza/account/fx_account.pyx":522
 *                 raise tpz_exception.CoverageError(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)),
 *                                                   quote.decode())
 *             elif coverage == b'partial':             # <<<<<<<<<<<<<<
 *                 volume_quote = c_precision_subtract(self._c_depot[quote], fee_volume * (fee_currency == quote))  # in quote currency
 *                 if volume_quote < 0:
 */
      goto __pyx_L5;
    }

    /* "trapeza/account/fx_account.pyx":528
 *                                                      'Transaction not feasible even though coverage set '
 *                                                      'to partial. Fees not covered.')
 *             elif coverage == b'ignore':             # <<<<<<<<<<<<<<
 *                 return -1
 *             elif coverage == b'debit':
 */
    __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"ignore")) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":529
 *                                                      'to partial. Fees not covered.')
 *             elif coverage == b'ignore':
 *                 return -1             # <<<<<<<<<<<<<<
 *             elif coverage == b'debit':
 *                 self._c_check_marked_coverage = 0
 */
      __pyx_r = -1;
      goto __pyx_L0;

      /* "trapeza/account/fx_account.pyx":528
 *                                                      'Transaction not feasible even though coverage set '
 *                                                      'to partial. Fees not covered.')
 *             elif coverage == b'ignore':             # <<<<<<<<<<<<<<
 *                 return -1
 *             elif coverage == b'debit':
 */
    }

    /* "trapeza/account/fx_account.pyx":530
 *             elif coverage == b'ignore':
 *                 return -1
 *             elif coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self._c_check_marked_coverage = 0
 * 
 */
    __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"debit")) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":531
 *                 return -1
 *             elif coverage == b'debit':
 *                 self._c_check_marked_coverage = 0             # <<<<<<<<<<<<<<
 * 
 *         # >>>check coverage before proceeding
 */
      __pyx_v_self->_c_check_marked_coverage = 0;

      /* "trapeza/account/fx_account.pyx":530
 *             elif coverage == b'ignore':
 *                 return -1
 *             elif coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self._c_check_marked_coverage = 0
 * 
 */
    }
    __pyx_L5:;

    /* "trapeza/account/fx_account.pyx":518
 *         # >>>get fulfillment method depending on account coverage and fee structure
 *         # volume is in quote currency
 *         if self._c_depot[quote] < c_precision_add(volume_quote, fee_volume * (fee_currency == quote)):             # <<<<<<<<<<<<<<
 *             if coverage == b'except':
 *                 raise tpz_exception.CoverageError(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)),
 */
  }

  /* "trapeza/account/fx_account.pyx":534
 * 
 *         # >>>check coverage before proceeding
 *         self._c_check_coverage(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)), quote,             # <<<<<<<<<<<<<<
 *                              self._c_clock + processing_duration * (1 - instant_withdrawal))
 *         if fee_volume > 0:
 */
  __pyx_t_20 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume_quote, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_quote))), __pyx_v_quote, (__pyx_v_self->_c_clock + (__pyx_v_processing_duration * (1 - __pyx_v_instant_withdrawal))), 0, NULL); if (unlikely(__pyx_t_20 == ((double)-1.0))) __PYX_ERR(0, 534, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":536
 *         self._c_check_coverage(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)), quote,
 *                              self._c_clock + processing_duration * (1 - instant_withdrawal))
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # if fee_volume is in quote (or generally speaking not in base),
 *             # we have to check that enough money is on depot
 */
  __pyx_t_19 = ((__pyx_v_fee_volume > 0.0) != 0);
  if (__pyx_t_19) {

    /* "trapeza/account/fx_account.pyx":539
 *             # if fee_volume is in quote (or generally speaking not in base),
 *             # we have to check that enough money is on depot
 *             if fee_currency != base:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
    __pyx_t_19 = ((__pyx_v_fee_currency != __pyx_v_base) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":540
 *             # we have to check that enough money is on depot
 *             if fee_currency != base:
 *                 self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             # if fee_volume is in base, we have to take processing times into account
 */
      __pyx_t_20 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, NULL); if (unlikely(__pyx_t_20 == ((double)-1.0))) __PYX_ERR(0, 540, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":539
 *             # if fee_volume is in quote (or generally speaking not in base),
 *             # we have to check that enough money is on depot
 *             if fee_currency != base:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
      goto __pyx_L8;
    }

    /* "trapeza/account/fx_account.pyx":548
 *             #       when checking coverage
 *             #   - fee before depositing: check that enough money in fee_currency is on depot
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
    __pyx_t_19 = (((__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee)) < __pyx_v_processing_duration) != 0);
    if (__pyx_t_19) {

      /* "trapeza/account/fx_account.pyx":549
 *             #   - fee before depositing: check that enough money in fee_currency is on depot
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:
 *                 self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             else:
 */
      __pyx_t_20 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, NULL); if (unlikely(__pyx_t_20 == ((double)-1.0))) __PYX_ERR(0, 549, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":548
 *             #       when checking coverage
 *             #   - fee before depositing: check that enough money in fee_currency is on depot
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
      goto __pyx_L8;
    }

    /* "trapeza/account/fx_account.pyx":552
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             else:
 *                 if self._c_isin_depot_quiet(fee_currency) == 0:             # <<<<<<<<<<<<<<
 *                     # this is done to prevent an exception if there is not yet an open position in fee_currency on
 *                     # account's depot (quote currency in particular)
 */
    /*else*/ {
      __pyx_t_18 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_isin_depot_quiet(__pyx_v_self, __pyx_v_fee_currency); if (unlikely(__pyx_t_18 == ((short)-1))) __PYX_ERR(0, 552, __pyx_L1_error)
      __pyx_t_19 = ((__pyx_t_18 == 0) != 0);
      if (__pyx_t_19) {

        /* "trapeza/account/fx_account.pyx":555
 *                     # this is done to prevent an exception if there is not yet an open position in fee_currency on
 *                     # account's depot (quote currency in particular)
 *                     self._c_depot[fee_currency] = 0             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee), volume)
 */
        if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 555, __pyx_L1_error)
        }
        __pyx_t_2 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_fee_currency); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 555, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (unlikely(PyDict_SetItem(__pyx_v_self->_c_depot, __pyx_t_2, __pyx_int_0) < 0)) __PYX_ERR(0, 555, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "trapeza/account/fx_account.pyx":552
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             else:
 *                 if self._c_isin_depot_quiet(fee_currency) == 0:             # <<<<<<<<<<<<<<
 *                     # this is done to prevent an exception if there is not yet an open position in fee_currency on
 *                     # account's depot (quote currency in particular)
 */
      }

      /* "trapeza/account/fx_account.pyx":556
 *                     # account's depot (quote currency in particular)
 *                     self._c_depot[fee_currency] = 0
 *                 self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee), volume)
 * 
 */
      __pyx_t_21.__pyx_n = 1;
      __pyx_t_21.virtual_deposit = __pyx_v_volume;
      __pyx_t_20 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, &__pyx_t_21); if (unlikely(__pyx_t_20 == ((double)-1.0))) __PYX_ERR(0, 556, __pyx_L1_error)
    }
    __pyx_L8:;

    /* "trapeza/account/fx_account.pyx":536
 *         self._c_check_coverage(c_precision_add(volume_quote, fee_volume * (fee_currency == quote)), quote,
 *                              self._c_clock + processing_duration * (1 - instant_withdrawal))
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # if fee_volume is in quote (or generally speaking not in base),
 *             # we have to check that enough money is on depot
 */
  }

  /* "trapeza/account/fx_account.pyx":560
 * 
 *         # >>>process transactions according to withdrawal execution duration
 *         self.c_withdraw(volume_quote, quote, processing_duration=processing_duration * (1 - instant_withdrawal),             # <<<<<<<<<<<<<<
 *                         coverage=coverage)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_withdraw); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_volume_quote); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_quote); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_13);
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_12 = __Pyx_PyInt_From_long((__pyx_v_processing_duration * (1 - __pyx_v_instant_withdrawal))); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_processing_duration, __pyx_t_12) < 0) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "trapeza/account/fx_account.pyx":561
 *         # >>>process transactions according to withdrawal execution duration
 *         self.c_withdraw(volume_quote, quote, processing_duration=processing_duration * (1 - instant_withdrawal),
 *                         coverage=coverage)             # <<<<<<<<<<<<<<
 * 
 *         # >>>deposit base currency
 */
  __pyx_t_12 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_coverage, __pyx_t_12) < 0) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "trapeza/account/fx_account.pyx":560
 * 
 *         # >>>process transactions according to withdrawal execution duration
 *         self.c_withdraw(volume_quote, quote, processing_duration=processing_duration * (1 - instant_withdrawal),             # <<<<<<<<<<<<<<
 *                         coverage=coverage)
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_17, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "trapeza/account/fx_account.pyx":564
 * 
 *         # >>>deposit base currency
 *         self.c_deposit(volume, base, processing_duration=processing_duration, coverage=coverage)             # <<<<<<<<<<<<<<
 * 
 *         # >>>handle fees
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_deposit); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_17 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_base); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_17);
  __pyx_t_13 = 0;
  __pyx_t_17 = 0;
  __pyx_t_17 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_13 = __Pyx_PyInt_From_long(__pyx_v_processing_duration); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_processing_duration, __pyx_t_13) < 0) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_coverage, __pyx_t_13) < 0) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_2, __pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "trapeza/account/fx_account.pyx":568
 *         # >>>handle fees
 *         cdef string propagate_coverage
 *         if coverage == b'partial':             # <<<<<<<<<<<<<<
 *             propagate_coverage = b'except'
 *         else:
 */
  __pyx_t_19 = ((__pyx_v_coverage == ((char const *)"partial")) != 0);
  if (__pyx_t_19) {

    /* "trapeza/account/fx_account.pyx":569
 *         cdef string propagate_coverage
 *         if coverage == b'partial':
 *             propagate_coverage = b'except'             # <<<<<<<<<<<<<<
 *         else:
 *             propagate_coverage = coverage
 */
    __pyx_t_22 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 569, __pyx_L1_error)
    __pyx_v_propagate_coverage = __pyx_t_22;

    /* "trapeza/account/fx_account.pyx":568
 *         # >>>handle fees
 *         cdef string propagate_coverage
 *         if coverage == b'partial':             # <<<<<<<<<<<<<<
 *             propagate_coverage = b'except'
 *         else:
 */
    goto __pyx_L10;
  }

  /* "trapeza/account/fx_account.pyx":571
 *             propagate_coverage = b'except'
 *         else:
 *             propagate_coverage = coverage             # <<<<<<<<<<<<<<
 *         self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,
 *                          fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 */
  /*else*/ {
    __pyx_v_propagate_coverage = __pyx_v_coverage;
  }
  __pyx_L10:;

  /* "trapeza/account/fx_account.pyx":572
 *         else:
 *             propagate_coverage = coverage
 *         self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,             # <<<<<<<<<<<<<<
 *                          fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 *                          forward_coverage=propagate_coverage)
 */
  __pyx_t_23.__pyx_n = 1;
  __pyx_t_23.forward_coverage = __pyx_v_propagate_coverage;
  __pyx_t_18 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_fill_fee(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee)), &__pyx_t_23); if (unlikely(__pyx_t_18 == ((short)-1))) __PYX_ERR(0, 572, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":577
 * 
 *         # >>>restore
 *         self._c_check_marked_coverage = curr_check_marked_coverage             # <<<<<<<<<<<<<<
 * 
 *         # >>> return confirmation
 */
  __pyx_v_self->_c_check_marked_coverage = __pyx_v_curr_check_marked_coverage;

  /* "trapeza/account/fx_account.pyx":580
 * 
 *         # >>> return confirmation
 *         return self._c_confirmation(processing_duration)             # <<<<<<<<<<<<<<
 * 
 *     # noinspection DuplicatedCode
 */
  __pyx_t_18 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_confirmation(__pyx_v_self, __pyx_v_processing_duration); if (unlikely(__pyx_t_18 == ((short)-1))) __PYX_ERR(0, 580, __pyx_L1_error)
  __pyx_r = __pyx_t_18;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":479
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_buy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -9999;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_13c_buy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_12c_buy[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.buy for further information.\n        \n        :param volume: double, in BASE currency\n        :param ask_price: double, current ask rate (base|quote notation)\n        :param base: std:string, currency\n        :param quote: std:string, currency\n        :param fee_volume: double, volume in param:fee_currency\n        :param fee_currency: std:string, if b'default', then param:fee_currency defaults to param:base\n        :param fee_exec_duration: long, processing time (delay) in time base units of internal clock\n        :param processing_duration: long, processing time (delay) in time base units of internal clock\n        :param coverage: std:string {b'partial', b'except', b'ignore', b'debit'},\n                         default=b'except'\n                         see FXAccount.buy for details\n        :param instant_withdrawal: std:bool, \n                                   see FXAccount.buy for details\n        :param instant_float_fee: std:bool, \n                                  see FXAccount.buy for details\n        :return: confirmation: short,\n                               confirmation states --> -1: ignored, 0: processing (processing_duration), 1: executed\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_13c_buy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_volume;
  double __pyx_v_ask_price;
  std::string __pyx_v_base;
  std::string __pyx_v_quote;
  double __pyx_v_fee_volume;
  std::string __pyx_v_fee_currency;
  long __pyx_v_fee_exec_duration;
  long __pyx_v_processing_duration;
  std::string __pyx_v_coverage;
  bool __pyx_v_instant_withdrawal;
  bool __pyx_v_instant_float_fee;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_buy (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_volume,&__pyx_n_s_ask_price,&__pyx_n_s_base,&__pyx_n_s_quote,&__pyx_n_s_fee_volume,&__pyx_n_s_fee_currency,&__pyx_n_s_fee_exec_duration,&__pyx_n_s_processing_duration,&__pyx_n_s_coverage,&__pyx_n_s_instant_withdrawal,&__pyx_n_s_instant_float_fee,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ask_price)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_buy", 0, 4, 11, 1); __PYX_ERR(0, 479, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_buy", 0, 4, 11, 2); __PYX_ERR(0, 479, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quote)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_buy", 0, 4, 11, 3); __PYX_ERR(0, 479, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_volume);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_currency);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_exec_duration);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coverage);
          if (value) { values[8] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_withdrawal);
          if (value) { values[9] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_float_fee);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "c_buy") < 0)) __PYX_ERR(0, 479, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 479, __pyx_L3_error)
    __pyx_v_ask_price = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_ask_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 479, __pyx_L3_error)
    __pyx_v_base = __pyx_convert_string_from_py_std__in_string(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 479, __pyx_L3_error)
    __pyx_v_quote = __pyx_convert_string_from_py_std__in_string(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 479, __pyx_L3_error)
    if (values[4]) {
      __pyx_v_fee_volume = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_fee_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 479, __pyx_L3_error)
    } else {
      __pyx_v_fee_volume = ((double)0.0);
    }
    if (values[5]) {
      __pyx_v_fee_currency = __pyx_convert_string_from_py_std__in_string(values[5]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 480, __pyx_L3_error)
    } else {
      __pyx_v_fee_currency = __pyx_k__4;
    }
    if (values[6]) {
      __pyx_v_fee_exec_duration = __Pyx_PyInt_As_long(values[6]); if (unlikely((__pyx_v_fee_exec_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 480, __pyx_L3_error)
    } else {
      __pyx_v_fee_exec_duration = ((long)0);
    }
    if (values[7]) {
      __pyx_v_processing_duration = __Pyx_PyInt_As_long(values[7]); if (unlikely((__pyx_v_processing_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 480, __pyx_L3_error)
    } else {
      __pyx_v_processing_duration = ((long)0);
    }
    if (values[8]) {
      __pyx_v_coverage = __pyx_convert_string_from_py_std__in_string(values[8]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 481, __pyx_L3_error)
    } else {
      __pyx_v_coverage = __pyx_k__5;
    }
    if (values[9]) {
      __pyx_v_instant_withdrawal = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_instant_withdrawal == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 481, __pyx_L3_error)
    } else {

      /* "trapeza/account/fx_account.pyx":481
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,             # <<<<<<<<<<<<<<
 *                       bool_t instant_float_fee=False) except -9999:
 *         """
 */
      __pyx_v_instant_withdrawal = ((bool)0);
    }
    if (values[10]) {
      __pyx_v_instant_float_fee = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_instant_float_fee == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 482, __pyx_L3_error)
    } else {

      /* "trapeza/account/fx_account.pyx":482
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,
 *                       bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.buy for further information.
 */
      __pyx_v_instant_float_fee = ((bool)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("c_buy", 0, 4, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 479, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_buy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_12c_buy(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_volume, __pyx_v_ask_price, __pyx_v_base, __pyx_v_quote, __pyx_v_fee_volume, __pyx_v_fee_currency, __pyx_v_fee_exec_duration, __pyx_v_processing_duration, __pyx_v_coverage, __pyx_v_instant_withdrawal, __pyx_v_instant_float_fee);

  /* "trapeza/account/fx_account.pyx":479
 *     # noinspection DuplicatedCode,PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_12c_buy(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, double __pyx_v_ask_price, std::string __pyx_v_base, std::string __pyx_v_quote, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, long __pyx_v_processing_duration, std::string __pyx_v_coverage, bool __pyx_v_instant_withdrawal, bool __pyx_v_instant_float_fee) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_buy __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_buy", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 7;
  __pyx_t_2.fee_volume = __pyx_v_fee_volume;
  __pyx_t_2.fee_currency = __pyx_v_fee_currency;
  __pyx_t_2.fee_exec_duration = __pyx_v_fee_exec_duration;
  __pyx_t_2.processing_duration = __pyx_v_processing_duration;
  __pyx_t_2.coverage = __pyx_v_coverage;
  __pyx_t_2.instant_withdrawal = __pyx_v_instant_withdrawal;
  __pyx_t_2.instant_float_fee = __pyx_v_instant_float_fee;
  __pyx_t_1 = __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount->c_buy(__pyx_v_self, __pyx_v_volume, __pyx_v_ask_price, __pyx_v_base, __pyx_v_quote, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((short)-9999))) __PYX_ERR(0, 479, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_buy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":584
 *     # noinspection DuplicatedCode
 *     @cython.wraparound(False)
 *     cpdef short c_transfer(self, double volume, string currency,             # <<<<<<<<<<<<<<
 *                          double payer_fee_volume=0, string payer_fee_currency=b'default',
 *                          long payer_fee_exec_duration=0, long payer_processing_duration=0) except -9999:
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_15c_transfer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_transfer(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_transfer *__pyx_optional_args) {
  double __pyx_v_payer_fee_volume = ((double)0.0);
  std::string __pyx_v_payer_fee_currency = __pyx_k__6;
  long __pyx_v_payer_fee_exec_duration = ((long)0);
  long __pyx_v_payer_processing_duration = ((long)0);
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  short __pyx_t_13;
  int __pyx_t_14;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_transfer", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_payer_fee_volume = __pyx_optional_args->payer_fee_volume;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_payer_fee_currency = __pyx_optional_args->payer_fee_currency;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_payer_fee_exec_duration = __pyx_optional_args->payer_fee_exec_duration;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_payer_processing_duration = __pyx_optional_args->payer_processing_duration;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_transfer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 584, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_15c_transfer)) {
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 584, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 584, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyFloat_FromDouble(__pyx_v_payer_fee_volume); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 584, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_payer_fee_currency); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 584, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_payer_fee_exec_duration); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 584, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_payer_processing_duration); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 584, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_9 = __pyx_t_1; __pyx_t_10 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
            __pyx_t_11 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[7] = {__pyx_t_10, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 6+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 584, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[7] = {__pyx_t_10, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 6+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 584, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(6+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 584, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_12, 5+__pyx_t_11, __pyx_t_8);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_6 = 0;
          __pyx_t_7 = 0;
          __pyx_t_8 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 584, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_13 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_13 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_13;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":600
 *         :return: confirmation: short, confirmation states --> 0: processing (processing_duration), 1: executed
 *         """
 *         if payer_fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             payer_fee_currency = currency
 * 
 */
  __pyx_t_14 = ((__pyx_v_payer_fee_currency == ((char const *)"default")) != 0);
  if (__pyx_t_14) {

    /* "trapeza/account/fx_account.pyx":601
 *         """
 *         if payer_fee_currency == b'default':
 *             payer_fee_currency = currency             # <<<<<<<<<<<<<<
 * 
 *         # >>>withdraw from own account
 */
    __pyx_v_payer_fee_currency = __pyx_v_currency;

    /* "trapeza/account/fx_account.pyx":600
 *         :return: confirmation: short, confirmation states --> 0: processing (processing_duration), 1: executed
 *         """
 *         if payer_fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             payer_fee_currency = currency
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":604
 * 
 *         # >>>withdraw from own account
 *         self.c_withdraw(volume, currency, payer_processing_duration, payer_fee_volume, payer_fee_currency,             # <<<<<<<<<<<<<<
 *                         payer_fee_exec_duration)
 * 
 */
  __pyx_t_15.__pyx_n = 4;
  __pyx_t_15.processing_duration = __pyx_v_payer_processing_duration;
  __pyx_t_15.fee_volume = __pyx_v_payer_fee_volume;
  __pyx_t_15.fee_currency = __pyx_v_payer_fee_currency;
  __pyx_t_15.fee_exec_duration = __pyx_v_payer_fee_exec_duration;
  __pyx_t_13 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->c_withdraw(__pyx_v_self, __pyx_v_volume, __pyx_v_currency, 0, &__pyx_t_15); if (unlikely(__pyx_t_13 == ((short)-9999))) __PYX_ERR(0, 604, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":607
 *                         payer_fee_exec_duration)
 * 
 *         return self._c_confirmation(payer_processing_duration)             # <<<<<<<<<<<<<<
 * 
 *     # noinspection DuplicatedCode
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_confirmation(__pyx_v_self, __pyx_v_payer_processing_duration); if (unlikely(__pyx_t_13 == ((short)-1))) __PYX_ERR(0, 607, __pyx_L1_error)
  __pyx_r = __pyx_t_13;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":584
 *     # noinspection DuplicatedCode
 *     @cython.wraparound(False)
 *     cpdef short c_transfer(self, double volume, string currency,             # <<<<<<<<<<<<<<
 *                          double payer_fee_volume=0, string payer_fee_currency=b'default',
 *                          long payer_fee_exec_duration=0, long payer_processing_duration=0) except -9999:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -9999;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_15c_transfer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_14c_transfer[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.transfer for further information.\n        \n        Same coverage as self.c_withdraw will be used (default=b'except').\n        \n        :param volume: double, volume in param:currency\n        :param currency: std:string\n        :param payer_fee_volume: double, volume in param:payer_fee_currency\n        :param payer_fee_currency: std:string, if b'default' then param:payer_fee_currency is used\n        :param payer_fee_exec_duration: long, processing time (delay) in time base units of internal clock\n        :param payer_processing_duration: long, processing time (delay) in time base units of internal clock\n        :return: confirmation: short, confirmation states --> 0: processing (processing_duration), 1: executed\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_15c_transfer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_volume;
  std::string __pyx_v_currency;
  double __pyx_v_payer_fee_volume;
  std::string __pyx_v_payer_fee_currency;
  long __pyx_v_payer_fee_exec_duration;
  long __pyx_v_payer_processing_duration;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_transfer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_volume,&__pyx_n_s_currency,&__pyx_n_s_payer_fee_volume,&__pyx_n_s_payer_fee_currency,&__pyx_n_s_payer_fee_exec_duration,&__pyx_n_s_payer_processing_duration,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_transfer", 0, 2, 6, 1); __PYX_ERR(0, 584, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payer_fee_volume);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payer_fee_currency);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payer_fee_exec_duration);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payer_processing_duration);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "c_transfer") < 0)) __PYX_ERR(0, 584, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L3_error)
    __pyx_v_currency = __pyx_convert_string_from_py_std__in_string(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_payer_fee_volume = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_payer_fee_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 585, __pyx_L3_error)
    } else {
      __pyx_v_payer_fee_volume = ((double)0.0);
    }
    if (values[3]) {
      __pyx_v_payer_fee_currency = __pyx_convert_string_from_py_std__in_string(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 585, __pyx_L3_error)
    } else {
      __pyx_v_payer_fee_currency = __pyx_k__6;
    }
    if (values[4]) {
      __pyx_v_payer_fee_exec_duration = __Pyx_PyInt_As_long(values[4]); if (unlikely((__pyx_v_payer_fee_exec_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 586, __pyx_L3_error)
    } else {
      __pyx_v_payer_fee_exec_duration = ((long)0);
    }
    if (values[5]) {
      __pyx_v_payer_processing_duration = __Pyx_PyInt_As_long(values[5]); if (unlikely((__pyx_v_payer_processing_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 586, __pyx_L3_error)
    } else {
      __pyx_v_payer_processing_duration = ((long)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("c_transfer", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 584, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_14c_transfer(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_volume, __pyx_v_currency, __pyx_v_payer_fee_volume, __pyx_v_payer_fee_currency, __pyx_v_payer_fee_exec_duration, __pyx_v_payer_processing_duration);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_14c_transfer(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, double __pyx_v_payer_fee_volume, std::string __pyx_v_payer_fee_currency, long __pyx_v_payer_fee_exec_duration, long __pyx_v_payer_processing_duration) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_transfer __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_transfer", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.payer_fee_volume = __pyx_v_payer_fee_volume;
  __pyx_t_2.payer_fee_currency = __pyx_v_payer_fee_currency;
  __pyx_t_2.payer_fee_exec_duration = __pyx_v_payer_fee_exec_duration;
  __pyx_t_2.payer_processing_duration = __pyx_v_payer_processing_duration;
  __pyx_t_1 = __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount->c_transfer(__pyx_v_self, __pyx_v_volume, __pyx_v_currency, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((short)-9999))) __PYX_ERR(0, 584, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":611
 *     # noinspection DuplicatedCode
 *     @cython.wraparound(False)
 *     cpdef short c_collect(self, double volume, string currency,             # <<<<<<<<<<<<<<
 *                         double payee_fee_volume=0, string payee_fee_currency=b'default', long payee_fee_exec_duration=0,
 *                         long payee_processing_duration=0) except -9999:
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17c_collect(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_collect(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_collect *__pyx_optional_args) {
  double __pyx_v_payee_fee_volume = ((double)0.0);
  std::string __pyx_v_payee_fee_currency = __pyx_k__7;
  long __pyx_v_payee_fee_exec_duration = ((long)0);
  long __pyx_v_payee_processing_duration = ((long)0);
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  short __pyx_t_13;
  int __pyx_t_14;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_deposit __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_collect", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_payee_fee_volume = __pyx_optional_args->payee_fee_volume;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_payee_fee_currency = __pyx_optional_args->payee_fee_currency;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_payee_fee_exec_duration = __pyx_optional_args->payee_fee_exec_duration;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_payee_processing_duration = __pyx_optional_args->payee_processing_duration;
          }
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_collect); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17c_collect)) {
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyFloat_FromDouble(__pyx_v_payee_fee_volume); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_payee_fee_currency); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_payee_fee_exec_duration); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_payee_processing_duration); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 611, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_9 = __pyx_t_1; __pyx_t_10 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
            __pyx_t_11 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[7] = {__pyx_t_10, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 6+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[7] = {__pyx_t_10, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 6+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(6+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_12, 5+__pyx_t_11, __pyx_t_8);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_6 = 0;
          __pyx_t_7 = 0;
          __pyx_t_8 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_13 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_13 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 611, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_13;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":628
 *         """
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if payee_fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             payee_fee_currency = currency
 * 
 */
  __pyx_t_14 = ((__pyx_v_payee_fee_currency == ((char const *)"default")) != 0);
  if (__pyx_t_14) {

    /* "trapeza/account/fx_account.pyx":629
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if payee_fee_currency == b'default':
 *             payee_fee_currency = currency             # <<<<<<<<<<<<<<
 * 
 *         # >>>deposit at own account
 */
    __pyx_v_payee_fee_currency = __pyx_v_currency;

    /* "trapeza/account/fx_account.pyx":628
 *         """
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if payee_fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             payee_fee_currency = currency
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":632
 * 
 *         # >>>deposit at own account
 *         self.c_deposit(volume, currency, payee_processing_duration, payee_fee_volume, payee_fee_currency,             # <<<<<<<<<<<<<<
 *                        payee_fee_exec_duration)
 * 
 */
  __pyx_t_15.__pyx_n = 3;
  __pyx_t_15.fee_volume = __pyx_v_payee_fee_volume;
  __pyx_t_15.fee_currency = __pyx_v_payee_fee_currency;
  __pyx_t_15.fee_exec_duration = __pyx_v_payee_fee_exec_duration;
  __pyx_t_13 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->c_deposit(__pyx_v_self, __pyx_v_volume, __pyx_v_currency, __pyx_v_payee_processing_duration, 0, &__pyx_t_15); if (unlikely(__pyx_t_13 == ((short)-9999))) __PYX_ERR(0, 632, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":635
 *                        payee_fee_exec_duration)
 * 
 *         return self._c_confirmation(payee_processing_duration)             # <<<<<<<<<<<<<<
 * 
 *     # noinspection PyUnresolvedReferences
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_confirmation(__pyx_v_self, __pyx_v_payee_processing_duration); if (unlikely(__pyx_t_13 == ((short)-1))) __PYX_ERR(0, 635, __pyx_L1_error)
  __pyx_r = __pyx_t_13;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":611
 *     # noinspection DuplicatedCode
 *     @cython.wraparound(False)
 *     cpdef short c_collect(self, double volume, string currency,             # <<<<<<<<<<<<<<
 *                         double payee_fee_volume=0, string payee_fee_currency=b'default', long payee_fee_exec_duration=0,
 *                         long payee_processing_duration=0) except -9999:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -9999;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17c_collect(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_16c_collect[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.collect for further information.\n        \n        Same coverage as self.c_deposit will be used (default=b'except').\n        \n        :param volume: double, volume in param:currency\n        :param currency: std:string\n        :param payee_fee_volume: double, volume in param:payee_fee_currency\n        :param payee_fee_currency: std:string, if b'default' then param:payee_fee_currency is used\n        :param payee_fee_exec_duration: long, processing time (delay) in time base units of internal clock\n        :param payee_processing_duration: long, processing time (delay) in time base units of internal clock\n        :return: confirmation: short, confirmation states --> 0: processing (processing_duration), 1: executed\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17c_collect(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_volume;
  std::string __pyx_v_currency;
  double __pyx_v_payee_fee_volume;
  std::string __pyx_v_payee_fee_currency;
  long __pyx_v_payee_fee_exec_duration;
  long __pyx_v_payee_processing_duration;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_collect (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_volume,&__pyx_n_s_currency,&__pyx_n_s_payee_fee_volume,&__pyx_n_s_payee_fee_currency,&__pyx_n_s_payee_fee_exec_duration,&__pyx_n_s_payee_processing_duration,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_collect", 0, 2, 6, 1); __PYX_ERR(0, 611, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payee_fee_volume);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payee_fee_currency);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payee_fee_exec_duration);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payee_processing_duration);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "c_collect") < 0)) __PYX_ERR(0, 611, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 611, __pyx_L3_error)
    __pyx_v_currency = __pyx_convert_string_from_py_std__in_string(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 611, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_payee_fee_volume = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_payee_fee_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 612, __pyx_L3_error)
    } else {
      __pyx_v_payee_fee_volume = ((double)0.0);
    }
    if (values[3]) {
      __pyx_v_payee_fee_currency = __pyx_convert_string_from_py_std__in_string(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 612, __pyx_L3_error)
    } else {
      __pyx_v_payee_fee_currency = __pyx_k__7;
    }
    if (values[4]) {
      __pyx_v_payee_fee_exec_duration = __Pyx_PyInt_As_long(values[4]); if (unlikely((__pyx_v_payee_fee_exec_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 612, __pyx_L3_error)
    } else {
      __pyx_v_payee_fee_exec_duration = ((long)0);
    }
    if (values[5]) {
      __pyx_v_payee_processing_duration = __Pyx_PyInt_As_long(values[5]); if (unlikely((__pyx_v_payee_processing_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 613, __pyx_L3_error)
    } else {
      __pyx_v_payee_processing_duration = ((long)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("c_collect", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 611, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_16c_collect(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_volume, __pyx_v_currency, __pyx_v_payee_fee_volume, __pyx_v_payee_fee_currency, __pyx_v_payee_fee_exec_duration, __pyx_v_payee_processing_duration);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_16c_collect(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, double __pyx_v_payee_fee_volume, std::string __pyx_v_payee_fee_currency, long __pyx_v_payee_fee_exec_duration, long __pyx_v_payee_processing_duration) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_collect __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_collect", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 4;
  __pyx_t_2.payee_fee_volume = __pyx_v_payee_fee_volume;
  __pyx_t_2.payee_fee_currency = __pyx_v_payee_fee_currency;
  __pyx_t_2.payee_fee_exec_duration = __pyx_v_payee_fee_exec_duration;
  __pyx_t_2.payee_processing_duration = __pyx_v_payee_processing_duration;
  __pyx_t_1 = __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount->c_collect(__pyx_v_self, __pyx_v_volume, __pyx_v_currency, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((short)-9999))) __PYX_ERR(0, 611, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 611, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":639
 *     # noinspection PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                         string fee_currency=b'default', long fee_exec_duration=0,
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_19c_deposit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_deposit(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, long __pyx_v_processing_duration, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_deposit *__pyx_optional_args) {
  double __pyx_v_fee_volume = ((double)0.0);
  std::string __pyx_v_fee_currency = __pyx_k__8;
  long __pyx_v_fee_exec_duration = ((long)0);
  std::string __pyx_v_coverage = __pyx_k__9;

  /* "trapeza/account/fx_account.pyx":641
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,
 *                         string fee_currency=b'default', long fee_exec_duration=0,
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.deposit for further information.
 */
  bool __pyx_v_instant_float_fee = ((bool)0);
  short __pyx_v_curr_check_marked_coverage;
  double __pyx_v_current_depot_fee_currency;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  short __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  double __pyx_t_18;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  std::string __pyx_t_23;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee __pyx_t_24;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_deposit", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_fee_volume = __pyx_optional_args->fee_volume;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_fee_currency = __pyx_optional_args->fee_currency;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_fee_exec_duration = __pyx_optional_args->fee_exec_duration;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_coverage = __pyx_optional_args->coverage;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_instant_float_fee = __pyx_optional_args->instant_float_fee;
            }
          }
        }
      }
    }
  }

  /* "trapeza/account/fx_account.pyx":639
 *     # noinspection PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                         string fee_currency=b'default', long fee_exec_duration=0,
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_deposit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_19c_deposit)) {
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_processing_duration); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = PyFloat_FromDouble(__pyx_v_fee_volume); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_fee_currency); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_fee_exec_duration); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = __Pyx_PyBool_FromLong(__pyx_v_instant_float_fee); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_11 = __pyx_t_1; __pyx_t_12 = NULL;
        __pyx_t_13 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_11, function);
            __pyx_t_13 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[9] = {__pyx_t_12, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_13, 8+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 639, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[9] = {__pyx_t_12, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_13, 8+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 639, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        {
          __pyx_t_14 = PyTuple_New(8+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 639, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          if (__pyx_t_12) {
            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_13, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_13, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_13, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_14, 5+__pyx_t_13, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_14, 6+__pyx_t_13, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_14, 7+__pyx_t_13, __pyx_t_10);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_6 = 0;
          __pyx_t_7 = 0;
          __pyx_t_8 = 0;
          __pyx_t_9 = 0;
          __pyx_t_10 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 639, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_15 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_15 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_15;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":664
 *         """
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             fee_currency = currency
 * 
 */
  __pyx_t_16 = ((__pyx_v_fee_currency == ((char const *)"default")) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":665
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':
 *             fee_currency = currency             # <<<<<<<<<<<<<<
 * 
 *         # >>>store value for later restoring
 */
    __pyx_v_fee_currency = __pyx_v_currency;

    /* "trapeza/account/fx_account.pyx":664
 *         """
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             fee_currency = currency
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":670
 *         cdef short curr_check_marked_coverage
 *         cdef double remaining_fees
 *         cdef double current_depot_fee_currency = 0             # <<<<<<<<<<<<<<
 *         curr_check_marked_coverage = self._c_check_marked_coverage
 * 
 */
  __pyx_v_current_depot_fee_currency = 0.0;

  /* "trapeza/account/fx_account.pyx":671
 *         cdef double remaining_fees
 *         cdef double current_depot_fee_currency = 0
 *         curr_check_marked_coverage = self._c_check_marked_coverage             # <<<<<<<<<<<<<<
 * 
 *         # >>>prevent KeyError if fee_currency is in currency as fees can be offset by incoming depositing volume
 */
  __pyx_t_15 = __pyx_v_self->_c_check_marked_coverage;
  __pyx_v_curr_check_marked_coverage = __pyx_t_15;

  /* "trapeza/account/fx_account.pyx":674
 * 
 *         # >>>prevent KeyError if fee_currency is in currency as fees can be offset by incoming depositing volume
 *         if currency == fee_currency and self._c_isin_depot_quiet(fee_currency) == 0:             # <<<<<<<<<<<<<<
 *             current_depot_fee_currency = 0
 *         else:
 */
  __pyx_t_17 = ((__pyx_v_currency == __pyx_v_fee_currency) != 0);
  if (__pyx_t_17) {
  } else {
    __pyx_t_16 = __pyx_t_17;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_isin_depot_quiet(__pyx_v_self, __pyx_v_fee_currency); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 674, __pyx_L1_error)
  __pyx_t_17 = ((__pyx_t_15 == 0) != 0);
  __pyx_t_16 = __pyx_t_17;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":675
 *         # >>>prevent KeyError if fee_currency is in currency as fees can be offset by incoming depositing volume
 *         if currency == fee_currency and self._c_isin_depot_quiet(fee_currency) == 0:
 *             current_depot_fee_currency = 0             # <<<<<<<<<<<<<<
 *         else:
 *             self._c_isin_depot(fee_currency)
 */
    __pyx_v_current_depot_fee_currency = 0.0;

    /* "trapeza/account/fx_account.pyx":674
 * 
 *         # >>>prevent KeyError if fee_currency is in currency as fees can be offset by incoming depositing volume
 *         if currency == fee_currency and self._c_isin_depot_quiet(fee_currency) == 0:             # <<<<<<<<<<<<<<
 *             current_depot_fee_currency = 0
 *         else:
 */
    goto __pyx_L4;
  }

  /* "trapeza/account/fx_account.pyx":677
 *             current_depot_fee_currency = 0
 *         else:
 *             self._c_isin_depot(fee_currency)             # <<<<<<<<<<<<<<
 *             current_depot_fee_currency = self._c_depot[fee_currency]
 * 
 */
  /*else*/ {
    __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_isin_depot(__pyx_v_self, __pyx_v_fee_currency, 0); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 677, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":678
 *         else:
 *             self._c_isin_depot(fee_currency)
 *             current_depot_fee_currency = self._c_depot[fee_currency]             # <<<<<<<<<<<<<<
 * 
 *         # when depositing, the only transaction, which might cause coverage violation, is the withdrawal of fees
 */
    if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 678, __pyx_L1_error)
    }
    __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_fee_currency); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 678, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 678, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_18 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_18 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 678, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_current_depot_fee_currency = __pyx_t_18;
  }
  __pyx_L4:;

  /* "trapeza/account/fx_account.pyx":693
 *         # >>>handle coverage exception induced by fees
 *         # fee coverage is checked at code block below, so we just have to set debiting mode if necessary
 *         if (fee_volume > 0 and coverage == b'except'             # <<<<<<<<<<<<<<
 *                 and current_depot_fee_currency + (volume * (currency==fee_currency)) < fee_volume):
 *             # this is rather a weak check as processing times of depositing and fee billing might cause
 */
  __pyx_t_17 = ((__pyx_v_fee_volume > 0.0) != 0);
  if (__pyx_t_17) {
  } else {
    __pyx_t_16 = __pyx_t_17;
    goto __pyx_L8_bool_binop_done;
  }

  /* "trapeza/account/fx_account.pyx":694
 *         # fee coverage is checked at code block below, so we just have to set debiting mode if necessary
 *         if (fee_volume > 0 and coverage == b'except'
 *                 and current_depot_fee_currency + (volume * (currency==fee_currency)) < fee_volume):             # <<<<<<<<<<<<<<
 *             # this is rather a weak check as processing times of depositing and fee billing might cause
 *             #   coverage violation
 */
  __pyx_t_17 = ((__pyx_v_coverage == ((char const *)"except")) != 0);
  if (__pyx_t_17) {
  } else {
    __pyx_t_16 = __pyx_t_17;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_17 = (((__pyx_v_current_depot_fee_currency + (__pyx_v_volume * (__pyx_v_currency == __pyx_v_fee_currency))) < __pyx_v_fee_volume) != 0);
  __pyx_t_16 = __pyx_t_17;
  __pyx_L8_bool_binop_done:;

  /* "trapeza/account/fx_account.pyx":693
 *         # >>>handle coverage exception induced by fees
 *         # fee coverage is checked at code block below, so we just have to set debiting mode if necessary
 *         if (fee_volume > 0 and coverage == b'except'             # <<<<<<<<<<<<<<
 *                 and current_depot_fee_currency + (volume * (currency==fee_currency)) < fee_volume):
 *             # this is rather a weak check as processing times of depositing and fee billing might cause
 */
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":700
 *             #   volume. Taking processing times into account is done later on, so we stick to this weaker check here
 *             # we do a re-check with precision arithmetics to avoid error caused by floating point errors
 *             if c_precision_add(current_depot_fee_currency, volume * (currency==fee_currency)) < fee_volume:             # <<<<<<<<<<<<<<
 *                 # multiplication is either with 1 or 0 so need for precision
 *                 if self._c_is_heap:
 */
    __pyx_t_16 = ((__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_current_depot_fee_currency, (__pyx_v_volume * (__pyx_v_currency == __pyx_v_fee_currency))) < __pyx_v_fee_volume) != 0);
    if (__pyx_t_16) {

      /* "trapeza/account/fx_account.pyx":702
 *             if c_precision_add(current_depot_fee_currency, volume * (currency==fee_currency)) < fee_volume:
 *                 # multiplication is either with 1 or 0 so need for precision
 *                 if self._c_is_heap:             # <<<<<<<<<<<<<<
 *                     self._c_issue_corruption_warning()
 *                 raise tpz_exception.CoverageError(fee_volume, currency.decode())
 */
      __pyx_t_16 = (__pyx_v_self->_c_is_heap != 0);
      if (__pyx_t_16) {

        /* "trapeza/account/fx_account.pyx":703
 *                 # multiplication is either with 1 or 0 so need for precision
 *                 if self._c_is_heap:
 *                     self._c_issue_corruption_warning()             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.CoverageError(fee_volume, currency.decode())
 *         elif coverage == b'debit':
 */
        __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_issue_corruption_warning(__pyx_v_self); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 703, __pyx_L1_error)

        /* "trapeza/account/fx_account.pyx":702
 *             if c_precision_add(current_depot_fee_currency, volume * (currency==fee_currency)) < fee_volume:
 *                 # multiplication is either with 1 or 0 so need for precision
 *                 if self._c_is_heap:             # <<<<<<<<<<<<<<
 *                     self._c_issue_corruption_warning()
 *                 raise tpz_exception.CoverageError(fee_volume, currency.decode())
 */
      }

      /* "trapeza/account/fx_account.pyx":704
 *                 if self._c_is_heap:
 *                     self._c_issue_corruption_warning()
 *                 raise tpz_exception.CoverageError(fee_volume, currency.decode())             # <<<<<<<<<<<<<<
 *         elif coverage == b'debit':
 *             self._c_check_marked_coverage = 0
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 704, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 704, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_fee_volume); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 704, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_14 = __Pyx_decode_cpp_string(__pyx_v_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 704, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_10 = NULL;
      __pyx_t_13 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
          __pyx_t_13 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_1, __pyx_t_14};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 704, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_1, __pyx_t_14};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 704, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 704, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_13, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_13, __pyx_t_14);
        __pyx_t_1 = 0;
        __pyx_t_14 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 704, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 704, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":700
 *             #   volume. Taking processing times into account is done later on, so we stick to this weaker check here
 *             # we do a re-check with precision arithmetics to avoid error caused by floating point errors
 *             if c_precision_add(current_depot_fee_currency, volume * (currency==fee_currency)) < fee_volume:             # <<<<<<<<<<<<<<
 *                 # multiplication is either with 1 or 0 so need for precision
 *                 if self._c_is_heap:
 */
    }

    /* "trapeza/account/fx_account.pyx":693
 *         # >>>handle coverage exception induced by fees
 *         # fee coverage is checked at code block below, so we just have to set debiting mode if necessary
 *         if (fee_volume > 0 and coverage == b'except'             # <<<<<<<<<<<<<<
 *                 and current_depot_fee_currency + (volume * (currency==fee_currency)) < fee_volume):
 *             # this is rather a weak check as processing times of depositing and fee billing might cause
 */
    goto __pyx_L7;
  }

  /* "trapeza/account/fx_account.pyx":705
 *                     self._c_issue_corruption_warning()
 *                 raise tpz_exception.CoverageError(fee_volume, currency.decode())
 *         elif coverage == b'debit':             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = 0
 * 
 */
  __pyx_t_16 = ((__pyx_v_coverage == ((char const *)"debit")) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":706
 *                 raise tpz_exception.CoverageError(fee_volume, currency.decode())
 *         elif coverage == b'debit':
 *             self._c_check_marked_coverage = 0             # <<<<<<<<<<<<<<
 * 
 *         # >>>check coverage of fees
 */
    __pyx_v_self->_c_check_marked_coverage = 0;

    /* "trapeza/account/fx_account.pyx":705
 *                     self._c_issue_corruption_warning()
 *                 raise tpz_exception.CoverageError(fee_volume, currency.decode())
 *         elif coverage == b'debit':             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = 0
 * 
 */
  }
  __pyx_L7:;

  /* "trapeza/account/fx_account.pyx":709
 * 
 *         # >>>check coverage of fees
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # if fee is billed in the same currency as deposit amount, then we have to take processing times into account:
 *             #   - fee and deposit at same time: we can emulate this by virtually depositing as fee is effectively subtracted
 */
  __pyx_t_16 = ((__pyx_v_fee_volume > 0.0) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":718
 *             #   - instant fee: we have to check current position and take depositing volume into account if also instant
 *             # >>different currencies, fees cannot be offset by incoming depositing amount
 *             if fee_currency != currency:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
    __pyx_t_16 = ((__pyx_v_fee_currency != __pyx_v_currency) != 0);
    if (__pyx_t_16) {

      /* "trapeza/account/fx_account.pyx":719
 *             # >>different currencies, fees cannot be offset by incoming depositing amount
 *             if fee_currency != currency:
 *                 self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             # from here on it's fee_currency == currency
 */
      __pyx_t_18 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, NULL); if (unlikely(__pyx_t_18 == ((double)-1.0))) __PYX_ERR(0, 719, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":718
 *             #   - instant fee: we have to check current position and take depositing volume into account if also instant
 *             # >>different currencies, fees cannot be offset by incoming depositing amount
 *             if fee_currency != currency:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
      goto __pyx_L14;
    }

    /* "trapeza/account/fx_account.pyx":723
 *             # from here on it's fee_currency == currency
 *             # >>instant fee
 *             elif fee_exec_duration * (1 - instant_float_fee) == 0:             # <<<<<<<<<<<<<<
 *                 # we have to implement a hard check here because self._c_check_coverage does not throw an exception
 *                 # if coverage checking is deactivated
 */
    __pyx_t_16 = (((__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee)) == 0) != 0);
    if (__pyx_t_16) {

      /* "trapeza/account/fx_account.pyx":728
 *                 # we're doing this explicitly to be consistent with behavior of other transactions
 *                 # this check must not be applied if debiting is allowed explicitly
 *                 if (coverage != b'debit'             # <<<<<<<<<<<<<<
 *                         and current_depot_fee_currency + volume*(processing_duration==0) < fee_volume):
 *                     # we do re-check to avoid floating point errors
 */
      __pyx_t_17 = ((__pyx_v_coverage != ((char const *)"debit")) != 0);
      if (__pyx_t_17) {
      } else {
        __pyx_t_16 = __pyx_t_17;
        goto __pyx_L16_bool_binop_done;
      }

      /* "trapeza/account/fx_account.pyx":729
 *                 # this check must not be applied if debiting is allowed explicitly
 *                 if (coverage != b'debit'
 *                         and current_depot_fee_currency + volume*(processing_duration==0) < fee_volume):             # <<<<<<<<<<<<<<
 *                     # we do re-check to avoid floating point errors
 *                     if c_precision_add(current_depot_fee_currency, volume*(processing_duration==0)) < fee_volume:
 */
      __pyx_t_17 = (((__pyx_v_current_depot_fee_currency + (__pyx_v_volume * (__pyx_v_processing_duration == 0))) < __pyx_v_fee_volume) != 0);
      __pyx_t_16 = __pyx_t_17;
      __pyx_L16_bool_binop_done:;

      /* "trapeza/account/fx_account.pyx":728
 *                 # we're doing this explicitly to be consistent with behavior of other transactions
 *                 # this check must not be applied if debiting is allowed explicitly
 *                 if (coverage != b'debit'             # <<<<<<<<<<<<<<
 *                         and current_depot_fee_currency + volume*(processing_duration==0) < fee_volume):
 *                     # we do re-check to avoid floating point errors
 */
      if (__pyx_t_16) {

        /* "trapeza/account/fx_account.pyx":731
 *                         and current_depot_fee_currency + volume*(processing_duration==0) < fee_volume):
 *                     # we do re-check to avoid floating point errors
 *                     if c_precision_add(current_depot_fee_currency, volume*(processing_duration==0)) < fee_volume:             # <<<<<<<<<<<<<<
 *                         # multiplication either with 1 or 0 so no need for precision
 *                         if self._c_is_heap:
 */
        __pyx_t_16 = ((__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_current_depot_fee_currency, (__pyx_v_volume * (__pyx_v_processing_duration == 0))) < __pyx_v_fee_volume) != 0);
        if (__pyx_t_16) {

          /* "trapeza/account/fx_account.pyx":733
 *                     if c_precision_add(current_depot_fee_currency, volume*(processing_duration==0)) < fee_volume:
 *                         # multiplication either with 1 or 0 so no need for precision
 *                         if self._c_is_heap:             # <<<<<<<<<<<<<<
 *                             self._c_issue_corruption_warning()
 *                         raise tpz_exception.CoverageError(fee_volume, fee_currency.decode())
 */
          __pyx_t_16 = (__pyx_v_self->_c_is_heap != 0);
          if (__pyx_t_16) {

            /* "trapeza/account/fx_account.pyx":734
 *                         # multiplication either with 1 or 0 so no need for precision
 *                         if self._c_is_heap:
 *                             self._c_issue_corruption_warning()             # <<<<<<<<<<<<<<
 *                         raise tpz_exception.CoverageError(fee_volume, fee_currency.decode())
 *             # >>fee before depositing
 */
            __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_issue_corruption_warning(__pyx_v_self); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 734, __pyx_L1_error)

            /* "trapeza/account/fx_account.pyx":733
 *                     if c_precision_add(current_depot_fee_currency, volume*(processing_duration==0)) < fee_volume:
 *                         # multiplication either with 1 or 0 so no need for precision
 *                         if self._c_is_heap:             # <<<<<<<<<<<<<<
 *                             self._c_issue_corruption_warning()
 *                         raise tpz_exception.CoverageError(fee_volume, fee_currency.decode())
 */
          }

          /* "trapeza/account/fx_account.pyx":735
 *                         if self._c_is_heap:
 *                             self._c_issue_corruption_warning()
 *                         raise tpz_exception.CoverageError(fee_volume, fee_currency.decode())             # <<<<<<<<<<<<<<
 *             # >>fee before depositing
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:
 */
          __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 735, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 735, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_11 = PyFloat_FromDouble(__pyx_v_fee_volume); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 735, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_14 = __Pyx_decode_cpp_string(__pyx_v_fee_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 735, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_1 = NULL;
          __pyx_t_13 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_9, function);
              __pyx_t_13 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_11, __pyx_t_14};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 735, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
            PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_11, __pyx_t_14};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 735, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          } else
          #endif
          {
            __pyx_t_10 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 735, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            if (__pyx_t_1) {
              __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __pyx_t_1 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_11);
            PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_13, __pyx_t_11);
            __Pyx_GIVEREF(__pyx_t_14);
            PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_13, __pyx_t_14);
            __pyx_t_11 = 0;
            __pyx_t_14 = 0;
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 735, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          }
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_Raise(__pyx_t_2, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __PYX_ERR(0, 735, __pyx_L1_error)

          /* "trapeza/account/fx_account.pyx":731
 *                         and current_depot_fee_currency + volume*(processing_duration==0) < fee_volume):
 *                     # we do re-check to avoid floating point errors
 *                     if c_precision_add(current_depot_fee_currency, volume*(processing_duration==0)) < fee_volume:             # <<<<<<<<<<<<<<
 *                         # multiplication either with 1 or 0 so no need for precision
 *                         if self._c_is_heap:
 */
        }

        /* "trapeza/account/fx_account.pyx":728
 *                 # we're doing this explicitly to be consistent with behavior of other transactions
 *                 # this check must not be applied if debiting is allowed explicitly
 *                 if (coverage != b'debit'             # <<<<<<<<<<<<<<
 *                         and current_depot_fee_currency + volume*(processing_duration==0) < fee_volume):
 *                     # we do re-check to avoid floating point errors
 */
      }

      /* "trapeza/account/fx_account.pyx":723
 *             # from here on it's fee_currency == currency
 *             # >>instant fee
 *             elif fee_exec_duration * (1 - instant_float_fee) == 0:             # <<<<<<<<<<<<<<
 *                 # we have to implement a hard check here because self._c_check_coverage does not throw an exception
 *                 # if coverage checking is deactivated
 */
      goto __pyx_L14;
    }

    /* "trapeza/account/fx_account.pyx":737
 *                         raise tpz_exception.CoverageError(fee_volume, fee_currency.decode())
 *             # >>fee before depositing
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
    __pyx_t_16 = (((__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee)) < __pyx_v_processing_duration) != 0);
    if (__pyx_t_16) {

      /* "trapeza/account/fx_account.pyx":738
 *             # >>fee before depositing
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:
 *                 self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 *             # >>fee after or at the same time of depositing
 */
      __pyx_t_18 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, NULL); if (unlikely(__pyx_t_18 == ((double)-1.0))) __PYX_ERR(0, 738, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":737
 *                         raise tpz_exception.CoverageError(fee_volume, fee_currency.decode())
 *             # >>fee before depositing
 *             elif fee_exec_duration * (1 - instant_float_fee) < processing_duration:             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 */
      goto __pyx_L14;
    }

    /* "trapeza/account/fx_account.pyx":742
 *             # >>fee after or at the same time of depositing
 *             else:
 *                 if current_depot_fee_currency == 0:             # <<<<<<<<<<<<<<
 *                     # this is done to prevent an exception if there is not yet an open position in fee_currency on
 *                     # account's depot (and if it's 0 even though position exists, then we can set it to 0 again
 */
    /*else*/ {
      __pyx_t_16 = ((__pyx_v_current_depot_fee_currency == 0.0) != 0);
      if (__pyx_t_16) {

        /* "trapeza/account/fx_account.pyx":746
 *                     # account's depot (and if it's 0 even though position exists, then we can set it to 0 again
 *                     # without any side effects)
 *                     self._c_depot[fee_currency] = 0             # <<<<<<<<<<<<<<
 *                 self._c_check_coverage(fee_volume, fee_currency,
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee), volume)
 */
        if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 746, __pyx_L1_error)
        }
        __pyx_t_2 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_fee_currency); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (unlikely(PyDict_SetItem(__pyx_v_self->_c_depot, __pyx_t_2, __pyx_int_0) < 0)) __PYX_ERR(0, 746, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "trapeza/account/fx_account.pyx":742
 *             # >>fee after or at the same time of depositing
 *             else:
 *                 if current_depot_fee_currency == 0:             # <<<<<<<<<<<<<<
 *                     # this is done to prevent an exception if there is not yet an open position in fee_currency on
 *                     # account's depot (and if it's 0 even though position exists, then we can set it to 0 again
 */
      }

      /* "trapeza/account/fx_account.pyx":747
 *                     # without any side effects)
 *                     self._c_depot[fee_currency] = 0
 *                 self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                        self._c_clock + fee_exec_duration * (1 - instant_float_fee), volume)
 * 
 */
      __pyx_t_19.__pyx_n = 1;
      __pyx_t_19.virtual_deposit = __pyx_v_volume;
      __pyx_t_18 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, &__pyx_t_19); if (unlikely(__pyx_t_18 == ((double)-1.0))) __PYX_ERR(0, 747, __pyx_L1_error)
    }
    __pyx_L14:;

    /* "trapeza/account/fx_account.pyx":709
 * 
 *         # >>>check coverage of fees
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # if fee is billed in the same currency as deposit amount, then we have to take processing times into account:
 *             #   - fee and deposit at same time: we can emulate this by virtually depositing as fee is effectively subtracted
 */
  }

  /* "trapeza/account/fx_account.pyx":751
 * 
 *         # >>>instant execution
 *         if processing_duration <= 0:             # <<<<<<<<<<<<<<
 *             try:  # if currency is already in depot
 *                 self._c_depot[currency] = c_precision_add(self._c_depot[currency], volume)
 */
  __pyx_t_16 = ((__pyx_v_processing_duration <= 0) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":752
 *         # >>>instant execution
 *         if processing_duration <= 0:
 *             try:  # if currency is already in depot             # <<<<<<<<<<<<<<
 *                 self._c_depot[currency] = c_precision_add(self._c_depot[currency], volume)
 *             except KeyError:  # else we open a new position in depot
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_21);
      __Pyx_XGOTREF(__pyx_t_22);
      /*try:*/ {

        /* "trapeza/account/fx_account.pyx":753
 *         if processing_duration <= 0:
 *             try:  # if currency is already in depot
 *                 self._c_depot[currency] = c_precision_add(self._c_depot[currency], volume)             # <<<<<<<<<<<<<<
 *             except KeyError:  # else we open a new position in depot
 *                 self._c_depot[currency] = volume
 */
        if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 753, __pyx_L22_error)
        }
        __pyx_t_2 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 753, __pyx_L22_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 753, __pyx_L22_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_18 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_18 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 753, __pyx_L22_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = PyFloat_FromDouble(__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_t_18, __pyx_v_volume)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 753, __pyx_L22_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 753, __pyx_L22_error)
        }
        __pyx_t_2 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 753, __pyx_L22_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (unlikely(PyDict_SetItem(__pyx_v_self->_c_depot, __pyx_t_2, __pyx_t_9) < 0)) __PYX_ERR(0, 753, __pyx_L22_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "trapeza/account/fx_account.pyx":752
 *         # >>>instant execution
 *         if processing_duration <= 0:
 *             try:  # if currency is already in depot             # <<<<<<<<<<<<<<
 *                 self._c_depot[currency] = c_precision_add(self._c_depot[currency], volume)
 *             except KeyError:  # else we open a new position in depot
 */
      }
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
      __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
      goto __pyx_L27_try_end;
      __pyx_L22_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "trapeza/account/fx_account.pyx":754
 *             try:  # if currency is already in depot
 *                 self._c_depot[currency] = c_precision_add(self._c_depot[currency], volume)
 *             except KeyError:  # else we open a new position in depot             # <<<<<<<<<<<<<<
 *                 self._c_depot[currency] = volume
 *         # >>>delayed transaction caused by necessary execution duration
 */
      __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
      if (__pyx_t_13) {
        __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_deposit", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_2, &__pyx_t_10) < 0) __PYX_ERR(0, 754, __pyx_L24_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_10);

        /* "trapeza/account/fx_account.pyx":755
 *                 self._c_depot[currency] = c_precision_add(self._c_depot[currency], volume)
 *             except KeyError:  # else we open a new position in depot
 *                 self._c_depot[currency] = volume             # <<<<<<<<<<<<<<
 *         # >>>delayed transaction caused by necessary execution duration
 *         else:
 */
        __pyx_t_14 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 755, __pyx_L24_except_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 755, __pyx_L24_except_error)
        }
        __pyx_t_11 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 755, __pyx_L24_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (unlikely(PyDict_SetItem(__pyx_v_self->_c_depot, __pyx_t_11, __pyx_t_14) < 0)) __PYX_ERR(0, 755, __pyx_L24_except_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L23_exception_handled;
      }
      goto __pyx_L24_except_error;
      __pyx_L24_except_error:;

      /* "trapeza/account/fx_account.pyx":752
 *         # >>>instant execution
 *         if processing_duration <= 0:
 *             try:  # if currency is already in depot             # <<<<<<<<<<<<<<
 *                 self._c_depot[currency] = c_precision_add(self._c_depot[currency], volume)
 *             except KeyError:  # else we open a new position in depot
 */
      __Pyx_XGIVEREF(__pyx_t_20);
      __Pyx_XGIVEREF(__pyx_t_21);
      __Pyx_XGIVEREF(__pyx_t_22);
      __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      goto __pyx_L1_error;
      __pyx_L23_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_20);
      __Pyx_XGIVEREF(__pyx_t_21);
      __Pyx_XGIVEREF(__pyx_t_22);
      __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      __pyx_L27_try_end:;
    }

    /* "trapeza/account/fx_account.pyx":751
 * 
 *         # >>>instant execution
 *         if processing_duration <= 0:             # <<<<<<<<<<<<<<
 *             try:  # if currency is already in depot
 *                 self._c_depot[currency] = c_precision_add(self._c_depot[currency], volume)
 */
    goto __pyx_L21;
  }

  /* "trapeza/account/fx_account.pyx":762
 *             # reduced, which does not follow the principle of least surprise. Instead turn 'partial' to except, which
 *             # is a more conservative guess (therefore just don't provide **kwargs, as 'except' is default value)
 *             if coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_deposit', volume, currency,
 *                                         coverage])
 */
  /*else*/ {
    __pyx_t_16 = ((__pyx_v_coverage == ((char const *)"debit")) != 0);
    if (__pyx_t_16) {

      /* "trapeza/account/fx_account.pyx":763
 *             # is a more conservative guess (therefore just don't provide **kwargs, as 'except' is default value)
 *             if coverage == b'debit':
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_deposit', volume, currency,             # <<<<<<<<<<<<<<
 *                                         coverage])
 *             else:
 */
      __pyx_t_10 = __Pyx_PyInt_From_long((__pyx_v_self->_c_clock + __pyx_v_processing_duration)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 763, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 763, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 763, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);

      /* "trapeza/account/fx_account.pyx":764
 *             if coverage == b'debit':
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_deposit', volume, currency,
 *                                         coverage])             # <<<<<<<<<<<<<<
 *             else:
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_deposit', volume, currency])
 */
      __pyx_t_14 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 764, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);

      /* "trapeza/account/fx_account.pyx":763
 *             # is a more conservative guess (therefore just don't provide **kwargs, as 'except' is default value)
 *             if coverage == b'debit':
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_deposit', volume, currency,             # <<<<<<<<<<<<<<
 *                                         coverage])
 *             else:
 */
      __pyx_t_11 = PyList_New(5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 763, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_10);
      PyList_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
      __Pyx_INCREF(__pyx_n_b_c_deposit);
      __Pyx_GIVEREF(__pyx_n_b_c_deposit);
      PyList_SET_ITEM(__pyx_t_11, 1, __pyx_n_b_c_deposit);
      __Pyx_GIVEREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_11, 2, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_11, 3, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_14);
      PyList_SET_ITEM(__pyx_t_11, 4, __pyx_t_14);
      __pyx_t_10 = 0;
      __pyx_t_2 = 0;
      __pyx_t_9 = 0;
      __pyx_t_14 = 0;
      ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->heappush(__pyx_v_self->vec_heap, ((PyObject*)__pyx_t_11));
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "trapeza/account/fx_account.pyx":762
 *             # reduced, which does not follow the principle of least surprise. Instead turn 'partial' to except, which
 *             # is a more conservative guess (therefore just don't provide **kwargs, as 'except' is default value)
 *             if coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_deposit', volume, currency,
 *                                         coverage])
 */
      goto __pyx_L30;
    }

    /* "trapeza/account/fx_account.pyx":766
 *                                         coverage])
 *             else:
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_deposit', volume, currency])             # <<<<<<<<<<<<<<
 * 
 *         # >>>handle fees
 */
    /*else*/ {
      __pyx_t_11 = __Pyx_PyInt_From_long((__pyx_v_self->_c_clock + __pyx_v_processing_duration)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_14 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_9 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_11);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_11);
      __Pyx_INCREF(__pyx_n_b_c_deposit);
      __Pyx_GIVEREF(__pyx_n_b_c_deposit);
      PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_b_c_deposit);
      __Pyx_GIVEREF(__pyx_t_14);
      PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_9);
      __pyx_t_11 = 0;
      __pyx_t_14 = 0;
      __pyx_t_9 = 0;
      ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->heappush(__pyx_v_self->vec_heap, ((PyObject*)__pyx_t_2));
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L30:;
  }
  __pyx_L21:;

  /* "trapeza/account/fx_account.pyx":769
 * 
 *         # >>>handle fees
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,
 *                              fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 */
  __pyx_t_16 = ((__pyx_v_fee_volume > 0.0) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":772
 *             self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,
 *                              fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 *                              forward_coverage=b'debit')             # <<<<<<<<<<<<<<
 * 
 *         # >>>restore
 */
    __pyx_t_23 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_debit); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 772, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":770
 *         # >>>handle fees
 *         if fee_volume > 0:
 *             self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,             # <<<<<<<<<<<<<<
 *                              fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 *                              forward_coverage=b'debit')
 */
    __pyx_t_24.__pyx_n = 1;
    __pyx_t_24.forward_coverage = __pyx_t_23;
    __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_fill_fee(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee)), &__pyx_t_24); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 770, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":769
 * 
 *         # >>>handle fees
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,
 *                              fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 */
  }

  /* "trapeza/account/fx_account.pyx":775
 * 
 *         # >>>restore
 *         self._c_check_marked_coverage = curr_check_marked_coverage             # <<<<<<<<<<<<<<
 * 
 *         # >>>return confirmation
 */
  __pyx_v_self->_c_check_marked_coverage = __pyx_v_curr_check_marked_coverage;

  /* "trapeza/account/fx_account.pyx":778
 * 
 *         # >>>return confirmation
 *         return self._c_confirmation(processing_duration)             # <<<<<<<<<<<<<<
 * 
 *     @cython.wraparound(False)
 */
  __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_confirmation(__pyx_v_self, __pyx_v_processing_duration); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 778, __pyx_L1_error)
  __pyx_r = __pyx_t_15;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":639
 *     # noinspection PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                         string fee_currency=b'default', long fee_exec_duration=0,
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_deposit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -9999;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_19c_deposit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_18c_deposit[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.deposit for further information.\n        \n        THIS METHOD IMPLEMENTS A SLIGHTLY DIFFERENT ORDER OF ARGUMENTS THAN FXAccount!\n        \n        :param volume: double, volume given in currency\n        :param currency: std:string\n        :param processing_duration: long, processing time (delay) in time base units of internal clock\n        :param fee_volume: double, volume given in fee_currency\n        :param fee_currency: std:string, if b'default' then param:currency is used\n        :param fee_exec_duration: long, processing time (delay) in time base units of internal clock\n        :param coverage: std:string {b'except', b'debit'}, default=b'except'\n                         see FXAccount.deposit for details\n                         b'partial' not available for this function (makes no sense, see comments\n                         in source code of this method)\n                         b'ignore' not available on purpose\n        :param instant_float_fee: std:bool, \n                                  see FXAccount.deposit for details\n        :return: confirmation: short, confirmation states --> 0: processing (processing_duration), 1: executed\n        :TODO: optimize performance\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_19c_deposit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_volume;
  std::string __pyx_v_currency;
  long __pyx_v_processing_duration;
  double __pyx_v_fee_volume;
  std::string __pyx_v_fee_currency;
  long __pyx_v_fee_exec_duration;
  std::string __pyx_v_coverage;
  bool __pyx_v_instant_float_fee;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_deposit (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_volume,&__pyx_n_s_currency,&__pyx_n_s_processing_duration,&__pyx_n_s_fee_volume,&__pyx_n_s_fee_currency,&__pyx_n_s_fee_exec_duration,&__pyx_n_s_coverage,&__pyx_n_s_instant_float_fee,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_deposit", 0, 3, 8, 1); __PYX_ERR(0, 639, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_deposit", 0, 3, 8, 2); __PYX_ERR(0, 639, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_volume);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_currency);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_exec_duration);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coverage);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_float_fee);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "c_deposit") < 0)) __PYX_ERR(0, 639, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 639, __pyx_L3_error)
    __pyx_v_currency = __pyx_convert_string_from_py_std__in_string(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 639, __pyx_L3_error)
    __pyx_v_processing_duration = __Pyx_PyInt_As_long(values[2]); if (unlikely((__pyx_v_processing_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 639, __pyx_L3_error)
    if (values[3]) {
      __pyx_v_fee_volume = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_fee_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 639, __pyx_L3_error)
    } else {
      __pyx_v_fee_volume = ((double)0.0);
    }
    if (values[4]) {
      __pyx_v_fee_currency = __pyx_convert_string_from_py_std__in_string(values[4]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 640, __pyx_L3_error)
    } else {
      __pyx_v_fee_currency = __pyx_k__8;
    }
    if (values[5]) {
      __pyx_v_fee_exec_duration = __Pyx_PyInt_As_long(values[5]); if (unlikely((__pyx_v_fee_exec_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 640, __pyx_L3_error)
    } else {
      __pyx_v_fee_exec_duration = ((long)0);
    }
    if (values[6]) {
      __pyx_v_coverage = __pyx_convert_string_from_py_std__in_string(values[6]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 641, __pyx_L3_error)
    } else {
      __pyx_v_coverage = __pyx_k__9;
    }
    if (values[7]) {
      __pyx_v_instant_float_fee = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_instant_float_fee == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 641, __pyx_L3_error)
    } else {

      /* "trapeza/account/fx_account.pyx":641
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,
 *                         string fee_currency=b'default', long fee_exec_duration=0,
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.deposit for further information.
 */
      __pyx_v_instant_float_fee = ((bool)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("c_deposit", 0, 3, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 639, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_deposit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_18c_deposit(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_volume, __pyx_v_currency, __pyx_v_processing_duration, __pyx_v_fee_volume, __pyx_v_fee_currency, __pyx_v_fee_exec_duration, __pyx_v_coverage, __pyx_v_instant_float_fee);

  /* "trapeza/account/fx_account.pyx":639
 *     # noinspection PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                         string fee_currency=b'default', long fee_exec_duration=0,
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_18c_deposit(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, long __pyx_v_processing_duration, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, std::string __pyx_v_coverage, bool __pyx_v_instant_float_fee) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_deposit __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_deposit", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 5;
  __pyx_t_2.fee_volume = __pyx_v_fee_volume;
  __pyx_t_2.fee_currency = __pyx_v_fee_currency;
  __pyx_t_2.fee_exec_duration = __pyx_v_fee_exec_duration;
  __pyx_t_2.coverage = __pyx_v_coverage;
  __pyx_t_2.instant_float_fee = __pyx_v_instant_float_fee;
  __pyx_t_1 = __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount->c_deposit(__pyx_v_self, __pyx_v_volume, __pyx_v_currency, __pyx_v_processing_duration, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((short)-9999))) __PYX_ERR(0, 639, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_deposit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":781
 * 
 *     @cython.wraparound(False)
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                          string fee_currency=b'default', long fee_exec_duration=0,
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21c_withdraw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw *__pyx_optional_args) {
  long __pyx_v_processing_duration = ((long)0);
  double __pyx_v_fee_volume = ((double)0.0);
  std::string __pyx_v_fee_currency = __pyx_k__10;
  long __pyx_v_fee_exec_duration = ((long)0);
  std::string __pyx_v_coverage = __pyx_k__11;

  /* "trapeza/account/fx_account.pyx":783
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,
 *                          string fee_currency=b'default', long fee_exec_duration=0,
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.withdraw for further information.
 */
  bool __pyx_v_instant_float_fee = ((bool)0);
  short __pyx_v_curr_check_marked_coverage;
  double __pyx_v_currency_position;
  std::string __pyx_v_propagate_coverage;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  short __pyx_t_15;
  int __pyx_t_16;
  double __pyx_t_17;
  std::string __pyx_t_18;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_withdraw", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_processing_duration = __pyx_optional_args->processing_duration;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_fee_volume = __pyx_optional_args->fee_volume;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_fee_currency = __pyx_optional_args->fee_currency;
          if (__pyx_optional_args->__pyx_n > 3) {
            __pyx_v_fee_exec_duration = __pyx_optional_args->fee_exec_duration;
            if (__pyx_optional_args->__pyx_n > 4) {
              __pyx_v_coverage = __pyx_optional_args->coverage;
              if (__pyx_optional_args->__pyx_n > 5) {
                __pyx_v_instant_float_fee = __pyx_optional_args->instant_float_fee;
              }
            }
          }
        }
      }
    }
  }

  /* "trapeza/account/fx_account.pyx":781
 * 
 *     @cython.wraparound(False)
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                          string fee_currency=b'default', long fee_exec_duration=0,
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_withdraw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 781, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21c_withdraw)) {
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 781, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 781, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_processing_duration); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 781, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = PyFloat_FromDouble(__pyx_v_fee_volume); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 781, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_fee_currency); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 781, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_fee_exec_duration); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 781, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 781, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = __Pyx_PyBool_FromLong(__pyx_v_instant_float_fee); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 781, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_11 = __pyx_t_1; __pyx_t_12 = NULL;
        __pyx_t_13 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_11, function);
            __pyx_t_13 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[9] = {__pyx_t_12, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_13, 8+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 781, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[9] = {__pyx_t_12, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_13, 8+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 781, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        {
          __pyx_t_14 = PyTuple_New(8+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 781, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          if (__pyx_t_12) {
            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_13, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_13, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_13, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_14, 5+__pyx_t_13, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_14, 6+__pyx_t_13, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_14, 7+__pyx_t_13, __pyx_t_10);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_6 = 0;
          __pyx_t_7 = 0;
          __pyx_t_8 = 0;
          __pyx_t_9 = 0;
          __pyx_t_10 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_14, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 781, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_15 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_15 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 781, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_15;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":803
 *         """
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             fee_currency = currency
 * 
 */
  __pyx_t_16 = ((__pyx_v_fee_currency == ((char const *)"default")) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":804
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':
 *             fee_currency = currency             # <<<<<<<<<<<<<<
 * 
 *         # >>>store for later restoring
 */
    __pyx_v_fee_currency = __pyx_v_currency;

    /* "trapeza/account/fx_account.pyx":803
 *         """
 *         # >>>parse fee_currency if necessary: not the most elegant job, but this way heap execution logic does not brake
 *         if fee_currency == b'default':             # <<<<<<<<<<<<<<
 *             fee_currency = currency
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":808
 *         # >>>store for later restoring
 *         cdef short curr_check_marked_coverage
 *         curr_check_marked_coverage = self._c_check_marked_coverage             # <<<<<<<<<<<<<<
 * 
 *         # >>>handle coverage exception
 */
  __pyx_t_15 = __pyx_v_self->_c_check_marked_coverage;
  __pyx_v_curr_check_marked_coverage = __pyx_t_15;

  /* "trapeza/account/fx_account.pyx":812
 *         # >>>handle coverage exception
 *         # volume is in currency
 *         cdef double currency_position = self._c_depot[currency]             # <<<<<<<<<<<<<<
 *         if currency_position < c_precision_add(volume, fee_volume * (fee_currency == currency)):
 *             if coverage == b'except':
 */
  if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 812, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_17 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_17 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_currency_position = __pyx_t_17;

  /* "trapeza/account/fx_account.pyx":813
 *         # volume is in currency
 *         cdef double currency_position = self._c_depot[currency]
 *         if currency_position < c_precision_add(volume, fee_volume * (fee_currency == currency)):             # <<<<<<<<<<<<<<
 *             if coverage == b'except':
 *                 if self._c_is_heap:
 */
  __pyx_t_16 = ((__pyx_v_currency_position < __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_currency)))) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":814
 *         cdef double currency_position = self._c_depot[currency]
 *         if currency_position < c_precision_add(volume, fee_volume * (fee_currency == currency)):
 *             if coverage == b'except':             # <<<<<<<<<<<<<<
 *                 if self._c_is_heap:
 *                     self._c_issue_corruption_warning()
 */
    __pyx_t_16 = ((__pyx_v_coverage == ((char const *)"except")) != 0);
    if (__pyx_t_16) {

      /* "trapeza/account/fx_account.pyx":815
 *         if currency_position < c_precision_add(volume, fee_volume * (fee_currency == currency)):
 *             if coverage == b'except':
 *                 if self._c_is_heap:             # <<<<<<<<<<<<<<
 *                     self._c_issue_corruption_warning()
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == currency)),
 */
      __pyx_t_16 = (__pyx_v_self->_c_is_heap != 0);
      if (__pyx_t_16) {

        /* "trapeza/account/fx_account.pyx":816
 *             if coverage == b'except':
 *                 if self._c_is_heap:
 *                     self._c_issue_corruption_warning()             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == currency)),
 *                                                   currency.decode())
 */
        __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_issue_corruption_warning(__pyx_v_self); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 816, __pyx_L1_error)

        /* "trapeza/account/fx_account.pyx":815
 *         if currency_position < c_precision_add(volume, fee_volume * (fee_currency == currency)):
 *             if coverage == b'except':
 *                 if self._c_is_heap:             # <<<<<<<<<<<<<<
 *                     self._c_issue_corruption_warning()
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == currency)),
 */
      }

      /* "trapeza/account/fx_account.pyx":817
 *                 if self._c_is_heap:
 *                     self._c_issue_corruption_warning()
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == currency)),             # <<<<<<<<<<<<<<
 *                                                   currency.decode())
 *             elif coverage == b'partial':
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 817, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_currency)))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);

      /* "trapeza/account/fx_account.pyx":818
 *                     self._c_issue_corruption_warning()
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == currency)),
 *                                                   currency.decode())             # <<<<<<<<<<<<<<
 *             elif coverage == b'partial':
 *                 volume = c_precision_subtract(currency_position, fee_volume * (fee_currency == currency))
 */
      __pyx_t_14 = __Pyx_decode_cpp_string(__pyx_v_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 818, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_10 = NULL;
      __pyx_t_13 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
          __pyx_t_13 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_1, __pyx_t_14};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 817, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_1, __pyx_t_14};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 817, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 817, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_13, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_13, __pyx_t_14);
        __pyx_t_1 = 0;
        __pyx_t_14 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 817, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 817, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":814
 *         cdef double currency_position = self._c_depot[currency]
 *         if currency_position < c_precision_add(volume, fee_volume * (fee_currency == currency)):
 *             if coverage == b'except':             # <<<<<<<<<<<<<<
 *                 if self._c_is_heap:
 *                     self._c_issue_corruption_warning()
 */
    }

    /* "trapeza/account/fx_account.pyx":819
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == currency)),
 *                                                   currency.decode())
 *             elif coverage == b'partial':             # <<<<<<<<<<<<<<
 *                 volume = c_precision_subtract(currency_position, fee_volume * (fee_currency == currency))
 *                 # in currency
 */
    __pyx_t_16 = ((__pyx_v_coverage == ((char const *)"partial")) != 0);
    if (__pyx_t_16) {

      /* "trapeza/account/fx_account.pyx":820
 *                                                   currency.decode())
 *             elif coverage == b'partial':
 *                 volume = c_precision_subtract(currency_position, fee_volume * (fee_currency == currency))             # <<<<<<<<<<<<<<
 *                 # in currency
 *                 if volume < 0:
 */
      __pyx_v_volume = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_subtract(__pyx_v_currency_position, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_currency)));

      /* "trapeza/account/fx_account.pyx":822
 *                 volume = c_precision_subtract(currency_position, fee_volume * (fee_currency == currency))
 *                 # in currency
 *                 if volume < 0:             # <<<<<<<<<<<<<<
 *                     if self._c_is_heap:
 *                         self._c_issue_corruption_warning()
 */
      __pyx_t_16 = ((__pyx_v_volume < 0.0) != 0);
      if (__pyx_t_16) {

        /* "trapeza/account/fx_account.pyx":823
 *                 # in currency
 *                 if volume < 0:
 *                     if self._c_is_heap:             # <<<<<<<<<<<<<<
 *                         self._c_issue_corruption_warning()
 *                     raise tpz_exception.CoverageError(fee_volume * (fee_currency == currency), currency.decode(),
 */
        __pyx_t_16 = (__pyx_v_self->_c_is_heap != 0);
        if (__pyx_t_16) {

          /* "trapeza/account/fx_account.pyx":824
 *                 if volume < 0:
 *                     if self._c_is_heap:
 *                         self._c_issue_corruption_warning()             # <<<<<<<<<<<<<<
 *                     raise tpz_exception.CoverageError(fee_volume * (fee_currency == currency), currency.decode(),
 *                                                      'Transaction not feasible even though coverage set '
 */
          __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_issue_corruption_warning(__pyx_v_self); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 824, __pyx_L1_error)

          /* "trapeza/account/fx_account.pyx":823
 *                 # in currency
 *                 if volume < 0:
 *                     if self._c_is_heap:             # <<<<<<<<<<<<<<
 *                         self._c_issue_corruption_warning()
 *                     raise tpz_exception.CoverageError(fee_volume * (fee_currency == currency), currency.decode(),
 */
        }

        /* "trapeza/account/fx_account.pyx":825
 *                     if self._c_is_heap:
 *                         self._c_issue_corruption_warning()
 *                     raise tpz_exception.CoverageError(fee_volume * (fee_currency == currency), currency.decode(),             # <<<<<<<<<<<<<<
 *                                                      'Transaction not feasible even though coverage set '
 *                                                      'to partial. Fees not covered')
 */
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_CoverageError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = PyFloat_FromDouble((__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_currency))); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_14 = __Pyx_decode_cpp_string(__pyx_v_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_1 = NULL;
        __pyx_t_13 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
            __pyx_t_13 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_t_14, __pyx_kp_u_Transaction_not_feasible_even_th_2};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 825, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_11, __pyx_t_14, __pyx_kp_u_Transaction_not_feasible_even_th_2};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 825, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(3+__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 825, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          if (__pyx_t_1) {
            __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __pyx_t_1 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_13, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_14);
          PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_13, __pyx_t_14);
          __Pyx_INCREF(__pyx_kp_u_Transaction_not_feasible_even_th_2);
          __Pyx_GIVEREF(__pyx_kp_u_Transaction_not_feasible_even_th_2);
          PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_13, __pyx_kp_u_Transaction_not_feasible_even_th_2);
          __pyx_t_11 = 0;
          __pyx_t_14 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 825, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(0, 825, __pyx_L1_error)

        /* "trapeza/account/fx_account.pyx":822
 *                 volume = c_precision_subtract(currency_position, fee_volume * (fee_currency == currency))
 *                 # in currency
 *                 if volume < 0:             # <<<<<<<<<<<<<<
 *                     if self._c_is_heap:
 *                         self._c_issue_corruption_warning()
 */
      }

      /* "trapeza/account/fx_account.pyx":819
 *                 raise tpz_exception.CoverageError(c_precision_add(volume, fee_volume * (fee_currency == currency)),
 *                                                   currency.decode())
 *             elif coverage == b'partial':             # <<<<<<<<<<<<<<
 *                 volume = c_precision_subtract(currency_position, fee_volume * (fee_currency == currency))
 *                 # in currency
 */
      goto __pyx_L5;
    }

    /* "trapeza/account/fx_account.pyx":828
 *                                                      'Transaction not feasible even though coverage set '
 *                                                      'to partial. Fees not covered')
 *             elif coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self._c_check_marked_coverage = 0
 * 
 */
    __pyx_t_16 = ((__pyx_v_coverage == ((char const *)"debit")) != 0);
    if (__pyx_t_16) {

      /* "trapeza/account/fx_account.pyx":829
 *                                                      'to partial. Fees not covered')
 *             elif coverage == b'debit':
 *                 self._c_check_marked_coverage = 0             # <<<<<<<<<<<<<<
 * 
 *         # >>>check coverage
 */
      __pyx_v_self->_c_check_marked_coverage = 0;

      /* "trapeza/account/fx_account.pyx":828
 *                                                      'Transaction not feasible even though coverage set '
 *                                                      'to partial. Fees not covered')
 *             elif coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self._c_check_marked_coverage = 0
 * 
 */
    }
    __pyx_L5:;

    /* "trapeza/account/fx_account.pyx":813
 *         # volume is in currency
 *         cdef double currency_position = self._c_depot[currency]
 *         if currency_position < c_precision_add(volume, fee_volume * (fee_currency == currency)):             # <<<<<<<<<<<<<<
 *             if coverage == b'except':
 *                 if self._c_is_heap:
 */
  }

  /* "trapeza/account/fx_account.pyx":832
 * 
 *         # >>>check coverage
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == currency)), currency,             # <<<<<<<<<<<<<<
 *                                self._c_clock + processing_duration)
 *         if fee_volume > 0:
 */
  __pyx_t_17 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume, (__pyx_v_fee_volume * (__pyx_v_fee_currency == __pyx_v_currency))), __pyx_v_currency, (__pyx_v_self->_c_clock + __pyx_v_processing_duration), 0, NULL); if (unlikely(__pyx_t_17 == ((double)-1.0))) __PYX_ERR(0, 832, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":834
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == currency)), currency,
 *                                self._c_clock + processing_duration)
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # when withdrawing, there is no depositing transaction onto the account
 *             # so we do not have to take different processing duration of withdrawal and fee billing into account as
 */
  __pyx_t_16 = ((__pyx_v_fee_volume > 0.0) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":838
 *             # so we do not have to take different processing duration of withdrawal and fee billing into account as
 *             # billed fees cannot be offset by any incoming deposits within this code block
 *             self._c_check_coverage(fee_volume, fee_currency,             # <<<<<<<<<<<<<<
 *                                    self._c_clock + fee_exec_duration * (1 - instant_float_fee))
 * 
 */
    __pyx_t_17 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_check_coverage(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_self->_c_clock + (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee))), 0, NULL); if (unlikely(__pyx_t_17 == ((double)-1.0))) __PYX_ERR(0, 838, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":834
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == currency)), currency,
 *                                self._c_clock + processing_duration)
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # when withdrawing, there is no depositing transaction onto the account
 *             # so we do not have to take different processing duration of withdrawal and fee billing into account as
 */
  }

  /* "trapeza/account/fx_account.pyx":842
 * 
 *         # >>>instant execution
 *         if processing_duration <= 0:             # <<<<<<<<<<<<<<
 *             # execute
 *             self._c_depot[currency] = c_precision_subtract(currency_position, volume)
 */
  __pyx_t_16 = ((__pyx_v_processing_duration <= 0) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":844
 *         if processing_duration <= 0:
 *             # execute
 *             self._c_depot[currency] = c_precision_subtract(currency_position, volume)             # <<<<<<<<<<<<<<
 *         # >>>delayed transaction caused by necessary execution duration
 *         else:
 */
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_subtract(__pyx_v_currency_position, __pyx_v_volume)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 844, __pyx_L1_error)
    }
    __pyx_t_9 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (unlikely(PyDict_SetItem(__pyx_v_self->_c_depot, __pyx_t_9, __pyx_t_2) < 0)) __PYX_ERR(0, 844, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "trapeza/account/fx_account.pyx":842
 * 
 *         # >>>instant execution
 *         if processing_duration <= 0:             # <<<<<<<<<<<<<<
 *             # execute
 *             self._c_depot[currency] = c_precision_subtract(currency_position, volume)
 */
    goto __pyx_L10;
  }

  /* "trapeza/account/fx_account.pyx":851
 *             # reduced, which does not follow the principle of least surprise. Instead turn 'partial' to except, which
 *             # is a more conservative guess (therefore just don't provide **kwargs, as 'except' is default value)
 *             if coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_withdraw', volume, currency,
 *                                         coverage])
 */
  /*else*/ {
    __pyx_t_16 = ((__pyx_v_coverage == ((char const *)"debit")) != 0);
    if (__pyx_t_16) {

      /* "trapeza/account/fx_account.pyx":852
 *             # is a more conservative guess (therefore just don't provide **kwargs, as 'except' is default value)
 *             if coverage == b'debit':
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_withdraw', volume, currency,             # <<<<<<<<<<<<<<
 *                                         coverage])
 *             else:
 */
      __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_self->_c_clock + __pyx_v_processing_duration)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);

      /* "trapeza/account/fx_account.pyx":853
 *             if coverage == b'debit':
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_withdraw', volume, currency,
 *                                         coverage])             # <<<<<<<<<<<<<<
 *             else:
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_withdraw', volume, currency])
 */
      __pyx_t_14 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_coverage); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 853, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);

      /* "trapeza/account/fx_account.pyx":852
 *             # is a more conservative guess (therefore just don't provide **kwargs, as 'except' is default value)
 *             if coverage == b'debit':
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_withdraw', volume, currency,             # <<<<<<<<<<<<<<
 *                                         coverage])
 *             else:
 */
      __pyx_t_11 = PyList_New(5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_11, 0, __pyx_t_2);
      __Pyx_INCREF(__pyx_n_b_c_withdraw);
      __Pyx_GIVEREF(__pyx_n_b_c_withdraw);
      PyList_SET_ITEM(__pyx_t_11, 1, __pyx_n_b_c_withdraw);
      __Pyx_GIVEREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_11, 2, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_10);
      PyList_SET_ITEM(__pyx_t_11, 3, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_14);
      PyList_SET_ITEM(__pyx_t_11, 4, __pyx_t_14);
      __pyx_t_2 = 0;
      __pyx_t_9 = 0;
      __pyx_t_10 = 0;
      __pyx_t_14 = 0;
      ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->heappush(__pyx_v_self->vec_heap, ((PyObject*)__pyx_t_11));
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "trapeza/account/fx_account.pyx":851
 *             # reduced, which does not follow the principle of least surprise. Instead turn 'partial' to except, which
 *             # is a more conservative guess (therefore just don't provide **kwargs, as 'except' is default value)
 *             if coverage == b'debit':             # <<<<<<<<<<<<<<
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_withdraw', volume, currency,
 *                                         coverage])
 */
      goto __pyx_L11;
    }

    /* "trapeza/account/fx_account.pyx":855
 *                                         coverage])
 *             else:
 *                 self.vec_heap.heappush([self._c_clock + processing_duration, b'c_withdraw', volume, currency])             # <<<<<<<<<<<<<<
 * 
 *         # >>>handle fees
 */
    /*else*/ {
      __pyx_t_11 = __Pyx_PyInt_From_long((__pyx_v_self->_c_clock + __pyx_v_processing_duration)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 855, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_14 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 855, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_10 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 855, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_9 = PyList_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 855, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_11);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_11);
      __Pyx_INCREF(__pyx_n_b_c_withdraw);
      __Pyx_GIVEREF(__pyx_n_b_c_withdraw);
      PyList_SET_ITEM(__pyx_t_9, 1, __pyx_n_b_c_withdraw);
      __Pyx_GIVEREF(__pyx_t_14);
      PyList_SET_ITEM(__pyx_t_9, 2, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_10);
      PyList_SET_ITEM(__pyx_t_9, 3, __pyx_t_10);
      __pyx_t_11 = 0;
      __pyx_t_14 = 0;
      __pyx_t_10 = 0;
      ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_v_self->vec_heap->__pyx_vtab)->heappush(__pyx_v_self->vec_heap, ((PyObject*)__pyx_t_9));
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __pyx_L11:;
  }
  __pyx_L10:;

  /* "trapeza/account/fx_account.pyx":859
 *         # >>>handle fees
 *         cdef string propagate_coverage
 *         if coverage == b'partial':             # <<<<<<<<<<<<<<
 *             propagate_coverage = b'except'
 *         else:
 */
  __pyx_t_16 = ((__pyx_v_coverage == ((char const *)"partial")) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":860
 *         cdef string propagate_coverage
 *         if coverage == b'partial':
 *             propagate_coverage = b'except'             # <<<<<<<<<<<<<<
 *         else:
 *             propagate_coverage = coverage
 */
    __pyx_t_18 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 860, __pyx_L1_error)
    __pyx_v_propagate_coverage = __pyx_t_18;

    /* "trapeza/account/fx_account.pyx":859
 *         # >>>handle fees
 *         cdef string propagate_coverage
 *         if coverage == b'partial':             # <<<<<<<<<<<<<<
 *             propagate_coverage = b'except'
 *         else:
 */
    goto __pyx_L12;
  }

  /* "trapeza/account/fx_account.pyx":862
 *             propagate_coverage = b'except'
 *         else:
 *             propagate_coverage = coverage             # <<<<<<<<<<<<<<
 *         if fee_volume > 0:
 *             self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,
 */
  /*else*/ {
    __pyx_v_propagate_coverage = __pyx_v_coverage;
  }
  __pyx_L12:;

  /* "trapeza/account/fx_account.pyx":863
 *         else:
 *             propagate_coverage = coverage
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,
 *                              fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 */
  __pyx_t_16 = ((__pyx_v_fee_volume > 0.0) != 0);
  if (__pyx_t_16) {

    /* "trapeza/account/fx_account.pyx":864
 *             propagate_coverage = coverage
 *         if fee_volume > 0:
 *             self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,             # <<<<<<<<<<<<<<
 *                              fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 *                              forward_coverage=propagate_coverage)
 */
    __pyx_t_19.__pyx_n = 1;
    __pyx_t_19.forward_coverage = __pyx_v_propagate_coverage;
    __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_fill_fee(__pyx_v_self, __pyx_v_fee_volume, __pyx_v_fee_currency, (__pyx_v_fee_exec_duration * (1 - __pyx_v_instant_float_fee)), &__pyx_t_19); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 864, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":863
 *         else:
 *             propagate_coverage = coverage
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self._c_fill_fee(fee_volume=fee_volume, fee_currency=fee_currency,
 *                              fee_exec_duration=fee_exec_duration * (1 - instant_float_fee),
 */
  }

  /* "trapeza/account/fx_account.pyx":869
 * 
 *         # >>>restore
 *         self._c_check_marked_coverage = curr_check_marked_coverage             # <<<<<<<<<<<<<<
 * 
 *         # >>>return confirmation
 */
  __pyx_v_self->_c_check_marked_coverage = __pyx_v_curr_check_marked_coverage;

  /* "trapeza/account/fx_account.pyx":872
 * 
 *         # >>>return confirmation
 *         return self._c_confirmation(processing_duration)             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __pyx_t_15 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_c_confirmation(__pyx_v_self, __pyx_v_processing_duration); if (unlikely(__pyx_t_15 == ((short)-1))) __PYX_ERR(0, 872, __pyx_L1_error)
  __pyx_r = __pyx_t_15;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":781
 * 
 *     @cython.wraparound(False)
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                          string fee_currency=b'default', long fee_exec_duration=0,
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_withdraw", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -9999;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21c_withdraw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_20c_withdraw[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.withdraw for further information.\n        \n        THIS METHOD IMPLEMENTS A SLIGHTLY DIFFERENT ORDER OF ARGUMENTS THAN FXAccount!\n        \n        :param volume: double, volume given in currency\n        :param currency: std:string\n        :param processing_duration: long, processing time (delay) in time base units of internal clock\n        :param fee_volume: double, volume given in fee_currency\n        :param fee_currency: std:string, if b'default' then param:currency is used\n        :param fee_exec_duration: long, processing time (delay) in time base units of internal clock\n        :param coverage: std:string {b'partial', b'except', b'debit'}, default=b'except'\n                         see FXAccount.withdraw for details\n                         b'ignore' not available on purpose\n        :param instant_float_fee: std:bool, \n                                  see FXAccount.withdraw for details\n        :return: confirmation: short, confirmation states --> 0: processing (processing_duration), 1: executed\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21c_withdraw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_volume;
  std::string __pyx_v_currency;
  long __pyx_v_processing_duration;
  double __pyx_v_fee_volume;
  std::string __pyx_v_fee_currency;
  long __pyx_v_fee_exec_duration;
  std::string __pyx_v_coverage;
  bool __pyx_v_instant_float_fee;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_withdraw (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_volume,&__pyx_n_s_currency,&__pyx_n_s_processing_duration,&__pyx_n_s_fee_volume,&__pyx_n_s_fee_currency,&__pyx_n_s_fee_exec_duration,&__pyx_n_s_coverage,&__pyx_n_s_instant_float_fee,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_withdraw", 0, 2, 8, 1); __PYX_ERR(0, 781, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_volume);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_currency);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_exec_duration);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coverage);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_float_fee);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "c_withdraw") < 0)) __PYX_ERR(0, 781, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 781, __pyx_L3_error)
    __pyx_v_currency = __pyx_convert_string_from_py_std__in_string(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 781, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_processing_duration = __Pyx_PyInt_As_long(values[2]); if (unlikely((__pyx_v_processing_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 781, __pyx_L3_error)
    } else {
      __pyx_v_processing_duration = ((long)0);
    }
    if (values[3]) {
      __pyx_v_fee_volume = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_fee_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 781, __pyx_L3_error)
    } else {
      __pyx_v_fee_volume = ((double)0.0);
    }
    if (values[4]) {
      __pyx_v_fee_currency = __pyx_convert_string_from_py_std__in_string(values[4]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 782, __pyx_L3_error)
    } else {
      __pyx_v_fee_currency = __pyx_k__10;
    }
    if (values[5]) {
      __pyx_v_fee_exec_duration = __Pyx_PyInt_As_long(values[5]); if (unlikely((__pyx_v_fee_exec_duration == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 782, __pyx_L3_error)
    } else {
      __pyx_v_fee_exec_duration = ((long)0);
    }
    if (values[6]) {
      __pyx_v_coverage = __pyx_convert_string_from_py_std__in_string(values[6]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 783, __pyx_L3_error)
    } else {
      __pyx_v_coverage = __pyx_k__11;
    }
    if (values[7]) {
      __pyx_v_instant_float_fee = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_instant_float_fee == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 783, __pyx_L3_error)
    } else {

      /* "trapeza/account/fx_account.pyx":783
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,
 *                          string fee_currency=b'default', long fee_exec_duration=0,
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.withdraw for further information.
 */
      __pyx_v_instant_float_fee = ((bool)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("c_withdraw", 0, 2, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 781, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_withdraw", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_20c_withdraw(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_volume, __pyx_v_currency, __pyx_v_processing_duration, __pyx_v_fee_volume, __pyx_v_fee_currency, __pyx_v_fee_exec_duration, __pyx_v_coverage, __pyx_v_instant_float_fee);

  /* "trapeza/account/fx_account.pyx":781
 * 
 *     @cython.wraparound(False)
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,             # <<<<<<<<<<<<<<
 *                          string fee_currency=b'default', long fee_exec_duration=0,
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_20c_withdraw(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_volume, std::string __pyx_v_currency, long __pyx_v_processing_duration, double __pyx_v_fee_volume, std::string __pyx_v_fee_currency, long __pyx_v_fee_exec_duration, std::string __pyx_v_coverage, bool __pyx_v_instant_float_fee) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_withdraw", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 6;
  __pyx_t_2.processing_duration = __pyx_v_processing_duration;
  __pyx_t_2.fee_volume = __pyx_v_fee_volume;
  __pyx_t_2.fee_currency = __pyx_v_fee_currency;
  __pyx_t_2.fee_exec_duration = __pyx_v_fee_exec_duration;
  __pyx_t_2.coverage = __pyx_v_coverage;
  __pyx_t_2.instant_float_fee = __pyx_v_instant_float_fee;
  __pyx_t_1 = __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount->c_withdraw(__pyx_v_self, __pyx_v_volume, __pyx_v_currency, 1, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((short)-9999))) __PYX_ERR(0, 781, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_withdraw", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":876
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cpdef long c_tick(self, long clock) except? -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.tick for further information.
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_23c_tick(PyObject *__pyx_v_self, PyObject *__pyx_arg_clock); /*proto*/
static long __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_tick(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, long __pyx_v_clock, int __pyx_skip_dispatch) {
  long __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  long __pyx_t_6;
  short __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_tick", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_tick); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 876, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_23c_tick)) {
        __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_clock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 876, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_6 = __Pyx_PyInt_As_long(__pyx_t_2); if (unlikely((__pyx_t_6 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 876, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_6;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":885
 *         :return: long, current (freshly set) clock time
 *         """
 *         self._c_clock = clock             # <<<<<<<<<<<<<<
 * 
 *         self._execute_heap()
 */
  __pyx_v_self->_c_clock = __pyx_v_clock;

  /* "trapeza/account/fx_account.pyx":887
 *         self._c_clock = clock
 * 
 *         self._execute_heap()             # <<<<<<<<<<<<<<
 *         return self._c_clock
 * 
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self->__pyx_vtab)->_execute_heap(__pyx_v_self); if (unlikely(__pyx_t_7 == ((short)-1))) __PYX_ERR(0, 887, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":888
 * 
 *         self._execute_heap()
 *         return self._c_clock             # <<<<<<<<<<<<<<
 * 
 *     @cython.wraparound(False)
 */
  __pyx_r = __pyx_v_self->_c_clock;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":876
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cpdef long c_tick(self, long clock) except? -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.tick for further information.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_tick", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -9999L;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_23c_tick(PyObject *__pyx_v_self, PyObject *__pyx_arg_clock); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_22c_tick[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.tick for further information.\n        \n        Executes exec_heap after new clock time is set.\n        \n        :param clock: long >= 0\n        :return: long, current (freshly set) clock time\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_23c_tick(PyObject *__pyx_v_self, PyObject *__pyx_arg_clock) {
  long __pyx_v_clock;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_tick (wrapper)", 0);
  assert(__pyx_arg_clock); {
    __pyx_v_clock = __Pyx_PyInt_As_long(__pyx_arg_clock); if (unlikely((__pyx_v_clock == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 876, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_tick", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_22c_tick(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((long)__pyx_v_clock));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_22c_tick(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, long __pyx_v_clock) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_tick", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_tick(__pyx_v_self, __pyx_v_clock, 1); if (unlikely(__pyx_t_1 == ((long)-9999L) && PyErr_Occurred())) __PYX_ERR(0, 876, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_tick", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":891
 * 
 *     @cython.wraparound(False)
 *     cpdef short c_update_exchange_rate(self, double rate, string base, string quote) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.update_exchange_rate for
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_25c_update_exchange_rate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_update_exchange_rate(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_rate, std::string __pyx_v_base, std::string __pyx_v_quote, int __pyx_skip_dispatch) {
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  short __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_update_exchange_rate", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_update_exchange_rate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 891, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_25c_update_exchange_rate)) {
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_rate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 891, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_base); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 891, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_quote); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 891, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_6 = __pyx_t_1; __pyx_t_7 = NULL;
        __pyx_t_8 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
            __pyx_t_8 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 891, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 891, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 891, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          if (__pyx_t_7) {
            __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 891, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_10 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_10 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 891, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_10;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":908
 *         """
 *         # >>>update
 *         self._c_exchange_rates[base, quote] = rate             # <<<<<<<<<<<<<<
 *         self._c_is_exchange_rate_updated = True
 *         return 1
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_rate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_self->_c_exchange_rates == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 908, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_quote); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 908, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_6);
  __pyx_t_2 = 0;
  __pyx_t_6 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_self->_c_exchange_rates, __pyx_t_9, __pyx_t_1) < 0)) __PYX_ERR(0, 908, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":909
 *         # >>>update
 *         self._c_exchange_rates[base, quote] = rate
 *         self._c_is_exchange_rate_updated = True             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  __pyx_v_self->_c_is_exchange_rate_updated = 1;

  /* "trapeza/account/fx_account.pyx":910
 *         self._c_exchange_rates[base, quote] = rate
 *         self._c_is_exchange_rate_updated = True
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     @cython.wraparound(False)
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":891
 * 
 *     @cython.wraparound(False)
 *     cpdef short c_update_exchange_rate(self, double rate, string base, string quote) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.update_exchange_rate for
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_update_exchange_rate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_25c_update_exchange_rate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_24c_update_exchange_rate[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.update_exchange_rate for \n        further information.\n        \n        Updates internal dict structure, which is needed during calculation of self.c_total_balance().\n        It's sufficient enough, to just provide base|quote ratio. quote|base ratio does not have to be added separately\n        and will be calculated automatically.\n\n        :param rate: double,\n                     use FX direct notation of base|quote pair (see docstring of class FXAccount for further information\n                     on notation conventions)\n        :param base: std:string\n        :param quote: std:string\n        :return: 1\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_25c_update_exchange_rate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_rate;
  std::string __pyx_v_base;
  std::string __pyx_v_quote;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_update_exchange_rate (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_rate,&__pyx_n_s_base,&__pyx_n_s_quote,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rate)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_update_exchange_rate", 1, 3, 3, 1); __PYX_ERR(0, 891, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quote)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_update_exchange_rate", 1, 3, 3, 2); __PYX_ERR(0, 891, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "c_update_exchange_rate") < 0)) __PYX_ERR(0, 891, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_rate = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_rate == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 891, __pyx_L3_error)
    __pyx_v_base = __pyx_convert_string_from_py_std__in_string(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 891, __pyx_L3_error)
    __pyx_v_quote = __pyx_convert_string_from_py_std__in_string(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 891, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("c_update_exchange_rate", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 891, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_update_exchange_rate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_24c_update_exchange_rate(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_rate, __pyx_v_base, __pyx_v_quote);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_24c_update_exchange_rate(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, double __pyx_v_rate, std::string __pyx_v_base, std::string __pyx_v_quote) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_update_exchange_rate", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_update_exchange_rate(__pyx_v_self, __pyx_v_rate, __pyx_v_base, __pyx_v_quote, 1); if (unlikely(__pyx_t_1 == ((short)-1))) __PYX_ERR(0, 891, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_update_exchange_rate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":913
 * 
 *     @cython.wraparound(False)
 *     cpdef short c_batch_update_exchange_rates(self, list list_rates, list list_base_quote_pair) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.batch_update_exchange_rates
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27c_batch_update_exchange_rates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static short __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_batch_update_exchange_rates(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_list_rates, PyObject *__pyx_v_list_base_quote_pair, int __pyx_skip_dispatch) {
  int __pyx_v_i;
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  short __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_batch_update_exchange_rates", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_batch_update_exchange_rates); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 913, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27c_batch_update_exchange_rates)) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_list_rates, __pyx_v_list_base_quote_pair};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 913, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_list_rates, __pyx_v_list_base_quote_pair};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 913, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 913, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(__pyx_v_list_rates);
          __Pyx_GIVEREF(__pyx_v_list_rates);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_list_rates);
          __Pyx_INCREF(__pyx_v_list_base_quote_pair);
          __Pyx_GIVEREF(__pyx_v_list_base_quote_pair);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_list_base_quote_pair);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 913, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_7 = __Pyx_PyInt_As_short(__pyx_t_2); if (unlikely((__pyx_t_7 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 913, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_7;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":934
 *         """
 *         cdef int i
 *         for i in range(len(list_rates)):             # <<<<<<<<<<<<<<
 *             # noinspection PyUnresolvedReferences
 *             self.update_exchange_rate(list_rates[i], list_base_quote_pair[i][0], list_base_quote_pair[i][1])
 */
  if (unlikely(__pyx_v_list_rates == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 934, __pyx_L1_error)
  }
  __pyx_t_8 = PyList_GET_SIZE(__pyx_v_list_rates); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 934, __pyx_L1_error)
  __pyx_t_9 = __pyx_t_8;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_9; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "trapeza/account/fx_account.pyx":936
 *         for i in range(len(list_rates)):
 *             # noinspection PyUnresolvedReferences
 *             self.update_exchange_rate(list_rates[i], list_base_quote_pair[i][0], list_base_quote_pair[i][1])             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_exchange_rate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__pyx_v_list_rates == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 936, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_list_rates, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_list_base_quote_pair == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 936, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_list_base_quote_pair, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v_list_base_quote_pair == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 936, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_list_base_quote_pair, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_6, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_10};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 936, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_10};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 936, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 936, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_t_10);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_10 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 936, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "trapeza/account/fx_account.pyx":937
 *             # noinspection PyUnresolvedReferences
 *             self.update_exchange_rate(list_rates[i], list_base_quote_pair[i][0], list_base_quote_pair[i][1])
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     # noinspection PyUnresolvedReferences
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":913
 * 
 *     @cython.wraparound(False)
 *     cpdef short c_batch_update_exchange_rates(self, list list_rates, list list_base_quote_pair) except -1:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.batch_update_exchange_rates
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_batch_update_exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27c_batch_update_exchange_rates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_26c_batch_update_exchange_rates[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.batch_update_exchange_rates \n        for further information.\n        \n        Updates internal dict structure all at once, which is needed during calculation of self.c_total_balance().\n        Updates are done all at once in contrast to self.c_update_exchange_rate, which only updates a single \n        base|quote pair.\n        It's sufficient enough, to just provide base|quote ratio. quote|base ratio does not have to be added separately\n        and will be calculated automatically.\n\n        :param list_rates: list of floats,\n                           exchange rate of base|quote pair in FX direct notation (see docstring of class FXAccount for \n                           further information on notation conventions)\n        :param list_base_quote_pair: list of tuples(base, quote),\n                                     base|quote pair notation\n                                     base: std:string\n                                     quote: std:string\n        :return: 1\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27c_batch_update_exchange_rates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_list_rates = 0;
  PyObject *__pyx_v_list_base_quote_pair = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_batch_update_exchange_rates (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_list_rates,&__pyx_n_s_list_base_quote_pair,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_list_rates)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_list_base_quote_pair)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_batch_update_exchange_rates", 1, 2, 2, 1); __PYX_ERR(0, 913, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "c_batch_update_exchange_rates") < 0)) __PYX_ERR(0, 913, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_list_rates = ((PyObject*)values[0]);
    __pyx_v_list_base_quote_pair = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("c_batch_update_exchange_rates", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 913, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_batch_update_exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_list_rates), (&PyList_Type), 1, "list_rates", 1))) __PYX_ERR(0, 913, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_list_base_quote_pair), (&PyList_Type), 1, "list_base_quote_pair", 1))) __PYX_ERR(0, 913, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_26c_batch_update_exchange_rates(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_list_rates, __pyx_v_list_base_quote_pair);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_26c_batch_update_exchange_rates(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_list_rates, PyObject *__pyx_v_list_base_quote_pair) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_batch_update_exchange_rates", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_batch_update_exchange_rates(__pyx_v_self, __pyx_v_list_rates, __pyx_v_list_base_quote_pair, 1); if (unlikely(__pyx_t_1 == ((short)-1))) __PYX_ERR(0, 913, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_short(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 913, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_batch_update_exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":941
 *     # noinspection PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef double c_total_balance(self, dict exchange_rates, string reference_currency) except? -1.7e+250:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.total_balance for further information.
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_29c_total_balance(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static double __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_total_balance(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_exchange_rates, std::string __pyx_v_reference_currency, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ext_currencies = 0;
  PyObject *__pyx_v_int_currencies = 0;
  double __pyx_v_balance;
  bool __pyx_v_is_base_quote_notation;
  bool __pyx_v_is_quote_base_notation;
  std::string __pyx_v_currency;
  double __pyx_v_currency_position;
  double __pyx_v_ex_rate;
  double __pyx_v_inv_ex_rate;
  struct __pyx_obj_7trapeza_7account_14execution_heap_DictKeysToVec *__pyx_v_currency_pairs = 0;
  PyObject *__pyx_7genexpr__pyx_v_pair_i = NULL;
  PyObject *__pyx_7genexpr__pyx_v_cur_i = NULL;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  double __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  std::string __pyx_t_15;
  __pyx_ctuple_bool__and_bool__and_double__and_double __pyx_t_16;
  bool __pyx_t_17;
  bool __pyx_t_18;
  double __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_total_balance", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_total_balance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 941, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_29c_total_balance)) {
        __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_reference_currency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 941, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_6 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_exchange_rates, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 941, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_exchange_rates, __pyx_t_3};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 941, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 941, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_INCREF(__pyx_v_exchange_rates);
          __Pyx_GIVEREF(__pyx_v_exchange_rates);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_exchange_rates);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 941, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 941, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_8;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":975
 *         cdef bytes cur_i
 *         cdef tuple pair_i
 *         ext_currencies = {cur_i for pair_i in exchange_rates.keys() for cur_i in pair_i}             # <<<<<<<<<<<<<<
 *         # get currencies which are currently in self.depot
 *         int_currencies = set(self._c_depot.keys())
 */
  { /* enter inner scope */
    __pyx_t_1 = PySet_New(NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 975, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = 0;
    if (unlikely(__pyx_v_exchange_rates == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "keys");
      __PYX_ERR(0, 975, __pyx_L5_error)
    }
    __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_exchange_rates, 1, __pyx_n_s_keys, (&__pyx_t_10), (&__pyx_t_6)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 975, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_4;
    __pyx_t_4 = 0;
    while (1) {
      __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_10, &__pyx_t_9, &__pyx_t_4, NULL, NULL, __pyx_t_6);
      if (unlikely(__pyx_t_11 == 0)) break;
      if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 975, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 975, __pyx_L5_error)
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_pair_i, ((PyObject*)__pyx_t_4));
      __pyx_t_4 = 0;
      if (unlikely(__pyx_7genexpr__pyx_v_pair_i == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 975, __pyx_L5_error)
      }
      __pyx_t_4 = __pyx_7genexpr__pyx_v_pair_i; __Pyx_INCREF(__pyx_t_4); __pyx_t_12 = 0;
      for (;;) {
        if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_12); __Pyx_INCREF(__pyx_t_7); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 975, __pyx_L5_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 975, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        if (!(likely(PyBytes_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(0, 975, __pyx_L5_error)
        __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_cur_i, ((PyObject*)__pyx_t_7));
        __pyx_t_7 = 0;
        if (unlikely(PySet_Add(__pyx_t_1, (PyObject*)__pyx_7genexpr__pyx_v_cur_i))) __PYX_ERR(0, 975, __pyx_L5_error)
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_cur_i); __pyx_7genexpr__pyx_v_cur_i = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_pair_i); __pyx_7genexpr__pyx_v_pair_i = 0;
    goto __pyx_L10_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_cur_i); __pyx_7genexpr__pyx_v_cur_i = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_pair_i); __pyx_7genexpr__pyx_v_pair_i = 0;
    goto __pyx_L1_error;
    __pyx_L10_exit_scope:;
  } /* exit inner scope */
  __pyx_v_ext_currencies = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":977
 *         ext_currencies = {cur_i for pair_i in exchange_rates.keys() for cur_i in pair_i}
 *         # get currencies which are currently in self.depot
 *         int_currencies = set(self._c_depot.keys())             # <<<<<<<<<<<<<<
 *         # check if int_currencies is a subset of ext_currencies
 *         if not int_currencies.issubset(ext_currencies):
 */
  if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "keys");
    __PYX_ERR(0, 977, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_Keys(__pyx_v_self->_c_depot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_int_currencies = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "trapeza/account/fx_account.pyx":979
 *         int_currencies = set(self._c_depot.keys())
 *         # check if int_currencies is a subset of ext_currencies
 *         if not int_currencies.issubset(ext_currencies):             # <<<<<<<<<<<<<<
 *             raise KeyError('exchange_rates does not include all currencies listed in account depot. '
 *                            'Currencies in current depot: {}. '
 */
  __pyx_t_2 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PySet_Type_issubset, __pyx_v_int_currencies, __pyx_v_ext_currencies); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 979, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 979, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_14 = ((!__pyx_t_13) != 0);
  if (unlikely(__pyx_t_14)) {

    /* "trapeza/account/fx_account.pyx":982
 *             raise KeyError('exchange_rates does not include all currencies listed in account depot. '
 *                            'Currencies in current depot: {}. '
 *                            'Currencies given by exchange_rates: {}'.format(int_currencies, ext_currencies))             # <<<<<<<<<<<<<<
 * 
 *         # >>>calculate total balance
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_exchange_rates_does_not_include, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 982, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_int_currencies, __pyx_v_ext_currencies};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 982, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_int_currencies, __pyx_v_ext_currencies};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 982, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 982, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_int_currencies);
      __Pyx_GIVEREF(__pyx_v_int_currencies);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_int_currencies);
      __Pyx_INCREF(__pyx_v_ext_currencies);
      __Pyx_GIVEREF(__pyx_v_ext_currencies);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_ext_currencies);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 982, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":980
 *         # check if int_currencies is a subset of ext_currencies
 *         if not int_currencies.issubset(ext_currencies):
 *             raise KeyError('exchange_rates does not include all currencies listed in account depot. '             # <<<<<<<<<<<<<<
 *                            'Currencies in current depot: {}. '
 *                            'Currencies given by exchange_rates: {}'.format(int_currencies, ext_currencies))
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 980, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 980, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":979
 *         int_currencies = set(self._c_depot.keys())
 *         # check if int_currencies is a subset of ext_currencies
 *         if not int_currencies.issubset(ext_currencies):             # <<<<<<<<<<<<<<
 *             raise KeyError('exchange_rates does not include all currencies listed in account depot. '
 *                            'Currencies in current depot: {}. '
 */
  }

  /* "trapeza/account/fx_account.pyx":993
 *         cdef double inv_ex_rate
 * 
 *         cdef DictKeysToVec currency_pairs = DictKeysToVec(exchange_rates)             # <<<<<<<<<<<<<<
 * 
 *         for currency, currency_position in self._c_depot.items():
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_7trapeza_7account_14execution_heap_DictKeysToVec), __pyx_v_exchange_rates); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 993, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_currency_pairs = ((struct __pyx_obj_7trapeza_7account_14execution_heap_DictKeysToVec *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":995
 *         cdef DictKeysToVec currency_pairs = DictKeysToVec(exchange_rates)
 * 
 *         for currency, currency_position in self._c_depot.items():             # <<<<<<<<<<<<<<
 *             if currency != reference_currency:
 *                 # not in reference currency, so we have to convert
 */
  __pyx_t_10 = 0;
  if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
    __PYX_ERR(0, 995, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_self->_c_depot, 1, __pyx_n_s_items, (&__pyx_t_9), (&__pyx_t_6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 995, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_2;
  __pyx_t_2 = 0;
  while (1) {
    __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_9, &__pyx_t_10, &__pyx_t_2, &__pyx_t_7, NULL, __pyx_t_6);
    if (unlikely(__pyx_t_11 == 0)) break;
    if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 995, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_15 = __pyx_convert_string_from_py_std__in_string(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 995, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 995, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_currency = __pyx_t_15;
    __pyx_v_currency_position = __pyx_t_8;

    /* "trapeza/account/fx_account.pyx":996
 * 
 *         for currency, currency_position in self._c_depot.items():
 *             if currency != reference_currency:             # <<<<<<<<<<<<<<
 *                 # not in reference currency, so we have to convert
 *                 # only base|quote, but not quote|base
 */
    __pyx_t_14 = ((__pyx_v_currency != __pyx_v_reference_currency) != 0);
    if (__pyx_t_14) {

      /* "trapeza/account/fx_account.pyx":1000
 *                 # only base|quote, but not quote|base
 *                 (is_base_quote_notation, is_quote_base_notation,
 *                  ex_rate, inv_ex_rate) = currency_pairs.is_tuple_key_in_tuple_vec(currency, reference_currency)             # <<<<<<<<<<<<<<
 *                 if is_base_quote_notation:
 *                     balance = c_precision_add(balance, c_precision_multiply(ex_rate, currency_position))
 */
      __pyx_t_16 = ((struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_DictKeysToVec *)__pyx_v_currency_pairs->__pyx_vtab)->is_tuple_key_in_tuple_vec(__pyx_v_currency_pairs, __pyx_v_currency, __pyx_v_reference_currency);
      __pyx_t_17 = __pyx_t_16.f0;
      __pyx_t_18 = __pyx_t_16.f1;
      __pyx_t_8 = __pyx_t_16.f2;
      __pyx_t_19 = __pyx_t_16.f3;
      __pyx_v_is_base_quote_notation = __pyx_t_17;
      __pyx_v_is_quote_base_notation = __pyx_t_18;
      __pyx_v_ex_rate = __pyx_t_8;
      __pyx_v_inv_ex_rate = __pyx_t_19;

      /* "trapeza/account/fx_account.pyx":1001
 *                 (is_base_quote_notation, is_quote_base_notation,
 *                  ex_rate, inv_ex_rate) = currency_pairs.is_tuple_key_in_tuple_vec(currency, reference_currency)
 *                 if is_base_quote_notation:             # <<<<<<<<<<<<<<
 *                     balance = c_precision_add(balance, c_precision_multiply(ex_rate, currency_position))
 *                 elif is_quote_base_notation:
 */
      __pyx_t_14 = (__pyx_v_is_base_quote_notation != 0);
      if (__pyx_t_14) {

        /* "trapeza/account/fx_account.pyx":1002
 *                  ex_rate, inv_ex_rate) = currency_pairs.is_tuple_key_in_tuple_vec(currency, reference_currency)
 *                 if is_base_quote_notation:
 *                     balance = c_precision_add(balance, c_precision_multiply(ex_rate, currency_position))             # <<<<<<<<<<<<<<
 *                 elif is_quote_base_notation:
 *                     balance = c_precision_add(balance, c_precision_divide(currency_position, inv_ex_rate))
 */
        __pyx_v_balance = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_balance, __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_multiply(__pyx_v_ex_rate, __pyx_v_currency_position));

        /* "trapeza/account/fx_account.pyx":1001
 *                 (is_base_quote_notation, is_quote_base_notation,
 *                  ex_rate, inv_ex_rate) = currency_pairs.is_tuple_key_in_tuple_vec(currency, reference_currency)
 *                 if is_base_quote_notation:             # <<<<<<<<<<<<<<
 *                     balance = c_precision_add(balance, c_precision_multiply(ex_rate, currency_position))
 *                 elif is_quote_base_notation:
 */
        goto __pyx_L15;
      }

      /* "trapeza/account/fx_account.pyx":1003
 *                 if is_base_quote_notation:
 *                     balance = c_precision_add(balance, c_precision_multiply(ex_rate, currency_position))
 *                 elif is_quote_base_notation:             # <<<<<<<<<<<<<<
 *                     balance = c_precision_add(balance, c_precision_divide(currency_position, inv_ex_rate))
 *                 else:
 */
      __pyx_t_14 = (__pyx_v_is_quote_base_notation != 0);
      if (likely(__pyx_t_14)) {

        /* "trapeza/account/fx_account.pyx":1004
 *                     balance = c_precision_add(balance, c_precision_multiply(ex_rate, currency_position))
 *                 elif is_quote_base_notation:
 *                     balance = c_precision_add(balance, c_precision_divide(currency_position, inv_ex_rate))             # <<<<<<<<<<<<<<
 *                 else:
 *                     # this theoretically should never happen
 */
        __pyx_v_balance = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_balance, __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_divide(__pyx_v_currency_position, __pyx_v_inv_ex_rate));

        /* "trapeza/account/fx_account.pyx":1003
 *                 if is_base_quote_notation:
 *                     balance = c_precision_add(balance, c_precision_multiply(ex_rate, currency_position))
 *                 elif is_quote_base_notation:             # <<<<<<<<<<<<<<
 *                     balance = c_precision_add(balance, c_precision_divide(currency_position, inv_ex_rate))
 *                 else:
 */
        goto __pyx_L15;
      }

      /* "trapeza/account/fx_account.pyx":1008
 *                     # this theoretically should never happen
 *                     # noinspection PyUnresolvedReferences
 *                     raise KeyError('{}|{} or {}|{} are not included in '             # <<<<<<<<<<<<<<
 *                                    'exchange_rates.'.format(currency.decode(), reference_currency.decode(),
 *                                                             reference_currency.decode(), currency.decode()))
 */
      /*else*/ {

        /* "trapeza/account/fx_account.pyx":1009
 *                     # noinspection PyUnresolvedReferences
 *                     raise KeyError('{}|{} or {}|{} are not included in '
 *                                    'exchange_rates.'.format(currency.decode(), reference_currency.decode(),             # <<<<<<<<<<<<<<
 *                                                             reference_currency.decode(), currency.decode()))
 *                 # if both notation variants are present in exchange_rate, then we have to check, if both rates are
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_or_are_not_included_in_exchange, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1009, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_decode_cpp_string(__pyx_v_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1009, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __Pyx_decode_cpp_string(__pyx_v_reference_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1009, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);

        /* "trapeza/account/fx_account.pyx":1010
 *                     raise KeyError('{}|{} or {}|{} are not included in '
 *                                    'exchange_rates.'.format(currency.decode(), reference_currency.decode(),
 *                                                             reference_currency.decode(), currency.decode()))             # <<<<<<<<<<<<<<
 *                 # if both notation variants are present in exchange_rate, then we have to check, if both rates are
 *                 # equivalent (respectively, one of them is inverted to check equality)
 */
        __pyx_t_5 = __Pyx_decode_cpp_string(__pyx_v_reference_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1010, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_20 = __Pyx_decode_cpp_string(__pyx_v_currency, 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1010, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_20);
        __pyx_t_21 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_21)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_21);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_11 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[5] = {__pyx_t_21, __pyx_t_4, __pyx_t_3, __pyx_t_5, __pyx_t_20};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1009, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[5] = {__pyx_t_21, __pyx_t_4, __pyx_t_3, __pyx_t_5, __pyx_t_20};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 4+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1009, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        } else
        #endif
        {
          __pyx_t_22 = PyTuple_New(4+__pyx_t_11); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1009, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_22);
          if (__pyx_t_21) {
            __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_21); __pyx_t_21 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_11, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_11, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_22, 2+__pyx_t_11, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_20);
          PyTuple_SET_ITEM(__pyx_t_22, 3+__pyx_t_11, __pyx_t_20);
          __pyx_t_4 = 0;
          __pyx_t_3 = 0;
          __pyx_t_5 = 0;
          __pyx_t_20 = 0;
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_22, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1009, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "trapeza/account/fx_account.pyx":1008
 *                     # this theoretically should never happen
 *                     # noinspection PyUnresolvedReferences
 *                     raise KeyError('{}|{} or {}|{} are not included in '             # <<<<<<<<<<<<<<
 *                                    'exchange_rates.'.format(currency.decode(), reference_currency.decode(),
 *                                                             reference_currency.decode(), currency.decode()))
 */
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1008, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(0, 1008, __pyx_L1_error)
      }
      __pyx_L15:;

      /* "trapeza/account/fx_account.pyx":1013
 *                 # if both notation variants are present in exchange_rate, then we have to check, if both rates are
 *                 # equivalent (respectively, one of them is inverted to check equality)
 *                 if is_base_quote_notation and is_quote_base_notation:             # <<<<<<<<<<<<<<
 *                     if ex_rate != c_precision_divide(1, inv_ex_rate):
 *                         raise ValueError('Exchange rates of base|quote and 1/quote|base do not match up.')
 */
      __pyx_t_13 = (__pyx_v_is_base_quote_notation != 0);
      if (__pyx_t_13) {
      } else {
        __pyx_t_14 = __pyx_t_13;
        goto __pyx_L17_bool_binop_done;
      }
      __pyx_t_13 = (__pyx_v_is_quote_base_notation != 0);
      __pyx_t_14 = __pyx_t_13;
      __pyx_L17_bool_binop_done:;
      if (__pyx_t_14) {

        /* "trapeza/account/fx_account.pyx":1014
 *                 # equivalent (respectively, one of them is inverted to check equality)
 *                 if is_base_quote_notation and is_quote_base_notation:
 *                     if ex_rate != c_precision_divide(1, inv_ex_rate):             # <<<<<<<<<<<<<<
 *                         raise ValueError('Exchange rates of base|quote and 1/quote|base do not match up.')
 *             else:
 */
        __pyx_t_14 = ((__pyx_v_ex_rate != __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_divide(1.0, __pyx_v_inv_ex_rate)) != 0);
        if (unlikely(__pyx_t_14)) {

          /* "trapeza/account/fx_account.pyx":1015
 *                 if is_base_quote_notation and is_quote_base_notation:
 *                     if ex_rate != c_precision_divide(1, inv_ex_rate):
 *                         raise ValueError('Exchange rates of base|quote and 1/quote|base do not match up.')             # <<<<<<<<<<<<<<
 *             else:
 *                 # already in reference currency, so just add
 */
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1015, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_Raise(__pyx_t_2, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __PYX_ERR(0, 1015, __pyx_L1_error)

          /* "trapeza/account/fx_account.pyx":1014
 *                 # equivalent (respectively, one of them is inverted to check equality)
 *                 if is_base_quote_notation and is_quote_base_notation:
 *                     if ex_rate != c_precision_divide(1, inv_ex_rate):             # <<<<<<<<<<<<<<
 *                         raise ValueError('Exchange rates of base|quote and 1/quote|base do not match up.')
 *             else:
 */
        }

        /* "trapeza/account/fx_account.pyx":1013
 *                 # if both notation variants are present in exchange_rate, then we have to check, if both rates are
 *                 # equivalent (respectively, one of them is inverted to check equality)
 *                 if is_base_quote_notation and is_quote_base_notation:             # <<<<<<<<<<<<<<
 *                     if ex_rate != c_precision_divide(1, inv_ex_rate):
 *                         raise ValueError('Exchange rates of base|quote and 1/quote|base do not match up.')
 */
      }

      /* "trapeza/account/fx_account.pyx":996
 * 
 *         for currency, currency_position in self._c_depot.items():
 *             if currency != reference_currency:             # <<<<<<<<<<<<<<
 *                 # not in reference currency, so we have to convert
 *                 # only base|quote, but not quote|base
 */
      goto __pyx_L14;
    }

    /* "trapeza/account/fx_account.pyx":1018
 *             else:
 *                 # already in reference currency, so just add
 *                 balance = c_precision_add(balance, currency_position)             # <<<<<<<<<<<<<<
 * 
 *         self._c_is_exchange_rate_updated = False
 */
    /*else*/ {
      __pyx_v_balance = __pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_balance, __pyx_v_currency_position);
    }
    __pyx_L14:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1020
 *                 balance = c_precision_add(balance, currency_position)
 * 
 *         self._c_is_exchange_rate_updated = False             # <<<<<<<<<<<<<<
 * 
 *         return balance
 */
  __pyx_v_self->_c_is_exchange_rate_updated = 0;

  /* "trapeza/account/fx_account.pyx":1022
 *         self._c_is_exchange_rate_updated = False
 * 
 *         return balance             # <<<<<<<<<<<<<<
 * 
 *     @cython.wraparound(False)
 */
  __pyx_r = __pyx_v_balance;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":941
 *     # noinspection PyUnresolvedReferences
 *     @cython.wraparound(False)
 *     cpdef double c_total_balance(self, dict exchange_rates, string reference_currency) except? -1.7e+250:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.total_balance for further information.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_total_balance", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = (-1.7e+250);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ext_currencies);
  __Pyx_XDECREF(__pyx_v_int_currencies);
  __Pyx_XDECREF((PyObject *)__pyx_v_currency_pairs);
  __Pyx_XDECREF(__pyx_7genexpr__pyx_v_pair_i);
  __Pyx_XDECREF(__pyx_7genexpr__pyx_v_cur_i);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_29c_total_balance(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_28c_total_balance[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.total_balance for further information.\n        \n        Calculates current value of all assets within self.depot in reference currency.\n        \n        DOES NOT CHECK IF self.exchange_rates HAS BEEN UPDATED (in contrast to FXAccount.total_balance)!\n        \n        :param exchange_rates: dict with tuple of bytes (encoded python strings) as keys\n\n                               key: (base, quote) as bytes (encoded python string) denoting currencies (or assets),\n                                    in FX direct notation  (see docstring of class FXAccount for further information\n                                    on notation conventions)\n                               value: float,\n                                      exchange_rate of base|quote pair in FX direct notation  \n                                      (see docstring of class FXAccount for further information on notation conventions)\n\n                               It's sufficient enough, to just provide base|quote ratio.\n                               quote|base ratio does not have to be added separately and will be calculated\n                               automatically (see self.c_batch_update_exchange_rates).\n                               \n                               see FXAccount.total_balance for details\n        :param reference_currency: std:string\n                                   reference_currency\n        :return: total_balance: double\n        :raises: KeyError: if exchange_rates does not include all currencies listed in account depot\n                 ValueError: if exchange rates of base|quote and 1/quote|base do not match up\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_29c_total_balance(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_exchange_rates = 0;
  std::string __pyx_v_reference_currency;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_total_balance (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_exchange_rates,&__pyx_n_s_reference_currency,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exchange_rates)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reference_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("c_total_balance", 1, 2, 2, 1); __PYX_ERR(0, 941, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "c_total_balance") < 0)) __PYX_ERR(0, 941, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_exchange_rates = ((PyObject*)values[0]);
    __pyx_v_reference_currency = __pyx_convert_string_from_py_std__in_string(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 941, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("c_total_balance", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 941, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_total_balance", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_exchange_rates), (&PyDict_Type), 1, "exchange_rates", 1))) __PYX_ERR(0, 941, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_28c_total_balance(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), __pyx_v_exchange_rates, __pyx_v_reference_currency);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_28c_total_balance(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_exchange_rates, std::string __pyx_v_reference_currency) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_total_balance", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_total_balance(__pyx_v_self, __pyx_v_exchange_rates, __pyx_v_reference_currency, 1); if (unlikely(__pyx_t_1 == ((double)(-1.7e+250)) && PyErr_Occurred())) __PYX_ERR(0, 941, __pyx_L1_error)
  __pyx_t_2 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_total_balance", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1025
 * 
 *     @cython.wraparound(False)
 *     cpdef double c_position(self, string currency) except? -1.7e+250:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.position for further information.
 */

static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_31c_position(PyObject *__pyx_v_self, PyObject *__pyx_arg_currency); /*proto*/
static double __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_position(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency, int __pyx_skip_dispatch) {
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_position", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1025, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_31c_position)) {
        __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1025, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1025, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1025, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_6;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "trapeza/account/fx_account.pyx":1036
 *         cdef double pos
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return self._c_depot[currency]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":1037
 * 
 *         try:
 *             return self._c_depot[currency]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return 0
 */
      if (unlikely(__pyx_v_self->_c_depot == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 1037, __pyx_L3_error)
      }
      __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_currency); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1037, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_c_depot, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1037, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1037, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      goto __pyx_L7_try_return;

      /* "trapeza/account/fx_account.pyx":1036
 *         cdef double pos
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return self._c_depot[currency]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "trapeza/account/fx_account.pyx":1038
 *         try:
 *             return self._c_depot[currency]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_position", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 1038, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "trapeza/account/fx_account.pyx":1039
 *             return self._c_depot[currency]
 *         except KeyError:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_r = 0.0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "trapeza/account/fx_account.pyx":1036
 *         cdef double pos
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return self._c_depot[currency]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L0;
  }

  /* "trapeza/account/fx_account.pyx":1025
 * 
 *     @cython.wraparound(False)
 *     cpdef double c_position(self, string currency) except? -1.7e+250:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.position for further information.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_position", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = (-1.7e+250);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_31c_position(PyObject *__pyx_v_self, PyObject *__pyx_arg_currency); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_30c_position[] = "\n        C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.position for further information.\n        \n        Returns current position size.\n        \n        :param currency: std:string\n        :return: position: double, volume of currency\n        ";
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_31c_position(PyObject *__pyx_v_self, PyObject *__pyx_arg_currency) {
  std::string __pyx_v_currency;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("c_position (wrapper)", 0);
  assert(__pyx_arg_currency); {
    __pyx_v_currency = __pyx_convert_string_from_py_std__in_string(__pyx_arg_currency); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1025, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_position", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_30c_position(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((std::string)__pyx_v_currency));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_30c_position(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, std::string __pyx_v_currency) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_position", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_position(__pyx_v_self, __pyx_v_currency, 1); if (unlikely(__pyx_t_1 == ((double)(-1.7e+250)) && PyErr_Occurred())) __PYX_ERR(0, 1025, __pyx_L1_error)
  __pyx_t_2 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1025, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.c_position", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":10
 * cdef class cFXAccount:
 *     # class attributes
 *     cdef public bool_t _c_is_heap             # <<<<<<<<<<<<<<
 *     cdef public bool_t _c_is_exchange_rate_updated
 *     cdef public bool_t _c_prohibit_debiting
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_is_heap); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_is_heap.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  bool __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(1, 10, __pyx_L1_error)
  __pyx_v_self->_c_is_heap = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_is_heap.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":11
 *     # class attributes
 *     cdef public bool_t _c_is_heap
 *     cdef public bool_t _c_is_exchange_rate_updated             # <<<<<<<<<<<<<<
 *     cdef public bool_t _c_prohibit_debiting
 *     cdef public string _c_reference_currency
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_is_exchange_rate_updated); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_is_exchange_rate_updated.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  bool __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(1, 11, __pyx_L1_error)
  __pyx_v_self->_c_is_exchange_rate_updated = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_is_exchange_rate_updated.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":12
 *     cdef public bool_t _c_is_heap
 *     cdef public bool_t _c_is_exchange_rate_updated
 *     cdef public bool_t _c_prohibit_debiting             # <<<<<<<<<<<<<<
 *     cdef public string _c_reference_currency
 *     cdef public dict _c_depot
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_prohibit_debiting); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_prohibit_debiting.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  bool __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __pyx_v_self->_c_prohibit_debiting = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_prohibit_debiting.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":13
 *     cdef public bool_t _c_is_exchange_rate_updated
 *     cdef public bool_t _c_prohibit_debiting
 *     cdef public string _c_reference_currency             # <<<<<<<<<<<<<<
 *     cdef public dict _c_depot
 *     cdef public dict _c_fee
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_self->_c_reference_currency); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_reference_currency.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  std::string __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_convert_string_from_py_std__in_string(__pyx_v_value); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_v_self->_c_reference_currency = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_reference_currency.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":14
 *     cdef public bool_t _c_prohibit_debiting
 *     cdef public string _c_reference_currency
 *     cdef public dict _c_depot             # <<<<<<<<<<<<<<
 *     cdef public dict _c_fee
 *     cdef public dict _c_exchange_rates
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_c_depot);
  __pyx_r = __pyx_v_self->_c_depot;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(1, 14, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_c_depot);
  __Pyx_DECREF(__pyx_v_self->_c_depot);
  __pyx_v_self->_c_depot = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_depot.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_4__del__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_4__del__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_c_depot);
  __Pyx_DECREF(__pyx_v_self->_c_depot);
  __pyx_v_self->_c_depot = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":15
 *     cdef public string _c_reference_currency
 *     cdef public dict _c_depot
 *     cdef public dict _c_fee             # <<<<<<<<<<<<<<
 *     cdef public dict _c_exchange_rates
 *     cdef readonly bool_t _c_ignore_type_checking
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_c_fee);
  __pyx_r = __pyx_v_self->_c_fee;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(1, 15, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_c_fee);
  __Pyx_DECREF(__pyx_v_self->_c_fee);
  __pyx_v_self->_c_fee = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_fee.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_4__del__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_4__del__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_c_fee);
  __Pyx_DECREF(__pyx_v_self->_c_fee);
  __pyx_v_self->_c_fee = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":16
 *     cdef public dict _c_depot
 *     cdef public dict _c_fee
 *     cdef public dict _c_exchange_rates             # <<<<<<<<<<<<<<
 *     cdef readonly bool_t _c_ignore_type_checking
 *     cdef public long _c_clock
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_c_exchange_rates);
  __pyx_r = __pyx_v_self->_c_exchange_rates;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(1, 16, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_c_exchange_rates);
  __Pyx_DECREF(__pyx_v_self->_c_exchange_rates);
  __pyx_v_self->_c_exchange_rates = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_exchange_rates.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_4__del__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_4__del__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_c_exchange_rates);
  __Pyx_DECREF(__pyx_v_self->_c_exchange_rates);
  __pyx_v_self->_c_exchange_rates = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":17
 *     cdef public dict _c_fee
 *     cdef public dict _c_exchange_rates
 *     cdef readonly bool_t _c_ignore_type_checking             # <<<<<<<<<<<<<<
 *     cdef public long _c_clock
 *     cdef public short _c_check_marked_coverage    # 0: False/ None, 1: min_backward, 2: max_forward
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_23_c_ignore_type_checking_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_23_c_ignore_type_checking_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_23_c_ignore_type_checking___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_23_c_ignore_type_checking___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_ignore_type_checking); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_ignore_type_checking.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":18
 *     cdef public dict _c_exchange_rates
 *     cdef readonly bool_t _c_ignore_type_checking
 *     cdef public long _c_clock             # <<<<<<<<<<<<<<
 *     cdef public short _c_check_marked_coverage    # 0: False/ None, 1: min_backward, 2: max_forward
 *     cdef public cFXWrapperVectorHeap vec_heap
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->_c_clock); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_clock.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyInt_As_long(__pyx_v_value); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 18, __pyx_L1_error)
  __pyx_v_self->_c_clock = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_clock.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":19
 *     cdef readonly bool_t _c_ignore_type_checking
 *     cdef public long _c_clock
 *     cdef public short _c_check_marked_coverage    # 0: False/ None, 1: min_backward, 2: max_forward             # <<<<<<<<<<<<<<
 *     cdef public cFXWrapperVectorHeap vec_heap
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_short(__pyx_v_self->_c_check_marked_coverage); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_check_marked_coverage.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  short __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyInt_As_short(__pyx_v_value); if (unlikely((__pyx_t_1 == (short)-1) && PyErr_Occurred())) __PYX_ERR(1, 19, __pyx_L1_error)
  __pyx_v_self->_c_check_marked_coverage = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount._c_check_marked_coverage.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pxd":20
 *     cdef public long _c_clock
 *     cdef public short _c_check_marked_coverage    # 0: False/ None, 1: min_backward, 2: max_forward
 *     cdef public cFXWrapperVectorHeap vec_heap             # <<<<<<<<<<<<<<
 * 
 *     # C-only interface
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap___get__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap___get__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->vec_heap));
  __pyx_r = ((PyObject *)__pyx_v_self->vec_heap);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_2__set__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_2__set__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap))))) __PYX_ERR(1, 20, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->vec_heap);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec_heap));
  __pyx_v_self->vec_heap = ((struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.vec_heap.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_4__del__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_4__del__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->vec_heap);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->vec_heap));
  __pyx_v_self->vec_heap = ((struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_33__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_33__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_32__reduce_cython__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_32__reduce_cython__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._c_check_marked_coverage, self._c_clock, self._c_depot, self._c_exchange_rates, self._c_fee, self._c_ignore_type_checking, self._c_is_exchange_rate_updated, self._c_is_heap, self._c_prohibit_debiting, self._c_reference_currency, self.vec_heap)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_short(__pyx_v_self->_c_check_marked_coverage); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->_c_clock); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_ignore_type_checking); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_is_exchange_rate_updated); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_is_heap); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_prohibit_debiting); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_self->_c_reference_currency); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(11); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->_c_depot);
  __Pyx_GIVEREF(__pyx_v_self->_c_depot);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_self->_c_depot);
  __Pyx_INCREF(__pyx_v_self->_c_exchange_rates);
  __Pyx_GIVEREF(__pyx_v_self->_c_exchange_rates);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_v_self->_c_exchange_rates);
  __Pyx_INCREF(__pyx_v_self->_c_fee);
  __Pyx_GIVEREF(__pyx_v_self->_c_fee);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_v_self->_c_fee);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_8, 7, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 8, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 9, __pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->vec_heap));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->vec_heap));
  PyTuple_SET_ITEM(__pyx_t_8, 10, ((PyObject *)__pyx_v_self->vec_heap));
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._c_check_marked_coverage, self._c_clock, self._c_depot, self._c_exchange_rates, self._c_fee, self._c_ignore_type_checking, self._c_is_exchange_rate_updated, self._c_is_heap, self._c_prohibit_debiting, self._c_reference_currency, self.vec_heap)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_8 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v__dict = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "(tree fragment)":7
 *     state = (self._c_check_marked_coverage, self._c_clock, self._c_depot, self._c_exchange_rates, self._c_fee, self._c_ignore_type_checking, self._c_is_exchange_rate_updated, self._c_is_heap, self._c_prohibit_debiting, self._c_reference_currency, self.vec_heap)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_9 = (__pyx_v__dict != Py_None);
  __pyx_t_10 = (__pyx_t_9 != 0);
  if (__pyx_t_10) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v__dict);
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._c_depot is not None or self._c_exchange_rates is not None or self._c_fee is not None or self.vec_heap is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._c_check_marked_coverage, self._c_clock, self._c_depot, self._c_exchange_rates, self._c_fee, self._c_ignore_type_checking, self._c_is_exchange_rate_updated, self._c_is_heap, self._c_prohibit_debiting, self._c_reference_currency, self.vec_heap)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._c_depot is not None or self._c_exchange_rates is not None or self._c_fee is not None or self.vec_heap is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, None), state
 */
  /*else*/ {
    __pyx_t_9 = (__pyx_v_self->_c_depot != ((PyObject*)Py_None));
    __pyx_t_11 = (__pyx_t_9 != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_10 = __pyx_t_11;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_11 = (__pyx_v_self->_c_exchange_rates != ((PyObject*)Py_None));
    __pyx_t_9 = (__pyx_t_11 != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_10 = __pyx_t_9;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_9 = (__pyx_v_self->_c_fee != ((PyObject*)Py_None));
    __pyx_t_11 = (__pyx_t_9 != 0);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_10 = __pyx_t_11;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_11 = (((PyObject *)__pyx_v_self->vec_heap) != Py_None);
    __pyx_t_9 = (__pyx_t_11 != 0);
    __pyx_t_10 = __pyx_t_9;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_10;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._c_depot is not None or self._c_exchange_rates is not None or self._c_fee is not None or self.vec_heap is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, None), state
 *     else:
 */
  __pyx_t_10 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_10) {

    /* "(tree fragment)":13
 *         use_setstate = self._c_depot is not None or self._c_exchange_rates is not None or self._c_fee is not None or self.vec_heap is not None
 *     if use_setstate:
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_pyx_unpickle_cFXAccount); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_252980303);
    __Pyx_GIVEREF(__pyx_int_252980303);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_252980303);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_8, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_8);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._c_depot is not None or self._c_exchange_rates is not None or self._c_fee is not None or self.vec_heap is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, None), state
 *     else:
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_cFXAccount__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_cFXAccount); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_252980303);
    __Pyx_GIVEREF(__pyx_int_252980303);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_252980303);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_state);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8);
    __pyx_t_6 = 0;
    __pyx_t_8 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_cFXAccount__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_35__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_35__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_34__setstate_cython__(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_10cFXAccount_34__setstate_cython__(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_cFXAccount__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_7trapeza_7account_10fx_account___pyx_unpickle_cFXAccount__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_cFXAccount, (type(self), 0xf142c4f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_cFXAccount__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.cFXAccount.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1188
 * 
 *     @property
 *     def exec_heap(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns internal heap of delayed transactions. Internally the heap is implemented as C++ vector int the
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_1exec_heap(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_exec_heap[] = "\n        Returns internal heap of delayed transactions. Internally the heap is implemented as C++ vector int the\n        cFXAccount class.\n        :return: (heap) list of lists,\n                 each sub-list is structured as follows:\n                    [int:execution_time, str:transaction_type, float:volume, str:currency, str:coverage]\n                 transaction_type is {'c_deposit', 'c_withdraw'} (or {'deposit', 'withdraw'}, gets automatically parsed\n                    to 'c_withdraw' and 'c_deposit')\n                 coverage: see docstring of FXAccount.deposit() or .withdraw()\n                 str denotes normal python string type\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_1exec_heap = {"exec_heap", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_1exec_heap, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_exec_heap};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_1exec_heap(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("exec_heap (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_exec_heap(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_exec_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("exec_heap", 0);

  /* "trapeza/account/fx_account.pyx":1200
 *                  str denotes normal python string type
 *         """
 *         return ProtectedExecHeap(self.vec_heap.tolist())             # <<<<<<<<<<<<<<
 *     @exec_heap.setter
 *     def exec_heap(self, inp):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ProtectedExecHeap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vec_heap); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_tolist); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1188
 * 
 *     @property
 *     def exec_heap(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns internal heap of delayed transactions. Internally the heap is implemented as C++ vector int the
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.exec_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1202
 *         return ProtectedExecHeap(self.vec_heap.tolist())
 *     @exec_heap.setter
 *     def exec_heap(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internal heap (and underlying C++ vector implementation). See getter method for further information.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_3exec_heap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_2exec_heap[] = "\n        Set internal heap (and underlying C++ vector implementation). See getter method for further information.\n        :param inp: list of lists (see getter) or None\n        :return: None\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_3exec_heap = {"exec_heap", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_3exec_heap, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_2exec_heap};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_3exec_heap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("exec_heap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_inp,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("exec_heap", 1, 2, 2, 1); __PYX_ERR(0, 1202, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "exec_heap") < 0)) __PYX_ERR(0, 1202, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_inp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("exec_heap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1202, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.exec_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_2exec_heap(__pyx_self, __pyx_v_self, __pyx_v_inp);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_2exec_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("exec_heap", 0);
  __Pyx_INCREF(__pyx_v_inp);

  /* "trapeza/account/fx_account.pyx":1208
 *         :return: None
 *         """
 *         inp = self._parse_exec_heap(inp, self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         self.vec_heap = cFXWrapperVectorHeap(inp)
 *     @exec_heap.deleter
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_exec_heap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_inp, __pyx_t_3};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1208, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_inp, __pyx_t_3};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1208, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1208, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_inp);
    __Pyx_GIVEREF(__pyx_v_inp);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_inp);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1208, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_inp, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1209
 *         """
 *         inp = self._parse_exec_heap(inp, self._c_ignore_type_checking)
 *         self.vec_heap = cFXWrapperVectorHeap(inp)             # <<<<<<<<<<<<<<
 *     @exec_heap.deleter
 *     def exec_heap(self):
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap), __pyx_v_inp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_vec_heap, __pyx_t_1) < 0) __PYX_ERR(0, 1209, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1202
 *         return ProtectedExecHeap(self.vec_heap.tolist())
 *     @exec_heap.setter
 *     def exec_heap(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internal heap (and underlying C++ vector implementation). See getter method for further information.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.exec_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_inp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1211
 *         self.vec_heap = cFXWrapperVectorHeap(inp)
 *     @exec_heap.deleter
 *     def exec_heap(self):             # <<<<<<<<<<<<<<
 *         del self.exec_heap
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_5exec_heap(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_5exec_heap = {"exec_heap", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_5exec_heap, METH_O, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_5exec_heap(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("exec_heap (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_4exec_heap(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_4exec_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("exec_heap", 0);

  /* "trapeza/account/fx_account.pyx":1212
 *     @exec_heap.deleter
 *     def exec_heap(self):
 *         del self.exec_heap             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (__Pyx_PyObject_DelAttrStr(__pyx_v_self, __pyx_n_s_exec_heap) < 0) __PYX_ERR(0, 1212, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1211
 *         self.vec_heap = cFXWrapperVectorHeap(inp)
 *     @exec_heap.deleter
 *     def exec_heap(self):             # <<<<<<<<<<<<<<
 *         del self.exec_heap
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.exec_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1215
 * 
 *     @property
 *     def check_marked_coverage(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns status of self.check_marked_coverage which denotes how coverage analysis is conducted for marked but
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_7check_marked_coverage(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_6check_marked_coverage[] = "\n        Returns status of self.check_marked_coverage which denotes how coverage analysis is conducted for marked but\n        not yet booked delayed transactions.\n        :return: {False, 'min_backward', 'max_forward'}\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_7check_marked_coverage = {"check_marked_coverage", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_7check_marked_coverage, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_6check_marked_coverage};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_7check_marked_coverage(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_marked_coverage (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_6check_marked_coverage(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_6check_marked_coverage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("check_marked_coverage", 0);

  /* "trapeza/account/fx_account.pyx":1221
 *         :return: {False, 'min_backward', 'max_forward'}
 *         """
 *         if self._c_check_marked_coverage == 0:             # <<<<<<<<<<<<<<
 *             return False
 *         elif self._c_check_marked_coverage == 1:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_check_marked_coverage); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1221, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "trapeza/account/fx_account.pyx":1222
 *         """
 *         if self._c_check_marked_coverage == 0:
 *             return False             # <<<<<<<<<<<<<<
 *         elif self._c_check_marked_coverage == 1:
 *             return 'min_backward'
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "trapeza/account/fx_account.pyx":1221
 *         :return: {False, 'min_backward', 'max_forward'}
 *         """
 *         if self._c_check_marked_coverage == 0:             # <<<<<<<<<<<<<<
 *             return False
 *         elif self._c_check_marked_coverage == 1:
 */
  }

  /* "trapeza/account/fx_account.pyx":1223
 *         if self._c_check_marked_coverage == 0:
 *             return False
 *         elif self._c_check_marked_coverage == 1:             # <<<<<<<<<<<<<<
 *             return 'min_backward'
 *         elif self._c_check_marked_coverage == 2:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_check_marked_coverage); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1223, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "trapeza/account/fx_account.pyx":1224
 *             return False
 *         elif self._c_check_marked_coverage == 1:
 *             return 'min_backward'             # <<<<<<<<<<<<<<
 *         elif self._c_check_marked_coverage == 2:
 *             return 'max_forward'
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_n_u_min_backward);
    __pyx_r = __pyx_n_u_min_backward;
    goto __pyx_L0;

    /* "trapeza/account/fx_account.pyx":1223
 *         if self._c_check_marked_coverage == 0:
 *             return False
 *         elif self._c_check_marked_coverage == 1:             # <<<<<<<<<<<<<<
 *             return 'min_backward'
 *         elif self._c_check_marked_coverage == 2:
 */
  }

  /* "trapeza/account/fx_account.pyx":1225
 *         elif self._c_check_marked_coverage == 1:
 *             return 'min_backward'
 *         elif self._c_check_marked_coverage == 2:             # <<<<<<<<<<<<<<
 *             return 'max_forward'
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_check_marked_coverage); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1225, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(__pyx_t_3)) {

    /* "trapeza/account/fx_account.pyx":1226
 *             return 'min_backward'
 *         elif self._c_check_marked_coverage == 2:
 *             return 'max_forward'             # <<<<<<<<<<<<<<
 *         else:
 *             raise tpz_exception.OperatingError('Internal logic error. Value in underlying c-implementation (cython) is '
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_n_u_max_forward);
    __pyx_r = __pyx_n_u_max_forward;
    goto __pyx_L0;

    /* "trapeza/account/fx_account.pyx":1225
 *         elif self._c_check_marked_coverage == 1:
 *             return 'min_backward'
 *         elif self._c_check_marked_coverage == 2:             # <<<<<<<<<<<<<<
 *             return 'max_forward'
 *         else:
 */
  }

  /* "trapeza/account/fx_account.pyx":1228
 *             return 'max_forward'
 *         else:
 *             raise tpz_exception.OperatingError('Internal logic error. Value in underlying c-implementation (cython) is '             # <<<<<<<<<<<<<<
 *                                               'set to an invalid value.')
 *     @check_marked_coverage.setter
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1228, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_OperatingError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1228, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_kp_u_Internal_logic_error_Value_in_un) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_Internal_logic_error_Value_in_un);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1228, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1228, __pyx_L1_error)
  }

  /* "trapeza/account/fx_account.pyx":1215
 * 
 *     @property
 *     def check_marked_coverage(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns status of self.check_marked_coverage which denotes how coverage analysis is conducted for marked but
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.check_marked_coverage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1231
 *                                               'set to an invalid value.')
 *     @check_marked_coverage.setter
 *     def check_marked_coverage(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set type of coverage analysis.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_9check_marked_coverage(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_8check_marked_coverage[] = "\n        Set type of coverage analysis.\n        :param inp: {None, False, 'min_backward', 'max_forward'}\n                    or 0 (None/ False), 1 ('min_forward'), 2 ('max_forward')\n        :return: None\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_9check_marked_coverage = {"check_marked_coverage", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_9check_marked_coverage, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_8check_marked_coverage};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_9check_marked_coverage(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_marked_coverage (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_inp,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("check_marked_coverage", 1, 2, 2, 1); __PYX_ERR(0, 1231, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "check_marked_coverage") < 0)) __PYX_ERR(0, 1231, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_inp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("check_marked_coverage", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1231, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.check_marked_coverage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_8check_marked_coverage(__pyx_self, __pyx_v_self, __pyx_v_inp);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_8check_marked_coverage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("check_marked_coverage", 0);

  /* "trapeza/account/fx_account.pyx":1239
 *         :raises: TypeError
 *         """
 *         if inp is None or inp is False:             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = 0
 *         elif inp == 'min_backward':
 */
  __pyx_t_2 = (__pyx_v_inp == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_inp == Py_False);
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "trapeza/account/fx_account.pyx":1240
 *         """
 *         if inp is None or inp is False:
 *             self._c_check_marked_coverage = 0             # <<<<<<<<<<<<<<
 *         elif inp == 'min_backward':
 *             self._c_check_marked_coverage = 1
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_check_marked_coverage, __pyx_int_0) < 0) __PYX_ERR(0, 1240, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":1239
 *         :raises: TypeError
 *         """
 *         if inp is None or inp is False:             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = 0
 *         elif inp == 'min_backward':
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1241
 *         if inp is None or inp is False:
 *             self._c_check_marked_coverage = 0
 *         elif inp == 'min_backward':             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = 1
 *         elif inp == 'max_forward':
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_inp, __pyx_n_u_min_backward, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1241, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "trapeza/account/fx_account.pyx":1242
 *             self._c_check_marked_coverage = 0
 *         elif inp == 'min_backward':
 *             self._c_check_marked_coverage = 1             # <<<<<<<<<<<<<<
 *         elif inp == 'max_forward':
 *             self._c_check_marked_coverage = 2
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_check_marked_coverage, __pyx_int_1) < 0) __PYX_ERR(0, 1242, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":1241
 *         if inp is None or inp is False:
 *             self._c_check_marked_coverage = 0
 *         elif inp == 'min_backward':             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = 1
 *         elif inp == 'max_forward':
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1243
 *         elif inp == 'min_backward':
 *             self._c_check_marked_coverage = 1
 *         elif inp == 'max_forward':             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = 2
 *         elif inp in [0, 1, 2]:
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_inp, __pyx_n_u_max_forward, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1243, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "trapeza/account/fx_account.pyx":1244
 *             self._c_check_marked_coverage = 1
 *         elif inp == 'max_forward':
 *             self._c_check_marked_coverage = 2             # <<<<<<<<<<<<<<
 *         elif inp in [0, 1, 2]:
 *             self._c_check_marked_coverage = inp
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_check_marked_coverage, __pyx_int_2) < 0) __PYX_ERR(0, 1244, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":1243
 *         elif inp == 'min_backward':
 *             self._c_check_marked_coverage = 1
 *         elif inp == 'max_forward':             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = 2
 *         elif inp in [0, 1, 2]:
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1245
 *         elif inp == 'max_forward':
 *             self._c_check_marked_coverage = 2
 *         elif inp in [0, 1, 2]:             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = inp
 *         else:
 */
  __Pyx_INCREF(__pyx_v_inp);
  __pyx_t_4 = __pyx_v_inp;
  __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1245, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1245, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1245, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (likely(__pyx_t_2)) {

    /* "trapeza/account/fx_account.pyx":1246
 *             self._c_check_marked_coverage = 2
 *         elif inp in [0, 1, 2]:
 *             self._c_check_marked_coverage = inp             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_check_marked_coverage, __pyx_v_inp) < 0) __PYX_ERR(0, 1246, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":1245
 *         elif inp == 'max_forward':
 *             self._c_check_marked_coverage = 2
 *         elif inp in [0, 1, 2]:             # <<<<<<<<<<<<<<
 *             self._c_check_marked_coverage = inp
 *         else:
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1248
 *             self._c_check_marked_coverage = inp
 *         else:
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')             # <<<<<<<<<<<<<<
 *     @check_marked_coverage.deleter
 *     def check_marked_coverage(self):
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1248, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "trapeza/account/fx_account.pyx":1231
 *                                               'set to an invalid value.')
 *     @check_marked_coverage.setter
 *     def check_marked_coverage(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set type of coverage analysis.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.check_marked_coverage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1250
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *     @check_marked_coverage.deleter
 *     def check_marked_coverage(self):             # <<<<<<<<<<<<<<
 *         del self.check_marked_coverage
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_11check_marked_coverage(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_11check_marked_coverage = {"check_marked_coverage", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_11check_marked_coverage, METH_O, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_11check_marked_coverage(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_marked_coverage (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_10check_marked_coverage(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_10check_marked_coverage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("check_marked_coverage", 0);

  /* "trapeza/account/fx_account.pyx":1251
 *     @check_marked_coverage.deleter
 *     def check_marked_coverage(self):
 *         del self.check_marked_coverage             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (__Pyx_PyObject_DelAttrStr(__pyx_v_self, __pyx_n_s_check_marked_coverage) < 0) __PYX_ERR(0, 1251, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1250
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *     @check_marked_coverage.deleter
 *     def check_marked_coverage(self):             # <<<<<<<<<<<<<<
 *         del self.check_marked_coverage
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.check_marked_coverage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1254
 * 
 *     @property
 *     def clock(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current internal clock.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_13clock(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_12clock[] = "\n        Return current internal clock.\n        :return: int\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_13clock = {"clock", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_13clock, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_12clock};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_13clock(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clock (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_12clock(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_12clock(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clock", 0);

  /* "trapeza/account/fx_account.pyx":1259
 *         :return: int
 *         """
 *         return self._c_clock             # <<<<<<<<<<<<<<
 *     @clock.setter
 *     def clock(self, inp):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_clock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1254
 * 
 *     @property
 *     def clock(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current internal clock.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.clock", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1261
 *         return self._c_clock
 *     @clock.setter
 *     def clock(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set current internal clock. It is not recommended to manually set internal clock, but use self.tick() instead.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_15clock(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_14clock[] = "\n        Set current internal clock. It is not recommended to manually set internal clock, but use self.tick() instead.\n        :param inp: int >= 0\n        :return: None\n        :raises: ValueError (inp < 0) or TypeError (inp not int)\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_15clock = {"clock", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_15clock, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_14clock};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_15clock(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clock (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_inp,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("clock", 1, 2, 2, 1); __PYX_ERR(0, 1261, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "clock") < 0)) __PYX_ERR(0, 1261, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_inp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("clock", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1261, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.clock", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_14clock(__pyx_self, __pyx_v_self, __pyx_v_inp);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_14clock(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp) {
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  char const *__pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clock", 0);

  /* "trapeza/account/fx_account.pyx":1268
 *         :raises: ValueError (inp < 0) or TypeError (inp not int)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if inp < 0:
 *                 raise ValueError('Internal clock must be set to >=0.')
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":1269
 *         """
 *         try:
 *             if inp < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Internal clock must be set to >=0.')
 *             elif not int(inp) == inp:
 */
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_inp, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1269, __pyx_L3_error)
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1269, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__pyx_t_5)) {

        /* "trapeza/account/fx_account.pyx":1270
 *         try:
 *             if inp < 0:
 *                 raise ValueError('Internal clock must be set to >=0.')             # <<<<<<<<<<<<<<
 *             elif not int(inp) == inp:
 *                 raise TypeError('Only integers for setting internal clock.')
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1270, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 1270, __pyx_L3_error)

        /* "trapeza/account/fx_account.pyx":1269
 *         """
 *         try:
 *             if inp < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Internal clock must be set to >=0.')
 *             elif not int(inp) == inp:
 */
      }

      /* "trapeza/account/fx_account.pyx":1271
 *             if inp < 0:
 *                 raise ValueError('Internal clock must be set to >=0.')
 *             elif not int(inp) == inp:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Only integers for setting internal clock.')
 *             else:
 */
      __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_v_inp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1271, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_v_inp, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1271, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1271, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = ((!__pyx_t_5) != 0);
      if (unlikely(__pyx_t_7)) {

        /* "trapeza/account/fx_account.pyx":1272
 *                 raise ValueError('Internal clock must be set to >=0.')
 *             elif not int(inp) == inp:
 *                 raise TypeError('Only integers for setting internal clock.')             # <<<<<<<<<<<<<<
 *             else:
 *                 self._c_clock = inp
 */
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1272, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __PYX_ERR(0, 1272, __pyx_L3_error)

        /* "trapeza/account/fx_account.pyx":1271
 *             if inp < 0:
 *                 raise ValueError('Internal clock must be set to >=0.')
 *             elif not int(inp) == inp:             # <<<<<<<<<<<<<<
 *                 raise TypeError('Only integers for setting internal clock.')
 *             else:
 */
      }

      /* "trapeza/account/fx_account.pyx":1274
 *                 raise TypeError('Only integers for setting internal clock.')
 *             else:
 *                 self._c_clock = inp             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             raise e
 */
      /*else*/ {
        if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_clock, __pyx_v_inp) < 0) __PYX_ERR(0, 1274, __pyx_L3_error)
      }

      /* "trapeza/account/fx_account.pyx":1268
 *         :raises: ValueError (inp < 0) or TypeError (inp not int)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if inp < 0:
 *                 raise ValueError('Internal clock must be set to >=0.')
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "trapeza/account/fx_account.pyx":1275
 *             else:
 *                 self._c_clock = inp
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             raise e
 *     @clock.deleter
 */
    __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_8) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.clock", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 1275, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_e = __pyx_t_4;
      /*try:*/ {

        /* "trapeza/account/fx_account.pyx":1276
 *                 self._c_clock = inp
 *         except Exception as e:
 *             raise e             # <<<<<<<<<<<<<<
 *     @clock.deleter
 *     def clock(self):
 */
        __Pyx_Raise(__pyx_v_e, 0, 0, 0);
        __PYX_ERR(0, 1276, __pyx_L15_error)
      }

      /* "trapeza/account/fx_account.pyx":1275
 *             else:
 *                 self._c_clock = inp
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             raise e
 *     @clock.deleter
 */
      /*finally:*/ {
        __pyx_L15_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_8 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e);
            __pyx_v_e = NULL;
          }
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
          }
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
          goto __pyx_L5_except_error;
        }
      }
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "trapeza/account/fx_account.pyx":1268
 *         :raises: ValueError (inp < 0) or TypeError (inp not int)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if inp < 0:
 *                 raise ValueError('Internal clock must be set to >=0.')
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":1261
 *         return self._c_clock
 *     @clock.setter
 *     def clock(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set current internal clock. It is not recommended to manually set internal clock, but use self.tick() instead.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.clock", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1278
 *             raise e
 *     @clock.deleter
 *     def clock(self):             # <<<<<<<<<<<<<<
 *         del self.clock
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_17clock(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_17clock = {"clock", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_17clock, METH_O, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_17clock(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clock (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_16clock(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_16clock(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clock", 0);

  /* "trapeza/account/fx_account.pyx":1279
 *     @clock.deleter
 *     def clock(self):
 *         del self.clock             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (__Pyx_PyObject_DelAttrStr(__pyx_v_self, __pyx_n_s_clock) < 0) __PYX_ERR(0, 1279, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1278
 *             raise e
 *     @clock.deleter
 *     def clock(self):             # <<<<<<<<<<<<<<
 *         del self.clock
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.clock", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1282
 * 
 *     @property
 *     def _ignore_type_checking(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns whether type checking is ignored or not.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_19_ignore_type_checking(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_18_ignore_type_checking[] = "\n        Returns whether type checking is ignored or not.\n        :return: bool\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_19_ignore_type_checking = {"_ignore_type_checking", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_19_ignore_type_checking, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_18_ignore_type_checking};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_19_ignore_type_checking(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_ignore_type_checking (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_18_ignore_type_checking(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_18_ignore_type_checking(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_ignore_type_checking", 0);

  /* "trapeza/account/fx_account.pyx":1288
 *         """
 *         # readonly access (cython extension type)
 *         return self._c_ignore_type_checking             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1282
 * 
 *     @property
 *     def _ignore_type_checking(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns whether type checking is ignored or not.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._ignore_type_checking", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1291
 * 
 *     @property
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current depot and it's positions. Returned dict is not manipulable/ mutable. Use setter method instead.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_21depot(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_20depot[] = "\n        Return current depot and it's positions. Returned dict is not manipulable/ mutable. Use setter method instead.\n        :return: dict, keys: str:currency, value: float:position_size\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_21depot = {"depot", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_21depot, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_20depot};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_21depot(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("depot (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_20depot(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7trapeza_7account_10fx_account_9FXAccount_5depot_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "trapeza/account/fx_account.pyx":1296
 *         :return: dict, keys: str:currency, value: float:position_size
 *         """
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_depot.items())             # <<<<<<<<<<<<<<
 *     @depot.setter
 *     def depot(self, inp):
 */

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_5depot_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *)__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr(__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1296, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7trapeza_7account_10fx_account_9FXAccount_5depot_2generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_FXAccount_depot_locals_genexpr, __pyx_n_s_trapeza_account_fx_account); if (unlikely(!gen)) __PYX_ERR(0, 1296, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.depot.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_7trapeza_7account_10fx_account_9FXAccount_5depot_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1296, __pyx_L1_error)
  __pyx_t_2 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1296, __pyx_L1_error) }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_n_s_c_depot); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(__pyx_t_5 == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
    __PYX_ERR(0, 1296, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_dict_iterator(__pyx_t_5, 0, __pyx_n_s_items, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_6;
  __pyx_t_6 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_6, &__pyx_t_5, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_k, __pyx_n_s_decode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_v);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_v);
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1296, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1291
 * 
 *     @property
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current depot and it's positions. Returned dict is not manipulable/ mutable. Use setter method instead.
 */

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_20depot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("depot", 0);
  __pyx_cur_scope = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *)__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct__depot(__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct__depot, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1291, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);

  /* "trapeza/account/fx_account.pyx":1296
 *         :return: dict, keys: str:currency, value: float:position_size
 *         """
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_depot.items())             # <<<<<<<<<<<<<<
 *     @depot.setter
 *     def depot(self, inp):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ProtectedDict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_5depot_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1291
 * 
 *     @property
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current depot and it's positions. Returned dict is not manipulable/ mutable. Use setter method instead.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1298
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_depot.items())
 *     @depot.setter
 *     def depot(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set depot by providing a complete dict of all new positions
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_23depot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_22depot[] = "\n        Set depot by providing a complete dict of all new positions\n        :param inp: dict with key str:currency, value: float\n        :return: None\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_23depot = {"depot", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_23depot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_22depot};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_23depot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("depot (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_inp,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("depot", 1, 2, 2, 1); __PYX_ERR(0, 1298, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "depot") < 0)) __PYX_ERR(0, 1298, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_inp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("depot", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1298, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_22depot(__pyx_self, __pyx_v_self, __pyx_v_inp);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_22depot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("depot", 0);

  /* "trapeza/account/fx_account.pyx":1305
 *         :raises: TypeError
 *         """
 *         check_types([inp], [dict], ['depot_setter'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         self._c_depot = self._parse_depot(inp, self._c_ignore_type_checking)
 *     @depot.deleter
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_inp);
  __Pyx_GIVEREF(__pyx_v_inp);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_inp);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)(&PyDict_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyDict_Type)));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyDict_Type)));
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_depot_setter);
  __Pyx_GIVEREF(__pyx_n_u_depot_setter);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_depot_setter);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1305, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1305, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1305, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, __pyx_t_6);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1305, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1306
 *         """
 *         check_types([inp], [dict], ['depot_setter'], self._c_ignore_type_checking)
 *         self._c_depot = self._parse_depot(inp, self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *     @depot.deleter
 *     def depot(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_depot); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_inp, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1306, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_inp, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1306, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_inp);
    __Pyx_GIVEREF(__pyx_v_inp);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_v_inp);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_depot, __pyx_t_1) < 0) __PYX_ERR(0, 1306, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1298
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_depot.items())
 *     @depot.setter
 *     def depot(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set depot by providing a complete dict of all new positions
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1308
 *         self._c_depot = self._parse_depot(inp, self._c_ignore_type_checking)
 *     @depot.deleter
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         del self.depot
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_25depot(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_25depot = {"depot", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_25depot, METH_O, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_25depot(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("depot (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_24depot(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_24depot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("depot", 0);

  /* "trapeza/account/fx_account.pyx":1309
 *     @depot.deleter
 *     def depot(self):
 *         del self.depot             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (__Pyx_PyObject_DelAttrStr(__pyx_v_self, __pyx_n_s_depot) < 0) __PYX_ERR(0, 1309, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1308
 *         self._c_depot = self._parse_depot(inp, self._c_ignore_type_checking)
 *     @depot.deleter
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         del self.depot
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1312
 * 
 *     @property
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current set fees. Returned dict is not manipulable/ mutable. Use setter method instead.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_27_fee(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_26_fee[] = "\n        Return current set fees. Returned dict is not manipulable/ mutable. Use setter method instead.\n        :return: dict, keys:{'sell', 'buy', 'withdraw', 'deposit'}, values: function\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_27_fee = {"_fee", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_27_fee, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_26_fee};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_27_fee(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_fee (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_26_fee(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7trapeza_7account_10fx_account_9FXAccount_4_fee_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "trapeza/account/fx_account.pyx":1317
 *         :return: dict, keys:{'sell', 'buy', 'withdraw', 'deposit'}, values: function
 *         """
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_fee.items())             # <<<<<<<<<<<<<<
 *     @_fee.setter
 *     def _fee(self, inp):
 */

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_4_fee_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *)__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr(__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1317, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7trapeza_7account_10fx_account_9FXAccount_4_fee_2generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_FXAccount__fee_locals_genexpr, __pyx_n_s_trapeza_account_fx_account); if (unlikely(!gen)) __PYX_ERR(0, 1317, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._fee.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_7trapeza_7account_10fx_account_9FXAccount_4_fee_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *__pyx_cur_scope = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1317, __pyx_L1_error)
  __pyx_t_2 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1317, __pyx_L1_error) }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_n_s_c_fee); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(__pyx_t_5 == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
    __PYX_ERR(0, 1317, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_dict_iterator(__pyx_t_5, 0, __pyx_n_s_items, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_6;
  __pyx_t_6 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_6, &__pyx_t_5, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1317, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_k, __pyx_n_s_decode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1317, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1317, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1317, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_v);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_v);
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1317, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1312
 * 
 *     @property
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current set fees. Returned dict is not manipulable/ mutable. Use setter method instead.
 */

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_26_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_fee", 0);
  __pyx_cur_scope = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *)__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee(__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1312, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);

  /* "trapeza/account/fx_account.pyx":1317
 *         :return: dict, keys:{'sell', 'buy', 'withdraw', 'deposit'}, values: function
 *         """
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_fee.items())             # <<<<<<<<<<<<<<
 *     @_fee.setter
 *     def _fee(self, inp):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ProtectedDict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_4_fee_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1312
 * 
 *     @property
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current set fees. Returned dict is not manipulable/ mutable. Use setter method instead.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1319
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_fee.items())
 *     @_fee.setter
 *     def _fee(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new fees by providing a dict. Dict can contain keys:{'sell', 'buy', 'withdraw', 'deposit'}. If one of the
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_29_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_28_fee[] = "\n        Set new fees by providing a dict. Dict can contain keys:{'sell', 'buy', 'withdraw', 'deposit'}. If one of the\n        keys is missing in inp, then the current internal setting for this key will be taken over and re-used.\n        :param inp: dict, keys:{'sell', 'buy', 'withdraw', 'deposit'}, values: function\n        :return: None\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_29_fee = {"_fee", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_29_fee, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_28_fee};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_29_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_fee (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_inp,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_fee", 1, 2, 2, 1); __PYX_ERR(0, 1319, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_fee") < 0)) __PYX_ERR(0, 1319, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_inp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_fee", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1319, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_28_fee(__pyx_self, __pyx_v_self, __pyx_v_inp);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_28_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp) {
  PyObject *__pyx_v__fee_tmp_dict = NULL;
  PyObject *__pyx_v__fee_keys = NULL;
  PyObject *__pyx_v__f_key = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_fee", 0);

  /* "trapeza/account/fx_account.pyx":1327
 *         :raises: TypeError
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if type(inp) != dict:
 *                 raise TypeError
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":1328
 *         """
 *         try:
 *             if type(inp) != dict:             # <<<<<<<<<<<<<<
 *                 raise TypeError
 *             _fee_tmp_dict = {}
 */
      __pyx_t_4 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_inp)), ((PyObject *)(&PyDict_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1328, __pyx_L3_error)
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1328, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__pyx_t_5)) {

        /* "trapeza/account/fx_account.pyx":1329
 *         try:
 *             if type(inp) != dict:
 *                 raise TypeError             # <<<<<<<<<<<<<<
 *             _fee_tmp_dict = {}
 *             _fee_keys = ['buy', 'sell', 'deposit', 'withdraw']
 */
        __Pyx_Raise(__pyx_builtin_TypeError, 0, 0, 0);
        __PYX_ERR(0, 1329, __pyx_L3_error)

        /* "trapeza/account/fx_account.pyx":1328
 *         """
 *         try:
 *             if type(inp) != dict:             # <<<<<<<<<<<<<<
 *                 raise TypeError
 *             _fee_tmp_dict = {}
 */
      }

      /* "trapeza/account/fx_account.pyx":1330
 *             if type(inp) != dict:
 *                 raise TypeError
 *             _fee_tmp_dict = {}             # <<<<<<<<<<<<<<
 *             _fee_keys = ['buy', 'sell', 'deposit', 'withdraw']
 *             for _f_key in _fee_keys:
 */
      __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1330, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v__fee_tmp_dict = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "trapeza/account/fx_account.pyx":1331
 *                 raise TypeError
 *             _fee_tmp_dict = {}
 *             _fee_keys = ['buy', 'sell', 'deposit', 'withdraw']             # <<<<<<<<<<<<<<
 *             for _f_key in _fee_keys:
 *                 if _f_key in inp.keys():
 */
      __pyx_t_4 = PyList_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1331, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_n_u_buy);
      __Pyx_GIVEREF(__pyx_n_u_buy);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_buy);
      __Pyx_INCREF(__pyx_n_u_sell);
      __Pyx_GIVEREF(__pyx_n_u_sell);
      PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_u_sell);
      __Pyx_INCREF(__pyx_n_u_deposit);
      __Pyx_GIVEREF(__pyx_n_u_deposit);
      PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_u_deposit);
      __Pyx_INCREF(__pyx_n_u_withdraw);
      __Pyx_GIVEREF(__pyx_n_u_withdraw);
      PyList_SET_ITEM(__pyx_t_4, 3, __pyx_n_u_withdraw);
      __pyx_v__fee_keys = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "trapeza/account/fx_account.pyx":1332
 *             _fee_tmp_dict = {}
 *             _fee_keys = ['buy', 'sell', 'deposit', 'withdraw']
 *             for _f_key in _fee_keys:             # <<<<<<<<<<<<<<
 *                 if _f_key in inp.keys():
 *                     _fee_tmp_dict[_f_key] = inp[_f_key]
 */
      __pyx_t_4 = __pyx_v__fee_keys; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
      for (;;) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 1332, __pyx_L3_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1332, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_XDECREF_SET(__pyx_v__f_key, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "trapeza/account/fx_account.pyx":1333
 *             _fee_keys = ['buy', 'sell', 'deposit', 'withdraw']
 *             for _f_key in _fee_keys:
 *                 if _f_key in inp.keys():             # <<<<<<<<<<<<<<
 *                     _fee_tmp_dict[_f_key] = inp[_f_key]
 *                 else:
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_inp, __pyx_n_s_keys); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1333, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1333, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_v__f_key, __pyx_t_7, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1333, __pyx_L3_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_10 = (__pyx_t_5 != 0);
        if (__pyx_t_10) {

          /* "trapeza/account/fx_account.pyx":1334
 *             for _f_key in _fee_keys:
 *                 if _f_key in inp.keys():
 *                     _fee_tmp_dict[_f_key] = inp[_f_key]             # <<<<<<<<<<<<<<
 *                 else:
 *                     _fee_tmp_dict[_f_key] = self._c_fee[_f_key.encode()]
 */
          __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_inp, __pyx_v__f_key); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1334, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (unlikely(PyDict_SetItem(__pyx_v__fee_tmp_dict, __pyx_v__f_key, __pyx_t_7) < 0)) __PYX_ERR(0, 1334, __pyx_L3_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "trapeza/account/fx_account.pyx":1333
 *             _fee_keys = ['buy', 'sell', 'deposit', 'withdraw']
 *             for _f_key in _fee_keys:
 *                 if _f_key in inp.keys():             # <<<<<<<<<<<<<<
 *                     _fee_tmp_dict[_f_key] = inp[_f_key]
 *                 else:
 */
          goto __pyx_L12;
        }

        /* "trapeza/account/fx_account.pyx":1336
 *                     _fee_tmp_dict[_f_key] = inp[_f_key]
 *                 else:
 *                     _fee_tmp_dict[_f_key] = self._c_fee[_f_key.encode()]             # <<<<<<<<<<<<<<
 *             if len(set(list(inp.keys())) - set(_fee_keys)) > 0:
 *                 raise KeyError
 */
        /*else*/ {
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_fee); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1336, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v__f_key, __pyx_n_s_encode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1336, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_11 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
            if (likely(__pyx_t_11)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_11);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_9, function);
            }
          }
          __pyx_t_8 = (__pyx_t_11) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1336, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1336, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(PyDict_SetItem(__pyx_v__fee_tmp_dict, __pyx_v__f_key, __pyx_t_9) < 0)) __PYX_ERR(0, 1336, __pyx_L3_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __pyx_L12:;

        /* "trapeza/account/fx_account.pyx":1332
 *             _fee_tmp_dict = {}
 *             _fee_keys = ['buy', 'sell', 'deposit', 'withdraw']
 *             for _f_key in _fee_keys:             # <<<<<<<<<<<<<<
 *                 if _f_key in inp.keys():
 *                     _fee_tmp_dict[_f_key] = inp[_f_key]
 */
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "trapeza/account/fx_account.pyx":1337
 *                 else:
 *                     _fee_tmp_dict[_f_key] = self._c_fee[_f_key.encode()]
 *             if len(set(list(inp.keys())) - set(_fee_keys)) > 0:             # <<<<<<<<<<<<<<
 *                 raise KeyError
 *             self._c_fee = self._parse_fees(_fee_tmp_dict['buy'], _fee_tmp_dict['sell'],
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_inp, __pyx_n_s_keys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1337, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1337, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1337, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PySet_New(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1337, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PySet_New(__pyx_v__fee_keys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1337, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = PyNumber_Subtract(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1337, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_6 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1337, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_10 = ((__pyx_t_6 > 0) != 0);
      if (unlikely(__pyx_t_10)) {

        /* "trapeza/account/fx_account.pyx":1338
 *                     _fee_tmp_dict[_f_key] = self._c_fee[_f_key.encode()]
 *             if len(set(list(inp.keys())) - set(_fee_keys)) > 0:
 *                 raise KeyError             # <<<<<<<<<<<<<<
 *             self._c_fee = self._parse_fees(_fee_tmp_dict['buy'], _fee_tmp_dict['sell'],
 *                                            _fee_tmp_dict['deposit'], _fee_tmp_dict['withdraw'],
 */
        __Pyx_Raise(__pyx_builtin_KeyError, 0, 0, 0);
        __PYX_ERR(0, 1338, __pyx_L3_error)

        /* "trapeza/account/fx_account.pyx":1337
 *                 else:
 *                     _fee_tmp_dict[_f_key] = self._c_fee[_f_key.encode()]
 *             if len(set(list(inp.keys())) - set(_fee_keys)) > 0:             # <<<<<<<<<<<<<<
 *                 raise KeyError
 *             self._c_fee = self._parse_fees(_fee_tmp_dict['buy'], _fee_tmp_dict['sell'],
 */
      }

      /* "trapeza/account/fx_account.pyx":1339
 *             if len(set(list(inp.keys())) - set(_fee_keys)) > 0:
 *                 raise KeyError
 *             self._c_fee = self._parse_fees(_fee_tmp_dict['buy'], _fee_tmp_dict['sell'],             # <<<<<<<<<<<<<<
 *                                            _fee_tmp_dict['deposit'], _fee_tmp_dict['withdraw'],
 *                                            self._c_ignore_type_checking)
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_fees); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1339, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v__fee_tmp_dict, __pyx_n_u_buy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1339, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v__fee_tmp_dict, __pyx_n_u_sell); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1339, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);

      /* "trapeza/account/fx_account.pyx":1340
 *                 raise KeyError
 *             self._c_fee = self._parse_fees(_fee_tmp_dict['buy'], _fee_tmp_dict['sell'],
 *                                            _fee_tmp_dict['deposit'], _fee_tmp_dict['withdraw'],             # <<<<<<<<<<<<<<
 *                                            self._c_ignore_type_checking)
 *         except TypeError:
 */
      __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v__fee_tmp_dict, __pyx_n_u_deposit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1340, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyDict_GetItem(__pyx_v__fee_tmp_dict, __pyx_n_u_withdraw); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1340, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_12);

      /* "trapeza/account/fx_account.pyx":1341
 *             self._c_fee = self._parse_fees(_fee_tmp_dict['buy'], _fee_tmp_dict['sell'],
 *                                            _fee_tmp_dict['deposit'], _fee_tmp_dict['withdraw'],
 *                                            self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         except TypeError:
 *             raise TypeError('_fee setter argument must be dict with fee["buy"], fee["sell"], fee["deposit"] '
 */
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1341, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_15 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[6] = {__pyx_t_14, __pyx_t_4, __pyx_t_7, __pyx_t_11, __pyx_t_12, __pyx_t_13};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_15, 5+__pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1339, __pyx_L3_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[6] = {__pyx_t_14, __pyx_t_4, __pyx_t_7, __pyx_t_11, __pyx_t_12, __pyx_t_13};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_15, 5+__pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1339, __pyx_L3_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      } else
      #endif
      {
        __pyx_t_16 = PyTuple_New(5+__pyx_t_15); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1339, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_16);
        if (__pyx_t_14) {
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_14); __pyx_t_14 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_15, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_15, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_15, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_16, 3+__pyx_t_15, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_16, 4+__pyx_t_15, __pyx_t_13);
        __pyx_t_4 = 0;
        __pyx_t_7 = 0;
        __pyx_t_11 = 0;
        __pyx_t_12 = 0;
        __pyx_t_13 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_16, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1339, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "trapeza/account/fx_account.pyx":1339
 *             if len(set(list(inp.keys())) - set(_fee_keys)) > 0:
 *                 raise KeyError
 *             self._c_fee = self._parse_fees(_fee_tmp_dict['buy'], _fee_tmp_dict['sell'],             # <<<<<<<<<<<<<<
 *                                            _fee_tmp_dict['deposit'], _fee_tmp_dict['withdraw'],
 *                                            self._c_ignore_type_checking)
 */
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_fee, __pyx_t_8) < 0) __PYX_ERR(0, 1339, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "trapeza/account/fx_account.pyx":1327
 *         :raises: TypeError
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if type(inp) != dict:
 *                 raise TypeError
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "trapeza/account/fx_account.pyx":1342
 *                                            _fee_tmp_dict['deposit'], _fee_tmp_dict['withdraw'],
 *                                            self._c_ignore_type_checking)
 *         except TypeError:             # <<<<<<<<<<<<<<
 *             raise TypeError('_fee setter argument must be dict with fee["buy"], fee["sell"], fee["deposit"] '
 *                             'and fee["withdraw"]. See docstring of FXAccount for further information about fee '
 */
    __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
    if (__pyx_t_15) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_16) < 0) __PYX_ERR(0, 1342, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_16);

      /* "trapeza/account/fx_account.pyx":1343
 *                                            self._c_ignore_type_checking)
 *         except TypeError:
 *             raise TypeError('_fee setter argument must be dict with fee["buy"], fee["sell"], fee["deposit"] '             # <<<<<<<<<<<<<<
 *                             'and fee["withdraw"]. See docstring of FXAccount for further information about fee '
 *                             'handling.')
 */
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1343, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_Raise(__pyx_t_13, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __PYX_ERR(0, 1343, __pyx_L5_except_error)
    }

    /* "trapeza/account/fx_account.pyx":1346
 *                             'and fee["withdraw"]. See docstring of FXAccount for further information about fee '
 *                             'handling.')
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             raise KeyError('_fee setter argument must be dict with fee["buy"], fee["sell"], fee["deposit"] '
 *                             'and fee["withdraw"]. See docstring of FXAccount for further information about fee '
 */
    __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_15) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_9, &__pyx_t_8) < 0) __PYX_ERR(0, 1346, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_8);

      /* "trapeza/account/fx_account.pyx":1347
 *                             'handling.')
 *         except KeyError:
 *             raise KeyError('_fee setter argument must be dict with fee["buy"], fee["sell"], fee["deposit"] '             # <<<<<<<<<<<<<<
 *                             'and fee["withdraw"]. See docstring of FXAccount for further information about fee '
 *                             'handling.')
 */
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1347, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_Raise(__pyx_t_13, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __PYX_ERR(0, 1347, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "trapeza/account/fx_account.pyx":1327
 *         :raises: TypeError
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if type(inp) != dict:
 *                 raise TypeError
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":1319
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_fee.items())
 *     @_fee.setter
 *     def _fee(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new fees by providing a dict. Dict can contain keys:{'sell', 'buy', 'withdraw', 'deposit'}. If one of the
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__fee_tmp_dict);
  __Pyx_XDECREF(__pyx_v__fee_keys);
  __Pyx_XDECREF(__pyx_v__f_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1351
 *                             'handling.')
 *     @_fee.deleter
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         del self._fee
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_31_fee(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_31_fee = {"_fee", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_31_fee, METH_O, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_31_fee(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_fee (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_30_fee(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_30_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_fee", 0);

  /* "trapeza/account/fx_account.pyx":1352
 *     @_fee.deleter
 *     def _fee(self):
 *         del self._fee             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (__Pyx_PyObject_DelAttrStr(__pyx_v_self, __pyx_n_s_fee) < 0) __PYX_ERR(0, 1352, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1351
 *                             'handling.')
 *     @_fee.deleter
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         del self._fee
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1355
 * 
 *     @property
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns current exchange rates (which was previously provided by self.tick(...), self.update_exchange_rate(...)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_33exchange_rates(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_32exchange_rates[] = "\n        Returns current exchange rates (which was previously provided by self.tick(...), self.update_exchange_rate(...)\n        or self.batch_update_exchange_rates(...)) as dict which is not manipulable/ mutable. Use setter method instead.\n        :return: dict with keys:tuple of str:currency (currency pair) and values:float\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_33exchange_rates = {"exchange_rates", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_33exchange_rates, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_32exchange_rates};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_33exchange_rates(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("exchange_rates (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_32exchange_rates(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7trapeza_7account_10fx_account_9FXAccount_14exchange_rates_2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "trapeza/account/fx_account.pyx":1361
 *         :return: dict with keys:tuple of str:currency (currency pair) and values:float
 *         """
 *         return ProtectedDict(((k[0].decode(), k[1].decode()), v) for k, v in self._c_exchange_rates.items())             # <<<<<<<<<<<<<<
 *     @exchange_rates.setter
 *     def exchange_rates(self, inp):
 */

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_14exchange_rates_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *)__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr(__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1361, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7trapeza_7account_10fx_account_9FXAccount_14exchange_rates_2generator2, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_FXAccount_exchange_rates_locals, __pyx_n_s_trapeza_account_fx_account); if (unlikely(!gen)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.exchange_rates.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_7trapeza_7account_10fx_account_9FXAccount_14exchange_rates_2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *__pyx_cur_scope = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1361, __pyx_L1_error)
  __pyx_t_2 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1361, __pyx_L1_error) }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_n_s_c_exchange_rates); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(__pyx_t_5 == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
    __PYX_ERR(0, 1361, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_dict_iterator(__pyx_t_5, 0, __pyx_n_s_items, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_6;
  __pyx_t_6 = 0;
  while (1) {
    __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_6, &__pyx_t_5, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_7 == 0)) break;
    if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_k, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_decode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_5 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_k, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_decode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_8 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8);
    __pyx_t_5 = 0;
    __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_v);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_cur_scope->__pyx_v_v);
    __pyx_t_9 = 0;
    __pyx_r = __pyx_t_8;
    __pyx_t_8 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1361, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1355
 * 
 *     @property
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns current exchange rates (which was previously provided by self.tick(...), self.update_exchange_rate(...)
 */

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_32exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("exchange_rates", 0);
  __pyx_cur_scope = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *)__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates(__pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1355, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);

  /* "trapeza/account/fx_account.pyx":1361
 *         :return: dict with keys:tuple of str:currency (currency pair) and values:float
 *         """
 *         return ProtectedDict(((k[0].decode(), k[1].decode()), v) for k, v in self._c_exchange_rates.items())             # <<<<<<<<<<<<<<
 *     @exchange_rates.setter
 *     def exchange_rates(self, inp):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ProtectedDict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_14exchange_rates_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1355
 * 
 *     @property
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns current exchange rates (which was previously provided by self.tick(...), self.update_exchange_rate(...)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1363
 *         return ProtectedDict(((k[0].decode(), k[1].decode()), v) for k, v in self._c_exchange_rates.items())
 *     @exchange_rates.setter
 *     def exchange_rates(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new exchange rates as complete dict of all currency pairs. Must contain all currency pairs which are also
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_35exchange_rates(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_34exchange_rates[] = "\n        Set new exchange rates as complete dict of all currency pairs. Must contain all currency pairs which are also\n        contained in self.depot, otherwise self.total_balance will throw an exception. Doesn't matter if keys are\n        noted as base|quote or quote|base as rates are automatically inverted to base|self.reference_currency (when\n        calling FXAccount.total_balance).\n        :param inp: dict with keys:tuple of str:currency (currency pair) and values:float\n        :return: None\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_35exchange_rates = {"exchange_rates", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_35exchange_rates, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_34exchange_rates};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_35exchange_rates(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("exchange_rates (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_inp,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("exchange_rates", 1, 2, 2, 1); __PYX_ERR(0, 1363, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "exchange_rates") < 0)) __PYX_ERR(0, 1363, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_inp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("exchange_rates", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1363, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_34exchange_rates(__pyx_self, __pyx_v_self, __pyx_v_inp);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_34exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("exchange_rates", 0);

  /* "trapeza/account/fx_account.pyx":1373
 *         :raises: TypeError
 *         """
 *         check_types([inp], [dict], ['exchange_rates_setter'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         self._c_exchange_rates = self._parse_exchange_rates(inp, self._c_ignore_type_checking)
 *     @exchange_rates.deleter
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_inp);
  __Pyx_GIVEREF(__pyx_v_inp);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_inp);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)(&PyDict_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyDict_Type)));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyDict_Type)));
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_exchange_rates_setter);
  __Pyx_GIVEREF(__pyx_n_u_exchange_rates_setter);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_exchange_rates_setter);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1373, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1373, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, __pyx_t_6);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1374
 *         """
 *         check_types([inp], [dict], ['exchange_rates_setter'], self._c_ignore_type_checking)
 *         self._c_exchange_rates = self._parse_exchange_rates(inp, self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *     @exchange_rates.deleter
 *     def exchange_rates(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_exchange_rates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_inp, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1374, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_inp, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1374, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_inp);
    __Pyx_GIVEREF(__pyx_v_inp);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_v_inp);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_exchange_rates, __pyx_t_1) < 0) __PYX_ERR(0, 1374, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1363
 *         return ProtectedDict(((k[0].decode(), k[1].decode()), v) for k, v in self._c_exchange_rates.items())
 *     @exchange_rates.setter
 *     def exchange_rates(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new exchange rates as complete dict of all currency pairs. Must contain all currency pairs which are also
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1376
 *         self._c_exchange_rates = self._parse_exchange_rates(inp, self._c_ignore_type_checking)
 *     @exchange_rates.deleter
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         del self.exchange_rates
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_37exchange_rates(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_37exchange_rates = {"exchange_rates", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_37exchange_rates, METH_O, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_37exchange_rates(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("exchange_rates (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_36exchange_rates(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_36exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("exchange_rates", 0);

  /* "trapeza/account/fx_account.pyx":1377
 *     @exchange_rates.deleter
 *     def exchange_rates(self):
 *         del self.exchange_rates             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (__Pyx_PyObject_DelAttrStr(__pyx_v_self, __pyx_n_s_exchange_rates) < 0) __PYX_ERR(0, 1377, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1376
 *         self._c_exchange_rates = self._parse_exchange_rates(inp, self._c_ignore_type_checking)
 *     @exchange_rates.deleter
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         del self.exchange_rates
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1380
 * 
 *     @property
 *     def reference_currency(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return reference currency used for calculating total balance/ value of depot and fees.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_39reference_currency(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_38reference_currency[] = "\n        Return reference currency used for calculating total balance/ value of depot and fees.\n        :return: str\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_39reference_currency = {"reference_currency", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_39reference_currency, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_38reference_currency};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_39reference_currency(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reference_currency (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_38reference_currency(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_38reference_currency(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reference_currency", 0);

  /* "trapeza/account/fx_account.pyx":1385
 *         :return: str
 *         """
 *         return self._c_reference_currency.decode()             # <<<<<<<<<<<<<<
 *     @reference_currency.setter
 *     def reference_currency(self, inp):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_reference_currency); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_decode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1380
 * 
 *     @property
 *     def reference_currency(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return reference currency used for calculating total balance/ value of depot and fees.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.reference_currency", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1387
 *         return self._c_reference_currency.decode()
 *     @reference_currency.setter
 *     def reference_currency(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new reference currency.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_41reference_currency(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_40reference_currency[] = "\n        Set new reference currency.\n        :param inp: str\n        :return: None\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_41reference_currency = {"reference_currency", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_41reference_currency, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_40reference_currency};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_41reference_currency(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reference_currency (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_inp,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("reference_currency", 1, 2, 2, 1); __PYX_ERR(0, 1387, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reference_currency") < 0)) __PYX_ERR(0, 1387, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_inp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("reference_currency", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1387, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.reference_currency", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_40reference_currency(__pyx_self, __pyx_v_self, __pyx_v_inp);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_40reference_currency(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reference_currency", 0);

  /* "trapeza/account/fx_account.pyx":1394
 *         :raises: TypeError
 *         """
 *         check_types([inp], [str], ['inp'])             # <<<<<<<<<<<<<<
 *         self._c_reference_currency = inp.encode()
 *     @reference_currency.deleter
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_inp);
  __Pyx_GIVEREF(__pyx_v_inp);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_inp);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyUnicode_Type)));
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_inp);
  __Pyx_GIVEREF(__pyx_n_u_inp);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_inp);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1394, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1394, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1395
 *         """
 *         check_types([inp], [str], ['inp'])
 *         self._c_reference_currency = inp.encode()             # <<<<<<<<<<<<<<
 *     @reference_currency.deleter
 *     def reference_currency(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_inp, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_reference_currency, __pyx_t_1) < 0) __PYX_ERR(0, 1395, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1387
 *         return self._c_reference_currency.decode()
 *     @reference_currency.setter
 *     def reference_currency(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new reference currency.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.reference_currency", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1397
 *         self._c_reference_currency = inp.encode()
 *     @reference_currency.deleter
 *     def reference_currency(self):             # <<<<<<<<<<<<<<
 *         del self.reference_currency
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_43reference_currency(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_43reference_currency = {"reference_currency", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_43reference_currency, METH_O, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_43reference_currency(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reference_currency (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_42reference_currency(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_42reference_currency(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reference_currency", 0);

  /* "trapeza/account/fx_account.pyx":1398
 *     @reference_currency.deleter
 *     def reference_currency(self):
 *         del self.reference_currency             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (__Pyx_PyObject_DelAttrStr(__pyx_v_self, __pyx_n_s_reference_currency) < 0) __PYX_ERR(0, 1398, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1397
 *         self._c_reference_currency = inp.encode()
 *     @reference_currency.deleter
 *     def reference_currency(self):             # <<<<<<<<<<<<<<
 *         del self.reference_currency
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.reference_currency", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1401
 * 
 *     @property
 *     def is_exchange_rate_updated(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns whether internal exchange rates have been updated and self.total_balance() is ready to be called.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_45is_exchange_rate_updated(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_44is_exchange_rate_updated[] = "\n        Returns whether internal exchange rates have been updated and self.total_balance() is ready to be called.\n        :return: bool\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_45is_exchange_rate_updated = {"is_exchange_rate_updated", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_45is_exchange_rate_updated, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_44is_exchange_rate_updated};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_45is_exchange_rate_updated(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_exchange_rate_updated (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_44is_exchange_rate_updated(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_44is_exchange_rate_updated(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_exchange_rate_updated", 0);

  /* "trapeza/account/fx_account.pyx":1406
 *         :return: bool
 *         """
 *         return self._c_is_exchange_rate_updated             # <<<<<<<<<<<<<<
 *     @is_exchange_rate_updated.setter
 *     def is_exchange_rate_updated(self, inp):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_is_exchange_rate_updated); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1401
 * 
 *     @property
 *     def is_exchange_rate_updated(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns whether internal exchange rates have been updated and self.total_balance() is ready to be called.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.is_exchange_rate_updated", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1408
 *         return self._c_is_exchange_rate_updated
 *     @is_exchange_rate_updated.setter
 *     def is_exchange_rate_updated(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internal status whether exchange rates have been updated and self.total_balance() is
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_47is_exchange_rate_updated(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_46is_exchange_rate_updated[] = "\n        Set internal status whether exchange rates have been updated and self.total_balance() is\n        ready to be called. It is not recommended to set this value manually.\n        :param inp: bool\n        :return: None\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_47is_exchange_rate_updated = {"is_exchange_rate_updated", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_47is_exchange_rate_updated, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_46is_exchange_rate_updated};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_47is_exchange_rate_updated(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_exchange_rate_updated (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_inp,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("is_exchange_rate_updated", 1, 2, 2, 1); __PYX_ERR(0, 1408, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "is_exchange_rate_updated") < 0)) __PYX_ERR(0, 1408, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_inp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("is_exchange_rate_updated", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1408, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.is_exchange_rate_updated", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_46is_exchange_rate_updated(__pyx_self, __pyx_v_self, __pyx_v_inp);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_46is_exchange_rate_updated(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_exchange_rate_updated", 0);

  /* "trapeza/account/fx_account.pyx":1416
 *         :raises: TypeError
 *         """
 *         check_types([inp], [bool], ['is_exchange_rate_updated_setter'])             # <<<<<<<<<<<<<<
 *         self._c_is_exchange_rate_updated = inp
 *     @is_exchange_rate_updated.deleter
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_inp);
  __Pyx_GIVEREF(__pyx_v_inp);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_inp);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject*)&PyBool_Type));
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_is_exchange_rate_updated_setter);
  __Pyx_GIVEREF(__pyx_n_u_is_exchange_rate_updated_setter);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_is_exchange_rate_updated_setter);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1416, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1416, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1417
 *         """
 *         check_types([inp], [bool], ['is_exchange_rate_updated_setter'])
 *         self._c_is_exchange_rate_updated = inp             # <<<<<<<<<<<<<<
 *     @is_exchange_rate_updated.deleter
 *     def is_exchange_rate_updated(self):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_is_exchange_rate_updated, __pyx_v_inp) < 0) __PYX_ERR(0, 1417, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1408
 *         return self._c_is_exchange_rate_updated
 *     @is_exchange_rate_updated.setter
 *     def is_exchange_rate_updated(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internal status whether exchange rates have been updated and self.total_balance() is
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.is_exchange_rate_updated", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1419
 *         self._c_is_exchange_rate_updated = inp
 *     @is_exchange_rate_updated.deleter
 *     def is_exchange_rate_updated(self):             # <<<<<<<<<<<<<<
 *         del self.is_exchange_rate_updated
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_49is_exchange_rate_updated(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_49is_exchange_rate_updated = {"is_exchange_rate_updated", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_49is_exchange_rate_updated, METH_O, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_49is_exchange_rate_updated(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_exchange_rate_updated (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_48is_exchange_rate_updated(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_48is_exchange_rate_updated(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_exchange_rate_updated", 0);

  /* "trapeza/account/fx_account.pyx":1420
 *     @is_exchange_rate_updated.deleter
 *     def is_exchange_rate_updated(self):
 *         del self.is_exchange_rate_updated             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  if (__Pyx_PyObject_DelAttrStr(__pyx_v_self, __pyx_n_s_is_exchange_rate_updated) < 0) __PYX_ERR(0, 1420, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1419
 *         self._c_is_exchange_rate_updated = inp
 *     @is_exchange_rate_updated.deleter
 *     def is_exchange_rate_updated(self):             # <<<<<<<<<<<<<<
 *         del self.is_exchange_rate_updated
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.is_exchange_rate_updated", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1423
 * 
 *     @property
 *     def prohibit_debiting(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return whether debiting of account is allowed or not.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_51prohibit_debiting(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_50prohibit_debiting[] = "\n        Return whether debiting of account is allowed or not.\n        :return: bool\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_51prohibit_debiting = {"prohibit_debiting", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_51prohibit_debiting, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_50prohibit_debiting};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_51prohibit_debiting(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prohibit_debiting (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_50prohibit_debiting(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_50prohibit_debiting(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("prohibit_debiting", 0);

  /* "trapeza/account/fx_account.pyx":1428
 *         :return: bool
 *         """
 *         return self._c_prohibit_debiting             # <<<<<<<<<<<<<<
 *     @prohibit_debiting.setter
 *     def prohibit_debiting(self, inp):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_prohibit_debiting); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1423
 * 
 *     @property
 *     def prohibit_debiting(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return whether debiting of account is allowed or not.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.prohibit_debiting", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1430
 *         return self._c_prohibit_debiting
 *     @prohibit_debiting.setter
 *     def prohibit_debiting(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internally whether debiting of account is allowed. It is not recommended to set this value manually as it
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_53prohibit_debiting(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_52prohibit_debiting[] = "\n        Set internally whether debiting of account is allowed. It is not recommended to set this value manually as it\n        might mess up internal heap execution.\n        :param inp: bool\n        :return: None\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_53prohibit_debiting = {"prohibit_debiting", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_53prohibit_debiting, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_52prohibit_debiting};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_53prohibit_debiting(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prohibit_debiting (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_inp,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inp)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("prohibit_debiting", 1, 2, 2, 1); __PYX_ERR(0, 1430, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "prohibit_debiting") < 0)) __PYX_ERR(0, 1430, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_inp = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("prohibit_debiting", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1430, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.prohibit_debiting", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_52prohibit_debiting(__pyx_self, __pyx_v_self, __pyx_v_inp);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_52prohibit_debiting(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_inp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("prohibit_debiting", 0);

  /* "trapeza/account/fx_account.pyx":1438
 *         :raises: TypeError
 *         """
 *         check_types([inp], [bool], ['prohibit_debiting_setter'])             # <<<<<<<<<<<<<<
 *         self._c_prohibit_debiting = inp
 *     @prohibit_debiting.deleter
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_inp);
  __Pyx_GIVEREF(__pyx_v_inp);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_inp);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject*)&PyBool_Type));
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_prohibit_debiting_setter);
  __Pyx_GIVEREF(__pyx_n_u_prohibit_debiting_setter);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_prohibit_debiting_setter);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1439
 *         """
 *         check_types([inp], [bool], ['prohibit_debiting_setter'])
 *         self._c_prohibit_debiting = inp             # <<<<<<<<<<<<<<
 *     @prohibit_debiting.deleter
 *     def prohibit_debiting(self):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_c_prohibit_debiting, __pyx_v_inp) < 0) __PYX_ERR(0, 1439, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1430
 *         return self._c_prohibit_debiting
 *     @prohibit_debiting.setter
 *     def prohibit_debiting(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internally whether debiting of account is allowed. It is not recommended to set this value manually as it
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.prohibit_debiting", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1441
 *         self._c_prohibit_debiting = inp
 *     @prohibit_debiting.deleter
 *     def prohibit_debiting(self):             # <<<<<<<<<<<<<<
 *         del self.prohibit_debiting
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_55prohibit_debiting(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_55prohibit_debiting = {"prohibit_debiting", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_55prohibit_debiting, METH_O, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_55prohibit_debiting(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prohibit_debiting (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_54prohibit_debiting(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_54prohibit_debiting(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("prohibit_debiting", 0);

  /* "trapeza/account/fx_account.pyx":1442
 *     @prohibit_debiting.deleter
 *     def prohibit_debiting(self):
 *         del self.prohibit_debiting             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, reference_currency, depot=None,
 */
  if (__Pyx_PyObject_DelAttrStr(__pyx_v_self, __pyx_n_s_prohibit_debiting) < 0) __PYX_ERR(0, 1442, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1441
 *         self._c_prohibit_debiting = inp
 *     @prohibit_debiting.deleter
 *     def prohibit_debiting(self):             # <<<<<<<<<<<<<<
 *         del self.prohibit_debiting
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.prohibit_debiting", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1444
 *         del self.prohibit_debiting
 * 
 *     def __init__(self, reference_currency, depot=None,             # <<<<<<<<<<<<<<
 *                  fee_buy=False, fee_sell=False, fee_deposit=False, fee_withdraw=False,
 *                  exec_heap=None, long clock=0, exchange_rates=None, marked_coverage='min_backward',
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_57__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_56__init__[] = "\n        Inherits from base class account of trapeza.account.base_account.BaseAccount.\n        Account for managing buy, sell, withdrawal, deposit,\n        transfer (between accounts derived from trapeza.account.base_account.BaseAccount) and\n        collect (between accounts derived from trapeza.account.base_account.BaseAccount) of FX trading transactions.\n        Customizable fee structure. Accounts for transaction processing durations by implementing time-state-logic\n        (comparable to stack automaton).\n        Call self.tick() for proceeding one time unit and to make transactions take effect if they incur transaction\n        processing duration.\n        This class is mainly a wrapper around cFXAccount, which is a more efficient C++ implementation.\n\n        :param reference_currency: str\n                                   reference currency for calculating fees, total balance, etc.\n        :param depot: {dict(currency: volume), None}, default=None\n                      Dictionary which keeps track of depot assets.\n                      depot=None initializes empty dictionary.\n\n                      currency: str (key)\n                      volume: float (value)\n        :param exec_heap: heapq (list) of lists: [time, action_func, volume, currency, coverage], default=None\n                          Heap that stores transactions which take place at future time steps (e.g. due to processing\n                          duration) and is executed at each clock cycle (self.tick()).\n                          Exec_heap=None initializes an empty heap.\n\n                          time: int, in clock cycles/ time base units (starting from 0)\n                          action_func: {'c_withdraw', 'c_deposit'} (or {'withdraw', 'deposit'}: gets parsed to\n                                        'c_withdraw' and 'c_deposit')\n                          volume: float\n                          currency: str\n                          coverage: str (see docstr""ing FXAccount.deposit() or .withdraw().\n                          str as python strings\n        :param clock: int, default=0\n                      internal clock in time base units (or any units the user wishes to define) for event handling\n                      such as transactions delayed by a certain transaction time for filling/ fulfillment.\n                      Increased by one unit when self.tick() is called.\n        :param fee_buy: {func, False}, default=False\n                        False: no fee applied\n                        func: function describing fee structure with signature as follows\n                              (fee_amount,\n                               fee_currency,\n                               fee_exec_time) = fee(volume, price, base, quote, processing_duration)\n                              func must follow above signature\n                              volume, price, base, quote, processing_duration are the same as used within respective\n                              transaction call (in this case FXAccount.buy()). Those arguments are just passed through\n                              from there.\n        :param fee_sell: see fee_buy\n        :param fee_withdraw: see fee_buy,\n                             if func: fee_amount, fee_currency, fee_exec_time\n                                        = fee(volume, price, base, quote, processing_duration)\n                                        = fee(volume, None, currency, currency, processing_duration)\n                                      base input is pre-set to/ called with hardcoded param:currency\n                                      price input is pre-set to/ called with hardcoded None\n                                      quote input is pre-set to/ called with hardcoded param:currency\n                             also applied at transfer\n        :param fee_deposit: see fee_buy\n                             if func: fee_amount, fee_currency, fee_exec_time\n              ""                          = fee(volume, price, base, quote, processing_duration)\n                                        = fee(volume, None, currency, currency, processing_duration)\n                                      base input is pre-set to/ called with hardcoded param:currency\n                                      price input is pre-set to/ called with hardcoded None\n                                      quote input is pre-set to/ called with hardcoded param:currency\n                             also applied at collect\n        :param exchange_rates: {dict, None}, default=None\n                               if None, self.exchange_rates is initialized as empty dict\n\n                               key: (base, quote) --> (from_currency, to_currency) see docstring of class for a\n                                    description of the notation convention in use.\n                                    Should contain all currency pairs of depot positions w.r.t. reference currency\n                                    (otherwise there might be a risk that other functions of FXAccount might throw an\n                                    exception due to data corruption. Data corruption might or might not occur, but\n                                    if it occurs, it will definitely throw an exception).\n                                    Doesn't matter if keys are supplied as base|quote or quote|base as rates will be\n                                    inverted automatically to match currency|reference_currency.\n                                    base: str\n                                    quote: str\n                               value: float,\n                                      exchange_rate of base|quote FX pair\n\n                               (!!!) use FX notation described in docstring of class (!!!)\n                               1.2 USD|EUR (FX) --> 1.2 EUR/USD (mathematical unit)\n                               --> 1 USD * 1.2 EUR/USD == 1.2 ""EUR --> exchange_rate['USD', 'EUR']=1.2\n\n                               It's sufficient enough, to just provide base|quote ratio or quote|base ratio (just one\n                               of them, the inverse is calculated automatically).\n        :param marked_coverage: {False, None, 'max_forward', 'min_backward'}, default = 'min_backward'\n                                      whether to check if marked but not yet booked transactions might lead to future\n                                      coverage violation.\n\n                                      None or False: No coverage checking\n                                      'max_forward': Get the maximum time_step in current heap and check if insertion\n                                                     of transaction into internal heap leads to coverage violation\n                                                     at any time_step (therefore called max_forward, as we look\n                                                     forward into future up to max time horizon within heap).\n                                                     This checks, if any insertion of transaction might lead to a\n                                                     coverage exception at any given time_step.\n                                      'min_backward': Take time_step given by processing_duration of transaction method\n                                                      call, and check if coverage\n                                                      is given up to this time_step. Therefore coverage is only checked\n                                                      whether specific transaction can be filled without coverage\n                                                      violation, but does not check, if transaction might lead to\n                                                      future coverage violations.\n\n                                      - if {'max_forward', 'min_backward'}: throws tr""apeza.exception.CoverageError if\n                                        future coverage is violated\n                                      - if None or False: no coverage check of marked but not yet booked transactions.\n                                        This is independent from the 'coverage' of a transaction's method argument of\n                                        transaction methods which only checks coverage at the time of calling the\n                                        transaction method (e.g. whether depot is covered just at the moment).\n        :param prohibit_debiting: {False, True}, default=False\n                                  if True: no negative positions allowed at time of a transaction's execution\n                                           !!! CoverageError is only thrown at _exec_heap(). This is not a good and\n                                           proper warning, but just a safety backup !!!\n                                  if False: negative positions are allowed. If self.check_marked_coverage is set to\n                                            None, then debiting might really occur.\n        :param ignore_type_checking: bool,\n                                     if True, type checking is omitted, which increases performance but is less safe\n        :raises: TypeError: if argument types are not of specified types\n\n        :TODO: integrate Futures, Options and other Derivatives? (add function which executes derivative; treat\n               derivatives as currency strings regarding sell(), buy() and push to exec_heap)\n        :TODO: reduce complexity in deposit(), withdraw(), transfer(), collect() and total_balance()\n        :TODO: implement rollover\n        :TODO: remove empty positions/ positions equal to zero from self.depot dict (?)\n        :TODO: insert additional abstraction layer to define persistent fee models in order to avoid specifying\n               fee terms separately every time when calling tra""nsactions methods, implementation similar to\n               order_management.monkey_patch()\n        :TODO: [prevent setting underlying c_attributes directly (e.g. _fee, see unit tests for examples): not sure\n                if this really possible or necessary as those attributes are not exposed to the user anyway...]\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_57__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_57__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_56__init__};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_57__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_reference_currency = 0;
  PyObject *__pyx_v_depot = 0;
  PyObject *__pyx_v_fee_buy = 0;
  PyObject *__pyx_v_fee_sell = 0;
  PyObject *__pyx_v_fee_deposit = 0;
  PyObject *__pyx_v_fee_withdraw = 0;
  PyObject *__pyx_v_exec_heap = 0;
  long __pyx_v_clock;
  PyObject *__pyx_v_exchange_rates = 0;
  PyObject *__pyx_v_marked_coverage = 0;
  PyObject *__pyx_v_prohibit_debiting = 0;
  PyObject *__pyx_v_ignore_type_checking = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_reference_currency,&__pyx_n_s_depot,&__pyx_n_s_fee_buy,&__pyx_n_s_fee_sell,&__pyx_n_s_fee_deposit,&__pyx_n_s_fee_withdraw,&__pyx_n_s_exec_heap,&__pyx_n_s_clock,&__pyx_n_s_exchange_rates,&__pyx_n_s_marked_coverage,&__pyx_n_s_prohibit_debiting,&__pyx_n_s_ignore_type_checking,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    values[2] = ((PyObject *)((PyObject *)Py_None));

    /* "trapeza/account/fx_account.pyx":1445
 * 
 *     def __init__(self, reference_currency, depot=None,
 *                  fee_buy=False, fee_sell=False, fee_deposit=False, fee_withdraw=False,             # <<<<<<<<<<<<<<
 *                  exec_heap=None, long clock=0, exchange_rates=None, marked_coverage='min_backward',
 *                  prohibit_debiting=False, ignore_type_checking=False):
 */
    values[3] = ((PyObject *)((PyObject *)Py_False));
    values[4] = ((PyObject *)((PyObject *)Py_False));
    values[5] = ((PyObject *)((PyObject *)Py_False));
    values[6] = ((PyObject *)((PyObject *)Py_False));

    /* "trapeza/account/fx_account.pyx":1446
 *     def __init__(self, reference_currency, depot=None,
 *                  fee_buy=False, fee_sell=False, fee_deposit=False, fee_withdraw=False,
 *                  exec_heap=None, long clock=0, exchange_rates=None, marked_coverage='min_backward',             # <<<<<<<<<<<<<<
 *                  prohibit_debiting=False, ignore_type_checking=False):
 *         """
 */
    values[7] = ((PyObject *)((PyObject *)Py_None));
    values[9] = ((PyObject *)((PyObject *)Py_None));
    values[10] = ((PyObject *)((PyObject*)__pyx_n_u_min_backward));

    /* "trapeza/account/fx_account.pyx":1447
 *                  fee_buy=False, fee_sell=False, fee_deposit=False, fee_withdraw=False,
 *                  exec_heap=None, long clock=0, exchange_rates=None, marked_coverage='min_backward',
 *                  prohibit_debiting=False, ignore_type_checking=False):             # <<<<<<<<<<<<<<
 *         """
 *         Inherits from base class account of trapeza.account.base_account.BaseAccount.
 */
    values[11] = ((PyObject *)((PyObject *)Py_False));
    values[12] = ((PyObject *)((PyObject *)Py_False));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reference_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 13, 1); __PYX_ERR(0, 1444, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_depot);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_buy);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_sell);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_deposit);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_withdraw);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exec_heap);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_clock);
          if (value) { values[8] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exchange_rates);
          if (value) { values[9] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_marked_coverage);
          if (value) { values[10] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_prohibit_debiting);
          if (value) { values[11] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ignore_type_checking);
          if (value) { values[12] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1444, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_reference_currency = values[1];
    __pyx_v_depot = values[2];
    __pyx_v_fee_buy = values[3];
    __pyx_v_fee_sell = values[4];
    __pyx_v_fee_deposit = values[5];
    __pyx_v_fee_withdraw = values[6];
    __pyx_v_exec_heap = values[7];
    if (values[8]) {
      __pyx_v_clock = __Pyx_PyInt_As_long(values[8]); if (unlikely((__pyx_v_clock == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 1446, __pyx_L3_error)
    } else {
      __pyx_v_clock = ((long)((long)0));
    }
    __pyx_v_exchange_rates = values[9];
    __pyx_v_marked_coverage = values[10];
    __pyx_v_prohibit_debiting = values[11];
    __pyx_v_ignore_type_checking = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1444, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_56__init__(__pyx_self, __pyx_v_self, __pyx_v_reference_currency, __pyx_v_depot, __pyx_v_fee_buy, __pyx_v_fee_sell, __pyx_v_fee_deposit, __pyx_v_fee_withdraw, __pyx_v_exec_heap, __pyx_v_clock, __pyx_v_exchange_rates, __pyx_v_marked_coverage, __pyx_v_prohibit_debiting, __pyx_v_ignore_type_checking);

  /* "trapeza/account/fx_account.pyx":1444
 *         del self.prohibit_debiting
 * 
 *     def __init__(self, reference_currency, depot=None,             # <<<<<<<<<<<<<<
 *                  fee_buy=False, fee_sell=False, fee_deposit=False, fee_withdraw=False,
 *                  exec_heap=None, long clock=0, exchange_rates=None, marked_coverage='min_backward',
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_56__init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_reference_currency, PyObject *__pyx_v_depot, PyObject *__pyx_v_fee_buy, PyObject *__pyx_v_fee_sell, PyObject *__pyx_v_fee_deposit, PyObject *__pyx_v_fee_withdraw, PyObject *__pyx_v_exec_heap, long __pyx_v_clock, PyObject *__pyx_v_exchange_rates, PyObject *__pyx_v_marked_coverage, PyObject *__pyx_v_prohibit_debiting, PyObject *__pyx_v_ignore_type_checking) {
  PyObject *__pyx_v_fee_dict = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_depot);
  __Pyx_INCREF(__pyx_v_exec_heap);
  __Pyx_INCREF(__pyx_v_exchange_rates);
  __Pyx_INCREF(__pyx_v_marked_coverage);

  /* "trapeza/account/fx_account.pyx":1577
 *                 if this really possible or necessary as those attributes are not exposed to the user anyway...]
 *         """
 *         check_types([ignore_type_checking], [bool], ['ignore_type_checking'], False)             # <<<<<<<<<<<<<<
 * 
 *         # >>>type checking
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_ignore_type_checking);
  __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_ignore_type_checking);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject*)&PyBool_Type));
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_ignore_type_checking);
  __Pyx_GIVEREF(__pyx_n_u_ignore_type_checking);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_ignore_type_checking);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5, Py_False};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1577, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_5, Py_False};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1577, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1577, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5);
    __Pyx_INCREF(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_7, Py_False);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1577, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1580
 * 
 *         # >>>type checking
 *         check_types([reference_currency, clock, prohibit_debiting],             # <<<<<<<<<<<<<<
 *                     [str, int, bool],
 *                     ['base_currency', 'clock', 'prohibit_debiting'], ignore_type_checking)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_clock); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_reference_currency);
  __Pyx_GIVEREF(__pyx_v_reference_currency);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_reference_currency);
  __Pyx_GIVEREF(__pyx_t_8);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_8);
  __Pyx_INCREF(__pyx_v_prohibit_debiting);
  __Pyx_GIVEREF(__pyx_v_prohibit_debiting);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_v_prohibit_debiting);
  __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1581
 *         # >>>type checking
 *         check_types([reference_currency, clock, prohibit_debiting],
 *                     [str, int, bool],             # <<<<<<<<<<<<<<
 *                     ['base_currency', 'clock', 'prohibit_debiting'], ignore_type_checking)
 *         if marked_coverage is None or marked_coverage is False:
 */
  __pyx_t_8 = PyList_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1581, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_8, 0, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_8, 1, ((PyObject *)(&PyInt_Type)));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_8, 2, ((PyObject*)&PyBool_Type));

  /* "trapeza/account/fx_account.pyx":1582
 *         check_types([reference_currency, clock, prohibit_debiting],
 *                     [str, int, bool],
 *                     ['base_currency', 'clock', 'prohibit_debiting'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *         if marked_coverage is None or marked_coverage is False:
 *             marked_coverage = 0
 */
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_u_base_currency);
  __Pyx_GIVEREF(__pyx_n_u_base_currency);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_base_currency);
  __Pyx_INCREF(__pyx_n_u_clock);
  __Pyx_GIVEREF(__pyx_n_u_clock);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_u_clock);
  __Pyx_INCREF(__pyx_n_u_prohibit_debiting);
  __Pyx_GIVEREF(__pyx_n_u_prohibit_debiting);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_u_prohibit_debiting);
  __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_t_5, __pyx_t_8, __pyx_t_4, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_t_5, __pyx_t_8, __pyx_t_4, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_ignore_type_checking);
    __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
    PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_7, __pyx_v_ignore_type_checking);
    __pyx_t_5 = 0;
    __pyx_t_8 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1583
 *                     [str, int, bool],
 *                     ['base_currency', 'clock', 'prohibit_debiting'], ignore_type_checking)
 *         if marked_coverage is None or marked_coverage is False:             # <<<<<<<<<<<<<<
 *             marked_coverage = 0
 *         elif marked_coverage == 'min_backward':
 */
  __pyx_t_10 = (__pyx_v_marked_coverage == Py_None);
  __pyx_t_11 = (__pyx_t_10 != 0);
  if (!__pyx_t_11) {
  } else {
    __pyx_t_9 = __pyx_t_11;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_11 = (__pyx_v_marked_coverage == Py_False);
  __pyx_t_10 = (__pyx_t_11 != 0);
  __pyx_t_9 = __pyx_t_10;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_9) {

    /* "trapeza/account/fx_account.pyx":1584
 *                     ['base_currency', 'clock', 'prohibit_debiting'], ignore_type_checking)
 *         if marked_coverage is None or marked_coverage is False:
 *             marked_coverage = 0             # <<<<<<<<<<<<<<
 *         elif marked_coverage == 'min_backward':
 *             marked_coverage = 1
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_DECREF_SET(__pyx_v_marked_coverage, __pyx_int_0);

    /* "trapeza/account/fx_account.pyx":1583
 *                     [str, int, bool],
 *                     ['base_currency', 'clock', 'prohibit_debiting'], ignore_type_checking)
 *         if marked_coverage is None or marked_coverage is False:             # <<<<<<<<<<<<<<
 *             marked_coverage = 0
 *         elif marked_coverage == 'min_backward':
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1585
 *         if marked_coverage is None or marked_coverage is False:
 *             marked_coverage = 0
 *         elif marked_coverage == 'min_backward':             # <<<<<<<<<<<<<<
 *             marked_coverage = 1
 *         elif marked_coverage == 'max_forward':
 */
  __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_v_marked_coverage, __pyx_n_u_min_backward, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1585, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "trapeza/account/fx_account.pyx":1586
 *             marked_coverage = 0
 *         elif marked_coverage == 'min_backward':
 *             marked_coverage = 1             # <<<<<<<<<<<<<<
 *         elif marked_coverage == 'max_forward':
 *             marked_coverage = 2
 */
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_DECREF_SET(__pyx_v_marked_coverage, __pyx_int_1);

    /* "trapeza/account/fx_account.pyx":1585
 *         if marked_coverage is None or marked_coverage is False:
 *             marked_coverage = 0
 *         elif marked_coverage == 'min_backward':             # <<<<<<<<<<<<<<
 *             marked_coverage = 1
 *         elif marked_coverage == 'max_forward':
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1587
 *         elif marked_coverage == 'min_backward':
 *             marked_coverage = 1
 *         elif marked_coverage == 'max_forward':             # <<<<<<<<<<<<<<
 *             marked_coverage = 2
 *         if marked_coverage not in [0, 1, 2]:
 */
  __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_v_marked_coverage, __pyx_n_u_max_forward, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1587, __pyx_L1_error)
  if (__pyx_t_9) {

    /* "trapeza/account/fx_account.pyx":1588
 *             marked_coverage = 1
 *         elif marked_coverage == 'max_forward':
 *             marked_coverage = 2             # <<<<<<<<<<<<<<
 *         if marked_coverage not in [0, 1, 2]:
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 */
    __Pyx_INCREF(__pyx_int_2);
    __Pyx_DECREF_SET(__pyx_v_marked_coverage, __pyx_int_2);

    /* "trapeza/account/fx_account.pyx":1587
 *         elif marked_coverage == 'min_backward':
 *             marked_coverage = 1
 *         elif marked_coverage == 'max_forward':             # <<<<<<<<<<<<<<
 *             marked_coverage = 2
 *         if marked_coverage not in [0, 1, 2]:
 */
  }
  __pyx_L3:;

  /* "trapeza/account/fx_account.pyx":1589
 *         elif marked_coverage == 'max_forward':
 *             marked_coverage = 2
 *         if marked_coverage not in [0, 1, 2]:             # <<<<<<<<<<<<<<
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *         if not ignore_type_checking:
 */
  __Pyx_INCREF(__pyx_v_marked_coverage);
  __pyx_t_1 = __pyx_v_marked_coverage;
  __pyx_t_2 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_10) {
  } else {
    __pyx_t_9 = __pyx_t_10;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_9 = __pyx_t_10;
  __pyx_L7_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_10 = (__pyx_t_9 != 0);
  if (unlikely(__pyx_t_10)) {

    /* "trapeza/account/fx_account.pyx":1590
 *             marked_coverage = 2
 *         if marked_coverage not in [0, 1, 2]:
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')             # <<<<<<<<<<<<<<
 *         if not ignore_type_checking:
 *             if fee_buy is not False:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 1590, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":1589
 *         elif marked_coverage == 'max_forward':
 *             marked_coverage = 2
 *         if marked_coverage not in [0, 1, 2]:             # <<<<<<<<<<<<<<
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *         if not ignore_type_checking:
 */
  }

  /* "trapeza/account/fx_account.pyx":1591
 *         if marked_coverage not in [0, 1, 2]:
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *         if not ignore_type_checking:             # <<<<<<<<<<<<<<
 *             if fee_buy is not False:
 *                 check_types([fee_buy], [callable], ['fee_buy'], False)
 */
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_ignore_type_checking); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1591, __pyx_L1_error)
  __pyx_t_9 = ((!__pyx_t_10) != 0);
  if (__pyx_t_9) {

    /* "trapeza/account/fx_account.pyx":1592
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *         if not ignore_type_checking:
 *             if fee_buy is not False:             # <<<<<<<<<<<<<<
 *                 check_types([fee_buy], [callable], ['fee_buy'], False)
 *             if fee_sell is not False:
 */
    __pyx_t_9 = (__pyx_v_fee_buy != Py_False);
    __pyx_t_10 = (__pyx_t_9 != 0);
    if (__pyx_t_10) {

      /* "trapeza/account/fx_account.pyx":1593
 *         if not ignore_type_checking:
 *             if fee_buy is not False:
 *                 check_types([fee_buy], [callable], ['fee_buy'], False)             # <<<<<<<<<<<<<<
 *             if fee_sell is not False:
 *                 check_types([fee_sell], [callable], ['fee_sell'], False)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_fee_buy);
      __Pyx_GIVEREF(__pyx_v_fee_buy);
      PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_fee_buy);
      __pyx_t_4 = __Pyx_GetBuiltinName(__pyx_n_s_callable); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_n_u_fee_buy);
      __Pyx_GIVEREF(__pyx_n_u_fee_buy);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_fee_buy);
      __pyx_t_5 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_6, __pyx_t_8, __pyx_t_4, Py_False};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1593, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_6, __pyx_t_8, __pyx_t_4, Py_False};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1593, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1593, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, __pyx_t_4);
        __Pyx_INCREF(Py_False);
        __Pyx_GIVEREF(Py_False);
        PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_7, Py_False);
        __pyx_t_6 = 0;
        __pyx_t_8 = 0;
        __pyx_t_4 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1593, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "trapeza/account/fx_account.pyx":1592
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *         if not ignore_type_checking:
 *             if fee_buy is not False:             # <<<<<<<<<<<<<<
 *                 check_types([fee_buy], [callable], ['fee_buy'], False)
 *             if fee_sell is not False:
 */
    }

    /* "trapeza/account/fx_account.pyx":1594
 *             if fee_buy is not False:
 *                 check_types([fee_buy], [callable], ['fee_buy'], False)
 *             if fee_sell is not False:             # <<<<<<<<<<<<<<
 *                 check_types([fee_sell], [callable], ['fee_sell'], False)
 *             if fee_deposit is not False:
 */
    __pyx_t_10 = (__pyx_v_fee_sell != Py_False);
    __pyx_t_9 = (__pyx_t_10 != 0);
    if (__pyx_t_9) {

      /* "trapeza/account/fx_account.pyx":1595
 *                 check_types([fee_buy], [callable], ['fee_buy'], False)
 *             if fee_sell is not False:
 *                 check_types([fee_sell], [callable], ['fee_sell'], False)             # <<<<<<<<<<<<<<
 *             if fee_deposit is not False:
 *                 check_types([fee_deposit], [callable], ['fee_deposit'], False)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1595, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1595, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_fee_sell);
      __Pyx_GIVEREF(__pyx_v_fee_sell);
      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_fee_sell);
      __pyx_t_4 = __Pyx_GetBuiltinName(__pyx_n_s_callable); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1595, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1595, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1595, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_n_u_fee_sell);
      __Pyx_GIVEREF(__pyx_n_u_fee_sell);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_fee_sell);
      __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_t_8, __pyx_t_4, Py_False};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1595, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_t_8, __pyx_t_4, Py_False};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1595, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1595, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__pyx_t_6) {
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_7, __pyx_t_4);
        __Pyx_INCREF(Py_False);
        __Pyx_GIVEREF(Py_False);
        PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_7, Py_False);
        __pyx_t_3 = 0;
        __pyx_t_8 = 0;
        __pyx_t_4 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1595, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "trapeza/account/fx_account.pyx":1594
 *             if fee_buy is not False:
 *                 check_types([fee_buy], [callable], ['fee_buy'], False)
 *             if fee_sell is not False:             # <<<<<<<<<<<<<<
 *                 check_types([fee_sell], [callable], ['fee_sell'], False)
 *             if fee_deposit is not False:
 */
    }

    /* "trapeza/account/fx_account.pyx":1596
 *             if fee_sell is not False:
 *                 check_types([fee_sell], [callable], ['fee_sell'], False)
 *             if fee_deposit is not False:             # <<<<<<<<<<<<<<
 *                 check_types([fee_deposit], [callable], ['fee_deposit'], False)
 *             if fee_withdraw is not False:
 */
    __pyx_t_9 = (__pyx_v_fee_deposit != Py_False);
    __pyx_t_10 = (__pyx_t_9 != 0);
    if (__pyx_t_10) {

      /* "trapeza/account/fx_account.pyx":1597
 *                 check_types([fee_sell], [callable], ['fee_sell'], False)
 *             if fee_deposit is not False:
 *                 check_types([fee_deposit], [callable], ['fee_deposit'], False)             # <<<<<<<<<<<<<<
 *             if fee_withdraw is not False:
 *                 check_types([fee_withdraw], [callable], ['fee_withdraw'], False)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1597, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1597, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_fee_deposit);
      __Pyx_GIVEREF(__pyx_v_fee_deposit);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_fee_deposit);
      __pyx_t_4 = __Pyx_GetBuiltinName(__pyx_n_s_callable); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1597, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1597, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1597, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_n_u_fee_deposit);
      __Pyx_GIVEREF(__pyx_n_u_fee_deposit);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_fee_deposit);
      __pyx_t_3 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_t_5, __pyx_t_8, __pyx_t_4, Py_False};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1597, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_t_5, __pyx_t_8, __pyx_t_4, Py_False};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1597, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1597, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_3) {
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, __pyx_t_4);
        __Pyx_INCREF(Py_False);
        __Pyx_GIVEREF(Py_False);
        PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_7, Py_False);
        __pyx_t_5 = 0;
        __pyx_t_8 = 0;
        __pyx_t_4 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1597, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "trapeza/account/fx_account.pyx":1596
 *             if fee_sell is not False:
 *                 check_types([fee_sell], [callable], ['fee_sell'], False)
 *             if fee_deposit is not False:             # <<<<<<<<<<<<<<
 *                 check_types([fee_deposit], [callable], ['fee_deposit'], False)
 *             if fee_withdraw is not False:
 */
    }

    /* "trapeza/account/fx_account.pyx":1598
 *             if fee_deposit is not False:
 *                 check_types([fee_deposit], [callable], ['fee_deposit'], False)
 *             if fee_withdraw is not False:             # <<<<<<<<<<<<<<
 *                 check_types([fee_withdraw], [callable], ['fee_withdraw'], False)
 * 
 */
    __pyx_t_10 = (__pyx_v_fee_withdraw != Py_False);
    __pyx_t_9 = (__pyx_t_10 != 0);
    if (__pyx_t_9) {

      /* "trapeza/account/fx_account.pyx":1599
 *                 check_types([fee_deposit], [callable], ['fee_deposit'], False)
 *             if fee_withdraw is not False:
 *                 check_types([fee_withdraw], [callable], ['fee_withdraw'], False)             # <<<<<<<<<<<<<<
 * 
 *         # >>>depot: key: currency, value: volume -> parse str keys to bytes keys to be compatible with C implementation
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1599, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1599, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_fee_withdraw);
      __Pyx_GIVEREF(__pyx_v_fee_withdraw);
      PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_fee_withdraw);
      __pyx_t_4 = __Pyx_GetBuiltinName(__pyx_n_s_callable); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1599, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1599, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1599, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_n_u_fee_withdraw);
      __Pyx_GIVEREF(__pyx_n_u_fee_withdraw);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_fee_withdraw);
      __pyx_t_5 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_6, __pyx_t_8, __pyx_t_4, Py_False};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_6, __pyx_t_8, __pyx_t_4, Py_False};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1599, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, __pyx_t_4);
        __Pyx_INCREF(Py_False);
        __Pyx_GIVEREF(Py_False);
        PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_7, Py_False);
        __pyx_t_6 = 0;
        __pyx_t_8 = 0;
        __pyx_t_4 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "trapeza/account/fx_account.pyx":1598
 *             if fee_deposit is not False:
 *                 check_types([fee_deposit], [callable], ['fee_deposit'], False)
 *             if fee_withdraw is not False:             # <<<<<<<<<<<<<<
 *                 check_types([fee_withdraw], [callable], ['fee_withdraw'], False)
 * 
 */
    }

    /* "trapeza/account/fx_account.pyx":1591
 *         if marked_coverage not in [0, 1, 2]:
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *         if not ignore_type_checking:             # <<<<<<<<<<<<<<
 *             if fee_buy is not False:
 *                 check_types([fee_buy], [callable], ['fee_buy'], False)
 */
  }

  /* "trapeza/account/fx_account.pyx":1603
 *         # >>>depot: key: currency, value: volume -> parse str keys to bytes keys to be compatible with C implementation
 *         #    of cFXAccount
 *         depot = self._parse_depot(depot, ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *         # >>>heap: (time, action_func, volume, currency, **kwargs)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_depot); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_depot, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1603, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_depot, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1603, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_depot);
    __Pyx_GIVEREF(__pyx_v_depot);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_v_depot);
    __Pyx_INCREF(__pyx_v_ignore_type_checking);
    __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_v_ignore_type_checking);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_depot, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1606
 * 
 *         # >>>heap: (time, action_func, volume, currency, **kwargs)
 *         exec_heap = self._parse_exec_heap(exec_heap, ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *         # >>>parse fees: parse str keys to bytes keys to be compatible with C implementation of cFXAccount
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_exec_heap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_exec_heap, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1606, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_exec_heap, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1606, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1606, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_exec_heap);
    __Pyx_GIVEREF(__pyx_v_exec_heap);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_v_exec_heap);
    __Pyx_INCREF(__pyx_v_ignore_type_checking);
    __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_v_ignore_type_checking);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1606, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_exec_heap, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1609
 * 
 *         # >>>parse fees: parse str keys to bytes keys to be compatible with C implementation of cFXAccount
 *         fee_dict = self._parse_fees(fee_buy, fee_sell, fee_deposit, fee_withdraw, ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *         # >>>exchange rates: parse str keys to bytes keys to be compatible with C implementation of cFXAccount
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_fees); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_fee_buy, __pyx_v_fee_sell, __pyx_v_fee_deposit, __pyx_v_fee_withdraw, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1609, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_v_fee_buy, __pyx_v_fee_sell, __pyx_v_fee_deposit, __pyx_v_fee_withdraw, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1609, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1609, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_fee_buy);
    __Pyx_GIVEREF(__pyx_v_fee_buy);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_v_fee_buy);
    __Pyx_INCREF(__pyx_v_fee_sell);
    __Pyx_GIVEREF(__pyx_v_fee_sell);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_v_fee_sell);
    __Pyx_INCREF(__pyx_v_fee_deposit);
    __Pyx_GIVEREF(__pyx_v_fee_deposit);
    PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_7, __pyx_v_fee_deposit);
    __Pyx_INCREF(__pyx_v_fee_withdraw);
    __Pyx_GIVEREF(__pyx_v_fee_withdraw);
    PyTuple_SET_ITEM(__pyx_t_4, 3+__pyx_t_7, __pyx_v_fee_withdraw);
    __Pyx_INCREF(__pyx_v_ignore_type_checking);
    __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
    PyTuple_SET_ITEM(__pyx_t_4, 4+__pyx_t_7, __pyx_v_ignore_type_checking);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1609, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_fee_dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1612
 * 
 *         # >>>exchange rates: parse str keys to bytes keys to be compatible with C implementation of cFXAccount
 *         exchange_rates =self._parse_exchange_rates(exchange_rates, ignore_type_checking)             # <<<<<<<<<<<<<<
 *         # >>>parse str keys to bytes keys to be compatible with C implementation of cFXAccount
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_exchange_rates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_exchange_rates, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1612, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_exchange_rates, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1612, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_exchange_rates);
    __Pyx_GIVEREF(__pyx_v_exchange_rates);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_v_exchange_rates);
    __Pyx_INCREF(__pyx_v_ignore_type_checking);
    __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_v_ignore_type_checking);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_exchange_rates, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1615
 *         # >>>parse str keys to bytes keys to be compatible with C implementation of cFXAccount
 * 
 *         if not ignore_type_checking:             # <<<<<<<<<<<<<<
 *             check_types([depot, exec_heap, fee_dict, exchange_rates],
 *                         [dict, list, dict, dict],
 */
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_ignore_type_checking); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 1615, __pyx_L1_error)
  __pyx_t_10 = ((!__pyx_t_9) != 0);
  if (__pyx_t_10) {

    /* "trapeza/account/fx_account.pyx":1616
 * 
 *         if not ignore_type_checking:
 *             check_types([depot, exec_heap, fee_dict, exchange_rates],             # <<<<<<<<<<<<<<
 *                         [dict, list, dict, dict],
 *                         ['depot', 'exec_heap', 'fee_dict', 'exchange_rates'], False)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyList_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_depot);
    __Pyx_GIVEREF(__pyx_v_depot);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_depot);
    __Pyx_INCREF(__pyx_v_exec_heap);
    __Pyx_GIVEREF(__pyx_v_exec_heap);
    PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_exec_heap);
    __Pyx_INCREF(__pyx_v_fee_dict);
    __Pyx_GIVEREF(__pyx_v_fee_dict);
    PyList_SET_ITEM(__pyx_t_3, 2, __pyx_v_fee_dict);
    __Pyx_INCREF(__pyx_v_exchange_rates);
    __Pyx_GIVEREF(__pyx_v_exchange_rates);
    PyList_SET_ITEM(__pyx_t_3, 3, __pyx_v_exchange_rates);

    /* "trapeza/account/fx_account.pyx":1617
 *         if not ignore_type_checking:
 *             check_types([depot, exec_heap, fee_dict, exchange_rates],
 *                         [dict, list, dict, dict],             # <<<<<<<<<<<<<<
 *                         ['depot', 'exec_heap', 'fee_dict', 'exchange_rates'], False)
 * 
 */
    __pyx_t_4 = PyList_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1617, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)(&PyDict_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyDict_Type)));
    PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyDict_Type)));
    __Pyx_INCREF(((PyObject *)(&PyList_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyList_Type)));
    PyList_SET_ITEM(__pyx_t_4, 1, ((PyObject *)(&PyList_Type)));
    __Pyx_INCREF(((PyObject *)(&PyDict_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyDict_Type)));
    PyList_SET_ITEM(__pyx_t_4, 2, ((PyObject *)(&PyDict_Type)));
    __Pyx_INCREF(((PyObject *)(&PyDict_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyDict_Type)));
    PyList_SET_ITEM(__pyx_t_4, 3, ((PyObject *)(&PyDict_Type)));

    /* "trapeza/account/fx_account.pyx":1618
 *             check_types([depot, exec_heap, fee_dict, exchange_rates],
 *                         [dict, list, dict, dict],
 *                         ['depot', 'exec_heap', 'fee_dict', 'exchange_rates'], False)             # <<<<<<<<<<<<<<
 * 
 *         super().__init__(reference_currency.encode(), depot, fee_dict, exec_heap, clock, exchange_rates,
 */
    __pyx_t_8 = PyList_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1618, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_n_u_depot);
    __Pyx_GIVEREF(__pyx_n_u_depot);
    PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_u_depot);
    __Pyx_INCREF(__pyx_n_u_exec_heap);
    __Pyx_GIVEREF(__pyx_n_u_exec_heap);
    PyList_SET_ITEM(__pyx_t_8, 1, __pyx_n_u_exec_heap);
    __Pyx_INCREF(__pyx_n_u_fee_dict);
    __Pyx_GIVEREF(__pyx_n_u_fee_dict);
    PyList_SET_ITEM(__pyx_t_8, 2, __pyx_n_u_fee_dict);
    __Pyx_INCREF(__pyx_n_u_exchange_rates);
    __Pyx_GIVEREF(__pyx_n_u_exchange_rates);
    PyList_SET_ITEM(__pyx_t_8, 3, __pyx_n_u_exchange_rates);
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_8, Py_False};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1616, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_3, __pyx_t_4, __pyx_t_8, Py_False};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1616, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1616, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_7, __pyx_t_8);
      __Pyx_INCREF(Py_False);
      __Pyx_GIVEREF(Py_False);
      PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_7, Py_False);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_8 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1616, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1615
 *         # >>>parse str keys to bytes keys to be compatible with C implementation of cFXAccount
 * 
 *         if not ignore_type_checking:             # <<<<<<<<<<<<<<
 *             check_types([depot, exec_heap, fee_dict, exchange_rates],
 *                         [dict, list, dict, dict],
 */
  }

  /* "trapeza/account/fx_account.pyx":1620
 *                         ['depot', 'exec_heap', 'fee_dict', 'exchange_rates'], False)
 * 
 *         super().__init__(reference_currency.encode(), depot, fee_dict, exec_heap, clock, exchange_rates,             # <<<<<<<<<<<<<<
 *                          marked_coverage, prohibit_debiting, ignore_type_checking)
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_GetClassObj(__pyx_self);
  if (!__pyx_t_2) { PyErr_SetString(PyExc_SystemError, "super(): empty __class__ cell"); __PYX_ERR(0, 1620, __pyx_L1_error) }
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_self);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_reference_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_clock); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "trapeza/account/fx_account.pyx":1621
 * 
 *         super().__init__(reference_currency.encode(), depot, fee_dict, exec_heap, clock, exchange_rates,
 *                          marked_coverage, prohibit_debiting, ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *     def _full_reset(self):
 */
  __pyx_t_4 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[10] = {__pyx_t_4, __pyx_t_2, __pyx_v_depot, __pyx_v_fee_dict, __pyx_v_exec_heap, __pyx_t_8, __pyx_v_exchange_rates, __pyx_v_marked_coverage, __pyx_v_prohibit_debiting, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 9+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1620, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[10] = {__pyx_t_4, __pyx_t_2, __pyx_v_depot, __pyx_v_fee_dict, __pyx_v_exec_heap, __pyx_t_8, __pyx_v_exchange_rates, __pyx_v_marked_coverage, __pyx_v_prohibit_debiting, __pyx_v_ignore_type_checking};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 9+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1620, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(9+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_depot);
    __Pyx_GIVEREF(__pyx_v_depot);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_v_depot);
    __Pyx_INCREF(__pyx_v_fee_dict);
    __Pyx_GIVEREF(__pyx_v_fee_dict);
    PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, __pyx_v_fee_dict);
    __Pyx_INCREF(__pyx_v_exec_heap);
    __Pyx_GIVEREF(__pyx_v_exec_heap);
    PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_7, __pyx_v_exec_heap);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_3, 4+__pyx_t_7, __pyx_t_8);
    __Pyx_INCREF(__pyx_v_exchange_rates);
    __Pyx_GIVEREF(__pyx_v_exchange_rates);
    PyTuple_SET_ITEM(__pyx_t_3, 5+__pyx_t_7, __pyx_v_exchange_rates);
    __Pyx_INCREF(__pyx_v_marked_coverage);
    __Pyx_GIVEREF(__pyx_v_marked_coverage);
    PyTuple_SET_ITEM(__pyx_t_3, 6+__pyx_t_7, __pyx_v_marked_coverage);
    __Pyx_INCREF(__pyx_v_prohibit_debiting);
    __Pyx_GIVEREF(__pyx_v_prohibit_debiting);
    PyTuple_SET_ITEM(__pyx_t_3, 7+__pyx_t_7, __pyx_v_prohibit_debiting);
    __Pyx_INCREF(__pyx_v_ignore_type_checking);
    __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
    PyTuple_SET_ITEM(__pyx_t_3, 8+__pyx_t_7, __pyx_v_ignore_type_checking);
    __pyx_t_2 = 0;
    __pyx_t_8 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1444
 *         del self.prohibit_debiting
 * 
 *     def __init__(self, reference_currency, depot=None,             # <<<<<<<<<<<<<<
 *                  fee_buy=False, fee_sell=False, fee_deposit=False, fee_withdraw=False,
 *                  exec_heap=None, long clock=0, exchange_rates=None, marked_coverage='min_backward',
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fee_dict);
  __Pyx_XDECREF(__pyx_v_depot);
  __Pyx_XDECREF(__pyx_v_exec_heap);
  __Pyx_XDECREF(__pyx_v_exchange_rates);
  __Pyx_XDECREF(__pyx_v_marked_coverage);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1623
 *                          marked_coverage, prohibit_debiting, ignore_type_checking)
 * 
 *     def _full_reset(self):             # <<<<<<<<<<<<<<
 *         """
 *         Resets account with depot=None, fee_x=False (e.g. fee_buy), check_marked_coverage='min_backward', empty heap,
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_59_full_reset(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_58_full_reset[] = "\n        Resets account with depot=None, fee_x=False (e.g. fee_buy), check_marked_coverage='min_backward', empty heap,\n        clock=0 and empty exchange_rate dict. Only initial reference_currency is retained. See docstring of __init__\n        for further information.\n        :return: None\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_59_full_reset = {"_full_reset", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_59_full_reset, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_58_full_reset};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_59_full_reset(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_full_reset (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_58_full_reset(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_58_full_reset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_full_reset", 0);

  /* "trapeza/account/fx_account.pyx":1630
 *         :return: None
 *         """
 *         self.__init__(self._c_reference_currency.decode())             # <<<<<<<<<<<<<<
 * 
 *     def _reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_reference_currency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_decode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1623
 *                          marked_coverage, prohibit_debiting, ignore_type_checking)
 * 
 *     def _full_reset(self):             # <<<<<<<<<<<<<<
 *         """
 *         Resets account with depot=None, fee_x=False (e.g. fee_buy), check_marked_coverage='min_backward', empty heap,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._full_reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1632
 *         self.__init__(self._c_reference_currency.decode())
 * 
 *     def _reset(self):             # <<<<<<<<<<<<<<
 *         """
 *         Resets account but retains reference_currency, check_marked_coverage, prohibit_debiting, ignore_type_checking
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_61_reset(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_60_reset[] = "\n        Resets account but retains reference_currency, check_marked_coverage, prohibit_debiting, ignore_type_checking\n        and fee_x (e.g. fee_buy). Depot, heap and exchange_rate dict are set to empty, clock is set to 0. See docstring\n        of __init__ for further information.\n        :return: None\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_61_reset = {"_reset", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_61_reset, METH_O, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_60_reset};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_61_reset(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_reset (wrapper)", 0);
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_60_reset(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_60_reset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_reset", 0);

  /* "trapeza/account/fx_account.pyx":1639
 *         :return: None
 *         """
 *         self._c_reset()             # <<<<<<<<<<<<<<
 * 
 *     def _check_is_valid_fee_func(self, func):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1632
 *         self.__init__(self._c_reference_currency.decode())
 * 
 *     def _reset(self):             # <<<<<<<<<<<<<<
 *         """
 *         Resets account but retains reference_currency, check_marked_coverage, prohibit_debiting, ignore_type_checking
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1641
 *         self._c_reset()
 * 
 *     def _check_is_valid_fee_func(self, func):             # <<<<<<<<<<<<<<
 *         """
 *         Checks if function is a valid function for fees and complies with following signature
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_63_check_is_valid_fee_func(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_62_check_is_valid_fee_func[] = "\n        Checks if function is a valid function for fees and complies with following signature\n        fee_amount, fee_currency, fee_exec_time = fee(volume, price, base, quote, processing_duration)\n        :param func: func\n        :return: None\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_63_check_is_valid_fee_func = {"_check_is_valid_fee_func", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_63_check_is_valid_fee_func, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_62_check_is_valid_fee_func};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_63_check_is_valid_fee_func(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_func = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_is_valid_fee_func (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_func,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_func)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_check_is_valid_fee_func", 1, 2, 2, 1); __PYX_ERR(0, 1641, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_check_is_valid_fee_func") < 0)) __PYX_ERR(0, 1641, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_func = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_check_is_valid_fee_func", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1641, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._check_is_valid_fee_func", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_62_check_is_valid_fee_func(__pyx_self, __pyx_v_self, __pyx_v_func);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_62_check_is_valid_fee_func(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_func) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_is_valid_fee_func", 0);

  /* "trapeza/account/fx_account.pyx":1649
 *         :raises: TypeError
 *         """
 *         result = func(1, 1, 'X', 'Y', 1)             # <<<<<<<<<<<<<<
 *         if len(result) != 3:
 *             raise TypeError
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_func, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1650
 *         """
 *         result = func(1, 1, 'X', 'Y', 1)
 *         if len(result) != 3:             # <<<<<<<<<<<<<<
 *             raise TypeError
 *         check_types([result[0], result[1], result[2]], [float, str, float],
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_result); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1650, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_2 != 3) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "trapeza/account/fx_account.pyx":1651
 *         result = func(1, 1, 'X', 'Y', 1)
 *         if len(result) != 3:
 *             raise TypeError             # <<<<<<<<<<<<<<
 *         check_types([result[0], result[1], result[2]], [float, str, float],
 *                     ['fee_amount', 'fee_currency', 'fee_processing_duration'], self._c_ignore_type_checking)
 */
    __Pyx_Raise(__pyx_builtin_TypeError, 0, 0, 0);
    __PYX_ERR(0, 1651, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":1650
 *         """
 *         result = func(1, 1, 'X', 'Y', 1)
 *         if len(result) != 3:             # <<<<<<<<<<<<<<
 *             raise TypeError
 *         check_types([result[0], result[1], result[2]], [float, str, float],
 */
  }

  /* "trapeza/account/fx_account.pyx":1652
 *         if len(result) != 3:
 *             raise TypeError
 *         check_types([result[0], result[1], result[2]], [float, str, float],             # <<<<<<<<<<<<<<
 *                     ['fee_amount', 'fee_currency', 'fee_processing_duration'], self._c_ignore_type_checking)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_result, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_result, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyList_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyList_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = PyList_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_7, 0, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_7, 1, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_7, 2, ((PyObject *)(&PyFloat_Type)));

  /* "trapeza/account/fx_account.pyx":1653
 *             raise TypeError
 *         check_types([result[0], result[1], result[2]], [float, str, float],
 *                     ['fee_amount', 'fee_currency', 'fee_processing_duration'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1653, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_n_u_fee_amount);
  __Pyx_GIVEREF(__pyx_n_u_fee_amount);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_fee_amount);
  __Pyx_INCREF(__pyx_n_u_fee_currency);
  __Pyx_GIVEREF(__pyx_n_u_fee_currency);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_n_u_fee_currency);
  __Pyx_INCREF(__pyx_n_u_fee_processing_duration);
  __Pyx_GIVEREF(__pyx_n_u_fee_processing_duration);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_n_u_fee_processing_duration);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1653, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_9 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_5);
    __pyx_t_8 = 0;
    __pyx_t_7 = 0;
    __pyx_t_6 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1641
 *         self._c_reset()
 * 
 *     def _check_is_valid_fee_func(self, func):             # <<<<<<<<<<<<<<
 *         """
 *         Checks if function is a valid function for fees and complies with following signature
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._check_is_valid_fee_func", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1656
 * 
 *     @staticmethod
 *     def _parse_depot(depot, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks init arguments
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_65_parse_depot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_64_parse_depot[] = "\n        Parses and checks init arguments\n        :param depot: dict(currency: volume) with currency as string and volume as float or None\n        :param ignore_type_checking: bool,\n                                     if True, type checking is omitted, which increases performance but is less safe\n        :return: dict (currency: volume) with currency as string and volume as float encoded for passing to underlying\n                 C++ implementation\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_65_parse_depot = {"_parse_depot", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_65_parse_depot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_64_parse_depot};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_65_parse_depot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_depot = 0;
  PyObject *__pyx_v_ignore_type_checking = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_parse_depot (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_depot,&__pyx_n_s_ignore_type_checking,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_depot)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ignore_type_checking)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_depot", 1, 2, 2, 1); __PYX_ERR(0, 1656, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse_depot") < 0)) __PYX_ERR(0, 1656, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_depot = values[0];
    __pyx_v_ignore_type_checking = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_parse_depot", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1656, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_64_parse_depot(__pyx_self, __pyx_v_depot, __pyx_v_ignore_type_checking);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_64_parse_depot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_depot, PyObject *__pyx_v_ignore_type_checking) {
  PyObject *__pyx_v_currency = NULL;
  PyObject *__pyx_v_volume = NULL;
  PyObject *__pyx_8genexpr4__pyx_v_k = NULL;
  PyObject *__pyx_8genexpr4__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_parse_depot", 0);
  __Pyx_INCREF(__pyx_v_depot);

  /* "trapeza/account/fx_account.pyx":1666
 *         :raises: TypeError
 *         """
 *         if depot is None:             # <<<<<<<<<<<<<<
 *             depot = dict()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_depot == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "trapeza/account/fx_account.pyx":1667
 *         """
 *         if depot is None:
 *             depot = dict()             # <<<<<<<<<<<<<<
 *         else:
 *             check_types([depot], [dict], ['depot'], ignore_type_checking)
 */
    __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1667, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_depot, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "trapeza/account/fx_account.pyx":1666
 *         :raises: TypeError
 *         """
 *         if depot is None:             # <<<<<<<<<<<<<<
 *             depot = dict()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1669
 *             depot = dict()
 *         else:
 *             check_types([depot], [dict], ['depot'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *             for currency, volume in depot.items():
 *                 check_types([currency, volume], [str, float], ['currency in depot', 'currency volume in depot'],
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_depot);
    __Pyx_GIVEREF(__pyx_v_depot);
    PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_depot);
    __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(((PyObject *)(&PyDict_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyDict_Type)));
    PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyDict_Type)));
    __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_n_u_depot);
    __Pyx_GIVEREF(__pyx_n_u_depot);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_u_depot);
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_v_ignore_type_checking};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1669, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_v_ignore_type_checking};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1669, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1669, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_7);
      __Pyx_INCREF(__pyx_v_ignore_type_checking);
      __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
      PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_v_ignore_type_checking);
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1669, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "trapeza/account/fx_account.pyx":1670
 *         else:
 *             check_types([depot], [dict], ['depot'], ignore_type_checking)
 *             for currency, volume in depot.items():             # <<<<<<<<<<<<<<
 *                 check_types([currency, volume], [str, float], ['currency in depot', 'currency volume in depot'],
 *                             ignore_type_checking)
 */
    __pyx_t_11 = 0;
    if (unlikely(__pyx_v_depot == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
      __PYX_ERR(0, 1670, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_depot, 0, __pyx_n_s_items, (&__pyx_t_12), (&__pyx_t_9)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1670, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
    while (1) {
      __pyx_t_13 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_12, &__pyx_t_11, &__pyx_t_4, &__pyx_t_10, NULL, __pyx_t_9);
      if (unlikely(__pyx_t_13 == 0)) break;
      if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1670, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_XDECREF_SET(__pyx_v_currency, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_volume, __pyx_t_10);
      __pyx_t_10 = 0;

      /* "trapeza/account/fx_account.pyx":1671
 *             check_types([depot], [dict], ['depot'], ignore_type_checking)
 *             for currency, volume in depot.items():
 *                 check_types([currency, volume], [str, float], ['currency in depot', 'currency volume in depot'],             # <<<<<<<<<<<<<<
 *                             ignore_type_checking)
 *             depot = {k.encode(): v for k, v in depot.items()}
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_currency);
      __Pyx_GIVEREF(__pyx_v_currency);
      PyList_SET_ITEM(__pyx_t_7, 0, __pyx_v_currency);
      __Pyx_INCREF(__pyx_v_volume);
      __Pyx_GIVEREF(__pyx_v_volume);
      PyList_SET_ITEM(__pyx_t_7, 1, __pyx_v_volume);
      __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
      PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyUnicode_Type)));
      __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
      PyList_SET_ITEM(__pyx_t_6, 1, ((PyObject *)(&PyFloat_Type)));
      __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_kp_u_currency_in_depot);
      __Pyx_GIVEREF(__pyx_kp_u_currency_in_depot);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_currency_in_depot);
      __Pyx_INCREF(__pyx_kp_u_currency_volume_in_depot);
      __Pyx_GIVEREF(__pyx_kp_u_currency_volume_in_depot);
      PyList_SET_ITEM(__pyx_t_5, 1, __pyx_kp_u_currency_volume_in_depot);

      /* "trapeza/account/fx_account.pyx":1672
 *             for currency, volume in depot.items():
 *                 check_types([currency, volume], [str, float], ['currency in depot', 'currency volume in depot'],
 *                             ignore_type_checking)             # <<<<<<<<<<<<<<
 *             depot = {k.encode(): v for k, v in depot.items()}
 *         return depot
 */
      __pyx_t_8 = NULL;
      __pyx_t_13 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_13 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_t_5, __pyx_v_ignore_type_checking};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_13, 4+__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1671, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_t_5, __pyx_v_ignore_type_checking};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_13, 4+__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1671, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(4+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1671, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_13, __pyx_t_5);
        __Pyx_INCREF(__pyx_v_ignore_type_checking);
        __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
        PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_13, __pyx_v_ignore_type_checking);
        __pyx_t_7 = 0;
        __pyx_t_6 = 0;
        __pyx_t_5 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_14, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1671, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "trapeza/account/fx_account.pyx":1673
 *                 check_types([currency, volume], [str, float], ['currency in depot', 'currency volume in depot'],
 *                             ignore_type_checking)
 *             depot = {k.encode(): v for k, v in depot.items()}             # <<<<<<<<<<<<<<
 *         return depot
 * 
 */
    { /* enter inner scope */
      __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1673, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_12 = 0;
      if (unlikely(__pyx_v_depot == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
        __PYX_ERR(0, 1673, __pyx_L8_error)
      }
      __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_depot, 0, __pyx_n_s_items, (&__pyx_t_11), (&__pyx_t_9)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1673, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_10);
      __pyx_t_10 = __pyx_t_4;
      __pyx_t_4 = 0;
      while (1) {
        __pyx_t_13 = __Pyx_dict_iter_next(__pyx_t_10, __pyx_t_11, &__pyx_t_12, &__pyx_t_4, &__pyx_t_14, NULL, __pyx_t_9);
        if (unlikely(__pyx_t_13 == 0)) break;
        if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1673, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_k, __pyx_t_4);
        __pyx_t_4 = 0;
        __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_v, __pyx_t_14);
        __pyx_t_14 = 0;
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr4__pyx_v_k, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1673, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_14 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1673, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_t_14, (PyObject*)__pyx_8genexpr4__pyx_v_v))) __PYX_ERR(0, 1673, __pyx_L8_error)
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_k); __pyx_8genexpr4__pyx_v_k = 0;
      __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_v); __pyx_8genexpr4__pyx_v_v = 0;
      goto __pyx_L11_exit_scope;
      __pyx_L8_error:;
      __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_k); __pyx_8genexpr4__pyx_v_k = 0;
      __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_v); __pyx_8genexpr4__pyx_v_v = 0;
      goto __pyx_L1_error;
      __pyx_L11_exit_scope:;
    } /* exit inner scope */
    __Pyx_DECREF_SET(__pyx_v_depot, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "trapeza/account/fx_account.pyx":1674
 *                             ignore_type_checking)
 *             depot = {k.encode(): v for k, v in depot.items()}
 *         return depot             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_depot);
  __pyx_r = __pyx_v_depot;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1656
 * 
 *     @staticmethod
 *     def _parse_depot(depot, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks init arguments
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_depot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_currency);
  __Pyx_XDECREF(__pyx_v_volume);
  __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_k);
  __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_depot);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1677
 * 
 *     @staticmethod
 *     def _parse_exec_heap(exec_heap, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks if provided (heap) list is valid as internal execution heap
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_67_parse_exec_heap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_66_parse_exec_heap[] = "\n        Parses and checks if provided (heap) list is valid as internal execution heap\n        :param exec_heap: heapq (list) of lists: [int:time, str:action_func, float:volume, str:currency, str:coverage]\n                          or None\n                          if None: empty heap\n        :return: parsed input as list of lists\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_67_parse_exec_heap = {"_parse_exec_heap", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_67_parse_exec_heap, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_66_parse_exec_heap};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_67_parse_exec_heap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_exec_heap = 0;
  PyObject *__pyx_v_ignore_type_checking = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_parse_exec_heap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_exec_heap,&__pyx_n_s_ignore_type_checking,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exec_heap)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ignore_type_checking)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_exec_heap", 1, 2, 2, 1); __PYX_ERR(0, 1677, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse_exec_heap") < 0)) __PYX_ERR(0, 1677, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_exec_heap = values[0];
    __pyx_v_ignore_type_checking = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_parse_exec_heap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1677, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_exec_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_66_parse_exec_heap(__pyx_self, __pyx_v_exec_heap, __pyx_v_ignore_type_checking);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_66_parse_exec_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_exec_heap, PyObject *__pyx_v_ignore_type_checking) {
  int __pyx_v_has_warn;
  int __pyx_v_has_risen;
  CYTHON_UNUSED Py_ssize_t __pyx_v__;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_element = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  Py_ssize_t __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_parse_exec_heap", 0);
  __Pyx_INCREF(__pyx_v_exec_heap);

  /* "trapeza/account/fx_account.pyx":1686
 *         :raises: TypeError
 *         """
 *         has_warn = False             # <<<<<<<<<<<<<<
 *         has_risen = False
 * 
 */
  __pyx_v_has_warn = 0;

  /* "trapeza/account/fx_account.pyx":1687
 *         """
 *         has_warn = False
 *         has_risen = False             # <<<<<<<<<<<<<<
 * 
 *         # heap: [time:int, action_func:str, volume:float, currency:str, coverage:str]
 */
  __pyx_v_has_risen = 0;

  /* "trapeza/account/fx_account.pyx":1690
 * 
 *         # heap: [time:int, action_func:str, volume:float, currency:str, coverage:str]
 *         if exec_heap is None:             # <<<<<<<<<<<<<<
 *             exec_heap = []
 *         elif type(exec_heap) in [tuple, list] and len(exec_heap) == 0:
 */
  __pyx_t_1 = (__pyx_v_exec_heap == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "trapeza/account/fx_account.pyx":1691
 *         # heap: [time:int, action_func:str, volume:float, currency:str, coverage:str]
 *         if exec_heap is None:
 *             exec_heap = []             # <<<<<<<<<<<<<<
 *         elif type(exec_heap) in [tuple, list] and len(exec_heap) == 0:
 *             exec_heap = []
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_exec_heap, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "trapeza/account/fx_account.pyx":1690
 * 
 *         # heap: [time:int, action_func:str, volume:float, currency:str, coverage:str]
 *         if exec_heap is None:             # <<<<<<<<<<<<<<
 *             exec_heap = []
 *         elif type(exec_heap) in [tuple, list] and len(exec_heap) == 0:
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1692
 *         if exec_heap is None:
 *             exec_heap = []
 *         elif type(exec_heap) in [tuple, list] and len(exec_heap) == 0:             # <<<<<<<<<<<<<<
 *             exec_heap = []
 *         else:
 */
  __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_exec_heap)));
  __pyx_t_3 = ((PyObject *)Py_TYPE(__pyx_v_exec_heap));
  __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_t_3), ((PyObject *)(&PyTuple_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1692, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1692, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_t_3), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1692, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1692, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_5;
  __pyx_L6_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = (__pyx_t_1 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = PyObject_Length(__pyx_v_exec_heap); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1692, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_6 == 0) != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "trapeza/account/fx_account.pyx":1693
 *             exec_heap = []
 *         elif type(exec_heap) in [tuple, list] and len(exec_heap) == 0:
 *             exec_heap = []             # <<<<<<<<<<<<<<
 *         else:
 *             try:
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_exec_heap, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "trapeza/account/fx_account.pyx":1692
 *         if exec_heap is None:
 *             exec_heap = []
 *         elif type(exec_heap) in [tuple, list] and len(exec_heap) == 0:             # <<<<<<<<<<<<<<
 *             exec_heap = []
 *         else:
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1695
 *             exec_heap = []
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 _ = len(exec_heap[0])  # this will throw an exception if 1D list
 *                 # if no exception, exec_heap is list of tuples or list of list
 */
  /*else*/ {
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      /*try:*/ {

        /* "trapeza/account/fx_account.pyx":1696
 *         else:
 *             try:
 *                 _ = len(exec_heap[0])  # this will throw an exception if 1D list             # <<<<<<<<<<<<<<
 *                 # if no exception, exec_heap is list of tuples or list of list
 *                 if tuple(exec_heap) == exec_heap:
 */
        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_exec_heap, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1696, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1696, __pyx_L8_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_v__ = __pyx_t_6;

        /* "trapeza/account/fx_account.pyx":1698
 *                 _ = len(exec_heap[0])  # this will throw an exception if 1D list
 *                 # if no exception, exec_heap is list of tuples or list of list
 *                 if tuple(exec_heap) == exec_heap:             # <<<<<<<<<<<<<<
 *                     # convert 2D tuple such that at leas outer container is list
 *                     exec_heap = list(exec_heap)
 */
        __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_exec_heap); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1698, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_exec_heap, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1698, __pyx_L8_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1698, __pyx_L8_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__pyx_t_2) {

          /* "trapeza/account/fx_account.pyx":1700
 *                 if tuple(exec_heap) == exec_heap:
 *                     # convert 2D tuple such that at leas outer container is list
 *                     exec_heap = list(exec_heap)             # <<<<<<<<<<<<<<
 *                 elif not list(exec_heap) == exec_heap:
 *                     has_risen = True
 */
          __pyx_t_4 = PySequence_List(__pyx_v_exec_heap); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1700, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF_SET(__pyx_v_exec_heap, __pyx_t_4);
          __pyx_t_4 = 0;

          /* "trapeza/account/fx_account.pyx":1698
 *                 _ = len(exec_heap[0])  # this will throw an exception if 1D list
 *                 # if no exception, exec_heap is list of tuples or list of list
 *                 if tuple(exec_heap) == exec_heap:             # <<<<<<<<<<<<<<
 *                     # convert 2D tuple such that at leas outer container is list
 *                     exec_heap = list(exec_heap)
 */
          goto __pyx_L14;
        }

        /* "trapeza/account/fx_account.pyx":1701
 *                     # convert 2D tuple such that at leas outer container is list
 *                     exec_heap = list(exec_heap)
 *                 elif not list(exec_heap) == exec_heap:             # <<<<<<<<<<<<<<
 *                     has_risen = True
 *                     raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'
 */
        __pyx_t_4 = PySequence_List(__pyx_v_exec_heap); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1701, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_v_exec_heap, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1701, __pyx_L8_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1701, __pyx_L8_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_5 = ((!__pyx_t_2) != 0);
        if (unlikely(__pyx_t_5)) {

          /* "trapeza/account/fx_account.pyx":1702
 *                     exec_heap = list(exec_heap)
 *                 elif not list(exec_heap) == exec_heap:
 *                     has_risen = True             # <<<<<<<<<<<<<<
 *                     raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'
 *                                     'to exec_heap or list of single entry to exec_heap. Single entry to exec_heap'
 */
          __pyx_v_has_risen = 1;

          /* "trapeza/account/fx_account.pyx":1703
 *                 elif not list(exec_heap) == exec_heap:
 *                     has_risen = True
 *                     raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'             # <<<<<<<<<<<<<<
 *                                     'to exec_heap or list of single entry to exec_heap. Single entry to exec_heap'
 *                                     'consists of: [int:time, str:action_func, float:volume, str:currency, '
 */
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1703, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __PYX_ERR(0, 1703, __pyx_L8_error)

          /* "trapeza/account/fx_account.pyx":1701
 *                     # convert 2D tuple such that at leas outer container is list
 *                     exec_heap = list(exec_heap)
 *                 elif not list(exec_heap) == exec_heap:             # <<<<<<<<<<<<<<
 *                     has_risen = True
 *                     raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'
 */
        }
        __pyx_L14:;

        /* "trapeza/account/fx_account.pyx":1695
 *             exec_heap = []
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 _ = len(exec_heap[0])  # this will throw an exception if 1D list
 *                 # if no exception, exec_heap is list of tuples or list of list
 */
      }
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L13_try_end;
      __pyx_L8_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "trapeza/account/fx_account.pyx":1707
 *                                     'consists of: [int:time, str:action_func, float:volume, str:currency, '
 *                                     'str:coverage]')
 *             except KeyError:             # <<<<<<<<<<<<<<
 *                 raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'
 *                                 'to exec_heap or list of single entry to exec_heap. Single entry to exec_heap'
 */
      __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
      if (__pyx_t_10) {
        __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_exec_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_11) < 0) __PYX_ERR(0, 1707, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_11);

        /* "trapeza/account/fx_account.pyx":1708
 *                                     'str:coverage]')
 *             except KeyError:
 *                 raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'             # <<<<<<<<<<<<<<
 *                                 'to exec_heap or list of single entry to exec_heap. Single entry to exec_heap'
 *                                 'consists of: [int:time, str:action_func, float:volume, str:currency, str:coverage]')
 */
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1708, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_Raise(__pyx_t_12, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __PYX_ERR(0, 1708, __pyx_L10_except_error)
      }

      /* "trapeza/account/fx_account.pyx":1711
 *                                 'to exec_heap or list of single entry to exec_heap. Single entry to exec_heap'
 *                                 'consists of: [int:time, str:action_func, float:volume, str:currency, str:coverage]')
 *             except (TypeError, IndexError):             # <<<<<<<<<<<<<<
 *                 if has_risen:
 *                     raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'
 */
      __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_IndexError);
      if (__pyx_t_10) {
        __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_exec_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_4, &__pyx_t_3) < 0) __PYX_ERR(0, 1711, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_3);

        /* "trapeza/account/fx_account.pyx":1712
 *                                 'consists of: [int:time, str:action_func, float:volume, str:currency, str:coverage]')
 *             except (TypeError, IndexError):
 *                 if has_risen:             # <<<<<<<<<<<<<<
 *                     raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'
 *                                     'to exec_heap or list of single entry to exec_heap. Single entry to exec_heap'
 */
        __pyx_t_5 = (__pyx_v_has_risen != 0);
        if (unlikely(__pyx_t_5)) {

          /* "trapeza/account/fx_account.pyx":1713
 *             except (TypeError, IndexError):
 *                 if has_risen:
 *                     raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'             # <<<<<<<<<<<<<<
 *                                     'to exec_heap or list of single entry to exec_heap. Single entry to exec_heap'
 *                                     'consists of: [int:time, str:action_func, float:volume, str:currency, '
 */
          __pyx_t_12 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1713, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_Raise(__pyx_t_12, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __PYX_ERR(0, 1713, __pyx_L10_except_error)

          /* "trapeza/account/fx_account.pyx":1712
 *                                 'consists of: [int:time, str:action_func, float:volume, str:currency, str:coverage]')
 *             except (TypeError, IndexError):
 *                 if has_risen:             # <<<<<<<<<<<<<<
 *                     raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'
 *                                     'to exec_heap or list of single entry to exec_heap. Single entry to exec_heap'
 */
        }

        /* "trapeza/account/fx_account.pyx":1719
 *                 else:
 *                     # exception indicates, that exec heap is 1D -> turn it into 2D array for heapify
 *                     exec_heap = [exec_heap]             # <<<<<<<<<<<<<<
 * 
 *             # turn list into heap
 */
        /*else*/ {
          __pyx_t_12 = PyList_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1719, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_v_exec_heap);
          __Pyx_GIVEREF(__pyx_v_exec_heap);
          PyList_SET_ITEM(__pyx_t_12, 0, __pyx_v_exec_heap);
          __Pyx_DECREF_SET(__pyx_v_exec_heap, __pyx_t_12);
          __pyx_t_12 = 0;
        }
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L9_exception_handled;
      }
      goto __pyx_L10_except_error;
      __pyx_L10_except_error:;

      /* "trapeza/account/fx_account.pyx":1695
 *             exec_heap = []
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 _ = len(exec_heap[0])  # this will throw an exception if 1D list
 *                 # if no exception, exec_heap is list of tuples or list of list
 */
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      goto __pyx_L1_error;
      __pyx_L9_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_L13_try_end:;
    }

    /* "trapeza/account/fx_account.pyx":1722
 * 
 *             # turn list into heap
 *             heapq.heapify(exec_heap)             # <<<<<<<<<<<<<<
 * 
 *             # do type checking
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_heapq); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_heapify); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_4, __pyx_v_exec_heap) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_exec_heap);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "trapeza/account/fx_account.pyx":1725
 * 
 *             # do type checking
 *             for i, element in enumerate(exec_heap):             # <<<<<<<<<<<<<<
 *                 # [time:int, action_func:str, volume:float, currency:str, coverage:str]
 *                 if type(element) is tuple:
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_3 = __pyx_int_0;
    if (likely(PyList_CheckExact(__pyx_v_exec_heap)) || PyTuple_CheckExact(__pyx_v_exec_heap)) {
      __pyx_t_11 = __pyx_v_exec_heap; __Pyx_INCREF(__pyx_t_11); __pyx_t_6 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_v_exec_heap); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1725, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_13 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1725, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_11))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_11)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 1725, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_11, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1725, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 1725, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_11, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1725, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_13(__pyx_t_11);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1725, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_element, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1725, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3);
      __pyx_t_3 = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "trapeza/account/fx_account.pyx":1727
 *             for i, element in enumerate(exec_heap):
 *                 # [time:int, action_func:str, volume:float, currency:str, coverage:str]
 *                 if type(element) is tuple:             # <<<<<<<<<<<<<<
 *                     exec_heap[i] = list(element)
 *                     element = exec_heap[i]
 */
      __pyx_t_5 = (((PyObject *)Py_TYPE(__pyx_v_element)) == ((PyObject *)(&PyTuple_Type)));
      __pyx_t_2 = (__pyx_t_5 != 0);
      if (__pyx_t_2) {

        /* "trapeza/account/fx_account.pyx":1728
 *                 # [time:int, action_func:str, volume:float, currency:str, coverage:str]
 *                 if type(element) is tuple:
 *                     exec_heap[i] = list(element)             # <<<<<<<<<<<<<<
 *                     element = exec_heap[i]
 * 
 */
        __pyx_t_4 = PySequence_List(__pyx_v_element); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1728, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (unlikely(PyObject_SetItem(__pyx_v_exec_heap, __pyx_v_i, __pyx_t_4) < 0)) __PYX_ERR(0, 1728, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "trapeza/account/fx_account.pyx":1729
 *                 if type(element) is tuple:
 *                     exec_heap[i] = list(element)
 *                     element = exec_heap[i]             # <<<<<<<<<<<<<<
 * 
 *                 if len(element) < 5:
 */
        __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_exec_heap, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1729, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF_SET(__pyx_v_element, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "trapeza/account/fx_account.pyx":1727
 *             for i, element in enumerate(exec_heap):
 *                 # [time:int, action_func:str, volume:float, currency:str, coverage:str]
 *                 if type(element) is tuple:             # <<<<<<<<<<<<<<
 *                     exec_heap[i] = list(element)
 *                     element = exec_heap[i]
 */
      }

      /* "trapeza/account/fx_account.pyx":1731
 *                     element = exec_heap[i]
 * 
 *                 if len(element) < 5:             # <<<<<<<<<<<<<<
 *                     raise TypeError('Single entry to exec_heap consists of: [int:time, str:action_func, float:volume, '
 *                                     'str:currency, str:coverage]. Only {} elements were given '
 */
      __pyx_t_14 = PyObject_Length(__pyx_v_element); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1731, __pyx_L1_error)
      __pyx_t_2 = ((__pyx_t_14 < 5) != 0);
      if (unlikely(__pyx_t_2)) {

        /* "trapeza/account/fx_account.pyx":1735
 *                                     'str:currency, str:coverage]. Only {} elements were given '
 *                                     'as single entry to exec_heap. Either a single entry or a list of single entries '
 *                                     'can be used to set exec_heap manually.'.format(len(element)))             # <<<<<<<<<<<<<<
 * 
 *                 if element[1] in ['withdraw', 'deposit']:
 */
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Single_entry_to_exec_heap_consis, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1735, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_14 = PyObject_Length(__pyx_v_element); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1735, __pyx_L1_error)
        __pyx_t_15 = PyInt_FromSsize_t(__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1735, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_16 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_12);
          if (likely(__pyx_t_16)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_16);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_12, function);
          }
        }
        __pyx_t_4 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_16, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_15);
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1735, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "trapeza/account/fx_account.pyx":1732
 * 
 *                 if len(element) < 5:
 *                     raise TypeError('Single entry to exec_heap consists of: [int:time, str:action_func, float:volume, '             # <<<<<<<<<<<<<<
 *                                     'str:currency, str:coverage]. Only {} elements were given '
 *                                     'as single entry to exec_heap. Either a single entry or a list of single entries '
 */
        __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1732, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_12, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __PYX_ERR(0, 1732, __pyx_L1_error)

        /* "trapeza/account/fx_account.pyx":1731
 *                     element = exec_heap[i]
 * 
 *                 if len(element) < 5:             # <<<<<<<<<<<<<<
 *                     raise TypeError('Single entry to exec_heap consists of: [int:time, str:action_func, float:volume, '
 *                                     'str:currency, str:coverage]. Only {} elements were given '
 */
      }

      /* "trapeza/account/fx_account.pyx":1737
 *                                     'can be used to set exec_heap manually.'.format(len(element)))
 * 
 *                 if element[1] in ['withdraw', 'deposit']:             # <<<<<<<<<<<<<<
 *                     exec_heap[i][1] = ''.join(['c_', element[1]])
 *                     if has_warn is False:
 */
      __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_element, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1737, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_withdraw, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1737, __pyx_L1_error)
      if (!__pyx_t_5) {
      } else {
        __pyx_t_2 = __pyx_t_5;
        goto __pyx_L25_bool_binop_done;
      }
      __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_deposit, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1737, __pyx_L1_error)
      __pyx_t_2 = __pyx_t_5;
      __pyx_L25_bool_binop_done:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_5 = (__pyx_t_2 != 0);
      if (__pyx_t_5) {

        /* "trapeza/account/fx_account.pyx":1738
 * 
 *                 if element[1] in ['withdraw', 'deposit']:
 *                     exec_heap[i][1] = ''.join(['c_', element[1]])             # <<<<<<<<<<<<<<
 *                     if has_warn is False:
 *                         warnings.warn('Auto-converting "withdraw" and "deposit" to "c_withdraw" and "c_deposit" (to '
 */
        __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_element, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1738, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1738, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_n_u_c);
        __Pyx_GIVEREF(__pyx_n_u_c);
        PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_c);
        __Pyx_GIVEREF(__pyx_t_12);
        PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_12);
        __pyx_t_12 = 0;
        __pyx_t_12 = PyUnicode_Join(__pyx_kp_u__19, __pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1738, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_exec_heap, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1738, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (unlikely(__Pyx_SetItemInt(__pyx_t_4, 1, __pyx_t_12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 1738, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "trapeza/account/fx_account.pyx":1739
 *                 if element[1] in ['withdraw', 'deposit']:
 *                     exec_heap[i][1] = ''.join(['c_', element[1]])
 *                     if has_warn is False:             # <<<<<<<<<<<<<<
 *                         warnings.warn('Auto-converting "withdraw" and "deposit" to "c_withdraw" and "c_deposit" (to '
 *                                       'match up cython-implemented exec_heap of cFXAccount, which wrapped is by '
 */
        __pyx_t_5 = ((__pyx_v_has_warn == 0) != 0);
        if (__pyx_t_5) {

          /* "trapeza/account/fx_account.pyx":1740
 *                     exec_heap[i][1] = ''.join(['c_', element[1]])
 *                     if has_warn is False:
 *                         warnings.warn('Auto-converting "withdraw" and "deposit" to "c_withdraw" and "c_deposit" (to '             # <<<<<<<<<<<<<<
 *                                       'match up cython-implemented exec_heap of cFXAccount, which wrapped is by '
 *                                       'FXAccount).')
 */
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_warnings); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1740, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1740, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_15);
            if (likely(__pyx_t_4)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_15, function);
            }
          }
          __pyx_t_12 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_4, __pyx_kp_u_Auto_converting_withdraw_and_dep) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_kp_u_Auto_converting_withdraw_and_dep);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1740, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "trapeza/account/fx_account.pyx":1743
 *                                       'match up cython-implemented exec_heap of cFXAccount, which wrapped is by '
 *                                       'FXAccount).')
 *                         has_warn = True             # <<<<<<<<<<<<<<
 *                 elif element[1] in ['c_withdraw', 'c_deposit']:
 *                     pass
 */
          __pyx_v_has_warn = 1;

          /* "trapeza/account/fx_account.pyx":1739
 *                 if element[1] in ['withdraw', 'deposit']:
 *                     exec_heap[i][1] = ''.join(['c_', element[1]])
 *                     if has_warn is False:             # <<<<<<<<<<<<<<
 *                         warnings.warn('Auto-converting "withdraw" and "deposit" to "c_withdraw" and "c_deposit" (to '
 *                                       'match up cython-implemented exec_heap of cFXAccount, which wrapped is by '
 */
        }

        /* "trapeza/account/fx_account.pyx":1737
 *                                     'can be used to set exec_heap manually.'.format(len(element)))
 * 
 *                 if element[1] in ['withdraw', 'deposit']:             # <<<<<<<<<<<<<<
 *                     exec_heap[i][1] = ''.join(['c_', element[1]])
 *                     if has_warn is False:
 */
        goto __pyx_L24;
      }

      /* "trapeza/account/fx_account.pyx":1744
 *                                       'FXAccount).')
 *                         has_warn = True
 *                 elif element[1] in ['c_withdraw', 'c_deposit']:             # <<<<<<<<<<<<<<
 *                     pass
 *                 else:
 */
      __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_element, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_c_withdraw, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1744, __pyx_L1_error)
      if (!__pyx_t_2) {
      } else {
        __pyx_t_5 = __pyx_t_2;
        goto __pyx_L28_bool_binop_done;
      }
      __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_c_deposit, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1744, __pyx_L1_error)
      __pyx_t_5 = __pyx_t_2;
      __pyx_L28_bool_binop_done:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_2 = (__pyx_t_5 != 0);
      if (likely(__pyx_t_2)) {
        goto __pyx_L24;
      }

      /* "trapeza/account/fx_account.pyx":1747
 *                     pass
 *                 else:
 *                     raise TypeError('When setting exec_heap manually, method argument must either be a list or tuple '             # <<<<<<<<<<<<<<
 *                                     'of single entries or a single entry itself as list or tuple of the following '
 *                                     'elements: [int:time, str:action_func, float:volume, str:currency, '
 */
      /*else*/ {

        /* "trapeza/account/fx_account.pyx":1751
 *                                     'elements: [int:time, str:action_func, float:volume, str:currency, '
 *                                     'str:coverage]. action_func must be either "withdraw" or '
 *                                     '"deposit", got {}'.format(element[1]))             # <<<<<<<<<<<<<<
 *                 if element[4] not in ['except', 'partial', 'debit', 'ignore']:
 *                     raise ValueError('coverage must be in ["except", "partial", "debit", "ignore"]')
 */
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_When_setting_exec_heap_manually, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1751, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_element, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1751, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_16 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15);
          if (likely(__pyx_t_16)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
            __Pyx_INCREF(__pyx_t_16);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_15, function);
          }
        }
        __pyx_t_12 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_16, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_4);
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1751, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

        /* "trapeza/account/fx_account.pyx":1747
 *                     pass
 *                 else:
 *                     raise TypeError('When setting exec_heap manually, method argument must either be a list or tuple '             # <<<<<<<<<<<<<<
 *                                     'of single entries or a single entry itself as list or tuple of the following '
 *                                     'elements: [int:time, str:action_func, float:volume, str:currency, '
 */
        __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1747, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_Raise(__pyx_t_15, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __PYX_ERR(0, 1747, __pyx_L1_error)
      }
      __pyx_L24:;

      /* "trapeza/account/fx_account.pyx":1752
 *                                     'str:coverage]. action_func must be either "withdraw" or '
 *                                     '"deposit", got {}'.format(element[1]))
 *                 if element[4] not in ['except', 'partial', 'debit', 'ignore']:             # <<<<<<<<<<<<<<
 *                     raise ValueError('coverage must be in ["except", "partial", "debit", "ignore"]')
 *                 check_types([element[0], element[1], element[2], element[3], element[4]],
 */
      __pyx_t_15 = __Pyx_GetItemInt(__pyx_v_element, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1752, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_15, __pyx_n_u_except, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1752, __pyx_L1_error)
      if (__pyx_t_5) {
      } else {
        __pyx_t_2 = __pyx_t_5;
        goto __pyx_L31_bool_binop_done;
      }
      __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_15, __pyx_n_u_partial, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1752, __pyx_L1_error)
      if (__pyx_t_5) {
      } else {
        __pyx_t_2 = __pyx_t_5;
        goto __pyx_L31_bool_binop_done;
      }
      __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_15, __pyx_n_u_debit, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1752, __pyx_L1_error)
      if (__pyx_t_5) {
      } else {
        __pyx_t_2 = __pyx_t_5;
        goto __pyx_L31_bool_binop_done;
      }
      __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_15, __pyx_n_u_ignore, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1752, __pyx_L1_error)
      __pyx_t_2 = __pyx_t_5;
      __pyx_L31_bool_binop_done:;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_5 = (__pyx_t_2 != 0);
      if (unlikely(__pyx_t_5)) {

        /* "trapeza/account/fx_account.pyx":1753
 *                                     '"deposit", got {}'.format(element[1]))
 *                 if element[4] not in ['except', 'partial', 'debit', 'ignore']:
 *                     raise ValueError('coverage must be in ["except", "partial", "debit", "ignore"]')             # <<<<<<<<<<<<<<
 *                 check_types([element[0], element[1], element[2], element[3], element[4]],
 *                             [int, str, float, str, str],
 */
        __pyx_t_15 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1753, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_Raise(__pyx_t_15, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __PYX_ERR(0, 1753, __pyx_L1_error)

        /* "trapeza/account/fx_account.pyx":1752
 *                                     'str:coverage]. action_func must be either "withdraw" or '
 *                                     '"deposit", got {}'.format(element[1]))
 *                 if element[4] not in ['except', 'partial', 'debit', 'ignore']:             # <<<<<<<<<<<<<<
 *                     raise ValueError('coverage must be in ["except", "partial", "debit", "ignore"]')
 *                 check_types([element[0], element[1], element[2], element[3], element[4]],
 */
      }

      /* "trapeza/account/fx_account.pyx":1754
 *                 if element[4] not in ['except', 'partial', 'debit', 'ignore']:
 *                     raise ValueError('coverage must be in ["except", "partial", "debit", "ignore"]')
 *                 check_types([element[0], element[1], element[2], element[3], element[4]],             # <<<<<<<<<<<<<<
 *                             [int, str, float, str, str],
 *                             ['heap_time', 'heap_action_type', 'heap_volume', 'heap_currency', 'heap_coverage'],
 */
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_check_types); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_element, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_16 = __Pyx_GetItemInt(__pyx_v_element, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = __Pyx_GetItemInt(__pyx_v_element, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_element, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_19 = __Pyx_GetItemInt(__pyx_v_element, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_20 = PyList_New(5); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_20, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_16);
      PyList_SET_ITEM(__pyx_t_20, 1, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_17);
      PyList_SET_ITEM(__pyx_t_20, 2, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_18);
      PyList_SET_ITEM(__pyx_t_20, 3, __pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_19);
      PyList_SET_ITEM(__pyx_t_20, 4, __pyx_t_19);
      __pyx_t_4 = 0;
      __pyx_t_16 = 0;
      __pyx_t_17 = 0;
      __pyx_t_18 = 0;
      __pyx_t_19 = 0;

      /* "trapeza/account/fx_account.pyx":1755
 *                     raise ValueError('coverage must be in ["except", "partial", "debit", "ignore"]')
 *                 check_types([element[0], element[1], element[2], element[3], element[4]],
 *                             [int, str, float, str, str],             # <<<<<<<<<<<<<<
 *                             ['heap_time', 'heap_action_type', 'heap_volume', 'heap_currency', 'heap_coverage'],
 *                             ignore_type_checking)
 */
      __pyx_t_19 = PyList_New(5); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1755, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyList_SET_ITEM(__pyx_t_19, 0, ((PyObject *)(&PyInt_Type)));
      __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
      PyList_SET_ITEM(__pyx_t_19, 1, ((PyObject *)(&PyUnicode_Type)));
      __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
      PyList_SET_ITEM(__pyx_t_19, 2, ((PyObject *)(&PyFloat_Type)));
      __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
      PyList_SET_ITEM(__pyx_t_19, 3, ((PyObject *)(&PyUnicode_Type)));
      __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
      PyList_SET_ITEM(__pyx_t_19, 4, ((PyObject *)(&PyUnicode_Type)));

      /* "trapeza/account/fx_account.pyx":1756
 *                 check_types([element[0], element[1], element[2], element[3], element[4]],
 *                             [int, str, float, str, str],
 *                             ['heap_time', 'heap_action_type', 'heap_volume', 'heap_currency', 'heap_coverage'],             # <<<<<<<<<<<<<<
 *                             ignore_type_checking)
 *         return exec_heap
 */
      __pyx_t_18 = PyList_New(5); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1756, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_INCREF(__pyx_n_u_heap_time);
      __Pyx_GIVEREF(__pyx_n_u_heap_time);
      PyList_SET_ITEM(__pyx_t_18, 0, __pyx_n_u_heap_time);
      __Pyx_INCREF(__pyx_n_u_heap_action_type);
      __Pyx_GIVEREF(__pyx_n_u_heap_action_type);
      PyList_SET_ITEM(__pyx_t_18, 1, __pyx_n_u_heap_action_type);
      __Pyx_INCREF(__pyx_n_u_heap_volume);
      __Pyx_GIVEREF(__pyx_n_u_heap_volume);
      PyList_SET_ITEM(__pyx_t_18, 2, __pyx_n_u_heap_volume);
      __Pyx_INCREF(__pyx_n_u_heap_currency);
      __Pyx_GIVEREF(__pyx_n_u_heap_currency);
      PyList_SET_ITEM(__pyx_t_18, 3, __pyx_n_u_heap_currency);
      __Pyx_INCREF(__pyx_n_u_heap_coverage);
      __Pyx_GIVEREF(__pyx_n_u_heap_coverage);
      PyList_SET_ITEM(__pyx_t_18, 4, __pyx_n_u_heap_coverage);

      /* "trapeza/account/fx_account.pyx":1757
 *                             [int, str, float, str, str],
 *                             ['heap_time', 'heap_action_type', 'heap_volume', 'heap_currency', 'heap_coverage'],
 *                             ignore_type_checking)             # <<<<<<<<<<<<<<
 *         return exec_heap
 * 
 */
      __pyx_t_17 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_17)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[5] = {__pyx_t_17, __pyx_t_20, __pyx_t_19, __pyx_t_18, __pyx_v_ignore_type_checking};
        __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1754, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[5] = {__pyx_t_17, __pyx_t_20, __pyx_t_19, __pyx_t_18, __pyx_v_ignore_type_checking};
        __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1754, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      } else
      #endif
      {
        __pyx_t_16 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1754, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_16);
        if (__pyx_t_17) {
          __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_17); __pyx_t_17 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_20);
        PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_10, __pyx_t_20);
        __Pyx_GIVEREF(__pyx_t_19);
        PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_10, __pyx_t_19);
        __Pyx_GIVEREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_10, __pyx_t_18);
        __Pyx_INCREF(__pyx_v_ignore_type_checking);
        __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
        PyTuple_SET_ITEM(__pyx_t_16, 3+__pyx_t_10, __pyx_v_ignore_type_checking);
        __pyx_t_20 = 0;
        __pyx_t_19 = 0;
        __pyx_t_18 = 0;
        __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_16, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1754, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

      /* "trapeza/account/fx_account.pyx":1725
 * 
 *             # do type checking
 *             for i, element in enumerate(exec_heap):             # <<<<<<<<<<<<<<
 *                 # [time:int, action_func:str, volume:float, currency:str, coverage:str]
 *                 if type(element) is tuple:
 */
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "trapeza/account/fx_account.pyx":1758
 *                             ['heap_time', 'heap_action_type', 'heap_volume', 'heap_currency', 'heap_coverage'],
 *                             ignore_type_checking)
 *         return exec_heap             # <<<<<<<<<<<<<<
 * 
 *     def _parse_fees(self, fee_buy, fee_sell, fee_deposit, fee_withdraw, ignore_type_checking):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_exec_heap);
  __pyx_r = __pyx_v_exec_heap;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1677
 * 
 *     @staticmethod
 *     def _parse_exec_heap(exec_heap, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks if provided (heap) list is valid as internal execution heap
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_exec_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_element);
  __Pyx_XDECREF(__pyx_v_exec_heap);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1760
 *         return exec_heap
 * 
 *     def _parse_fees(self, fee_buy, fee_sell, fee_deposit, fee_withdraw, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks fees. Uses standard fee function (equivalent to not applying any fees) if argument is set
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_69_parse_fees(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_68_parse_fees[] = "\n        Parses and checks fees. Uses standard fee function (equivalent to not applying any fees) if argument is set\n        to False.\n        :param fee_buy: {False, func}\n        :param fee_sell: {False, func}\n        :param fee_deposit: {False, func}\n        :param fee_withdraw: {False, func}\n        :return: dict with {'sell': func, 'buy': func, 'deposit': func, 'withdraw': func}\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_69_parse_fees = {"_parse_fees", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_69_parse_fees, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_68_parse_fees};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_69_parse_fees(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fee_buy = 0;
  PyObject *__pyx_v_fee_sell = 0;
  PyObject *__pyx_v_fee_deposit = 0;
  PyObject *__pyx_v_fee_withdraw = 0;
  PyObject *__pyx_v_ignore_type_checking = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_parse_fees (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_fee_buy,&__pyx_n_s_fee_sell,&__pyx_n_s_fee_deposit,&__pyx_n_s_fee_withdraw,&__pyx_n_s_ignore_type_checking,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_buy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fees", 1, 6, 6, 1); __PYX_ERR(0, 1760, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_sell)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fees", 1, 6, 6, 2); __PYX_ERR(0, 1760, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_deposit)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fees", 1, 6, 6, 3); __PYX_ERR(0, 1760, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_withdraw)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fees", 1, 6, 6, 4); __PYX_ERR(0, 1760, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ignore_type_checking)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fees", 1, 6, 6, 5); __PYX_ERR(0, 1760, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse_fees") < 0)) __PYX_ERR(0, 1760, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
    }
    __pyx_v_self = values[0];
    __pyx_v_fee_buy = values[1];
    __pyx_v_fee_sell = values[2];
    __pyx_v_fee_deposit = values[3];
    __pyx_v_fee_withdraw = values[4];
    __pyx_v_ignore_type_checking = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_parse_fees", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1760, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_fees", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_68_parse_fees(__pyx_self, __pyx_v_self, __pyx_v_fee_buy, __pyx_v_fee_sell, __pyx_v_fee_deposit, __pyx_v_fee_withdraw, __pyx_v_ignore_type_checking);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_68_parse_fees(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fee_buy, PyObject *__pyx_v_fee_sell, PyObject *__pyx_v_fee_deposit, PyObject *__pyx_v_fee_withdraw, PyObject *__pyx_v_ignore_type_checking) {
  PyObject *__pyx_v__fee = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_parse_fees", 0);

  /* "trapeza/account/fx_account.pyx":1771
 *         :raises: TypeError
 *         """
 *         _fee = dict()             # <<<<<<<<<<<<<<
 * 
 *         if fee_buy is False:
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__fee = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1773
 *         _fee = dict()
 * 
 *         if fee_buy is False:             # <<<<<<<<<<<<<<
 *             _fee[b'buy'] = fx_null_fee
 *         else:
 */
  __pyx_t_2 = (__pyx_v_fee_buy == Py_False);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "trapeza/account/fx_account.pyx":1774
 * 
 *         if fee_buy is False:
 *             _fee[b'buy'] = fx_null_fee             # <<<<<<<<<<<<<<
 *         else:
 *             check_types([fee_buy], [callable], ['fee_buy'], ignore_type_checking)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_fx_null_fee); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1774, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyDict_SetItem(__pyx_v__fee, __pyx_n_b_buy, __pyx_t_1) < 0)) __PYX_ERR(0, 1774, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1773
 *         _fee = dict()
 * 
 *         if fee_buy is False:             # <<<<<<<<<<<<<<
 *             _fee[b'buy'] = fx_null_fee
 *         else:
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1776
 *             _fee[b'buy'] = fx_null_fee
 *         else:
 *             check_types([fee_buy], [callable], ['fee_buy'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *             self._check_is_valid_fee_func(fee_buy)
 *             _fee[b'buy'] = fee_buy
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_fee_buy);
    __Pyx_GIVEREF(__pyx_v_fee_buy);
    PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_fee_buy);
    __pyx_t_6 = __Pyx_GetBuiltinName(__pyx_n_s_callable); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_n_u_fee_buy);
    __Pyx_GIVEREF(__pyx_n_u_fee_buy);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_fee_buy);
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_5, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1776, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_5, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1776, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1776, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
      __Pyx_INCREF(__pyx_v_ignore_type_checking);
      __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
      PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_v_ignore_type_checking);
      __pyx_t_5 = 0;
      __pyx_t_7 = 0;
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1776, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1777
 *         else:
 *             check_types([fee_buy], [callable], ['fee_buy'], ignore_type_checking)
 *             self._check_is_valid_fee_func(fee_buy)             # <<<<<<<<<<<<<<
 *             _fee[b'buy'] = fee_buy
 *         if fee_sell is False:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_check_is_valid_fee_func); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_10, __pyx_v_fee_buy) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_fee_buy);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1778
 *             check_types([fee_buy], [callable], ['fee_buy'], ignore_type_checking)
 *             self._check_is_valid_fee_func(fee_buy)
 *             _fee[b'buy'] = fee_buy             # <<<<<<<<<<<<<<
 *         if fee_sell is False:
 *             _fee[b'sell'] = fx_null_fee
 */
    if (unlikely(PyDict_SetItem(__pyx_v__fee, __pyx_n_b_buy, __pyx_v_fee_buy) < 0)) __PYX_ERR(0, 1778, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "trapeza/account/fx_account.pyx":1779
 *             self._check_is_valid_fee_func(fee_buy)
 *             _fee[b'buy'] = fee_buy
 *         if fee_sell is False:             # <<<<<<<<<<<<<<
 *             _fee[b'sell'] = fx_null_fee
 *         else:
 */
  __pyx_t_3 = (__pyx_v_fee_sell == Py_False);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "trapeza/account/fx_account.pyx":1780
 *             _fee[b'buy'] = fee_buy
 *         if fee_sell is False:
 *             _fee[b'sell'] = fx_null_fee             # <<<<<<<<<<<<<<
 *         else:
 *             check_types([fee_sell], [callable], ['fee_sell'], ignore_type_checking)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_fx_null_fee); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1780, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyDict_SetItem(__pyx_v__fee, __pyx_n_b_sell, __pyx_t_1) < 0)) __PYX_ERR(0, 1780, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1779
 *             self._check_is_valid_fee_func(fee_buy)
 *             _fee[b'buy'] = fee_buy
 *         if fee_sell is False:             # <<<<<<<<<<<<<<
 *             _fee[b'sell'] = fx_null_fee
 *         else:
 */
    goto __pyx_L4;
  }

  /* "trapeza/account/fx_account.pyx":1782
 *             _fee[b'sell'] = fx_null_fee
 *         else:
 *             check_types([fee_sell], [callable], ['fee_sell'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *             self._check_is_valid_fee_func(fee_sell)
 *             _fee[b'sell'] = fee_sell
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = PyList_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_v_fee_sell);
    __Pyx_GIVEREF(__pyx_v_fee_sell);
    PyList_SET_ITEM(__pyx_t_10, 0, __pyx_v_fee_sell);
    __pyx_t_6 = __Pyx_GetBuiltinName(__pyx_n_s_callable); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_n_u_fee_sell);
    __Pyx_GIVEREF(__pyx_n_u_fee_sell);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_fee_sell);
    __pyx_t_5 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_10, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1782, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_10, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1782, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_9, __pyx_t_6);
      __Pyx_INCREF(__pyx_v_ignore_type_checking);
      __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
      PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_9, __pyx_v_ignore_type_checking);
      __pyx_t_10 = 0;
      __pyx_t_7 = 0;
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1783
 *         else:
 *             check_types([fee_sell], [callable], ['fee_sell'], ignore_type_checking)
 *             self._check_is_valid_fee_func(fee_sell)             # <<<<<<<<<<<<<<
 *             _fee[b'sell'] = fee_sell
 *         if fee_deposit is False:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_check_is_valid_fee_func); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_8, __pyx_v_fee_sell) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_fee_sell);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1784
 *             check_types([fee_sell], [callable], ['fee_sell'], ignore_type_checking)
 *             self._check_is_valid_fee_func(fee_sell)
 *             _fee[b'sell'] = fee_sell             # <<<<<<<<<<<<<<
 *         if fee_deposit is False:
 *             _fee[b'deposit'] = fx_null_fee
 */
    if (unlikely(PyDict_SetItem(__pyx_v__fee, __pyx_n_b_sell, __pyx_v_fee_sell) < 0)) __PYX_ERR(0, 1784, __pyx_L1_error)
  }
  __pyx_L4:;

  /* "trapeza/account/fx_account.pyx":1785
 *             self._check_is_valid_fee_func(fee_sell)
 *             _fee[b'sell'] = fee_sell
 *         if fee_deposit is False:             # <<<<<<<<<<<<<<
 *             _fee[b'deposit'] = fx_null_fee
 *         else:
 */
  __pyx_t_2 = (__pyx_v_fee_deposit == Py_False);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "trapeza/account/fx_account.pyx":1786
 *             _fee[b'sell'] = fee_sell
 *         if fee_deposit is False:
 *             _fee[b'deposit'] = fx_null_fee             # <<<<<<<<<<<<<<
 *         else:
 *             check_types([fee_deposit], [callable], ['fee_deposit'], ignore_type_checking)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_fx_null_fee); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyDict_SetItem(__pyx_v__fee, __pyx_n_b_deposit, __pyx_t_1) < 0)) __PYX_ERR(0, 1786, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1785
 *             self._check_is_valid_fee_func(fee_sell)
 *             _fee[b'sell'] = fee_sell
 *         if fee_deposit is False:             # <<<<<<<<<<<<<<
 *             _fee[b'deposit'] = fx_null_fee
 *         else:
 */
    goto __pyx_L5;
  }

  /* "trapeza/account/fx_account.pyx":1788
 *             _fee[b'deposit'] = fx_null_fee
 *         else:
 *             check_types([fee_deposit], [callable], ['fee_deposit'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *             self._check_is_valid_fee_func(fee_deposit)
 *             _fee[b'deposit'] = fee_deposit
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_fee_deposit);
    __Pyx_GIVEREF(__pyx_v_fee_deposit);
    PyList_SET_ITEM(__pyx_t_8, 0, __pyx_v_fee_deposit);
    __pyx_t_6 = __Pyx_GetBuiltinName(__pyx_n_s_callable); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_n_u_fee_deposit);
    __Pyx_GIVEREF(__pyx_n_u_fee_deposit);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_fee_deposit);
    __pyx_t_10 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1788, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1788, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1788, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_9, __pyx_t_6);
      __Pyx_INCREF(__pyx_v_ignore_type_checking);
      __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
      PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_9, __pyx_v_ignore_type_checking);
      __pyx_t_8 = 0;
      __pyx_t_7 = 0;
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1788, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1789
 *         else:
 *             check_types([fee_deposit], [callable], ['fee_deposit'], ignore_type_checking)
 *             self._check_is_valid_fee_func(fee_deposit)             # <<<<<<<<<<<<<<
 *             _fee[b'deposit'] = fee_deposit
 *         if fee_withdraw is False:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_check_is_valid_fee_func); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_fee_deposit) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_fee_deposit);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1790
 *             check_types([fee_deposit], [callable], ['fee_deposit'], ignore_type_checking)
 *             self._check_is_valid_fee_func(fee_deposit)
 *             _fee[b'deposit'] = fee_deposit             # <<<<<<<<<<<<<<
 *         if fee_withdraw is False:
 *             _fee[b'withdraw'] = fx_null_fee
 */
    if (unlikely(PyDict_SetItem(__pyx_v__fee, __pyx_n_b_deposit, __pyx_v_fee_deposit) < 0)) __PYX_ERR(0, 1790, __pyx_L1_error)
  }
  __pyx_L5:;

  /* "trapeza/account/fx_account.pyx":1791
 *             self._check_is_valid_fee_func(fee_deposit)
 *             _fee[b'deposit'] = fee_deposit
 *         if fee_withdraw is False:             # <<<<<<<<<<<<<<
 *             _fee[b'withdraw'] = fx_null_fee
 *         else:
 */
  __pyx_t_3 = (__pyx_v_fee_withdraw == Py_False);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "trapeza/account/fx_account.pyx":1792
 *             _fee[b'deposit'] = fee_deposit
 *         if fee_withdraw is False:
 *             _fee[b'withdraw'] = fx_null_fee             # <<<<<<<<<<<<<<
 *         else:
 *             check_types([fee_withdraw], [callable], ['fee_withdraw'], ignore_type_checking)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_fx_null_fee); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1792, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyDict_SetItem(__pyx_v__fee, __pyx_n_b_withdraw, __pyx_t_1) < 0)) __PYX_ERR(0, 1792, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1791
 *             self._check_is_valid_fee_func(fee_deposit)
 *             _fee[b'deposit'] = fee_deposit
 *         if fee_withdraw is False:             # <<<<<<<<<<<<<<
 *             _fee[b'withdraw'] = fx_null_fee
 *         else:
 */
    goto __pyx_L6;
  }

  /* "trapeza/account/fx_account.pyx":1794
 *             _fee[b'withdraw'] = fx_null_fee
 *         else:
 *             check_types([fee_withdraw], [callable], ['fee_withdraw'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *             self._check_is_valid_fee_func(fee_withdraw)
 *             _fee[b'withdraw'] = fee_withdraw
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_fee_withdraw);
    __Pyx_GIVEREF(__pyx_v_fee_withdraw);
    PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_fee_withdraw);
    __pyx_t_6 = __Pyx_GetBuiltinName(__pyx_n_s_callable); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_n_u_fee_withdraw);
    __Pyx_GIVEREF(__pyx_n_u_fee_withdraw);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_fee_withdraw);
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_5, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1794, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_5, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1794, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1794, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
      __Pyx_INCREF(__pyx_v_ignore_type_checking);
      __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
      PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_v_ignore_type_checking);
      __pyx_t_5 = 0;
      __pyx_t_7 = 0;
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1794, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1795
 *         else:
 *             check_types([fee_withdraw], [callable], ['fee_withdraw'], ignore_type_checking)
 *             self._check_is_valid_fee_func(fee_withdraw)             # <<<<<<<<<<<<<<
 *             _fee[b'withdraw'] = fee_withdraw
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_check_is_valid_fee_func); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_10, __pyx_v_fee_withdraw) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_fee_withdraw);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":1796
 *             check_types([fee_withdraw], [callable], ['fee_withdraw'], ignore_type_checking)
 *             self._check_is_valid_fee_func(fee_withdraw)
 *             _fee[b'withdraw'] = fee_withdraw             # <<<<<<<<<<<<<<
 * 
 *         return _fee
 */
    if (unlikely(PyDict_SetItem(__pyx_v__fee, __pyx_n_b_withdraw, __pyx_v_fee_withdraw) < 0)) __PYX_ERR(0, 1796, __pyx_L1_error)
  }
  __pyx_L6:;

  /* "trapeza/account/fx_account.pyx":1798
 *             _fee[b'withdraw'] = fee_withdraw
 * 
 *         return _fee             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v__fee);
  __pyx_r = __pyx_v__fee;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1760
 *         return exec_heap
 * 
 *     def _parse_fees(self, fee_buy, fee_sell, fee_deposit, fee_withdraw, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks fees. Uses standard fee function (equivalent to not applying any fees) if argument is set
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_fees", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__fee);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1801
 * 
 *     @staticmethod
 *     def _parse_exchange_rates(exchange_rates, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks exchange rates.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_71_parse_exchange_rates(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_70_parse_exchange_rates[] = "\n        Parses and checks exchange rates.\n        :param exchange_rates: dict with keys:tuple(str:currency, str:currency) and value as float or None\n        :return: dict encoded for passing to underlying C++ implementation\n        :raises: TypeError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_71_parse_exchange_rates = {"_parse_exchange_rates", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_71_parse_exchange_rates, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_70_parse_exchange_rates};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_71_parse_exchange_rates(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_exchange_rates = 0;
  PyObject *__pyx_v_ignore_type_checking = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_parse_exchange_rates (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_exchange_rates,&__pyx_n_s_ignore_type_checking,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exchange_rates)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ignore_type_checking)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_exchange_rates", 1, 2, 2, 1); __PYX_ERR(0, 1801, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse_exchange_rates") < 0)) __PYX_ERR(0, 1801, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_exchange_rates = values[0];
    __pyx_v_ignore_type_checking = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_parse_exchange_rates", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1801, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_70_parse_exchange_rates(__pyx_self, __pyx_v_exchange_rates, __pyx_v_ignore_type_checking);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_70_parse_exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_exchange_rates, PyObject *__pyx_v_ignore_type_checking) {
  PyObject *__pyx_v_sample_key = NULL;
  PyObject *__pyx_8genexpr5__pyx_v_k = NULL;
  PyObject *__pyx_8genexpr5__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_parse_exchange_rates", 0);
  __Pyx_INCREF(__pyx_v_exchange_rates);

  /* "trapeza/account/fx_account.pyx":1808
 *         :raises: TypeError
 *         """
 *         if exchange_rates is None:             # <<<<<<<<<<<<<<
 *             exchange_rates = dict()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_exchange_rates == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "trapeza/account/fx_account.pyx":1809
 *         """
 *         if exchange_rates is None:
 *             exchange_rates = dict()             # <<<<<<<<<<<<<<
 *         else:
 *             if not ignore_type_checking:
 */
    __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1809, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_exchange_rates, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "trapeza/account/fx_account.pyx":1808
 *         :raises: TypeError
 *         """
 *         if exchange_rates is None:             # <<<<<<<<<<<<<<
 *             exchange_rates = dict()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1811
 *             exchange_rates = dict()
 *         else:
 *             if not ignore_type_checking:             # <<<<<<<<<<<<<<
 *                 check_types([exchange_rates], [dict], ['exchange_rates'], ignore_type_checking)
 *                 # sample check types within dict
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_ignore_type_checking); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1811, __pyx_L1_error)
    __pyx_t_1 = ((!__pyx_t_2) != 0);
    if (__pyx_t_1) {

      /* "trapeza/account/fx_account.pyx":1812
 *         else:
 *             if not ignore_type_checking:
 *                 check_types([exchange_rates], [dict], ['exchange_rates'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *                 # sample check types within dict
 *                 sample_key = list(exchange_rates.keys())[0]
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1812, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1812, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_exchange_rates);
      __Pyx_GIVEREF(__pyx_v_exchange_rates);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_exchange_rates);
      __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1812, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(((PyObject *)(&PyDict_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyDict_Type)));
      PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyDict_Type)));
      __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1812, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_n_u_exchange_rates);
      __Pyx_GIVEREF(__pyx_n_u_exchange_rates);
      PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_u_exchange_rates);
      __pyx_t_8 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_v_ignore_type_checking};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1812, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_v_ignore_type_checking};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1812, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1812, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_7);
        __Pyx_INCREF(__pyx_v_ignore_type_checking);
        __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
        PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_v_ignore_type_checking);
        __pyx_t_5 = 0;
        __pyx_t_6 = 0;
        __pyx_t_7 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1812, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "trapeza/account/fx_account.pyx":1814
 *                 check_types([exchange_rates], [dict], ['exchange_rates'], ignore_type_checking)
 *                 # sample check types within dict
 *                 sample_key = list(exchange_rates.keys())[0]             # <<<<<<<<<<<<<<
 *                 check_types([sample_key], [tuple], ['exchange_rate_key_tuple'], ignore_type_checking)
 *                 check_types([sample_key[0], sample_key[1]],
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_exchange_rates, __pyx_n_s_keys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1814, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1814, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1814, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1814, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_sample_key = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "trapeza/account/fx_account.pyx":1815
 *                 # sample check types within dict
 *                 sample_key = list(exchange_rates.keys())[0]
 *                 check_types([sample_key], [tuple], ['exchange_rate_key_tuple'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *                 check_types([sample_key[0], sample_key[1]],
 *                             [str, str],
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1815, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = PyList_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1815, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_v_sample_key);
      __Pyx_GIVEREF(__pyx_v_sample_key);
      PyList_SET_ITEM(__pyx_t_10, 0, __pyx_v_sample_key);
      __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1815, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(((PyObject *)(&PyTuple_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type)));
      PyList_SET_ITEM(__pyx_t_7, 0, ((PyObject *)(&PyTuple_Type)));
      __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1815, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_n_u_exchange_rate_key_tuple);
      __Pyx_GIVEREF(__pyx_n_u_exchange_rate_key_tuple);
      PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_exchange_rate_key_tuple);
      __pyx_t_5 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_10, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1815, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_10, __pyx_t_7, __pyx_t_6, __pyx_v_ignore_type_checking};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1815, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1815, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_9, __pyx_t_6);
        __Pyx_INCREF(__pyx_v_ignore_type_checking);
        __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
        PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_9, __pyx_v_ignore_type_checking);
        __pyx_t_10 = 0;
        __pyx_t_7 = 0;
        __pyx_t_6 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1815, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "trapeza/account/fx_account.pyx":1816
 *                 sample_key = list(exchange_rates.keys())[0]
 *                 check_types([sample_key], [tuple], ['exchange_rate_key_tuple'], ignore_type_checking)
 *                 check_types([sample_key[0], sample_key[1]],             # <<<<<<<<<<<<<<
 *                             [str, str],
 *                             ['exchange_rate_currency', 'exchange_rate_currency'], ignore_type_checking)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_sample_key, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_sample_key, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
      __pyx_t_8 = 0;
      __pyx_t_6 = 0;

      /* "trapeza/account/fx_account.pyx":1817
 *                 check_types([sample_key], [tuple], ['exchange_rate_key_tuple'], ignore_type_checking)
 *                 check_types([sample_key[0], sample_key[1]],
 *                             [str, str],             # <<<<<<<<<<<<<<
 *                             ['exchange_rate_currency', 'exchange_rate_currency'], ignore_type_checking)
 *                 check_types([exchange_rates[sample_key]], [float], ['exchange_rate_value'], ignore_type_checking)
 */
      __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1817, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
      PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyUnicode_Type)));
      __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
      PyList_SET_ITEM(__pyx_t_6, 1, ((PyObject *)(&PyUnicode_Type)));

      /* "trapeza/account/fx_account.pyx":1818
 *                 check_types([sample_key[0], sample_key[1]],
 *                             [str, str],
 *                             ['exchange_rate_currency', 'exchange_rate_currency'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *                 check_types([exchange_rates[sample_key]], [float], ['exchange_rate_value'], ignore_type_checking)
 *             exchange_rates = {(k[0].encode(), k[1].encode()): v for k, v in exchange_rates.items()}
 */
      __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1818, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_n_u_exchange_rate_currency);
      __Pyx_GIVEREF(__pyx_n_u_exchange_rate_currency);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_u_exchange_rate_currency);
      __Pyx_INCREF(__pyx_n_u_exchange_rate_currency);
      __Pyx_GIVEREF(__pyx_n_u_exchange_rate_currency);
      PyList_SET_ITEM(__pyx_t_8, 1, __pyx_n_u_exchange_rate_currency);
      __pyx_t_10 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_7, __pyx_t_6, __pyx_t_8, __pyx_v_ignore_type_checking};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1816, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_7, __pyx_t_6, __pyx_t_8, __pyx_v_ignore_type_checking};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1816, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1816, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_9, __pyx_t_8);
        __Pyx_INCREF(__pyx_v_ignore_type_checking);
        __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
        PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_9, __pyx_v_ignore_type_checking);
        __pyx_t_7 = 0;
        __pyx_t_6 = 0;
        __pyx_t_8 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1816, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "trapeza/account/fx_account.pyx":1819
 *                             [str, str],
 *                             ['exchange_rate_currency', 'exchange_rate_currency'], ignore_type_checking)
 *                 check_types([exchange_rates[sample_key]], [float], ['exchange_rate_value'], ignore_type_checking)             # <<<<<<<<<<<<<<
 *             exchange_rates = {(k[0].encode(), k[1].encode()): v for k, v in exchange_rates.items()}
 *         return exchange_rates
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_check_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_exchange_rates, __pyx_v_sample_key); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
      PyList_SET_ITEM(__pyx_t_5, 0, ((PyObject *)(&PyFloat_Type)));
      __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1819, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_n_u_exchange_rate_value);
      __Pyx_GIVEREF(__pyx_n_u_exchange_rate_value);
      PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_exchange_rate_value);
      __pyx_t_7 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_8, __pyx_t_5, __pyx_t_6, __pyx_v_ignore_type_checking};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1819, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_8, __pyx_t_5, __pyx_t_6, __pyx_v_ignore_type_checking};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1819, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_6);
        __Pyx_INCREF(__pyx_v_ignore_type_checking);
        __Pyx_GIVEREF(__pyx_v_ignore_type_checking);
        PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_v_ignore_type_checking);
        __pyx_t_8 = 0;
        __pyx_t_5 = 0;
        __pyx_t_6 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "trapeza/account/fx_account.pyx":1811
 *             exchange_rates = dict()
 *         else:
 *             if not ignore_type_checking:             # <<<<<<<<<<<<<<
 *                 check_types([exchange_rates], [dict], ['exchange_rates'], ignore_type_checking)
 *                 # sample check types within dict
 */
    }

    /* "trapeza/account/fx_account.pyx":1820
 *                             ['exchange_rate_currency', 'exchange_rate_currency'], ignore_type_checking)
 *                 check_types([exchange_rates[sample_key]], [float], ['exchange_rate_value'], ignore_type_checking)
 *             exchange_rates = {(k[0].encode(), k[1].encode()): v for k, v in exchange_rates.items()}             # <<<<<<<<<<<<<<
 *         return exchange_rates
 * 
 */
    { /* enter inner scope */
      __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1820, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_11 = 0;
      if (unlikely(__pyx_v_exchange_rates == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
        __PYX_ERR(0, 1820, __pyx_L7_error)
      }
      __pyx_t_10 = __Pyx_dict_iterator(__pyx_v_exchange_rates, 0, __pyx_n_s_items, (&__pyx_t_12), (&__pyx_t_9)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1820, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_XDECREF(__pyx_t_4);
      __pyx_t_4 = __pyx_t_10;
      __pyx_t_10 = 0;
      while (1) {
        __pyx_t_13 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_12, &__pyx_t_11, &__pyx_t_10, &__pyx_t_6, NULL, __pyx_t_9);
        if (unlikely(__pyx_t_13 == 0)) break;
        if (unlikely(__pyx_t_13 == -1)) __PYX_ERR(0, 1820, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_k, __pyx_t_10);
        __pyx_t_10 = 0;
        __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_v, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_10 = __Pyx_GetItemInt(__pyx_8genexpr5__pyx_v_k, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1820, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1820, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_6 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1820, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_10 = __Pyx_GetItemInt(__pyx_8genexpr5__pyx_v_k, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1820, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_encode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1820, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        __pyx_t_5 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1820, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1820, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5);
        __pyx_t_6 = 0;
        __pyx_t_5 = 0;
        if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_t_8, (PyObject*)__pyx_8genexpr5__pyx_v_v))) __PYX_ERR(0, 1820, __pyx_L7_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_k); __pyx_8genexpr5__pyx_v_k = 0;
      __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_v); __pyx_8genexpr5__pyx_v_v = 0;
      goto __pyx_L10_exit_scope;
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_k); __pyx_8genexpr5__pyx_v_k = 0;
      __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_v); __pyx_8genexpr5__pyx_v_v = 0;
      goto __pyx_L1_error;
      __pyx_L10_exit_scope:;
    } /* exit inner scope */
    __Pyx_DECREF_SET(__pyx_v_exchange_rates, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "trapeza/account/fx_account.pyx":1821
 *                 check_types([exchange_rates[sample_key]], [float], ['exchange_rate_value'], ignore_type_checking)
 *             exchange_rates = {(k[0].encode(), k[1].encode()): v for k, v in exchange_rates.items()}
 *         return exchange_rates             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_exchange_rates);
  __pyx_r = __pyx_v_exchange_rates;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1801
 * 
 *     @staticmethod
 *     def _parse_exchange_rates(exchange_rates, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks exchange rates.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sample_key);
  __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_k);
  __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_exchange_rates);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1824
 * 
 *     @staticmethod
 *     def _check_alt_fee(alt_fee, str alt_fee_error_msg):             # <<<<<<<<<<<<<<
 *         """
 *         Checks if param:alt_fee is of type {None, False, callable, float}. If alt_fee is callable method, method
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_73_check_alt_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_72_check_alt_fee[] = "\n        Checks if param:alt_fee is of type {None, False, callable, float}. If alt_fee is callable method, method\n        signature is not checked in detail !!! (see param:fee_buy func definition/ signature at self.__init__())\n        :param alt_fee: alternative fee, {None, False, callable, float}\n        :param alt_fee_error_msg: str,\n                                  for error message when NotImplementedError is raised:\n                                  '{} must be of type None, bool, '\n                                  'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee))\n        :return: None\n        :raises: NotImplementedError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_73_check_alt_fee = {"_check_alt_fee", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_73_check_alt_fee, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_72_check_alt_fee};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_73_check_alt_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_alt_fee = 0;
  PyObject *__pyx_v_alt_fee_error_msg = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_alt_fee (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_alt_fee,&__pyx_n_s_alt_fee_error_msg,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alt_fee)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alt_fee_error_msg)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_check_alt_fee", 1, 2, 2, 1); __PYX_ERR(0, 1824, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_check_alt_fee") < 0)) __PYX_ERR(0, 1824, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_alt_fee = values[0];
    __pyx_v_alt_fee_error_msg = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_check_alt_fee", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1824, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._check_alt_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alt_fee_error_msg), (&PyUnicode_Type), 1, "alt_fee_error_msg", 1))) __PYX_ERR(0, 1824, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_72_check_alt_fee(__pyx_self, __pyx_v_alt_fee, __pyx_v_alt_fee_error_msg);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_72_check_alt_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_alt_fee, PyObject *__pyx_v_alt_fee_error_msg) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_alt_fee", 0);

  /* "trapeza/account/fx_account.pyx":1836
 *         :raises: NotImplementedError
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):
 *                 pass
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":1837
 *         """
 *         try:
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):             # <<<<<<<<<<<<<<
 *                 pass
 *             elif float(alt_fee) == alt_fee:
 */
      __pyx_t_5 = (__pyx_v_alt_fee == Py_None);
      __pyx_t_6 = (__pyx_t_5 != 0);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_6 = (__pyx_v_alt_fee == Py_False);
      __pyx_t_5 = (__pyx_t_6 != 0);
      if (!__pyx_t_5) {
      } else {
        __pyx_t_4 = __pyx_t_5;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_5 = __Pyx_PyCallable_Check(__pyx_v_alt_fee); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1837, __pyx_L3_error)
      __pyx_t_6 = (__pyx_t_5 != 0);
      __pyx_t_4 = __pyx_t_6;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_4) {
        goto __pyx_L9;
      }

      /* "trapeza/account/fx_account.pyx":1839
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):
 *                 pass
 *             elif float(alt_fee) == alt_fee:             # <<<<<<<<<<<<<<
 *                 pass
 *             else:
 */
      __pyx_t_7 = __Pyx_PyNumber_Float(__pyx_v_alt_fee); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1839, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, __pyx_v_alt_fee, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1839, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1839, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (likely(__pyx_t_4)) {
        goto __pyx_L9;
      }

      /* "trapeza/account/fx_account.pyx":1842
 *                 pass
 *             else:
 *                 raise NotImplementedError('{} must be of type None, bool, '             # <<<<<<<<<<<<<<
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except (ValueError, TypeError):
 */
      /*else*/ {

        /* "trapeza/account/fx_account.pyx":1843
 *             else:
 *                 raise NotImplementedError('{} must be of type None, bool, '
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))             # <<<<<<<<<<<<<<
 *         except (ValueError, TypeError):
 *             raise NotImplementedError('{} must be of type None, bool, '
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_must_be_of_type_None_bool_float, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1843, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_9 = NULL;
        __pyx_t_10 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
            __pyx_t_10 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1843, __pyx_L3_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1843, __pyx_L3_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1843, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__pyx_t_9) {
            __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
          }
          __Pyx_INCREF(__pyx_v_alt_fee_error_msg);
          __Pyx_GIVEREF(__pyx_v_alt_fee_error_msg);
          PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_alt_fee_error_msg);
          __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
          __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
          PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, ((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1843, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "trapeza/account/fx_account.pyx":1842
 *                 pass
 *             else:
 *                 raise NotImplementedError('{} must be of type None, bool, '             # <<<<<<<<<<<<<<
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except (ValueError, TypeError):
 */
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_NotImplementedError, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1842, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(0, 1842, __pyx_L3_error)
      }
      __pyx_L9:;

      /* "trapeza/account/fx_account.pyx":1836
 *         :raises: NotImplementedError
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):
 *                 pass
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "trapeza/account/fx_account.pyx":1844
 *                 raise NotImplementedError('{} must be of type None, bool, '
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except (ValueError, TypeError):             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 */
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._check_alt_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_11) < 0) __PYX_ERR(0, 1844, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_11);

      /* "trapeza/account/fx_account.pyx":1846
 *         except (ValueError, TypeError):
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))             # <<<<<<<<<<<<<<
 *         except NotImplementedError:
 *             raise NotImplementedError('{} must be of type None, bool, '
 */
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_must_be_of_type_None_bool_float, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1846, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1846, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1846, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1846, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_13) {
          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
        }
        __Pyx_INCREF(__pyx_v_alt_fee_error_msg);
        __Pyx_GIVEREF(__pyx_v_alt_fee_error_msg);
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_10, __pyx_v_alt_fee_error_msg);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_10, ((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1846, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "trapeza/account/fx_account.pyx":1845
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except (ValueError, TypeError):
 *             raise NotImplementedError('{} must be of type None, bool, '             # <<<<<<<<<<<<<<
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except NotImplementedError:
 */
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_NotImplementedError, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1845, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_12, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __PYX_ERR(0, 1845, __pyx_L5_except_error)
    }

    /* "trapeza/account/fx_account.pyx":1847
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except NotImplementedError:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 */
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_NotImplementedError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._check_alt_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_8, &__pyx_t_7) < 0) __PYX_ERR(0, 1847, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_7);

      /* "trapeza/account/fx_account.pyx":1849
 *         except NotImplementedError:
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_must_be_of_type_None_bool_float, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1849, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_14 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1849, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1849, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else
      #endif
      {
        __pyx_t_13 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1849, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_14) {
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = NULL;
        }
        __Pyx_INCREF(__pyx_v_alt_fee_error_msg);
        __Pyx_GIVEREF(__pyx_v_alt_fee_error_msg);
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_10, __pyx_v_alt_fee_error_msg);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_10, ((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1849, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "trapeza/account/fx_account.pyx":1848
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except NotImplementedError:
 *             raise NotImplementedError('{} must be of type None, bool, '             # <<<<<<<<<<<<<<
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_NotImplementedError, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1848, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 1848, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "trapeza/account/fx_account.pyx":1836
 *         :raises: NotImplementedError
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):
 *                 pass
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":1824
 * 
 *     @staticmethod
 *     def _check_alt_fee(alt_fee, str alt_fee_error_msg):             # <<<<<<<<<<<<<<
 *         """
 *         Checks if param:alt_fee is of type {None, False, callable, float}. If alt_fee is callable method, method
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._check_alt_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1852
 * 
 *     @staticmethod
 *     def _parse_fee_and_transaction_params(float_fee_currency,             # <<<<<<<<<<<<<<
 *                                           str default_float_currency,
 *                                           alt_fee, str alt_fee_error_msg, instant_float_fee,
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_75_parse_fee_and_transaction_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_74_parse_fee_and_transaction_params[] = "\n        Parses parameters regarding fees and transaction. Called by transactions methods.\n        :param float_fee_currency: {None, str}, parsed to default_currency if None\n        :param default_float_currency: str\n        :param alt_fee: alternative fee, {None, False, callable, float}, else raise NotImplementedError\n        :param alt_fee_error_msg: str, error message when NotImplementedError is raised:\n                                  '{} must be of type None, bool, float or func and not '\n                                  'of type {}'.format(alt_fee_error_msg, type(alt_fee)))\n        :param instant_float_fee: bool, parsed to False if alt_fee is {None, alt_fee, callable}\n        :param processing_duration: {None, int}, parsed to 0 if None\n        :return: float_fee_currency: str\n                 instant_float_fee: bool\n                 processing_duration: int\n        :raises: NotImplementedError\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_75_parse_fee_and_transaction_params = {"_parse_fee_and_transaction_params", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_75_parse_fee_and_transaction_params, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_74_parse_fee_and_transaction_params};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_75_parse_fee_and_transaction_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_float_fee_currency = 0;
  PyObject *__pyx_v_default_float_currency = 0;
  PyObject *__pyx_v_alt_fee = 0;
  PyObject *__pyx_v_alt_fee_error_msg = 0;
  PyObject *__pyx_v_instant_float_fee = 0;
  PyObject *__pyx_v_processing_duration = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_parse_fee_and_transaction_params (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_float_fee_currency,&__pyx_n_s_default_float_currency,&__pyx_n_s_alt_fee,&__pyx_n_s_alt_fee_error_msg,&__pyx_n_s_instant_float_fee,&__pyx_n_s_processing_duration,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_float_fee_currency)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default_float_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fee_and_transaction_params", 1, 6, 6, 1); __PYX_ERR(0, 1852, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alt_fee)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fee_and_transaction_params", 1, 6, 6, 2); __PYX_ERR(0, 1852, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alt_fee_error_msg)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fee_and_transaction_params", 1, 6, 6, 3); __PYX_ERR(0, 1852, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_float_fee)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fee_and_transaction_params", 1, 6, 6, 4); __PYX_ERR(0, 1852, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_parse_fee_and_transaction_params", 1, 6, 6, 5); __PYX_ERR(0, 1852, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parse_fee_and_transaction_params") < 0)) __PYX_ERR(0, 1852, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
    }
    __pyx_v_float_fee_currency = values[0];
    __pyx_v_default_float_currency = ((PyObject*)values[1]);
    __pyx_v_alt_fee = values[2];
    __pyx_v_alt_fee_error_msg = ((PyObject*)values[3]);
    __pyx_v_instant_float_fee = values[4];
    __pyx_v_processing_duration = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_parse_fee_and_transaction_params", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1852, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_fee_and_transaction_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_default_float_currency), (&PyUnicode_Type), 1, "default_float_currency", 1))) __PYX_ERR(0, 1853, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alt_fee_error_msg), (&PyUnicode_Type), 1, "alt_fee_error_msg", 1))) __PYX_ERR(0, 1854, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_74_parse_fee_and_transaction_params(__pyx_self, __pyx_v_float_fee_currency, __pyx_v_default_float_currency, __pyx_v_alt_fee, __pyx_v_alt_fee_error_msg, __pyx_v_instant_float_fee, __pyx_v_processing_duration);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_74_parse_fee_and_transaction_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_float_fee_currency, PyObject *__pyx_v_default_float_currency, PyObject *__pyx_v_alt_fee, PyObject *__pyx_v_alt_fee_error_msg, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_processing_duration) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_parse_fee_and_transaction_params", 0);
  __Pyx_INCREF(__pyx_v_float_fee_currency);
  __Pyx_INCREF(__pyx_v_instant_float_fee);
  __Pyx_INCREF(__pyx_v_processing_duration);

  /* "trapeza/account/fx_account.pyx":1871
 *         :raises: NotImplementedError
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):
 *                 instant_float_fee = False
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":1872
 *         """
 *         try:
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):             # <<<<<<<<<<<<<<
 *                 instant_float_fee = False
 *                 float_fee_currency = default_float_currency
 */
      __pyx_t_5 = (__pyx_v_alt_fee == Py_None);
      __pyx_t_6 = (__pyx_t_5 != 0);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_6 = (__pyx_v_alt_fee == Py_False);
      __pyx_t_5 = (__pyx_t_6 != 0);
      if (!__pyx_t_5) {
      } else {
        __pyx_t_4 = __pyx_t_5;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_5 = __Pyx_PyCallable_Check(__pyx_v_alt_fee); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1872, __pyx_L3_error)
      __pyx_t_6 = (__pyx_t_5 != 0);
      __pyx_t_4 = __pyx_t_6;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_4) {

        /* "trapeza/account/fx_account.pyx":1873
 *         try:
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):
 *                 instant_float_fee = False             # <<<<<<<<<<<<<<
 *                 float_fee_currency = default_float_currency
 *             elif float(alt_fee) == alt_fee:  # if float, than just pass
 */
        __Pyx_INCREF(Py_False);
        __Pyx_DECREF_SET(__pyx_v_instant_float_fee, Py_False);

        /* "trapeza/account/fx_account.pyx":1874
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):
 *                 instant_float_fee = False
 *                 float_fee_currency = default_float_currency             # <<<<<<<<<<<<<<
 *             elif float(alt_fee) == alt_fee:  # if float, than just pass
 *                 if float_fee_currency is None:
 */
        __Pyx_INCREF(__pyx_v_default_float_currency);
        __Pyx_DECREF_SET(__pyx_v_float_fee_currency, __pyx_v_default_float_currency);

        /* "trapeza/account/fx_account.pyx":1872
 *         """
 *         try:
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):             # <<<<<<<<<<<<<<
 *                 instant_float_fee = False
 *                 float_fee_currency = default_float_currency
 */
        goto __pyx_L9;
      }

      /* "trapeza/account/fx_account.pyx":1875
 *                 instant_float_fee = False
 *                 float_fee_currency = default_float_currency
 *             elif float(alt_fee) == alt_fee:  # if float, than just pass             # <<<<<<<<<<<<<<
 *                 if float_fee_currency is None:
 *                     float_fee_currency = default_float_currency
 */
      __pyx_t_7 = __Pyx_PyNumber_Float(__pyx_v_alt_fee); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1875, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, __pyx_v_alt_fee, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1875, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1875, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (likely(__pyx_t_4)) {

        /* "trapeza/account/fx_account.pyx":1876
 *                 float_fee_currency = default_float_currency
 *             elif float(alt_fee) == alt_fee:  # if float, than just pass
 *                 if float_fee_currency is None:             # <<<<<<<<<<<<<<
 *                     float_fee_currency = default_float_currency
 *             else:
 */
        __pyx_t_4 = (__pyx_v_float_fee_currency == Py_None);
        __pyx_t_6 = (__pyx_t_4 != 0);
        if (__pyx_t_6) {

          /* "trapeza/account/fx_account.pyx":1877
 *             elif float(alt_fee) == alt_fee:  # if float, than just pass
 *                 if float_fee_currency is None:
 *                     float_fee_currency = default_float_currency             # <<<<<<<<<<<<<<
 *             else:
 *                 # alt_fee must be in [func, None, bool, float]
 */
          __Pyx_INCREF(__pyx_v_default_float_currency);
          __Pyx_DECREF_SET(__pyx_v_float_fee_currency, __pyx_v_default_float_currency);

          /* "trapeza/account/fx_account.pyx":1876
 *                 float_fee_currency = default_float_currency
 *             elif float(alt_fee) == alt_fee:  # if float, than just pass
 *                 if float_fee_currency is None:             # <<<<<<<<<<<<<<
 *                     float_fee_currency = default_float_currency
 *             else:
 */
        }

        /* "trapeza/account/fx_account.pyx":1875
 *                 instant_float_fee = False
 *                 float_fee_currency = default_float_currency
 *             elif float(alt_fee) == alt_fee:  # if float, than just pass             # <<<<<<<<<<<<<<
 *                 if float_fee_currency is None:
 *                     float_fee_currency = default_float_currency
 */
        goto __pyx_L9;
      }

      /* "trapeza/account/fx_account.pyx":1880
 *             else:
 *                 # alt_fee must be in [func, None, bool, float]
 *                 raise NotImplementedError('{} must be of type None, bool, '             # <<<<<<<<<<<<<<
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except (TypeError, ValueError):
 */
      /*else*/ {

        /* "trapeza/account/fx_account.pyx":1881
 *                 # alt_fee must be in [func, None, bool, float]
 *                 raise NotImplementedError('{} must be of type None, bool, '
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))             # <<<<<<<<<<<<<<
 *         except (TypeError, ValueError):
 *             raise NotImplementedError('{} must be of type None, bool, '
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_must_be_of_type_None_bool_float, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1881, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_9 = NULL;
        __pyx_t_10 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
            __pyx_t_10 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1881, __pyx_L3_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1881, __pyx_L3_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_8);
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1881, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__pyx_t_9) {
            __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
          }
          __Pyx_INCREF(__pyx_v_alt_fee_error_msg);
          __Pyx_GIVEREF(__pyx_v_alt_fee_error_msg);
          PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_alt_fee_error_msg);
          __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
          __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
          PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, ((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1881, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "trapeza/account/fx_account.pyx":1880
 *             else:
 *                 # alt_fee must be in [func, None, bool, float]
 *                 raise NotImplementedError('{} must be of type None, bool, '             # <<<<<<<<<<<<<<
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except (TypeError, ValueError):
 */
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_NotImplementedError, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1880, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __PYX_ERR(0, 1880, __pyx_L3_error)
      }
      __pyx_L9:;

      /* "trapeza/account/fx_account.pyx":1871
 *         :raises: NotImplementedError
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):
 *                 instant_float_fee = False
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "trapeza/account/fx_account.pyx":1882
 *                 raise NotImplementedError('{} must be of type None, bool, '
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except (TypeError, ValueError):             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 */
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_fee_and_transaction_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_11) < 0) __PYX_ERR(0, 1882, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_11);

      /* "trapeza/account/fx_account.pyx":1884
 *         except (TypeError, ValueError):
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))             # <<<<<<<<<<<<<<
 *         except NotImplementedError:
 *             raise NotImplementedError('{} must be of type None, bool, '
 */
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_must_be_of_type_None_bool_float, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1884, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1884, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1884, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1884, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (__pyx_t_13) {
          __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
        }
        __Pyx_INCREF(__pyx_v_alt_fee_error_msg);
        __Pyx_GIVEREF(__pyx_v_alt_fee_error_msg);
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_10, __pyx_v_alt_fee_error_msg);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_10, ((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1884, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "trapeza/account/fx_account.pyx":1883
 *                                           'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except (TypeError, ValueError):
 *             raise NotImplementedError('{} must be of type None, bool, '             # <<<<<<<<<<<<<<
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except NotImplementedError:
 */
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_NotImplementedError, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1883, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_12, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __PYX_ERR(0, 1883, __pyx_L5_except_error)
    }

    /* "trapeza/account/fx_account.pyx":1885
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except NotImplementedError:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 */
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_NotImplementedError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_fee_and_transaction_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_8, &__pyx_t_7) < 0) __PYX_ERR(0, 1885, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_7);

      /* "trapeza/account/fx_account.pyx":1887
 *         except NotImplementedError:
 *             raise NotImplementedError('{} must be of type None, bool, '
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))             # <<<<<<<<<<<<<<
 * 
 *         if float_fee_currency is None:
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_must_be_of_type_None_bool_float, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1887, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_14 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1887, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_alt_fee_error_msg, ((PyObject *)Py_TYPE(__pyx_v_alt_fee))};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1887, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else
      #endif
      {
        __pyx_t_13 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1887, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_14) {
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = NULL;
        }
        __Pyx_INCREF(__pyx_v_alt_fee_error_msg);
        __Pyx_GIVEREF(__pyx_v_alt_fee_error_msg);
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_10, __pyx_v_alt_fee_error_msg);
        __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_10, ((PyObject *)Py_TYPE(__pyx_v_alt_fee)));
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1887, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "trapeza/account/fx_account.pyx":1886
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 *         except NotImplementedError:
 *             raise NotImplementedError('{} must be of type None, bool, '             # <<<<<<<<<<<<<<
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_NotImplementedError, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1886, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 1886, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "trapeza/account/fx_account.pyx":1871
 *         :raises: NotImplementedError
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             if alt_fee is None or alt_fee is False or callable(alt_fee):
 *                 instant_float_fee = False
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":1889
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 * 
 *         if float_fee_currency is None:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('alt_fee must be in {None, False, func, Float')
 * 
 */
  __pyx_t_6 = (__pyx_v_float_fee_currency == Py_None);
  __pyx_t_4 = (__pyx_t_6 != 0);
  if (unlikely(__pyx_t_4)) {

    /* "trapeza/account/fx_account.pyx":1890
 * 
 *         if float_fee_currency is None:
 *             raise NotImplementedError('alt_fee must be in {None, False, func, Float')             # <<<<<<<<<<<<<<
 * 
 *         if processing_duration is None:
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1890, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __PYX_ERR(0, 1890, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":1889
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 * 
 *         if float_fee_currency is None:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('alt_fee must be in {None, False, func, Float')
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":1892
 *             raise NotImplementedError('alt_fee must be in {None, False, func, Float')
 * 
 *         if processing_duration is None:             # <<<<<<<<<<<<<<
 *             processing_duration = 0
 *         return float_fee_currency, instant_float_fee, processing_duration
 */
  __pyx_t_4 = (__pyx_v_processing_duration == Py_None);
  __pyx_t_6 = (__pyx_t_4 != 0);
  if (__pyx_t_6) {

    /* "trapeza/account/fx_account.pyx":1893
 * 
 *         if processing_duration is None:
 *             processing_duration = 0             # <<<<<<<<<<<<<<
 *         return float_fee_currency, instant_float_fee, processing_duration
 * 
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_DECREF_SET(__pyx_v_processing_duration, __pyx_int_0);

    /* "trapeza/account/fx_account.pyx":1892
 *             raise NotImplementedError('alt_fee must be in {None, False, func, Float')
 * 
 *         if processing_duration is None:             # <<<<<<<<<<<<<<
 *             processing_duration = 0
 *         return float_fee_currency, instant_float_fee, processing_duration
 */
  }

  /* "trapeza/account/fx_account.pyx":1894
 *         if processing_duration is None:
 *             processing_duration = 0
 *         return float_fee_currency, instant_float_fee, processing_duration             # <<<<<<<<<<<<<<
 * 
 *     def _check_coverage(self, debit_amount, currency, time_step):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1894, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_float_fee_currency);
  __Pyx_GIVEREF(__pyx_v_float_fee_currency);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_float_fee_currency);
  __Pyx_INCREF(__pyx_v_instant_float_fee);
  __Pyx_GIVEREF(__pyx_v_instant_float_fee);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_instant_float_fee);
  __Pyx_INCREF(__pyx_v_processing_duration);
  __Pyx_GIVEREF(__pyx_v_processing_duration);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_processing_duration);
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1852
 * 
 *     @staticmethod
 *     def _parse_fee_and_transaction_params(float_fee_currency,             # <<<<<<<<<<<<<<
 *                                           str default_float_currency,
 *                                           alt_fee, str alt_fee_error_msg, instant_float_fee,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._parse_fee_and_transaction_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_float_fee_currency);
  __Pyx_XDECREF(__pyx_v_instant_float_fee);
  __Pyx_XDECREF(__pyx_v_processing_duration);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1896
 *         return float_fee_currency, instant_float_fee, processing_duration
 * 
 *     def _check_coverage(self, debit_amount, currency, time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_77_check_coverage(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_76_check_coverage[] = "\n        Only used for unit testing. Thin wrapper for underlying C++ implementation.\n        Checks coverage if param:debit_amount is withdrawn including marked withdrawals up to param:time_step in\n        param:currency\n\n        DO NOT USE -1 as return value. This is reserved to indicate exception (cython specifics).\n\n        :param debit_amount: float\n        :param currency: str\n        :param time_step: int\n        :return: float or math.inf (if self.check_marked_coverage=False or self.check_marked_coverage=None)\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_77_check_coverage = {"_check_coverage", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_77_check_coverage, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_76_check_coverage};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_77_check_coverage(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_debit_amount = 0;
  PyObject *__pyx_v_currency = 0;
  PyObject *__pyx_v_time_step = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_coverage (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_debit_amount,&__pyx_n_s_currency,&__pyx_n_s_time_step,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_debit_amount)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_check_coverage", 1, 4, 4, 1); __PYX_ERR(0, 1896, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_check_coverage", 1, 4, 4, 2); __PYX_ERR(0, 1896, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_time_step)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_check_coverage", 1, 4, 4, 3); __PYX_ERR(0, 1896, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_check_coverage") < 0)) __PYX_ERR(0, 1896, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_self = values[0];
    __pyx_v_debit_amount = values[1];
    __pyx_v_currency = values[2];
    __pyx_v_time_step = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_check_coverage", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1896, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._check_coverage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_76_check_coverage(__pyx_self, __pyx_v_self, __pyx_v_debit_amount, __pyx_v_currency, __pyx_v_time_step);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_76_check_coverage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_debit_amount, PyObject *__pyx_v_currency, PyObject *__pyx_v_time_step) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_coverage", 0);

  /* "trapeza/account/fx_account.pyx":1909
 *         :return: float or math.inf (if self.check_marked_coverage=False or self.check_marked_coverage=None)
 *         """
 *         return self._c_check_coverage(debit_amount, currency.encode(), time_step)             # <<<<<<<<<<<<<<
 * 
 *     def _eval_fee(self, str action_type, alt_fee, double volume, double current_rate, str base, str quote,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_check_coverage); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1909, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1909, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1909, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_debit_amount, __pyx_t_3, __pyx_v_time_step};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1909, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_debit_amount, __pyx_t_3, __pyx_v_time_step};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1909, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1909, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_debit_amount);
    __Pyx_GIVEREF(__pyx_v_debit_amount);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_debit_amount);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_time_step);
    __Pyx_GIVEREF(__pyx_v_time_step);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, __pyx_v_time_step);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1909, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1896
 *         return float_fee_currency, instant_float_fee, processing_duration
 * 
 *     def _check_coverage(self, debit_amount, currency, time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._check_coverage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1911
 *         return self._c_check_coverage(debit_amount, currency.encode(), time_step)
 * 
 *     def _eval_fee(self, str action_type, alt_fee, double volume, double current_rate, str base, str quote,             # <<<<<<<<<<<<<<
 *                   processing_duration):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_79_eval_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_78_eval_fee[] = "\n        Evaluates fee without processing any transaction. Takes processing_duration into account. Used to predict\n        fee costs.\n        :param action_type: {'buy', 'sell', 'deposit', 'withdraw'},\n                            ignored if alt_fee != None\n        :param alt_fee: alternative fee, {func, False, None, float}\n        :param volume: float\n        :param base: str\n        :param current_rate: float\n        :param quote: str\n        :param processing_duration: int\n        :return: fee_amount: float\n                 fee_currency: str\n                 fee_exec_duration: int\n        :raises: NotImplementedError if alt_fee is not in {func, False, None, float}\n                 ValueError if volume < 0\n                 TypeError if volume and price are not float/int or if processing duration is not int\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_79_eval_fee = {"_eval_fee", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_79_eval_fee, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_78_eval_fee};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_79_eval_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_action_type = 0;
  PyObject *__pyx_v_alt_fee = 0;
  double __pyx_v_volume;
  double __pyx_v_current_rate;
  PyObject *__pyx_v_base = 0;
  PyObject *__pyx_v_quote = 0;
  PyObject *__pyx_v_processing_duration = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_eval_fee (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_action_type,&__pyx_n_s_alt_fee,&__pyx_n_s_volume,&__pyx_n_s_current_rate,&__pyx_n_s_base,&__pyx_n_s_quote,&__pyx_n_s_processing_duration,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_action_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_eval_fee", 1, 8, 8, 1); __PYX_ERR(0, 1911, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alt_fee)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_eval_fee", 1, 8, 8, 2); __PYX_ERR(0, 1911, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_eval_fee", 1, 8, 8, 3); __PYX_ERR(0, 1911, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_current_rate)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_eval_fee", 1, 8, 8, 4); __PYX_ERR(0, 1911, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_eval_fee", 1, 8, 8, 5); __PYX_ERR(0, 1911, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quote)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_eval_fee", 1, 8, 8, 6); __PYX_ERR(0, 1911, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_eval_fee", 1, 8, 8, 7); __PYX_ERR(0, 1911, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_eval_fee") < 0)) __PYX_ERR(0, 1911, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
    }
    __pyx_v_self = values[0];
    __pyx_v_action_type = ((PyObject*)values[1]);
    __pyx_v_alt_fee = values[2];
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1911, __pyx_L3_error)
    __pyx_v_current_rate = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_current_rate == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1911, __pyx_L3_error)
    __pyx_v_base = ((PyObject*)values[5]);
    __pyx_v_quote = ((PyObject*)values[6]);
    __pyx_v_processing_duration = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_eval_fee", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1911, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._eval_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_action_type), (&PyUnicode_Type), 1, "action_type", 1))) __PYX_ERR(0, 1911, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyUnicode_Type), 1, "base", 1))) __PYX_ERR(0, 1911, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_quote), (&PyUnicode_Type), 1, "quote", 1))) __PYX_ERR(0, 1911, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_78_eval_fee(__pyx_self, __pyx_v_self, __pyx_v_action_type, __pyx_v_alt_fee, __pyx_v_volume, __pyx_v_current_rate, __pyx_v_base, __pyx_v_quote, __pyx_v_processing_duration);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_78_eval_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_action_type, PyObject *__pyx_v_alt_fee, double __pyx_v_volume, double __pyx_v_current_rate, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, PyObject *__pyx_v_processing_duration) {
  PyObject *__pyx_v_fee_amount = NULL;
  PyObject *__pyx_v_fee_currency = NULL;
  PyObject *__pyx_v_fee_exec_duration = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_eval_fee", 0);

  /* "trapeza/account/fx_account.pyx":1932
 *         """
 *         # >>>sanity check
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError
 * 
 */
  __pyx_t_1 = ((__pyx_v_volume < 0.0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "trapeza/account/fx_account.pyx":1933
 *         # >>>sanity check
 *         if volume < 0:
 *             raise ValueError             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
    __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
    __PYX_ERR(0, 1933, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":1932
 *         """
 *         # >>>sanity check
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":1935
 *             raise ValueError
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if alt_fee is None:  # apply self.fee
 *                 (fee_amount,
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":1936
 * 
 *         try:
 *             if alt_fee is None:  # apply self.fee             # <<<<<<<<<<<<<<
 *                 (fee_amount,
 *                  fee_currency,
 */
      __pyx_t_1 = (__pyx_v_alt_fee == Py_None);
      __pyx_t_5 = (__pyx_t_1 != 0);
      if (__pyx_t_5) {

        /* "trapeza/account/fx_account.pyx":1939
 *                 (fee_amount,
 *                  fee_currency,
 *                  fee_exec_duration) = self._c_fee[action_type.encode()](volume, current_rate, base, quote,             # <<<<<<<<<<<<<<
 *                                                                         processing_duration)
 *             elif alt_fee is False:  # no fee
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_fee); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1939, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (unlikely(__pyx_v_action_type == Py_None)) {
          PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
          __PYX_ERR(0, 1939, __pyx_L4_error)
        }
        __pyx_t_8 = PyUnicode_AsEncodedString(__pyx_v_action_type, NULL, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1939, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1939, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1939, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_7 = PyFloat_FromDouble(__pyx_v_current_rate); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1939, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);

        /* "trapeza/account/fx_account.pyx":1940
 *                  fee_currency,
 *                  fee_exec_duration) = self._c_fee[action_type.encode()](volume, current_rate, base, quote,
 *                                                                         processing_duration)             # <<<<<<<<<<<<<<
 *             elif alt_fee is False:  # no fee
 *                 fee_amount, fee_currency, fee_exec_duration = 0, base, 0
 */
        __pyx_t_10 = NULL;
        __pyx_t_11 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
            __pyx_t_11 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_8, __pyx_t_7, __pyx_v_base, __pyx_v_quote, __pyx_v_processing_duration};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1939, __pyx_L4_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_8, __pyx_t_7, __pyx_v_base, __pyx_v_quote, __pyx_v_processing_duration};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1939, __pyx_L4_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1939, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_12);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_7);
          __Pyx_INCREF(__pyx_v_base);
          __Pyx_GIVEREF(__pyx_v_base);
          PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_v_base);
          __Pyx_INCREF(__pyx_v_quote);
          __Pyx_GIVEREF(__pyx_v_quote);
          PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_v_quote);
          __Pyx_INCREF(__pyx_v_processing_duration);
          __Pyx_GIVEREF(__pyx_v_processing_duration);
          PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, __pyx_v_processing_duration);
          __pyx_t_8 = 0;
          __pyx_t_7 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1939, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
          PyObject* sequence = __pyx_t_6;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 3)) {
            if (size > 3) __Pyx_RaiseTooManyValuesError(3);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 1937, __pyx_L4_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
            __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
          } else {
            __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
            __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
          }
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_7);
          #else
          __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1937, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1937, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1937, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_8 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1937, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_13 = Py_TYPE(__pyx_t_8)->tp_iternext;
          index = 0; __pyx_t_9 = __pyx_t_13(__pyx_t_8); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_9);
          index = 1; __pyx_t_12 = __pyx_t_13(__pyx_t_8); if (unlikely(!__pyx_t_12)) goto __pyx_L11_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_12);
          index = 2; __pyx_t_7 = __pyx_t_13(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L11_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_7);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_8), 3) < 0) __PYX_ERR(0, 1937, __pyx_L4_error)
          __pyx_t_13 = NULL;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          goto __pyx_L12_unpacking_done;
          __pyx_L11_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_13 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 1937, __pyx_L4_error)
          __pyx_L12_unpacking_done:;
        }

        /* "trapeza/account/fx_account.pyx":1937
 *         try:
 *             if alt_fee is None:  # apply self.fee
 *                 (fee_amount,             # <<<<<<<<<<<<<<
 *                  fee_currency,
 *                  fee_exec_duration) = self._c_fee[action_type.encode()](volume, current_rate, base, quote,
 */
        __pyx_v_fee_amount = __pyx_t_9;
        __pyx_t_9 = 0;
        __pyx_v_fee_currency = __pyx_t_12;
        __pyx_t_12 = 0;
        __pyx_v_fee_exec_duration = __pyx_t_7;
        __pyx_t_7 = 0;

        /* "trapeza/account/fx_account.pyx":1936
 * 
 *         try:
 *             if alt_fee is None:  # apply self.fee             # <<<<<<<<<<<<<<
 *                 (fee_amount,
 *                  fee_currency,
 */
        goto __pyx_L10;
      }

      /* "trapeza/account/fx_account.pyx":1941
 *                  fee_exec_duration) = self._c_fee[action_type.encode()](volume, current_rate, base, quote,
 *                                                                         processing_duration)
 *             elif alt_fee is False:  # no fee             # <<<<<<<<<<<<<<
 *                 fee_amount, fee_currency, fee_exec_duration = 0, base, 0
 *             elif callable(alt_fee):
 */
      __pyx_t_5 = (__pyx_v_alt_fee == Py_False);
      __pyx_t_1 = (__pyx_t_5 != 0);
      if (__pyx_t_1) {

        /* "trapeza/account/fx_account.pyx":1942
 *                                                                         processing_duration)
 *             elif alt_fee is False:  # no fee
 *                 fee_amount, fee_currency, fee_exec_duration = 0, base, 0             # <<<<<<<<<<<<<<
 *             elif callable(alt_fee):
 *                 try:
 */
        __pyx_t_6 = __pyx_int_0;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_7 = __pyx_v_base;
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_12 = __pyx_int_0;
        __Pyx_INCREF(__pyx_t_12);
        __pyx_v_fee_amount = __pyx_t_6;
        __pyx_t_6 = 0;
        __pyx_v_fee_currency = __pyx_t_7;
        __pyx_t_7 = 0;
        __pyx_v_fee_exec_duration = __pyx_t_12;
        __pyx_t_12 = 0;

        /* "trapeza/account/fx_account.pyx":1941
 *                  fee_exec_duration) = self._c_fee[action_type.encode()](volume, current_rate, base, quote,
 *                                                                         processing_duration)
 *             elif alt_fee is False:  # no fee             # <<<<<<<<<<<<<<
 *                 fee_amount, fee_currency, fee_exec_duration = 0, base, 0
 *             elif callable(alt_fee):
 */
        goto __pyx_L10;
      }

      /* "trapeza/account/fx_account.pyx":1943
 *             elif alt_fee is False:  # no fee
 *                 fee_amount, fee_currency, fee_exec_duration = 0, base, 0
 *             elif callable(alt_fee):             # <<<<<<<<<<<<<<
 *                 try:
 *                     fee_amount, fee_currency, fee_exec_duration = alt_fee(volume, current_rate, base, quote,
 */
      __pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_alt_fee); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1943, __pyx_L4_error)
      __pyx_t_5 = (__pyx_t_1 != 0);
      if (__pyx_t_5) {

        /* "trapeza/account/fx_account.pyx":1944
 *                 fee_amount, fee_currency, fee_exec_duration = 0, base, 0
 *             elif callable(alt_fee):
 *                 try:             # <<<<<<<<<<<<<<
 *                     fee_amount, fee_currency, fee_exec_duration = alt_fee(volume, current_rate, base, quote,
 *                                                                           processing_duration)
 */
        {
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_16);
          /*try:*/ {

            /* "trapeza/account/fx_account.pyx":1945
 *             elif callable(alt_fee):
 *                 try:
 *                     fee_amount, fee_currency, fee_exec_duration = alt_fee(volume, current_rate, base, quote,             # <<<<<<<<<<<<<<
 *                                                                           processing_duration)
 *                 except (NameError, TypeError):
 */
            __pyx_t_7 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1945, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_6 = PyFloat_FromDouble(__pyx_v_current_rate); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1945, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_6);

            /* "trapeza/account/fx_account.pyx":1946
 *                 try:
 *                     fee_amount, fee_currency, fee_exec_duration = alt_fee(volume, current_rate, base, quote,
 *                                                                           processing_duration)             # <<<<<<<<<<<<<<
 *                 except (NameError, TypeError):
 *                     raise NotImplementedError
 */
            __Pyx_INCREF(__pyx_v_alt_fee);
            __pyx_t_9 = __pyx_v_alt_fee; __pyx_t_8 = NULL;
            __pyx_t_11 = 0;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
              __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
              if (likely(__pyx_t_8)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_8);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_9, function);
                __pyx_t_11 = 1;
              }
            }
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_9)) {
              PyObject *__pyx_temp[6] = {__pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_v_base, __pyx_v_quote, __pyx_v_processing_duration};
              __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1945, __pyx_L13_error)
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
              PyObject *__pyx_temp[6] = {__pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_v_base, __pyx_v_quote, __pyx_v_processing_duration};
              __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1945, __pyx_L13_error)
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            } else
            #endif
            {
              __pyx_t_10 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1945, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_10);
              if (__pyx_t_8) {
                __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
              }
              __Pyx_GIVEREF(__pyx_t_7);
              PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, __pyx_t_7);
              __Pyx_GIVEREF(__pyx_t_6);
              PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_t_6);
              __Pyx_INCREF(__pyx_v_base);
              __Pyx_GIVEREF(__pyx_v_base);
              PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_11, __pyx_v_base);
              __Pyx_INCREF(__pyx_v_quote);
              __Pyx_GIVEREF(__pyx_v_quote);
              PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_11, __pyx_v_quote);
              __Pyx_INCREF(__pyx_v_processing_duration);
              __Pyx_GIVEREF(__pyx_v_processing_duration);
              PyTuple_SET_ITEM(__pyx_t_10, 4+__pyx_t_11, __pyx_v_processing_duration);
              __pyx_t_7 = 0;
              __pyx_t_6 = 0;
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1945, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            }
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
              PyObject* sequence = __pyx_t_12;
              Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
              if (unlikely(size != 3)) {
                if (size > 3) __Pyx_RaiseTooManyValuesError(3);
                else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                __PYX_ERR(0, 1945, __pyx_L13_error)
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              if (likely(PyTuple_CheckExact(sequence))) {
                __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
                __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
                __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
              } else {
                __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
                __pyx_t_10 = PyList_GET_ITEM(sequence, 1); 
                __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
              }
              __Pyx_INCREF(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_6);
              #else
              __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1945, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_9);
              __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1945, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1945, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_6);
              #endif
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            } else {
              Py_ssize_t index = -1;
              __pyx_t_7 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1945, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __pyx_t_13 = Py_TYPE(__pyx_t_7)->tp_iternext;
              index = 0; __pyx_t_9 = __pyx_t_13(__pyx_t_7); if (unlikely(!__pyx_t_9)) goto __pyx_L19_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_9);
              index = 1; __pyx_t_10 = __pyx_t_13(__pyx_t_7); if (unlikely(!__pyx_t_10)) goto __pyx_L19_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_10);
              index = 2; __pyx_t_6 = __pyx_t_13(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L19_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_6);
              if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_7), 3) < 0) __PYX_ERR(0, 1945, __pyx_L13_error)
              __pyx_t_13 = NULL;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              goto __pyx_L20_unpacking_done;
              __pyx_L19_unpacking_failed:;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __pyx_t_13 = NULL;
              if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
              __PYX_ERR(0, 1945, __pyx_L13_error)
              __pyx_L20_unpacking_done:;
            }

            /* "trapeza/account/fx_account.pyx":1945
 *             elif callable(alt_fee):
 *                 try:
 *                     fee_amount, fee_currency, fee_exec_duration = alt_fee(volume, current_rate, base, quote,             # <<<<<<<<<<<<<<
 *                                                                           processing_duration)
 *                 except (NameError, TypeError):
 */
            __pyx_v_fee_amount = __pyx_t_9;
            __pyx_t_9 = 0;
            __pyx_v_fee_currency = __pyx_t_10;
            __pyx_t_10 = 0;
            __pyx_v_fee_exec_duration = __pyx_t_6;
            __pyx_t_6 = 0;

            /* "trapeza/account/fx_account.pyx":1944
 *                 fee_amount, fee_currency, fee_exec_duration = 0, base, 0
 *             elif callable(alt_fee):
 *                 try:             # <<<<<<<<<<<<<<
 *                     fee_amount, fee_currency, fee_exec_duration = alt_fee(volume, current_rate, base, quote,
 *                                                                           processing_duration)
 */
          }
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          goto __pyx_L18_try_end;
          __pyx_L13_error:;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

          /* "trapeza/account/fx_account.pyx":1947
 *                     fee_amount, fee_currency, fee_exec_duration = alt_fee(volume, current_rate, base, quote,
 *                                                                           processing_duration)
 *                 except (NameError, TypeError):             # <<<<<<<<<<<<<<
 *                     raise NotImplementedError
 *             elif float(alt_fee) == alt_fee:
 */
          __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_NameError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
          if (__pyx_t_11) {
            __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._eval_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_6, &__pyx_t_10) < 0) __PYX_ERR(0, 1947, __pyx_L15_except_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_GOTREF(__pyx_t_10);

            /* "trapeza/account/fx_account.pyx":1948
 *                                                                           processing_duration)
 *                 except (NameError, TypeError):
 *                     raise NotImplementedError             # <<<<<<<<<<<<<<
 *             elif float(alt_fee) == alt_fee:
 *                 fee_amount, fee_currency, fee_exec_duration = alt_fee, base, processing_duration
 */
            __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
            __PYX_ERR(0, 1948, __pyx_L15_except_error)
          }
          goto __pyx_L15_except_error;
          __pyx_L15_except_error:;

          /* "trapeza/account/fx_account.pyx":1944
 *                 fee_amount, fee_currency, fee_exec_duration = 0, base, 0
 *             elif callable(alt_fee):
 *                 try:             # <<<<<<<<<<<<<<
 *                     fee_amount, fee_currency, fee_exec_duration = alt_fee(volume, current_rate, base, quote,
 *                                                                           processing_duration)
 */
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
          goto __pyx_L4_error;
          __pyx_L18_try_end:;
        }

        /* "trapeza/account/fx_account.pyx":1943
 *             elif alt_fee is False:  # no fee
 *                 fee_amount, fee_currency, fee_exec_duration = 0, base, 0
 *             elif callable(alt_fee):             # <<<<<<<<<<<<<<
 *                 try:
 *                     fee_amount, fee_currency, fee_exec_duration = alt_fee(volume, current_rate, base, quote,
 */
        goto __pyx_L10;
      }

      /* "trapeza/account/fx_account.pyx":1949
 *                 except (NameError, TypeError):
 *                     raise NotImplementedError
 *             elif float(alt_fee) == alt_fee:             # <<<<<<<<<<<<<<
 *                 fee_amount, fee_currency, fee_exec_duration = alt_fee, base, processing_duration
 *             else:
 */
      __pyx_t_10 = __Pyx_PyNumber_Float(__pyx_v_alt_fee); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1949, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_6 = PyObject_RichCompare(__pyx_t_10, __pyx_v_alt_fee, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1949, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1949, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (likely(__pyx_t_5)) {

        /* "trapeza/account/fx_account.pyx":1950
 *                     raise NotImplementedError
 *             elif float(alt_fee) == alt_fee:
 *                 fee_amount, fee_currency, fee_exec_duration = alt_fee, base, processing_duration             # <<<<<<<<<<<<<<
 *             else:
 *                 raise NotImplementedError
 */
        __pyx_t_6 = __pyx_v_alt_fee;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_10 = __pyx_v_base;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_12 = __pyx_v_processing_duration;
        __Pyx_INCREF(__pyx_t_12);
        __pyx_v_fee_amount = __pyx_t_6;
        __pyx_t_6 = 0;
        __pyx_v_fee_currency = __pyx_t_10;
        __pyx_t_10 = 0;
        __pyx_v_fee_exec_duration = __pyx_t_12;
        __pyx_t_12 = 0;

        /* "trapeza/account/fx_account.pyx":1949
 *                 except (NameError, TypeError):
 *                     raise NotImplementedError
 *             elif float(alt_fee) == alt_fee:             # <<<<<<<<<<<<<<
 *                 fee_amount, fee_currency, fee_exec_duration = alt_fee, base, processing_duration
 *             else:
 */
        goto __pyx_L10;
      }

      /* "trapeza/account/fx_account.pyx":1952
 *                 fee_amount, fee_currency, fee_exec_duration = alt_fee, base, processing_duration
 *             else:
 *                 raise NotImplementedError             # <<<<<<<<<<<<<<
 *         except ValueError:
 *             raise NotImplementedError
 */
      /*else*/ {
        __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
        __PYX_ERR(0, 1952, __pyx_L4_error)
      }
      __pyx_L10:;

      /* "trapeza/account/fx_account.pyx":1935
 *             raise ValueError
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if alt_fee is None:  # apply self.fee
 *                 (fee_amount,
 */
    }
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "trapeza/account/fx_account.pyx":1953
 *             else:
 *                 raise NotImplementedError
 *         except ValueError:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError
 *         except NotImplementedError:
 */
    __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError);
    if (__pyx_t_11) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._eval_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_10, &__pyx_t_6) < 0) __PYX_ERR(0, 1953, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GOTREF(__pyx_t_6);

      /* "trapeza/account/fx_account.pyx":1954
 *                 raise NotImplementedError
 *         except ValueError:
 *             raise NotImplementedError             # <<<<<<<<<<<<<<
 *         except NotImplementedError:
 *             raise NotImplementedError
 */
      __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
      __PYX_ERR(0, 1954, __pyx_L6_except_error)
    }

    /* "trapeza/account/fx_account.pyx":1955
 *         except ValueError:
 *             raise NotImplementedError
 *         except NotImplementedError:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError
 * 
 */
    __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_NotImplementedError);
    if (__pyx_t_11) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._eval_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_10, &__pyx_t_12) < 0) __PYX_ERR(0, 1955, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GOTREF(__pyx_t_12);

      /* "trapeza/account/fx_account.pyx":1956
 *             raise NotImplementedError
 *         except NotImplementedError:
 *             raise NotImplementedError             # <<<<<<<<<<<<<<
 * 
 *         # noinspection PyUnboundLocalVariable
 */
      __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
      __PYX_ERR(0, 1956, __pyx_L6_except_error)
    }
    goto __pyx_L6_except_error;
    __pyx_L6_except_error:;

    /* "trapeza/account/fx_account.pyx":1935
 *             raise ValueError
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if alt_fee is None:  # apply self.fee
 *                 (fee_amount,
 */
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L1_error;
    __pyx_L9_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":1959
 * 
 *         # noinspection PyUnboundLocalVariable
 *         return fee_amount, fee_currency, fee_exec_duration             # <<<<<<<<<<<<<<
 * 
 *     def _cum_sum_heap(self, currency, action_func_type, long time_step):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1959, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(__pyx_v_fee_amount);
  __Pyx_GIVEREF(__pyx_v_fee_amount);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_fee_amount);
  __Pyx_INCREF(__pyx_v_fee_currency);
  __Pyx_GIVEREF(__pyx_v_fee_currency);
  PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_fee_currency);
  __Pyx_INCREF(__pyx_v_fee_exec_duration);
  __Pyx_GIVEREF(__pyx_v_fee_exec_duration);
  PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_v_fee_exec_duration);
  __pyx_r = __pyx_t_12;
  __pyx_t_12 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1911
 *         return self._c_check_coverage(debit_amount, currency.encode(), time_step)
 * 
 *     def _eval_fee(self, str action_type, alt_fee, double volume, double current_rate, str base, str quote,             # <<<<<<<<<<<<<<
 *                   processing_duration):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._eval_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fee_amount);
  __Pyx_XDECREF(__pyx_v_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_exec_duration);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1961
 *         return fee_amount, fee_currency, fee_exec_duration
 * 
 *     def _cum_sum_heap(self, currency, action_func_type, long time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_81_cum_sum_heap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_80_cum_sum_heap[] = "\n        Only used for unit testing. Thin wrapper for underlying C++ implementation.\n\n        Cumulative sum of all transactions in the defined currency, which are located on the internal heap, up to the\n        defined time_step. Internal heap consists entries which are defined by execution time, transaction, etc., see\n        docstring of property exec_heap for further details.\n        :param currency: str\n        :param action_func_type: str\n        :param time_step: int\n        :return: float\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_81_cum_sum_heap = {"_cum_sum_heap", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_81_cum_sum_heap, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_80_cum_sum_heap};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_81_cum_sum_heap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_currency = 0;
  PyObject *__pyx_v_action_func_type = 0;
  long __pyx_v_time_step;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_cum_sum_heap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_currency,&__pyx_n_s_action_func_type,&__pyx_n_s_time_step,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cum_sum_heap", 1, 4, 4, 1); __PYX_ERR(0, 1961, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_action_func_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cum_sum_heap", 1, 4, 4, 2); __PYX_ERR(0, 1961, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_time_step)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cum_sum_heap", 1, 4, 4, 3); __PYX_ERR(0, 1961, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_cum_sum_heap") < 0)) __PYX_ERR(0, 1961, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_self = values[0];
    __pyx_v_currency = values[1];
    __pyx_v_action_func_type = values[2];
    __pyx_v_time_step = __Pyx_PyInt_As_long(values[3]); if (unlikely((__pyx_v_time_step == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 1961, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_cum_sum_heap", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1961, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._cum_sum_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_80_cum_sum_heap(__pyx_self, __pyx_v_self, __pyx_v_currency, __pyx_v_action_func_type, __pyx_v_time_step);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_80_cum_sum_heap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_currency, PyObject *__pyx_v_action_func_type, long __pyx_v_time_step) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_cum_sum_heap", 0);
  __Pyx_INCREF(__pyx_v_action_func_type);

  /* "trapeza/account/fx_account.pyx":1973
 *         :return: float
 *         """
 *         if action_func_type in ['withdraw', 'deposit']:             # <<<<<<<<<<<<<<
 *             action_func_type = ''.join(['c_', action_func_type])
 *             warnings.warn('Auto-converting "withdraw" and "deposit" to "c_withdraw" and "c_deposit" (to '
 */
  __Pyx_INCREF(__pyx_v_action_func_type);
  __pyx_t_1 = __pyx_v_action_func_type;
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_withdraw, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1973, __pyx_L1_error)
  if (!__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_deposit, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1973, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "trapeza/account/fx_account.pyx":1974
 *         """
 *         if action_func_type in ['withdraw', 'deposit']:
 *             action_func_type = ''.join(['c_', action_func_type])             # <<<<<<<<<<<<<<
 *             warnings.warn('Auto-converting "withdraw" and "deposit" to "c_withdraw" and "c_deposit" (to '
 *                           'match up cython-implemented exec_heap of cFXAccount, which wrapped is by '
 */
    __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1974, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_u_c);
    __Pyx_GIVEREF(__pyx_n_u_c);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_c);
    __Pyx_INCREF(__pyx_v_action_func_type);
    __Pyx_GIVEREF(__pyx_v_action_func_type);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_action_func_type);
    __pyx_t_4 = PyUnicode_Join(__pyx_kp_u__19, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1974, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_action_func_type, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "trapeza/account/fx_account.pyx":1975
 *         if action_func_type in ['withdraw', 'deposit']:
 *             action_func_type = ''.join(['c_', action_func_type])
 *             warnings.warn('Auto-converting "withdraw" and "deposit" to "c_withdraw" and "c_deposit" (to '             # <<<<<<<<<<<<<<
 *                           'match up cython-implemented exec_heap of cFXAccount, which wrapped is by '
 *                           'FXAccount).')
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1975, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1975, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_1, __pyx_kp_u_Auto_converting_withdraw_and_dep) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u_Auto_converting_withdraw_and_dep);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1975, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "trapeza/account/fx_account.pyx":1973
 *         :return: float
 *         """
 *         if action_func_type in ['withdraw', 'deposit']:             # <<<<<<<<<<<<<<
 *             action_func_type = ''.join(['c_', action_func_type])
 *             warnings.warn('Auto-converting "withdraw" and "deposit" to "c_withdraw" and "c_deposit" (to '
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1978
 *                           'match up cython-implemented exec_heap of cFXAccount, which wrapped is by '
 *                           'FXAccount).')
 *         elif action_func_type in ['c_withdraw', 'c_deposit']:             # <<<<<<<<<<<<<<
 *             pass
 *         else:
 */
  __Pyx_INCREF(__pyx_v_action_func_type);
  __pyx_t_4 = __pyx_v_action_func_type;
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_c_withdraw, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1978, __pyx_L1_error)
  if (!__pyx_t_2) {
  } else {
    __pyx_t_3 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_c_deposit, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1978, __pyx_L1_error)
  __pyx_t_3 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (likely(__pyx_t_2)) {
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":1981
 *             pass
 *         else:
 *             raise TypeError('action_func_type must be "c_withdraw", "c_deposit". "withdraw", "deposit" (auto-'             # <<<<<<<<<<<<<<
 *                             'converting to "withdraw" and "deposit" to "c_..."), got {}'.format(action_func_type))
 *         return self.vec_heap.cum_sum_heap(currency.encode(), action_func_type.encode(), time_step, self._c_clock)
 */
  /*else*/ {

    /* "trapeza/account/fx_account.pyx":1982
 *         else:
 *             raise TypeError('action_func_type must be "c_withdraw", "c_deposit". "withdraw", "deposit" (auto-'
 *                             'converting to "withdraw" and "deposit" to "c_..."), got {}'.format(action_func_type))             # <<<<<<<<<<<<<<
 *         return self.vec_heap.cum_sum_heap(currency.encode(), action_func_type.encode(), time_step, self._c_clock)
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_action_func_type_must_be_c_withd, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1982, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_1, __pyx_v_action_func_type) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_action_func_type);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1982, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "trapeza/account/fx_account.pyx":1981
 *             pass
 *         else:
 *             raise TypeError('action_func_type must be "c_withdraw", "c_deposit". "withdraw", "deposit" (auto-'             # <<<<<<<<<<<<<<
 *                             'converting to "withdraw" and "deposit" to "c_..."), got {}'.format(action_func_type))
 *         return self.vec_heap.cum_sum_heap(currency.encode(), action_func_type.encode(), time_step, self._c_clock)
 */
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1981, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 1981, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "trapeza/account/fx_account.pyx":1983
 *             raise TypeError('action_func_type must be "c_withdraw", "c_deposit". "withdraw", "deposit" (auto-'
 *                             'converting to "withdraw" and "deposit" to "c_..."), got {}'.format(action_func_type))
 *         return self.vec_heap.cum_sum_heap(currency.encode(), action_func_type.encode(), time_step, self._c_clock)             # <<<<<<<<<<<<<<
 * 
 *     def _cum_sum_marked_fund(self, currency, long time_step):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vec_heap); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_cum_sum_heap); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_action_func_type, __pyx_n_s_encode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_time_step); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_clock); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_4, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1983, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_4, __pyx_t_6, __pyx_t_7, __pyx_t_8};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1983, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_8);
    __pyx_t_4 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1983, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1961
 *         return fee_amount, fee_currency, fee_exec_duration
 * 
 *     def _cum_sum_heap(self, currency, action_func_type, long time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._cum_sum_heap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_action_func_type);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1985
 *         return self.vec_heap.cum_sum_heap(currency.encode(), action_func_type.encode(), time_step, self._c_clock)
 * 
 *     def _cum_sum_marked_fund(self, currency, long time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_83_cum_sum_marked_fund(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_82_cum_sum_marked_fund[] = "\n        Only used for unit testing. Thin wrapper for underlying C++ implementation.\n\n        Cumulative sum of depositing orders in heap up to time_step in given currency.\n        :param currency: str\n        :param time_step: int\n        :return: float\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_83_cum_sum_marked_fund = {"_cum_sum_marked_fund", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_83_cum_sum_marked_fund, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_82_cum_sum_marked_fund};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_83_cum_sum_marked_fund(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_currency = 0;
  long __pyx_v_time_step;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_cum_sum_marked_fund (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_currency,&__pyx_n_s_time_step,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cum_sum_marked_fund", 1, 3, 3, 1); __PYX_ERR(0, 1985, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_time_step)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cum_sum_marked_fund", 1, 3, 3, 2); __PYX_ERR(0, 1985, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_cum_sum_marked_fund") < 0)) __PYX_ERR(0, 1985, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_currency = values[1];
    __pyx_v_time_step = __Pyx_PyInt_As_long(values[2]); if (unlikely((__pyx_v_time_step == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 1985, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_cum_sum_marked_fund", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1985, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._cum_sum_marked_fund", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_82_cum_sum_marked_fund(__pyx_self, __pyx_v_self, __pyx_v_currency, __pyx_v_time_step);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_82_cum_sum_marked_fund(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_currency, long __pyx_v_time_step) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_cum_sum_marked_fund", 0);

  /* "trapeza/account/fx_account.pyx":1994
 *         :return: float
 *         """
 *         return self.vec_heap.cum_sum_marked_fund(currency.encode(), time_step, self._c_clock)             # <<<<<<<<<<<<<<
 * 
 *     def _cum_sum_marked_debit(self, currency, time_step):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vec_heap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_cum_sum_marked_fund); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_time_step); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_clock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_2, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1994, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_2, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1994, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1994, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1985
 *         return self.vec_heap.cum_sum_heap(currency.encode(), action_func_type.encode(), time_step, self._c_clock)
 * 
 *     def _cum_sum_marked_fund(self, currency, long time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._cum_sum_marked_fund", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":1996
 *         return self.vec_heap.cum_sum_marked_fund(currency.encode(), time_step, self._c_clock)
 * 
 *     def _cum_sum_marked_debit(self, currency, time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_85_cum_sum_marked_debit(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_84_cum_sum_marked_debit[] = "\n        Only used for unit testing. Thin wrapper for underlying C++ implementation.\n\n        Cumulative sum of withdrawal orders in heap up to time_step in given currency.\n        :param currency: str\n        :param time_step: int\n        :return: float\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_85_cum_sum_marked_debit = {"_cum_sum_marked_debit", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_85_cum_sum_marked_debit, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_84_cum_sum_marked_debit};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_85_cum_sum_marked_debit(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_currency = 0;
  PyObject *__pyx_v_time_step = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_cum_sum_marked_debit (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_currency,&__pyx_n_s_time_step,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cum_sum_marked_debit", 1, 3, 3, 1); __PYX_ERR(0, 1996, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_time_step)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cum_sum_marked_debit", 1, 3, 3, 2); __PYX_ERR(0, 1996, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_cum_sum_marked_debit") < 0)) __PYX_ERR(0, 1996, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_currency = values[1];
    __pyx_v_time_step = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_cum_sum_marked_debit", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1996, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._cum_sum_marked_debit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_84_cum_sum_marked_debit(__pyx_self, __pyx_v_self, __pyx_v_currency, __pyx_v_time_step);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_84_cum_sum_marked_debit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_currency, PyObject *__pyx_v_time_step) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_cum_sum_marked_debit", 0);

  /* "trapeza/account/fx_account.pyx":2005
 *         :return: float
 *         """
 *         return self.vec_heap.cum_sum_marked_debit(currency.encode(), time_step, self._c_clock)             # <<<<<<<<<<<<<<
 * 
 *     def _fill_fee(self, action_type, alt_fee, volume, price, base, quote, processing_duration,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_vec_heap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_cum_sum_marked_debit); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_clock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_2, __pyx_v_time_step, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2005, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_2, __pyx_v_time_step, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2005, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2005, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_time_step);
    __Pyx_GIVEREF(__pyx_v_time_step);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_time_step);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2005, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":1996
 *         return self.vec_heap.cum_sum_marked_fund(currency.encode(), time_step, self._c_clock)
 * 
 *     def _cum_sum_marked_debit(self, currency, time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._cum_sum_marked_debit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2007
 *         return self.vec_heap.cum_sum_marked_debit(currency.encode(), time_step, self._c_clock)
 * 
 *     def _fill_fee(self, action_type, alt_fee, volume, price, base, quote, processing_duration,             # <<<<<<<<<<<<<<
 *                   forward_coverage='except'):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_87_fill_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_86_fill_fee[] = "\n        Only used for unit testing.\n\n        Handles fee internally (parsing of arguments and evaluation of fee amount, currency and processing duration)\n        and calls self.withdraw(), which takes processing_duration, etc. into account to process fees.\n        :param action_type: {'buy', 'sell', 'deposit', 'withdraw'},\n                            ignored if alt_fee != None\n        :param alt_fee: alternative fee, {func, False, None, float}\n        :param volume: float\n        :param base: str\n        :param price: float\n        :param quote: str\n        :param processing_duration: int\n        :param forward_coverage: str,\n                                 propagates coverage from method, from which\n                                 self._fill_fee() was called, to self.withdraw()\n        :return: fee_volume: float\n                 fee_currency: str\n                 fee_exec_duration: int\n        :raises: NotImplementedError if alt_fee is not in {func, False, None, float}\n                 ValueError if volume < 0\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_87_fill_fee = {"_fill_fee", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_87_fill_fee, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_86_fill_fee};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_87_fill_fee(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_action_type = 0;
  PyObject *__pyx_v_alt_fee = 0;
  PyObject *__pyx_v_volume = 0;
  PyObject *__pyx_v_price = 0;
  PyObject *__pyx_v_base = 0;
  PyObject *__pyx_v_quote = 0;
  PyObject *__pyx_v_processing_duration = 0;
  PyObject *__pyx_v_forward_coverage = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_fill_fee (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_action_type,&__pyx_n_s_alt_fee,&__pyx_n_s_volume,&__pyx_n_s_price,&__pyx_n_s_base,&__pyx_n_s_quote,&__pyx_n_s_processing_duration,&__pyx_n_s_forward_coverage,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
    values[8] = ((PyObject *)((PyObject*)__pyx_n_u_except));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_action_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_fill_fee", 0, 8, 9, 1); __PYX_ERR(0, 2007, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alt_fee)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_fill_fee", 0, 8, 9, 2); __PYX_ERR(0, 2007, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_fill_fee", 0, 8, 9, 3); __PYX_ERR(0, 2007, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_price)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_fill_fee", 0, 8, 9, 4); __PYX_ERR(0, 2007, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_fill_fee", 0, 8, 9, 5); __PYX_ERR(0, 2007, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quote)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_fill_fee", 0, 8, 9, 6); __PYX_ERR(0, 2007, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_fill_fee", 0, 8, 9, 7); __PYX_ERR(0, 2007, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_forward_coverage);
          if (value) { values[8] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_fill_fee") < 0)) __PYX_ERR(0, 2007, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_action_type = values[1];
    __pyx_v_alt_fee = values[2];
    __pyx_v_volume = values[3];
    __pyx_v_price = values[4];
    __pyx_v_base = values[5];
    __pyx_v_quote = values[6];
    __pyx_v_processing_duration = values[7];
    __pyx_v_forward_coverage = values[8];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_fill_fee", 0, 8, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2007, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._fill_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_86_fill_fee(__pyx_self, __pyx_v_self, __pyx_v_action_type, __pyx_v_alt_fee, __pyx_v_volume, __pyx_v_price, __pyx_v_base, __pyx_v_quote, __pyx_v_processing_duration, __pyx_v_forward_coverage);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_86_fill_fee(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_action_type, PyObject *__pyx_v_alt_fee, PyObject *__pyx_v_volume, PyObject *__pyx_v_price, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_forward_coverage) {
  PyObject *__pyx_v_fee_volume = NULL;
  PyObject *__pyx_v_fee_currency = NULL;
  PyObject *__pyx_v_fee_exec_duration = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_fill_fee", 0);

  /* "trapeza/account/fx_account.pyx":2033
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type=action_type, alt_fee=alt_fee, volume=volume, current_rate=price,             # <<<<<<<<<<<<<<
 *                                              base=base, quote=quote, processing_duration=processing_duration)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_eval_fee); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_action_type, __pyx_v_action_type) < 0) __PYX_ERR(0, 2033, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_alt_fee, __pyx_v_alt_fee) < 0) __PYX_ERR(0, 2033, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_volume, __pyx_v_volume) < 0) __PYX_ERR(0, 2033, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_current_rate, __pyx_v_price) < 0) __PYX_ERR(0, 2033, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2034
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type=action_type, alt_fee=alt_fee, volume=volume, current_rate=price,
 *                                              base=base, quote=quote, processing_duration=processing_duration)             # <<<<<<<<<<<<<<
 * 
 *         # noinspection PyUnboundLocalVariable
 */
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_base, __pyx_v_base) < 0) __PYX_ERR(0, 2033, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_quote, __pyx_v_quote) < 0) __PYX_ERR(0, 2033, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_processing_duration, __pyx_v_processing_duration) < 0) __PYX_ERR(0, 2033, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2033
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type=action_type, alt_fee=alt_fee, volume=volume, current_rate=price,             # <<<<<<<<<<<<<<
 *                                              base=base, quote=quote, processing_duration=processing_duration)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2031, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 2031, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2031, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2031
 *                  ValueError if volume < 0
 *         """
 *         (fee_volume,             # <<<<<<<<<<<<<<
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type=action_type, alt_fee=alt_fee, volume=volume, current_rate=price,
 */
  __pyx_v_fee_volume = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_fee_currency = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_fee_exec_duration = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "trapeza/account/fx_account.pyx":2037
 * 
 *         # noinspection PyUnboundLocalVariable
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # noinspection PyUnboundLocalVariable
 *             self.withdraw(volume=fee_volume, currency=fee_currency, processing_duration=fee_exec_duration,
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_fee_volume, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2037, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2037, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_7) {

    /* "trapeza/account/fx_account.pyx":2039
 *         if fee_volume > 0:
 *             # noinspection PyUnboundLocalVariable
 *             self.withdraw(volume=fee_volume, currency=fee_currency, processing_duration=fee_exec_duration,             # <<<<<<<<<<<<<<
 *                           coverage=forward_coverage)
 *         return fee_volume, fee_currency, fee_exec_duration
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_withdraw); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_volume, __pyx_v_fee_volume) < 0) __PYX_ERR(0, 2039, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_currency, __pyx_v_fee_currency) < 0) __PYX_ERR(0, 2039, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_processing_duration, __pyx_v_fee_exec_duration) < 0) __PYX_ERR(0, 2039, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2040
 *             # noinspection PyUnboundLocalVariable
 *             self.withdraw(volume=fee_volume, currency=fee_currency, processing_duration=fee_exec_duration,
 *                           coverage=forward_coverage)             # <<<<<<<<<<<<<<
 *         return fee_volume, fee_currency, fee_exec_duration
 * 
 */
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_coverage, __pyx_v_forward_coverage) < 0) __PYX_ERR(0, 2039, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2039
 *         if fee_volume > 0:
 *             # noinspection PyUnboundLocalVariable
 *             self.withdraw(volume=fee_volume, currency=fee_currency, processing_duration=fee_exec_duration,             # <<<<<<<<<<<<<<
 *                           coverage=forward_coverage)
 *         return fee_volume, fee_currency, fee_exec_duration
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "trapeza/account/fx_account.pyx":2037
 * 
 *         # noinspection PyUnboundLocalVariable
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             # noinspection PyUnboundLocalVariable
 *             self.withdraw(volume=fee_volume, currency=fee_currency, processing_duration=fee_exec_duration,
 */
  }

  /* "trapeza/account/fx_account.pyx":2041
 *             self.withdraw(volume=fee_volume, currency=fee_currency, processing_duration=fee_exec_duration,
 *                           coverage=forward_coverage)
 *         return fee_volume, fee_currency, fee_exec_duration             # <<<<<<<<<<<<<<
 * 
 *     def withdraw(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_fee_volume);
  __Pyx_GIVEREF(__pyx_v_fee_volume);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fee_volume);
  __Pyx_INCREF(__pyx_v_fee_currency);
  __Pyx_GIVEREF(__pyx_v_fee_currency);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_fee_currency);
  __Pyx_INCREF(__pyx_v_fee_exec_duration);
  __Pyx_GIVEREF(__pyx_v_fee_exec_duration);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_fee_exec_duration);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":2007
 *         return self.vec_heap.cum_sum_marked_debit(currency.encode(), time_step, self._c_clock)
 * 
 *     def _fill_fee(self, action_type, alt_fee, volume, price, base, quote, processing_duration,             # <<<<<<<<<<<<<<
 *                   forward_coverage='except'):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount._fill_fee", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fee_volume);
  __Pyx_XDECREF(__pyx_v_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_exec_duration);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2043
 *         return fee_volume, fee_currency, fee_exec_duration
 * 
 *     def withdraw(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                  float_fee_currency=None):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_89withdraw(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_88withdraw[] = "\n        Withdraws volume given in currency from account.\n        Furthermore, processing duration (e.g. transmission time of messages in real-life systems, broker execution,\n        etc.) can be modelled.\n        Fees can be defined either as function or float. If fee is float, then a separate currency in which to bill fees\n        can be defined. Additionally, if fees are float, fees can be withdrawn immediately even though withdrawal of\n        transaction volume might take some processing duration. This is controlled via instant_float_fee (bool).\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param volume: float, >= 0\n                       volume given in currency\n        :param currency: str\n        :param processing_duration: int or None, default=None\n                                    processing time (delay) in time base units of internal clock until transaction takes\n                                    effect on account's depot\n                                    time of execution/ billing = self.clock + processing_duration\n                                    None is equivalent to 0 in behavior\n        :param fee: {func, False, None, float}, default=None\n                               fee setting for withdrawal\n\n                               None: self._fee['withdraw'] is applied which is set at __init__. Default at __init__ is\n                                     not applying any fees. See docstring of self.__init__ and docstring of class for\n                                     further information about globally applied fees and how to set\n                                     self._fee['withdraw']\n                               False: no fees at all applied, even if self._fee['withdraw'] is set (overrides globally\n                                      set fees: self._fee['withdraw'] will be temporarily ignored for this one\n                                      transaction)\n                     ""          func: alternative function to self._fee is applied (self._fee['withdraw'] will be\n                                     ignored for this one transaction and func will be applied instead)\n                                     Must follow call signature:\n                                         fee_volume, fee_currency, fee_exec_time\n                                              = fee(volume, price, base, quote, processing_duration)\n                                              = fee(volume, 1, currency, currency, processing_duration)\n                                     base input is pre-set to/ called with hardcoded param:currency\n                                     price input is pre-set to/ called with hardcoded 1\n                                     quote input is pre-set to/ called with hardcoded param:currency\n                               float: constant fee is applied and billed in param:float_fee_currency\n                                      if instant_float_fee = False: fee is billed at the same time as set by\n                                                                    param:processing_duration (same time step when\n                                                                    transaction takes effect on account's depot)\n                                      if instant_float_fee = True: fee is billed instantly independent from\n                                                                   param:processing_duration of transaction\n        :param coverage: {'partial', 'except', 'debit'}, default='except'\n                                   Controls exception behavior in case of coverage violation.\n                                   This coverage analysis checks whether transaction is conductible in principal (e.g.\n                                   if currently account's depot position is sufficient right now) but does not check\n                                   against marked but not yet billed transactions.\n""\n                                   'partial': partial fulfilment as far as possible (including fees).\n                                              Withdrawal volume will be reduced s.t. that coverage conditions are met.\n                                              This means, if withdrawal volume + fees is greater than current depot\n                                              position, then withdrawal volume will be reduced, such that no debiting\n                                              in account's depot positions occurs. If volume and fees are not in the\n                                              same currency, this reduction is only performed on the volume (fees might\n                                              still cause a coverage violation), amount of fees stays untouched then.\n                                              volume is reduced to meet initially calculated fees, fees are not\n                                              adapted to reduced volume (guessing interdependency would be hard), s.t.\n                                              more fees might be payed than according to reduced volume.\n                                              This does not guarantee transaction fulfillment, as this just checks\n                                              current depot but does not check against marked but not yet billed\n                                              (delayed) transactions, which is done independently of this coverage check\n                                   'except': raises trapeza.exception.CoverageError if coverage is violated, which is\n                                             the case if withdrawal (including fees) is\n                                             greater than current depot position (in same currency as volume)\n                                   'debit': temporarily deactivates coverage check of current depot position as well as\n                                            covera""ge check of marked but not yet booked transactions.\n                                            If prohibit_debiting is set to False at __init__(), then negative (debt)\n                                            positions are possible, else a trapeza.exception.CoverageError will be\n                                            thrown at time of execution.\n\n                                    Coverage checking of current depot position is done independently of\n                                    self.check_marked_coverage, which additionally checks against marked but not yet\n                                    filled future transactions (e.g. if self.check_marked_coverage is set to\n                                    'min_backward' or 'max_forward).\n                                    'debit' deactivates coverage check regarding future marked, not yet filled\n                                    transactions as well as coverage check of current depot positions for this one\n                                    transaction (see above).\n        :param instant_float_fee: bool, default=False\n                                  ONLY APPLIES if fee = float, else ignored\n                                  if True, fees are withdrawn instantly independent of processing_duration. This does\n                                    not affect processing duration of withdrawing param:volume.\n                                  if False, fees are billed at the same time as withdrawing param:volume given by the\n                                    processing duration.\n        :param float_fee_currency: {str, None}, default=None\n                                   currency type to bill fee if fee=float, else ignored\n                                   if None or ignored, float_fee_currency is set to param:currency\n        :return: int\n                 confirmation states --> 0: processing (processing_duration greater 0), 1: executed/ billed\n        :raises: TypeError: if param""eters do not match specified types\n                 NotImplementedError: if coverage not in {'partial', 'except', 'debit'} or fee not\n                                      in {None, False, func, float}\n                 trapeza.exception.CoverageError: if coverage not sufficient (transaction or fee) depending on\n                                                  coverage and if checking of marked transaction is\n                                                  switched on\n                 trapeza.exception.PositionNAError: if currency (str) or float_fee_currency (str) is not\n                                                    in self.depot.keys()\n                 ValueError: if volume < 0\n        :TODO: when coverage='partial', than recalculate fees according to reducing volume to meet coverage\n        :TODO:  volume-depot + f(volume-x) -x = 0 --> min\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_89withdraw = {"withdraw", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_89withdraw, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_88withdraw};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_89withdraw(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_volume = 0;
  PyObject *__pyx_v_currency = 0;
  PyObject *__pyx_v_fee = 0;
  PyObject *__pyx_v_processing_duration = 0;
  PyObject *__pyx_v_coverage = 0;
  PyObject *__pyx_v_instant_float_fee = 0;
  PyObject *__pyx_v_float_fee_currency = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("withdraw (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_volume,&__pyx_n_s_currency,&__pyx_n_s_fee_2,&__pyx_n_s_processing_duration,&__pyx_n_s_coverage,&__pyx_n_s_instant_float_fee,&__pyx_n_s_float_fee_currency,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    values[3] = ((PyObject *)((PyObject *)Py_None));
    values[4] = ((PyObject *)((PyObject *)Py_None));
    values[5] = ((PyObject *)((PyObject*)__pyx_n_u_except));
    values[6] = ((PyObject *)((PyObject *)Py_False));

    /* "trapeza/account/fx_account.pyx":2044
 * 
 *     def withdraw(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,
 *                  float_fee_currency=None):             # <<<<<<<<<<<<<<
 *         """
 *         Withdraws volume given in currency from account.
 */
    values[7] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("withdraw", 0, 3, 8, 1); __PYX_ERR(0, 2043, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("withdraw", 0, 3, 8, 2); __PYX_ERR(0, 2043, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_2);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coverage);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_float_fee);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_float_fee_currency);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "withdraw") < 0)) __PYX_ERR(0, 2043, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_volume = values[1];
    __pyx_v_currency = values[2];
    __pyx_v_fee = values[3];
    __pyx_v_processing_duration = values[4];
    __pyx_v_coverage = values[5];
    __pyx_v_instant_float_fee = values[6];
    __pyx_v_float_fee_currency = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("withdraw", 0, 3, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2043, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.withdraw", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_88withdraw(__pyx_self, __pyx_v_self, __pyx_v_volume, __pyx_v_currency, __pyx_v_fee, __pyx_v_processing_duration, __pyx_v_coverage, __pyx_v_instant_float_fee, __pyx_v_float_fee_currency);

  /* "trapeza/account/fx_account.pyx":2043
 *         return fee_volume, fee_currency, fee_exec_duration
 * 
 *     def withdraw(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                  float_fee_currency=None):
 *         """
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_88withdraw(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_volume, PyObject *__pyx_v_currency, PyObject *__pyx_v_fee, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_coverage, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_float_fee_currency) {
  PyObject *__pyx_v_parsed_fee_currency = NULL;
  PyObject *__pyx_v_fee_volume = NULL;
  PyObject *__pyx_v_fee_currency = NULL;
  PyObject *__pyx_v_fee_exec_duration = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("withdraw", 0);
  __Pyx_INCREF(__pyx_v_processing_duration);
  __Pyx_INCREF(__pyx_v_instant_float_fee);

  /* "trapeza/account/fx_account.pyx":2149
 *         (parsed_fee_currency,
 *          instant_float_fee,
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, currency,             # <<<<<<<<<<<<<<
 *                                                                        fee, 'withdrawal_fee',
 *                                                                        instant_float_fee, processing_duration)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_fee_and_transaction_param); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "trapeza/account/fx_account.pyx":2151
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, currency,
 *                                                                        fee, 'withdrawal_fee',
 *                                                                        instant_float_fee, processing_duration)             # <<<<<<<<<<<<<<
 * 
 *         # >>>sanity and type checking
 */
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_3, __pyx_v_float_fee_currency, __pyx_v_currency, __pyx_v_fee, __pyx_n_u_withdrawal_fee, __pyx_v_instant_float_fee, __pyx_v_processing_duration};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2149, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_3, __pyx_v_float_fee_currency, __pyx_v_currency, __pyx_v_fee, __pyx_n_u_withdrawal_fee, __pyx_v_instant_float_fee, __pyx_v_processing_duration};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2149, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(6+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2149, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_float_fee_currency);
    __Pyx_GIVEREF(__pyx_v_float_fee_currency);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_float_fee_currency);
    __Pyx_INCREF(__pyx_v_currency);
    __Pyx_GIVEREF(__pyx_v_currency);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_currency);
    __Pyx_INCREF(__pyx_v_fee);
    __Pyx_GIVEREF(__pyx_v_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_fee);
    __Pyx_INCREF(__pyx_n_u_withdrawal_fee);
    __Pyx_GIVEREF(__pyx_n_u_withdrawal_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_n_u_withdrawal_fee);
    __Pyx_INCREF(__pyx_v_instant_float_fee);
    __Pyx_GIVEREF(__pyx_v_instant_float_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_v_instant_float_fee);
    __Pyx_INCREF(__pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_v_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_processing_duration);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2149, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2147, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 2; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) __PYX_ERR(0, 2147, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2147, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2147
 *         """
 *         # >>>parsing inputs
 *         (parsed_fee_currency,             # <<<<<<<<<<<<<<
 *          instant_float_fee,
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, currency,
 */
  __pyx_v_parsed_fee_currency = __pyx_t_2;
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_instant_float_fee, __pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_processing_duration, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "trapeza/account/fx_account.pyx":2154
 * 
 *         # >>>sanity and type checking
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('volume must be grater than 0.')
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_volume, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2154, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2154, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_t_8)) {

    /* "trapeza/account/fx_account.pyx":2155
 *         # >>>sanity and type checking
 *         if volume < 0:
 *             raise ValueError('volume must be grater than 0.')             # <<<<<<<<<<<<<<
 * 
 *         check_types([volume, currency, processing_duration, parsed_fee_currency, instant_float_fee, coverage],
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 2155, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2154
 * 
 *         # >>>sanity and type checking
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('volume must be grater than 0.')
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2157
 *             raise ValueError('volume must be grater than 0.')
 * 
 *         check_types([volume, currency, processing_duration, parsed_fee_currency, instant_float_fee, coverage],             # <<<<<<<<<<<<<<
 *                     [float, str, int, str, bool, str],
 *                     ['volume', 'currency', 'processing_duration', 'float_fee_currency', 'instant_float_fee',
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_check_types); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyList_New(6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_volume);
  __Pyx_GIVEREF(__pyx_v_volume);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_volume);
  __Pyx_INCREF(__pyx_v_currency);
  __Pyx_GIVEREF(__pyx_v_currency);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_v_currency);
  __Pyx_INCREF(__pyx_v_processing_duration);
  __Pyx_GIVEREF(__pyx_v_processing_duration);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_v_processing_duration);
  __Pyx_INCREF(__pyx_v_parsed_fee_currency);
  __Pyx_GIVEREF(__pyx_v_parsed_fee_currency);
  PyList_SET_ITEM(__pyx_t_5, 3, __pyx_v_parsed_fee_currency);
  __Pyx_INCREF(__pyx_v_instant_float_fee);
  __Pyx_GIVEREF(__pyx_v_instant_float_fee);
  PyList_SET_ITEM(__pyx_t_5, 4, __pyx_v_instant_float_fee);
  __Pyx_INCREF(__pyx_v_coverage);
  __Pyx_GIVEREF(__pyx_v_coverage);
  PyList_SET_ITEM(__pyx_t_5, 5, __pyx_v_coverage);

  /* "trapeza/account/fx_account.pyx":2158
 * 
 *         check_types([volume, currency, processing_duration, parsed_fee_currency, instant_float_fee, coverage],
 *                     [float, str, int, str, bool, str],             # <<<<<<<<<<<<<<
 *                     ['volume', 'currency', 'processing_duration', 'float_fee_currency', 'instant_float_fee',
 *                      'coverage'], self._c_ignore_type_checking)
 */
  __pyx_t_2 = PyList_New(6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PyInt_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 3, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_2, 4, ((PyObject*)&PyBool_Type));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 5, ((PyObject *)(&PyUnicode_Type)));

  /* "trapeza/account/fx_account.pyx":2159
 *         check_types([volume, currency, processing_duration, parsed_fee_currency, instant_float_fee, coverage],
 *                     [float, str, int, str, bool, str],
 *                     ['volume', 'currency', 'processing_duration', 'float_fee_currency', 'instant_float_fee',             # <<<<<<<<<<<<<<
 *                      'coverage'], self._c_ignore_type_checking)
 *         self._c_isin_depot(currency.encode())
 */
  __pyx_t_6 = PyList_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_n_u_volume);
  __Pyx_GIVEREF(__pyx_n_u_volume);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_volume);
  __Pyx_INCREF(__pyx_n_u_currency);
  __Pyx_GIVEREF(__pyx_n_u_currency);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_n_u_currency);
  __Pyx_INCREF(__pyx_n_u_processing_duration);
  __Pyx_GIVEREF(__pyx_n_u_processing_duration);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_n_u_processing_duration);
  __Pyx_INCREF(__pyx_n_u_float_fee_currency);
  __Pyx_GIVEREF(__pyx_n_u_float_fee_currency);
  PyList_SET_ITEM(__pyx_t_6, 3, __pyx_n_u_float_fee_currency);
  __Pyx_INCREF(__pyx_n_u_instant_float_fee);
  __Pyx_GIVEREF(__pyx_n_u_instant_float_fee);
  PyList_SET_ITEM(__pyx_t_6, 4, __pyx_n_u_instant_float_fee);
  __Pyx_INCREF(__pyx_n_u_coverage);
  __Pyx_GIVEREF(__pyx_n_u_coverage);
  PyList_SET_ITEM(__pyx_t_6, 5, __pyx_n_u_coverage);

  /* "trapeza/account/fx_account.pyx":2160
 *                     [float, str, int, str, bool, str],
 *                     ['volume', 'currency', 'processing_duration', 'float_fee_currency', 'instant_float_fee',
 *                      'coverage'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         self._c_isin_depot(currency.encode())
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_5, __pyx_t_2, __pyx_t_6, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2157, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_5, __pyx_t_2, __pyx_t_6, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2157, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_4, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_4, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_4, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_4, __pyx_t_9);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_9 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":2161
 *                     ['volume', 'currency', 'processing_duration', 'float_fee_currency', 'instant_float_fee',
 *                      'coverage'], self._c_ignore_type_checking)
 *         self._c_isin_depot(currency.encode())             # <<<<<<<<<<<<<<
 * 
 *         # >>>evaluate fees
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_isin_depot); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  __pyx_t_11 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_9, __pyx_t_11) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":2166
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=fee, volume=volume,             # <<<<<<<<<<<<<<
 *                                              current_rate=1, base=parsed_fee_currency, quote=currency,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_eval_fee); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_action_type, __pyx_n_u_withdraw) < 0) __PYX_ERR(0, 2166, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_alt_fee, __pyx_v_fee) < 0) __PYX_ERR(0, 2166, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_volume, __pyx_v_volume) < 0) __PYX_ERR(0, 2166, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_current_rate, __pyx_int_1) < 0) __PYX_ERR(0, 2166, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2167
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=fee, volume=volume,
 *                                              current_rate=1, base=parsed_fee_currency, quote=currency,             # <<<<<<<<<<<<<<
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 * 
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_base, __pyx_v_parsed_fee_currency) < 0) __PYX_ERR(0, 2166, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_quote, __pyx_v_currency) < 0) __PYX_ERR(0, 2166, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2168
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=fee, volume=volume,
 *                                              current_rate=1, base=parsed_fee_currency, quote=currency,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))             # <<<<<<<<<<<<<<
 * 
 *         # >>>handle coverage exception
 */
  __pyx_t_11 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_instant_float_fee, 1, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = PyNumber_Multiply(__pyx_v_processing_duration, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_processing_duration, __pyx_t_9) < 0) __PYX_ERR(0, 2166, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "trapeza/account/fx_account.pyx":2166
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=fee, volume=volume,             # <<<<<<<<<<<<<<
 *                                              current_rate=1, base=parsed_fee_currency, quote=currency,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 */
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
    PyObject* sequence = __pyx_t_9;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2164, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_6 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2164, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_1 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_1)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 2; __pyx_t_11 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_11)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_11);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) __PYX_ERR(0, 2164, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L7_unpacking_done;
    __pyx_L6_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2164, __pyx_L1_error)
    __pyx_L7_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2164
 * 
 *         # >>>evaluate fees
 *         (fee_volume,             # <<<<<<<<<<<<<<
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=fee, volume=volume,
 */
  __pyx_v_fee_volume = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_fee_currency = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_fee_exec_duration = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "trapeza/account/fx_account.pyx":2171
 * 
 *         # >>>handle coverage exception
 *         if coverage not in ['except', 'partial', 'debit']:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')
 * 
 */
  __Pyx_INCREF(__pyx_v_coverage);
  __pyx_t_9 = __pyx_v_coverage;
  __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_t_9, __pyx_n_u_except, Py_NE)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 2171, __pyx_L1_error)
  if (__pyx_t_12) {
  } else {
    __pyx_t_8 = __pyx_t_12;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_t_9, __pyx_n_u_partial, Py_NE)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 2171, __pyx_L1_error)
  if (__pyx_t_12) {
  } else {
    __pyx_t_8 = __pyx_t_12;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_t_9, __pyx_n_u_debit, Py_NE)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 2171, __pyx_L1_error)
  __pyx_t_8 = __pyx_t_12;
  __pyx_L9_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_12 = (__pyx_t_8 != 0);
  if (unlikely(__pyx_t_12)) {

    /* "trapeza/account/fx_account.pyx":2172
 *         # >>>handle coverage exception
 *         if coverage not in ['except', 'partial', 'debit']:
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')             # <<<<<<<<<<<<<<
 * 
 *         return self.c_withdraw(volume, currency.encode(), processing_duration, fee_volume, fee_currency.encode(),
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2172, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2171
 * 
 *         # >>>handle coverage exception
 *         if coverage not in ['except', 'partial', 'debit']:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2174
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')
 * 
 *         return self.c_withdraw(volume, currency.encode(), processing_duration, fee_volume, fee_currency.encode(),             # <<<<<<<<<<<<<<
 *                                fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_withdraw); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_fee_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":2175
 * 
 *         return self.c_withdraw(volume, currency.encode(), processing_duration, fee_volume, fee_currency.encode(),
 *                                fee_exec_duration, coverage.encode(), instant_float_fee)             # <<<<<<<<<<<<<<
 * 
 *     def deposit(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_coverage, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_6 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_11)) {
    PyObject *__pyx_temp[9] = {__pyx_t_2, __pyx_v_volume, __pyx_t_1, __pyx_v_processing_duration, __pyx_v_fee_volume, __pyx_t_3, __pyx_v_fee_exec_duration, __pyx_t_6, __pyx_v_instant_float_fee};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_4, 8+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2174, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
    PyObject *__pyx_temp[9] = {__pyx_t_2, __pyx_v_volume, __pyx_t_1, __pyx_v_processing_duration, __pyx_v_fee_volume, __pyx_t_3, __pyx_v_fee_exec_duration, __pyx_t_6, __pyx_v_instant_float_fee};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_4, 8+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2174, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(8+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2174, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_volume);
    __Pyx_GIVEREF(__pyx_v_volume);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_volume);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_v_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_processing_duration);
    __Pyx_INCREF(__pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_v_fee_volume);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_fee_exec_duration);
    __Pyx_GIVEREF(__pyx_v_fee_exec_duration);
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_fee_exec_duration);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 6+__pyx_t_4, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_instant_float_fee);
    __Pyx_GIVEREF(__pyx_v_instant_float_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 7+__pyx_t_4, __pyx_v_instant_float_fee);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_6 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2174, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":2043
 *         return fee_volume, fee_currency, fee_exec_duration
 * 
 *     def withdraw(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                  float_fee_currency=None):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.withdraw", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parsed_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_volume);
  __Pyx_XDECREF(__pyx_v_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_exec_duration);
  __Pyx_XDECREF(__pyx_v_processing_duration);
  __Pyx_XDECREF(__pyx_v_instant_float_fee);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2177
 *                                fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def deposit(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                 float_fee_currency=None):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_91deposit(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_90deposit[] = "\n        Deposits volume given in currency onto account.\n        Furthermore, processing duration (e.g. transmission time of messages in real-life systems, broker execution,\n        etc.) can be modelled.\n        Fees can be defined either as function or float. If fee is float, then a separate currency in which to bill fees\n        can be defined. Additionally, if fees are float, fees can be withdrawn immediately even though depositing of\n        transaction volume might take some processing duration. This is controlled via instant_float_fee (bool).\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param volume: float, >= 0\n                       volume given in currency\n        :param currency: str\n        :param processing_duration: int or None, default=None\n                                    processing time (delay) in time base units of internal clock until transaction takes\n                                    effect on account's depot\n                                    time of execution/ billing = self.clock + processing_duration\n                                    None is equivalent to 0 in behavior\n        :param fee: {func, False, None, float}, default=None\n                            fee setting for depositing\n\n                            None: self._fee['deposit'] is applied which is set at __init__. Default at __init__ is\n                                  not applying any fees. See docstring of self.__init__ and docstring of class for\n                                  further information about globally applied fees and how to set self._fee['deposit']\n                            False: no fees at all applied, even if self._fee['deposit'] is set (overrides globally\n                                   set fees: self._fee['deposit'] will be temporarily ignored for this one\n                                   transaction)\n                            func: alternative function to self._fee is applied (self.""_fee['deposit'] will be ignored\n                                  for this one transaction and func will be applied instead)\n                                  Must follow call signature:\n                                      fee_volume, fee_currency, fee_exec_time\n                                           = fee(volume, price, base, quote, processing_duration)\n                                           = fee(volume, 1, currency, currency, processing_duration)\n                                  base input is pre-set to/ called with hardcoded param:currency\n                                  price input is pre-set to/ called with hardcoded 1\n                                  quote input is pre-set to/ called with hardcoded param:currency\n                            float: constant fee is applied and billed in param:float_fee_currency\n                                   if instant_float_fee = False: fee is billed at the same time as set by\n                                                                 param:processing_duration (same time step when\n                                                                 transaction takes effect on account's depot)\n                                   if instant_float_fee = True: fee is billed instantly independent from\n                                                                param:processing_duration of transaction\n        :param coverage: {'except', 'debit'}, default='except'\n                                   Controls exception behavior in case of coverage violation.\n                                   This coverage analysis checks whether transaction is conductible in principal (e.g.\n                                   if currently account's depot position is sufficient right now) but does not check\n                                   against marked but not yet billed transactions.\n\n                                   'except': raises trapeza.exception.CoverageError if coverage is violated, which is\n   ""                                          the case if fee is greater than current depot position (in same currency\n                                             as fee)\n                                   'debit': temporarily deactivates coverage check of current depot position as well as\n                                            coverage check of marked but not yet booked transactions. If\n                                            prohibit_debiting is set to False at __init__(), then negative (debt)\n                                            positions are possible, else a trapeza.exception.CoverageError will be\n                                            thrown at time of execution.\n\n                                   Coverage checking of current depot position is done independently of\n                                   self.check_marked_coverage, which additionally checks against marked but not yet\n                                   filled future transactions (e.g. if self.check_marked_coverage is set to\n                                   'min_backward' or 'max_forward).\n                                   'debit' deactivates coverage check regarding future marked, not yet filled\n                                   transactions as well as coverage check of current depot positions (see above).\n\n                                   'partial' makes no sense in this context. See comments in source code of\n                                   cFXAccount.c_deposit for further information.\n        :param instant_float_fee: bool, default=False\n                                  ONLY APPLIES if fee = float, else ignored\n                                  if True, fees are withdrawn instantly independent of processing_duration. This does\n                                    not affect processing duration of withdrawing param:volume.\n                                  if False, fees are billed at the same time as withdrawing param:volume given by the\n          ""                          processing duration.\n        :param float_fee_currency: {str, None}, default=None\n                                   currency type to bill fee if fee=float, else ignored\n                                   if None or ignored, float_fee_currency is set to param:currency\n        :return: int\n                 confirmation states --> 0: processing (processing_duration greater 0), 1: executed/ billed\n        :raises: TypeError if parameters do not match specified types\n                 NotImplementedError: if coverage not in {'partial', 'except', 'debit'} or fee not\n                                      in {None, False, func, float}\n                 trapeza.exception.CoverageError: if coverage not sufficient (transaction or fee) depending on\n                                                  coverage and if checking of marked transaction is\n                                                  switched on\n                 trapeza.exception.PositionNAError: if currency (str) or float_fee_currency (str) is not\n                                                    in self.depot.keys()\n                 ValueError: if volume < 0\n        :TODO: when coverage='partial', than recalculate fees according to reducing volume to meet coverage\n        :TODO:  volume-depot + f(volume-x) -x = 0 --> min\n        :TODO: optimize performance of underlying cython implementation\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_91deposit = {"deposit", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_91deposit, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_90deposit};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_91deposit(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_volume = 0;
  PyObject *__pyx_v_currency = 0;
  PyObject *__pyx_v_fee = 0;
  PyObject *__pyx_v_processing_duration = 0;
  PyObject *__pyx_v_coverage = 0;
  PyObject *__pyx_v_instant_float_fee = 0;
  PyObject *__pyx_v_float_fee_currency = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("deposit (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_volume,&__pyx_n_s_currency,&__pyx_n_s_fee_2,&__pyx_n_s_processing_duration,&__pyx_n_s_coverage,&__pyx_n_s_instant_float_fee,&__pyx_n_s_float_fee_currency,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    values[3] = ((PyObject *)((PyObject *)Py_None));
    values[4] = ((PyObject *)((PyObject *)Py_None));
    values[5] = ((PyObject *)((PyObject*)__pyx_n_u_except));
    values[6] = ((PyObject *)((PyObject *)Py_False));

    /* "trapeza/account/fx_account.pyx":2178
 * 
 *     def deposit(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,
 *                 float_fee_currency=None):             # <<<<<<<<<<<<<<
 *         """
 *         Deposits volume given in currency onto account.
 */
    values[7] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("deposit", 0, 3, 8, 1); __PYX_ERR(0, 2177, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("deposit", 0, 3, 8, 2); __PYX_ERR(0, 2177, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_2);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coverage);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_float_fee);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_float_fee_currency);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "deposit") < 0)) __PYX_ERR(0, 2177, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_volume = values[1];
    __pyx_v_currency = values[2];
    __pyx_v_fee = values[3];
    __pyx_v_processing_duration = values[4];
    __pyx_v_coverage = values[5];
    __pyx_v_instant_float_fee = values[6];
    __pyx_v_float_fee_currency = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("deposit", 0, 3, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2177, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.deposit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_90deposit(__pyx_self, __pyx_v_self, __pyx_v_volume, __pyx_v_currency, __pyx_v_fee, __pyx_v_processing_duration, __pyx_v_coverage, __pyx_v_instant_float_fee, __pyx_v_float_fee_currency);

  /* "trapeza/account/fx_account.pyx":2177
 *                                fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def deposit(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                 float_fee_currency=None):
 *         """
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_90deposit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_volume, PyObject *__pyx_v_currency, PyObject *__pyx_v_fee, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_coverage, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_float_fee_currency) {
  PyObject *__pyx_v_parsed_fee_currency = NULL;
  PyObject *__pyx_v_fee_volume = NULL;
  PyObject *__pyx_v_fee_currency = NULL;
  PyObject *__pyx_v_fee_exec_duration = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("deposit", 0);
  __Pyx_INCREF(__pyx_v_processing_duration);
  __Pyx_INCREF(__pyx_v_instant_float_fee);

  /* "trapeza/account/fx_account.pyx":2272
 *         (parsed_fee_currency,
 *          instant_float_fee,
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, currency,             # <<<<<<<<<<<<<<
 *                                                                        fee, 'deposit_fee', instant_float_fee,
 *                                                                        processing_duration)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_fee_and_transaction_param); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "trapeza/account/fx_account.pyx":2274
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, currency,
 *                                                                        fee, 'deposit_fee', instant_float_fee,
 *                                                                        processing_duration)             # <<<<<<<<<<<<<<
 * 
 *         # >>>sanity and type checking
 */
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_3, __pyx_v_float_fee_currency, __pyx_v_currency, __pyx_v_fee, __pyx_n_u_deposit_fee, __pyx_v_instant_float_fee, __pyx_v_processing_duration};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2272, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_3, __pyx_v_float_fee_currency, __pyx_v_currency, __pyx_v_fee, __pyx_n_u_deposit_fee, __pyx_v_instant_float_fee, __pyx_v_processing_duration};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2272, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(6+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_float_fee_currency);
    __Pyx_GIVEREF(__pyx_v_float_fee_currency);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_float_fee_currency);
    __Pyx_INCREF(__pyx_v_currency);
    __Pyx_GIVEREF(__pyx_v_currency);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_currency);
    __Pyx_INCREF(__pyx_v_fee);
    __Pyx_GIVEREF(__pyx_v_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_fee);
    __Pyx_INCREF(__pyx_n_u_deposit_fee);
    __Pyx_GIVEREF(__pyx_n_u_deposit_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_n_u_deposit_fee);
    __Pyx_INCREF(__pyx_v_instant_float_fee);
    __Pyx_GIVEREF(__pyx_v_instant_float_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_v_instant_float_fee);
    __Pyx_INCREF(__pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_v_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_processing_duration);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2270, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 2; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) __PYX_ERR(0, 2270, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2270, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2270
 *         """
 *         # >>>parsing inputs
 *         (parsed_fee_currency,             # <<<<<<<<<<<<<<
 *          instant_float_fee,
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, currency,
 */
  __pyx_v_parsed_fee_currency = __pyx_t_2;
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_instant_float_fee, __pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_processing_duration, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "trapeza/account/fx_account.pyx":2277
 * 
 *         # >>>sanity and type checking
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('volume must be grater than 0.')
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_volume, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2277, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 2277, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_t_8)) {

    /* "trapeza/account/fx_account.pyx":2278
 *         # >>>sanity and type checking
 *         if volume < 0:
 *             raise ValueError('volume must be grater than 0.')             # <<<<<<<<<<<<<<
 * 
 *         check_types([volume, currency, processing_duration, parsed_fee_currency, instant_float_fee, coverage],
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 2278, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2277
 * 
 *         # >>>sanity and type checking
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('volume must be grater than 0.')
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2280
 *             raise ValueError('volume must be grater than 0.')
 * 
 *         check_types([volume, currency, processing_duration, parsed_fee_currency, instant_float_fee, coverage],             # <<<<<<<<<<<<<<
 *                     [float, str, int, str, bool, str],
 *                     ['volume', 'currency', 'processing_duration', 'float_fee_currency', 'instant_float_fee',
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_check_types); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyList_New(6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_volume);
  __Pyx_GIVEREF(__pyx_v_volume);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_volume);
  __Pyx_INCREF(__pyx_v_currency);
  __Pyx_GIVEREF(__pyx_v_currency);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_v_currency);
  __Pyx_INCREF(__pyx_v_processing_duration);
  __Pyx_GIVEREF(__pyx_v_processing_duration);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_v_processing_duration);
  __Pyx_INCREF(__pyx_v_parsed_fee_currency);
  __Pyx_GIVEREF(__pyx_v_parsed_fee_currency);
  PyList_SET_ITEM(__pyx_t_5, 3, __pyx_v_parsed_fee_currency);
  __Pyx_INCREF(__pyx_v_instant_float_fee);
  __Pyx_GIVEREF(__pyx_v_instant_float_fee);
  PyList_SET_ITEM(__pyx_t_5, 4, __pyx_v_instant_float_fee);
  __Pyx_INCREF(__pyx_v_coverage);
  __Pyx_GIVEREF(__pyx_v_coverage);
  PyList_SET_ITEM(__pyx_t_5, 5, __pyx_v_coverage);

  /* "trapeza/account/fx_account.pyx":2281
 * 
 *         check_types([volume, currency, processing_duration, parsed_fee_currency, instant_float_fee, coverage],
 *                     [float, str, int, str, bool, str],             # <<<<<<<<<<<<<<
 *                     ['volume', 'currency', 'processing_duration', 'float_fee_currency', 'instant_float_fee',
 *                      'coverage'], self._c_ignore_type_checking)
 */
  __pyx_t_2 = PyList_New(6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PyInt_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 3, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_2, 4, ((PyObject*)&PyBool_Type));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 5, ((PyObject *)(&PyUnicode_Type)));

  /* "trapeza/account/fx_account.pyx":2282
 *         check_types([volume, currency, processing_duration, parsed_fee_currency, instant_float_fee, coverage],
 *                     [float, str, int, str, bool, str],
 *                     ['volume', 'currency', 'processing_duration', 'float_fee_currency', 'instant_float_fee',             # <<<<<<<<<<<<<<
 *                      'coverage'], self._c_ignore_type_checking)
 * 
 */
  __pyx_t_6 = PyList_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_n_u_volume);
  __Pyx_GIVEREF(__pyx_n_u_volume);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_volume);
  __Pyx_INCREF(__pyx_n_u_currency);
  __Pyx_GIVEREF(__pyx_n_u_currency);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_n_u_currency);
  __Pyx_INCREF(__pyx_n_u_processing_duration);
  __Pyx_GIVEREF(__pyx_n_u_processing_duration);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_n_u_processing_duration);
  __Pyx_INCREF(__pyx_n_u_float_fee_currency);
  __Pyx_GIVEREF(__pyx_n_u_float_fee_currency);
  PyList_SET_ITEM(__pyx_t_6, 3, __pyx_n_u_float_fee_currency);
  __Pyx_INCREF(__pyx_n_u_instant_float_fee);
  __Pyx_GIVEREF(__pyx_n_u_instant_float_fee);
  PyList_SET_ITEM(__pyx_t_6, 4, __pyx_n_u_instant_float_fee);
  __Pyx_INCREF(__pyx_n_u_coverage);
  __Pyx_GIVEREF(__pyx_n_u_coverage);
  PyList_SET_ITEM(__pyx_t_6, 5, __pyx_n_u_coverage);

  /* "trapeza/account/fx_account.pyx":2283
 *                     [float, str, int, str, bool, str],
 *                     ['volume', 'currency', 'processing_duration', 'float_fee_currency', 'instant_float_fee',
 *                      'coverage'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *         # >>>evaluate fees
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_5, __pyx_t_2, __pyx_t_6, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2280, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_5, __pyx_t_2, __pyx_t_6, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2280, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2280, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_4, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_4, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_4, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_4, __pyx_t_9);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_9 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2280, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":2288
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=fee, volume=volume, current_rate=1,             # <<<<<<<<<<<<<<
 *                                              base=parsed_fee_currency, quote=currency,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_eval_fee); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_action_type, __pyx_n_u_deposit) < 0) __PYX_ERR(0, 2288, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_alt_fee, __pyx_v_fee) < 0) __PYX_ERR(0, 2288, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_volume, __pyx_v_volume) < 0) __PYX_ERR(0, 2288, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_current_rate, __pyx_int_1) < 0) __PYX_ERR(0, 2288, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2289
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=fee, volume=volume, current_rate=1,
 *                                              base=parsed_fee_currency, quote=currency,             # <<<<<<<<<<<<<<
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 * 
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_base, __pyx_v_parsed_fee_currency) < 0) __PYX_ERR(0, 2288, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_quote, __pyx_v_currency) < 0) __PYX_ERR(0, 2288, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2290
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=fee, volume=volume, current_rate=1,
 *                                              base=parsed_fee_currency, quote=currency,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))             # <<<<<<<<<<<<<<
 * 
 *         # >>>handle coverage exception induced by fees
 */
  __pyx_t_11 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_instant_float_fee, 1, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = PyNumber_Multiply(__pyx_v_processing_duration, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_processing_duration, __pyx_t_9) < 0) __PYX_ERR(0, 2288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "trapeza/account/fx_account.pyx":2288
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=fee, volume=volume, current_rate=1,             # <<<<<<<<<<<<<<
 *                                              base=parsed_fee_currency, quote=currency,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 */
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
    PyObject* sequence = __pyx_t_9;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2286, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_6 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_1 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_1)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 2; __pyx_t_11 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_11)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_11);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) __PYX_ERR(0, 2286, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L7_unpacking_done;
    __pyx_L6_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2286, __pyx_L1_error)
    __pyx_L7_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2286
 * 
 *         # >>>evaluate fees
 *         (fee_volume,             # <<<<<<<<<<<<<<
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=fee, volume=volume, current_rate=1,
 */
  __pyx_v_fee_volume = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_fee_currency = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_fee_exec_duration = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "trapeza/account/fx_account.pyx":2293
 * 
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'debit']:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('coverage must be {"except", "debit"}.')
 * 
 */
  __Pyx_INCREF(__pyx_v_coverage);
  __pyx_t_9 = __pyx_v_coverage;
  __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_t_9, __pyx_n_u_except, Py_NE)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 2293, __pyx_L1_error)
  if (__pyx_t_12) {
  } else {
    __pyx_t_8 = __pyx_t_12;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_t_9, __pyx_n_u_debit, Py_NE)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 2293, __pyx_L1_error)
  __pyx_t_8 = __pyx_t_12;
  __pyx_L9_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_12 = (__pyx_t_8 != 0);
  if (unlikely(__pyx_t_12)) {

    /* "trapeza/account/fx_account.pyx":2294
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'debit']:
 *             raise NotImplementedError('coverage must be {"except", "debit"}.')             # <<<<<<<<<<<<<<
 * 
 *         return self.c_deposit(volume, currency.encode(), processing_duration, fee_volume, fee_currency.encode(),
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2294, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2293
 * 
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'debit']:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('coverage must be {"except", "debit"}.')
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2296
 *             raise NotImplementedError('coverage must be {"except", "debit"}.')
 * 
 *         return self.c_deposit(volume, currency.encode(), processing_duration, fee_volume, fee_currency.encode(),             # <<<<<<<<<<<<<<
 *                               fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_deposit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_fee_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":2297
 * 
 *         return self.c_deposit(volume, currency.encode(), processing_duration, fee_volume, fee_currency.encode(),
 *                               fee_exec_duration, coverage.encode(), instant_float_fee)             # <<<<<<<<<<<<<<
 * 
 *     def collect(self, payer_account, double volume, str currency, payee_fee=False, payer_fee=False,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_coverage, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_6 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_11)) {
    PyObject *__pyx_temp[9] = {__pyx_t_2, __pyx_v_volume, __pyx_t_1, __pyx_v_processing_duration, __pyx_v_fee_volume, __pyx_t_3, __pyx_v_fee_exec_duration, __pyx_t_6, __pyx_v_instant_float_fee};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_4, 8+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2296, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
    PyObject *__pyx_temp[9] = {__pyx_t_2, __pyx_v_volume, __pyx_t_1, __pyx_v_processing_duration, __pyx_v_fee_volume, __pyx_t_3, __pyx_v_fee_exec_duration, __pyx_t_6, __pyx_v_instant_float_fee};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_4, 8+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2296, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(8+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_volume);
    __Pyx_GIVEREF(__pyx_v_volume);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_volume);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_v_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_processing_duration);
    __Pyx_INCREF(__pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_v_fee_volume);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_fee_exec_duration);
    __Pyx_GIVEREF(__pyx_v_fee_exec_duration);
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_fee_exec_duration);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 6+__pyx_t_4, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_instant_float_fee);
    __Pyx_GIVEREF(__pyx_v_instant_float_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 7+__pyx_t_4, __pyx_v_instant_float_fee);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_6 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":2177
 *                                fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def deposit(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                 float_fee_currency=None):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.deposit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parsed_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_volume);
  __Pyx_XDECREF(__pyx_v_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_exec_duration);
  __Pyx_XDECREF(__pyx_v_processing_duration);
  __Pyx_XDECREF(__pyx_v_instant_float_fee);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2299
 *                               fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def collect(self, payer_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                 payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_93collect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_92collect[] = "\n        Collects payment volume in given currency from payer account to this:account.\n        Furthermore, processing duration (e.g. transmission time of messages in real-life systems, broker execution,\n        etc.) can be modelled.\n        Fees can be defined either as function or float for payer and payee. If payee_fee=None and payer_fee=None, then\n        the standard and globally set fees of self._fee['deposit'] and self._fee['withdraw'] (which are set at __init__)\n        will be applied. If None (default), no fees will be applied\n\n        If payer_fee or payer_processing_duration shall be applied, then payer class must implement\n        payer_account.withdraw(volume, currency, payer_fee, payer_processing_duration)\n\n        Coverage analysis is conducted with default arguments of withdraw() and deposit()\n        (e.g. coverage='except', instant_float_fee=False)\n\n        !!! If execution is not instant (e.g. processing_duration is not None), both accounts have to call .tick() to\n            make transaction take effect on both accounts. It is not sufficient to just only .tick() one account !!!\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param payer_account: class trapeza.account.base_account.BaseAccount (or derived class) object\n        :param volume: float, >= 0\n                       volume of currency\n        :param currency: str\n        :param payee_fee: {None, False, func, float}, default=False\n                          fee setting for payee account\n\n                          None: self._fee['deposit'] is applied which is set at __init__. Default at __init__ is\n                                not applying any fees. See docstring of self.__init__ and docstring of class for\n                                further information about globally applied fees and how to set self._fee['deposit'].\n                                Call signature will be parsed to:\n                                    fee(""volume, 1, currency, currency, processing_duration)\n                          False: no fees at all applied, even if self._fee['deposit'] is set (overrides globally\n                                 set fees: self._fee['deposit'] will be temporarily ignored for this one transaction)\n                          func: alternative function to calculate fees is applied with signature (self._fee['deposit']\n                                will be ignored for this one transaction and func will be applied instead)\n                                fee_volume, fee_currency, fee_exec_time\n                                     = fee(volume, price, base, quote, processing_duration)\n                                     = fee(volume, 1, currency, currency, processing_duration)\n                                price is set/ hard coded to 1 (induced by withdraw()/ deposit())\n                                base and quote are set/ hard coded to param:currency (induced by withdraw()/ deposit())\n                          float: constant fee is applied and billed in param:currency at the same time as the collect\n                                 transaction takes effect (e.g. when payee_processing_duration is not 0)\n        :param payer_fee: dependent on payer class implementation of payer_account.withdraw()\n                          default=False\n\n                          (!) if not {None, False, 0}:\n                            payer_account.withdraw(volume, currency, payer_fee, payer_processing_duration) is called\n                            to withdraw transaction volume and fees\n        :param payee_processing_duration: int or None, default=None\n                                          processing time (delay) in time base units of internal clock until transaction\n                                          takes effect on account's depot\n                                          time of execution/ billing = self.clock + processing_duration\n                            ""              None is equivalent to 0 in behavior\n        :param payer_processing_duration: int or None, default=None\n                                          processing time (delay) in time base units of internal clock until transaction\n                                          takes effect on account's depot\n                                          time of execution/ billing = self.clock + processing_duration\n                                          None is equivalent to 0 in behavior\n\n                                         (!) if not {None, 0}:\n                                            payer_account.withdraw(volume, currency, payer_fee,\n                                                                   payer_processing_duration)\n                                            is called (make sure, this method is implemented at payer_account)\n                                         else:\n                                            payer_account.withdraw(volume, currency) is called\n        :return: confirmation states --> 0: processing (processing_duration), 1: executed/ billed\n        :raises: TypeError: if volume, currency, processing_duration not of specified type\n                 trapeza.exception.CoverageError: if coverage not sufficient (transaction or fee).\n                                                  Coverage analysis is set to 'except' (see docstring of self.deposit()\n                                                  or self.withdraw()).\n                                                  Coverage is only checked at payee account.\n                 NotImplementedError: if payee_fee not in {None, False, func, float}\n                 trapeza.exception.PositionNAError: if currency (str) or fee_currency (str) from payee_fee is not\n                                                    in self.depot.keys()\n                 trapeza.exception.AccountError: if payer_account is not derived\n                                                 f""rom trapeza.account.base_account.BaseAccount\n                 ValueError: if volume < 0\n                 if exception raised, then no transactions have been billed (no change in heap or depot,\n                 nothing happened)\n                 additional exceptions may be risen by payer_account\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_93collect = {"collect", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_93collect, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_92collect};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_93collect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_payer_account = 0;
  double __pyx_v_volume;
  PyObject *__pyx_v_currency = 0;
  PyObject *__pyx_v_payee_fee = 0;
  PyObject *__pyx_v_payer_fee = 0;
  PyObject *__pyx_v_payee_processing_duration = 0;
  PyObject *__pyx_v_payer_processing_duration = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("collect (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_payer_account,&__pyx_n_s_volume,&__pyx_n_s_currency,&__pyx_n_s_payee_fee,&__pyx_n_s_payer_fee,&__pyx_n_s_payee_processing_duration,&__pyx_n_s_payer_processing_duration,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    values[4] = ((PyObject *)((PyObject *)Py_False));
    values[5] = ((PyObject *)((PyObject *)Py_False));

    /* "trapeza/account/fx_account.pyx":2300
 * 
 *     def collect(self, payer_account, double volume, str currency, payee_fee=False, payer_fee=False,
 *                 payee_processing_duration=None, payer_processing_duration=None):             # <<<<<<<<<<<<<<
 *         """
 *         Collects payment volume in given currency from payer account to this:account.
 */
    values[6] = ((PyObject *)((PyObject *)Py_None));
    values[7] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payer_account)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("collect", 0, 4, 8, 1); __PYX_ERR(0, 2299, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("collect", 0, 4, 8, 2); __PYX_ERR(0, 2299, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("collect", 0, 4, 8, 3); __PYX_ERR(0, 2299, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payee_fee);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payer_fee);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payee_processing_duration);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payer_processing_duration);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "collect") < 0)) __PYX_ERR(0, 2299, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_payer_account = values[1];
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2299, __pyx_L3_error)
    __pyx_v_currency = ((PyObject*)values[3]);
    __pyx_v_payee_fee = values[4];
    __pyx_v_payer_fee = values[5];
    __pyx_v_payee_processing_duration = values[6];
    __pyx_v_payer_processing_duration = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("collect", 0, 4, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2299, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyUnicode_Type), 1, "currency", 1))) __PYX_ERR(0, 2299, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_92collect(__pyx_self, __pyx_v_self, __pyx_v_payer_account, __pyx_v_volume, __pyx_v_currency, __pyx_v_payee_fee, __pyx_v_payer_fee, __pyx_v_payee_processing_duration, __pyx_v_payer_processing_duration);

  /* "trapeza/account/fx_account.pyx":2299
 *                               fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def collect(self, payer_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                 payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_92collect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_payer_account, double __pyx_v_volume, PyObject *__pyx_v_currency, PyObject *__pyx_v_payee_fee, PyObject *__pyx_v_payer_fee, PyObject *__pyx_v_payee_processing_duration, PyObject *__pyx_v_payer_processing_duration) {
  PyObject *__pyx_v_fee_volume = NULL;
  PyObject *__pyx_v_fee_currency = NULL;
  PyObject *__pyx_v_fee_exec_duration = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  int __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("collect", 0);
  __Pyx_INCREF(__pyx_v_payee_processing_duration);
  __Pyx_INCREF(__pyx_v_payer_processing_duration);

  /* "trapeza/account/fx_account.pyx":2383
 *         """
 *         # >>>sanity check
 *         try:             # <<<<<<<<<<<<<<
 *             if not issubclass(payer_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payer_account)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":2384
 *         # >>>sanity check
 *         try:
 *             if not issubclass(payer_account.__class__, BaseAccount):             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.AccountError(payer_account)
 *         except TypeError:
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_payer_account, __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2384, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_BaseAccount); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2384, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_IsSubclass(__pyx_t_4, __pyx_t_5); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 2384, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0);
      if (unlikely(__pyx_t_7)) {

        /* "trapeza/account/fx_account.pyx":2385
 *         try:
 *             if not issubclass(payer_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payer_account)             # <<<<<<<<<<<<<<
 *         except TypeError:
 *             raise tpz_exception.AccountError(payer_account)
 */
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2385, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2385, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_4, __pyx_v_payer_account) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_payer_account);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2385, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(0, 2385, __pyx_L3_error)

        /* "trapeza/account/fx_account.pyx":2384
 *         # >>>sanity check
 *         try:
 *             if not issubclass(payer_account.__class__, BaseAccount):             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.AccountError(payer_account)
 *         except TypeError:
 */
      }

      /* "trapeza/account/fx_account.pyx":2383
 *         """
 *         # >>>sanity check
 *         try:             # <<<<<<<<<<<<<<
 *             if not issubclass(payer_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payer_account)
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "trapeza/account/fx_account.pyx":2386
 *             if not issubclass(payer_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payer_account)
 *         except TypeError:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.AccountError(payer_account)
 *         except tpz_exception.AccountError:
 */
    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
    if (__pyx_t_9) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 2386, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_4);

      /* "trapeza/account/fx_account.pyx":2387
 *                 raise tpz_exception.AccountError(payer_account)
 *         except TypeError:
 *             raise tpz_exception.AccountError(payer_account)             # <<<<<<<<<<<<<<
 *         except tpz_exception.AccountError:
 *             raise tpz_exception.AccountError(payer_account)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2387, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2387, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      __pyx_t_10 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_11, __pyx_v_payer_account) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_payer_account);
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2387, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 2387, __pyx_L5_except_error)
    }

    /* "trapeza/account/fx_account.pyx":2388
 *         except TypeError:
 *             raise tpz_exception.AccountError(payer_account)
 *         except tpz_exception.AccountError:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.AccountError(payer_account)
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_8, &__pyx_t_5);
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2388, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2388, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_9 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_12);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_ErrRestore(__pyx_t_4, __pyx_t_8, __pyx_t_5);
    __pyx_t_4 = 0; __pyx_t_8 = 0; __pyx_t_5 = 0;
    if (__pyx_t_9) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 2388, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_4);

      /* "trapeza/account/fx_account.pyx":2389
 *             raise tpz_exception.AccountError(payer_account)
 *         except tpz_exception.AccountError:
 *             raise tpz_exception.AccountError(payer_account)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2389, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2389, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_12 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_10, __pyx_v_payer_account) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_payer_account);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2389, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_12, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __PYX_ERR(0, 2389, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "trapeza/account/fx_account.pyx":2383
 *         """
 *         # >>>sanity check
 *         try:             # <<<<<<<<<<<<<<
 *             if not issubclass(payer_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payer_account)
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":2391
 *             raise tpz_exception.AccountError(payer_account)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if payer_account == self:
 *                 raise tpz_exception.AccountError(payer_account)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_1);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":2392
 * 
 *         try:
 *             if payer_account == self:             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.AccountError(payer_account)
 *         except TypeError:
 */
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_payer_account, __pyx_v_self, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2392, __pyx_L14_error)
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2392, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__pyx_t_7)) {

        /* "trapeza/account/fx_account.pyx":2393
 *         try:
 *             if payer_account == self:
 *                 raise tpz_exception.AccountError(payer_account)             # <<<<<<<<<<<<<<
 *         except TypeError:
 *             raise tpz_exception.AccountError(payer_account)
 */
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2393, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2393, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_8, __pyx_v_payer_account) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_payer_account);
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2393, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 2393, __pyx_L14_error)

        /* "trapeza/account/fx_account.pyx":2392
 * 
 *         try:
 *             if payer_account == self:             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.AccountError(payer_account)
 *         except TypeError:
 */
      }

      /* "trapeza/account/fx_account.pyx":2391
 *             raise tpz_exception.AccountError(payer_account)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if payer_account == self:
 *                 raise tpz_exception.AccountError(payer_account)
 */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L19_try_end;
    __pyx_L14_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "trapeza/account/fx_account.pyx":2394
 *             if payer_account == self:
 *                 raise tpz_exception.AccountError(payer_account)
 *         except TypeError:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.AccountError(payer_account)
 *         except tpz_exception.AccountError:
 */
    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
    if (__pyx_t_9) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_8) < 0) __PYX_ERR(0, 2394, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_8);

      /* "trapeza/account/fx_account.pyx":2395
 *                 raise tpz_exception.AccountError(payer_account)
 *         except TypeError:
 *             raise tpz_exception.AccountError(payer_account)             # <<<<<<<<<<<<<<
 *         except tpz_exception.AccountError:
 *             raise tpz_exception.AccountError(payer_account)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2395, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2395, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      __pyx_t_12 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_11, __pyx_v_payer_account) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_payer_account);
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2395, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_12, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __PYX_ERR(0, 2395, __pyx_L16_except_error)
    }

    /* "trapeza/account/fx_account.pyx":2396
 *         except TypeError:
 *             raise tpz_exception.AccountError(payer_account)
 *         except tpz_exception.AccountError:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.AccountError(payer_account)
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_5, &__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2396, __pyx_L16_except_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2396, __pyx_L16_except_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_9 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_8, __pyx_t_10);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_ErrRestore(__pyx_t_8, __pyx_t_5, __pyx_t_4);
    __pyx_t_8 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0;
    if (__pyx_t_9) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_8) < 0) __PYX_ERR(0, 2396, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_8);

      /* "trapeza/account/fx_account.pyx":2397
 *             raise tpz_exception.AccountError(payer_account)
 *         except tpz_exception.AccountError:
 *             raise tpz_exception.AccountError(payer_account)             # <<<<<<<<<<<<<<
 * 
 *         # >>>parsing
 */
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2397, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2397, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_10 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_v_payer_account) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_payer_account);
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2397, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 2397, __pyx_L16_except_error)
    }
    goto __pyx_L16_except_error;
    __pyx_L16_except_error:;

    /* "trapeza/account/fx_account.pyx":2391
 *             raise tpz_exception.AccountError(payer_account)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if payer_account == self:
 *                 raise tpz_exception.AccountError(payer_account)
 */
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
    goto __pyx_L1_error;
    __pyx_L19_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":2400
 * 
 *         # >>>parsing
 *         if payer_processing_duration is None:             # <<<<<<<<<<<<<<
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:
 */
  __pyx_t_7 = (__pyx_v_payer_processing_duration == Py_None);
  __pyx_t_6 = (__pyx_t_7 != 0);
  if (__pyx_t_6) {

    /* "trapeza/account/fx_account.pyx":2401
 *         # >>>parsing
 *         if payer_processing_duration is None:
 *             payer_processing_duration = 0             # <<<<<<<<<<<<<<
 *         if payee_processing_duration is None:
 *             payee_processing_duration = 0
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_DECREF_SET(__pyx_v_payer_processing_duration, __pyx_int_0);

    /* "trapeza/account/fx_account.pyx":2400
 * 
 *         # >>>parsing
 *         if payer_processing_duration is None:             # <<<<<<<<<<<<<<
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:
 */
  }

  /* "trapeza/account/fx_account.pyx":2402
 *         if payer_processing_duration is None:
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:             # <<<<<<<<<<<<<<
 *             payee_processing_duration = 0
 * 
 */
  __pyx_t_6 = (__pyx_v_payee_processing_duration == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "trapeza/account/fx_account.pyx":2403
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:
 *             payee_processing_duration = 0             # <<<<<<<<<<<<<<
 * 
 *         # >>>type checking
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_DECREF_SET(__pyx_v_payee_processing_duration, __pyx_int_0);

    /* "trapeza/account/fx_account.pyx":2402
 *         if payer_processing_duration is None:
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:             # <<<<<<<<<<<<<<
 *             payee_processing_duration = 0
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2406
 * 
 *         # >>>type checking
 *         check_types([volume, currency, payer_processing_duration, payee_processing_duration],             # <<<<<<<<<<<<<<
 *                     [float, str, int, int],
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_check_types); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = PyList_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_4);
  PyList_SET_ITEM(__pyx_t_10, 0, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_currency);
  __Pyx_GIVEREF(__pyx_v_currency);
  PyList_SET_ITEM(__pyx_t_10, 1, __pyx_v_currency);
  __Pyx_INCREF(__pyx_v_payer_processing_duration);
  __Pyx_GIVEREF(__pyx_v_payer_processing_duration);
  PyList_SET_ITEM(__pyx_t_10, 2, __pyx_v_payer_processing_duration);
  __Pyx_INCREF(__pyx_v_payee_processing_duration);
  __Pyx_GIVEREF(__pyx_v_payee_processing_duration);
  PyList_SET_ITEM(__pyx_t_10, 3, __pyx_v_payee_processing_duration);
  __pyx_t_4 = 0;

  /* "trapeza/account/fx_account.pyx":2407
 *         # >>>type checking
 *         check_types([volume, currency, payer_processing_duration, payee_processing_duration],
 *                     [float, str, int, int],             # <<<<<<<<<<<<<<
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],
 *                     self._c_ignore_type_checking)
 */
  __pyx_t_4 = PyList_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_4, 1, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_4, 2, ((PyObject *)(&PyInt_Type)));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_4, 3, ((PyObject *)(&PyInt_Type)));

  /* "trapeza/account/fx_account.pyx":2408
 *         check_types([volume, currency, payer_processing_duration, payee_processing_duration],
 *                     [float, str, int, int],
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],             # <<<<<<<<<<<<<<
 *                     self._c_ignore_type_checking)
 *         self._check_alt_fee(payee_fee, 'payer_fee')  # only check payee fee structure, payer fee structure unknown
 */
  __pyx_t_11 = PyList_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_n_u_volume);
  __Pyx_GIVEREF(__pyx_n_u_volume);
  PyList_SET_ITEM(__pyx_t_11, 0, __pyx_n_u_volume);
  __Pyx_INCREF(__pyx_n_u_currency);
  __Pyx_GIVEREF(__pyx_n_u_currency);
  PyList_SET_ITEM(__pyx_t_11, 1, __pyx_n_u_currency);
  __Pyx_INCREF(__pyx_n_u_payer_processing_duration);
  __Pyx_GIVEREF(__pyx_n_u_payer_processing_duration);
  PyList_SET_ITEM(__pyx_t_11, 2, __pyx_n_u_payer_processing_duration);
  __Pyx_INCREF(__pyx_n_u_payee_processing_duration);
  __Pyx_GIVEREF(__pyx_n_u_payee_processing_duration);
  PyList_SET_ITEM(__pyx_t_11, 3, __pyx_n_u_payee_processing_duration);

  /* "trapeza/account/fx_account.pyx":2409
 *                     [float, str, int, int],
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],
 *                     self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         self._check_alt_fee(payee_fee, 'payer_fee')  # only check payee fee structure, payer fee structure unknown
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[5] = {__pyx_t_13, __pyx_t_10, __pyx_t_4, __pyx_t_11, __pyx_t_12};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2406, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[5] = {__pyx_t_13, __pyx_t_10, __pyx_t_4, __pyx_t_11, __pyx_t_12};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2406, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_9, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_9, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_9, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_9, __pyx_t_12);
    __pyx_t_10 = 0;
    __pyx_t_4 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":2410
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],
 *                     self._c_ignore_type_checking)
 *         self._check_alt_fee(payee_fee, 'payer_fee')  # only check payee fee structure, payer fee structure unknown             # <<<<<<<<<<<<<<
 * 
 *         if volume < 0:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_check_alt_fee); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_14 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_payee_fee, __pyx_n_u_payer_fee};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_payee_fee, __pyx_n_u_payer_fee};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_14) {
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_14); __pyx_t_14 = NULL;
    }
    __Pyx_INCREF(__pyx_v_payee_fee);
    __Pyx_GIVEREF(__pyx_v_payee_fee);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_9, __pyx_v_payee_fee);
    __Pyx_INCREF(__pyx_n_u_payer_fee);
    __Pyx_GIVEREF(__pyx_n_u_payer_fee);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_9, __pyx_n_u_payer_fee);
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":2412
 *         self._check_alt_fee(payee_fee, 'payer_fee')  # only check payee fee structure, payer fee structure unknown
 * 
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError
 * 
 */
  __pyx_t_7 = ((__pyx_v_volume < 0.0) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "trapeza/account/fx_account.pyx":2413
 * 
 *         if volume < 0:
 *             raise ValueError             # <<<<<<<<<<<<<<
 * 
 *         # >>>check coverage deposit, which is only checking if fees are covered as we do not withdraw anything
 */
    __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
    __PYX_ERR(0, 2413, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2412
 *         self._check_alt_fee(payee_fee, 'payer_fee')  # only check payee fee structure, payer fee structure unknown
 * 
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2419
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=payee_fee, volume=volume, current_rate=1,             # <<<<<<<<<<<<<<
 *                                              base=currency, quote=currency,
 *                                              processing_duration=payee_processing_duration)
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_eval_fee); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_action_type, __pyx_n_u_deposit) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_alt_fee, __pyx_v_payee_fee) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_volume, __pyx_t_12) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_current_rate, __pyx_int_1) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2420
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=payee_fee, volume=volume, current_rate=1,
 *                                              base=currency, quote=currency,             # <<<<<<<<<<<<<<
 *                                              processing_duration=payee_processing_duration)
 * 
 */
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_base, __pyx_v_currency) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_quote, __pyx_v_currency) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2421
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=payee_fee, volume=volume, current_rate=1,
 *                                              base=currency, quote=currency,
 *                                              processing_duration=payee_processing_duration)             # <<<<<<<<<<<<<<
 * 
 *         if fee_volume > 0:
 */
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_processing_duration, __pyx_v_payee_processing_duration) < 0) __PYX_ERR(0, 2419, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2419
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=payee_fee, volume=volume, current_rate=1,             # <<<<<<<<<<<<<<
 *                                              base=currency, quote=currency,
 *                                              processing_duration=payee_processing_duration)
 */
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
    PyObject* sequence = __pyx_t_12;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2417, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_14 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_14 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_14);
    #else
    __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_14 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    #endif
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_15 = Py_TYPE(__pyx_t_11)->tp_iternext;
    index = 0; __pyx_t_5 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_5)) goto __pyx_L28_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 1; __pyx_t_8 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L28_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_8);
    index = 2; __pyx_t_14 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_14)) goto __pyx_L28_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_14);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_11), 3) < 0) __PYX_ERR(0, 2417, __pyx_L1_error)
    __pyx_t_15 = NULL;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    goto __pyx_L29_unpacking_done;
    __pyx_L28_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_15 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2417, __pyx_L1_error)
    __pyx_L29_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2417
 *         # >>>check coverage deposit, which is only checking if fees are covered as we do not withdraw anything
 *         # only check payee
 *         (fee_volume,             # <<<<<<<<<<<<<<
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='deposit', alt_fee=payee_fee, volume=volume, current_rate=1,
 */
  __pyx_v_fee_volume = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_fee_currency = __pyx_t_8;
  __pyx_t_8 = 0;
  __pyx_v_fee_exec_duration = __pyx_t_14;
  __pyx_t_14 = 0;

  /* "trapeza/account/fx_account.pyx":2423
 *                                              processing_duration=payee_processing_duration)
 * 
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self._c_check_coverage(fee_volume, fee_currency.encode(), self._c_clock + fee_exec_duration)
 * 
 */
  __pyx_t_12 = PyObject_RichCompare(__pyx_v_fee_volume, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2423, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2423, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_7) {

    /* "trapeza/account/fx_account.pyx":2424
 * 
 *         if fee_volume > 0:
 *             self._c_check_coverage(fee_volume, fee_currency.encode(), self._c_clock + fee_exec_duration)             # <<<<<<<<<<<<<<
 * 
 *         # >>>withdraw from payer account
 */
    __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_check_coverage); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_fee_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_8 = (__pyx_t_11) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_11) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_clock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_11 = PyNumber_Add(__pyx_t_5, __pyx_v_fee_exec_duration); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_14);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_14, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_fee_volume, __pyx_t_8, __pyx_t_11};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2424, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_fee_volume, __pyx_t_8, __pyx_t_11};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2424, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2424, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_fee_volume);
      __Pyx_GIVEREF(__pyx_v_fee_volume);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_v_fee_volume);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_9, __pyx_t_11);
      __pyx_t_8 = 0;
      __pyx_t_11 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_4, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2424, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "trapeza/account/fx_account.pyx":2423
 *                                              processing_duration=payee_processing_duration)
 * 
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self._c_check_coverage(fee_volume, fee_currency.encode(), self._c_clock + fee_exec_duration)
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2429
 *         # if payer account is not covered, then this line will (hopefully) throw an error, such that the next line
 *         # won't proceed and no false transaction at the own account will be incurred
 *         if payer_processing_duration == 0 and (payer_fee is False or payer_fee is None or payer_fee == 0):             # <<<<<<<<<<<<<<
 *             payer_account.withdraw(volume, currency)
 *         else:
 */
  __pyx_t_12 = __Pyx_PyInt_EqObjC(__pyx_v_payer_processing_duration, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2429, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_6 = (__pyx_v_payer_fee == Py_False);
  __pyx_t_16 = (__pyx_t_6 != 0);
  if (!__pyx_t_16) {
  } else {
    __pyx_t_7 = __pyx_t_16;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_16 = (__pyx_v_payer_fee == Py_None);
  __pyx_t_6 = (__pyx_t_16 != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_12 = __Pyx_PyInt_EqObjC(__pyx_v_payer_fee, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2429, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_7 = __pyx_t_6;
  __pyx_L32_bool_binop_done:;
  if (__pyx_t_7) {

    /* "trapeza/account/fx_account.pyx":2430
 *         # won't proceed and no false transaction at the own account will be incurred
 *         if payer_processing_duration == 0 and (payer_fee is False or payer_fee is None or payer_fee == 0):
 *             payer_account.withdraw(volume, currency)             # <<<<<<<<<<<<<<
 *         else:
 *             try:
 */
    __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_payer_account, __pyx_n_s_withdraw); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_14);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_14, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_4, __pyx_v_currency};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2430, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_4, __pyx_v_currency};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2430, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2430, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_t_4);
      __Pyx_INCREF(__pyx_v_currency);
      __Pyx_GIVEREF(__pyx_v_currency);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_v_currency);
      __pyx_t_4 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_8, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2430, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "trapeza/account/fx_account.pyx":2429
 *         # if payer account is not covered, then this line will (hopefully) throw an error, such that the next line
 *         # won't proceed and no false transaction at the own account will be incurred
 *         if payer_processing_duration == 0 and (payer_fee is False or payer_fee is None or payer_fee == 0):             # <<<<<<<<<<<<<<
 *             payer_account.withdraw(volume, currency)
 *         else:
 */
    goto __pyx_L31;
  }

  /* "trapeza/account/fx_account.pyx":2432
 *             payer_account.withdraw(volume, currency)
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 payer_account.withdraw(volume, currency, payer_fee, payer_processing_duration)
 *             except TypeError:
 */
  /*else*/ {
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_3);
      /*try:*/ {

        /* "trapeza/account/fx_account.pyx":2433
 *         else:
 *             try:
 *                 payer_account.withdraw(volume, currency, payer_fee, payer_processing_duration)             # <<<<<<<<<<<<<<
 *             except TypeError:
 *                 raise tpz_exception.AccountError('payer_account has no implementation '
 */
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_payer_account, __pyx_n_s_withdraw); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2433, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_8 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2433, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_4 = NULL;
        __pyx_t_9 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_14);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_14, function);
            __pyx_t_9 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_t_8, __pyx_v_currency, __pyx_v_payer_fee, __pyx_v_payer_processing_duration};
          __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2433, __pyx_L36_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_t_8, __pyx_v_currency, __pyx_v_payer_fee, __pyx_v_payer_processing_duration};
          __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2433, __pyx_L36_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2433, __pyx_L36_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_8);
          __Pyx_INCREF(__pyx_v_currency);
          __Pyx_GIVEREF(__pyx_v_currency);
          PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_v_currency);
          __Pyx_INCREF(__pyx_v_payer_fee);
          __Pyx_GIVEREF(__pyx_v_payer_fee);
          PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_v_payer_fee);
          __Pyx_INCREF(__pyx_v_payer_processing_duration);
          __Pyx_GIVEREF(__pyx_v_payer_processing_duration);
          PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_9, __pyx_v_payer_processing_duration);
          __pyx_t_8 = 0;
          __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2433, __pyx_L36_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "trapeza/account/fx_account.pyx":2432
 *             payer_account.withdraw(volume, currency)
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 payer_account.withdraw(volume, currency, payer_fee, payer_processing_duration)
 *             except TypeError:
 */
      }
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L41_try_end;
      __pyx_L36_error:;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "trapeza/account/fx_account.pyx":2434
 *             try:
 *                 payer_account.withdraw(volume, currency, payer_fee, payer_processing_duration)
 *             except TypeError:             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.AccountError('payer_account has no implementation '
 *                                                  'payer_account.withdraw(volume, currency, payer_fee, '
 */
      __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_9) {
        __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_14, &__pyx_t_11) < 0) __PYX_ERR(0, 2434, __pyx_L38_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_GOTREF(__pyx_t_11);

        /* "trapeza/account/fx_account.pyx":2435
 *                 payer_account.withdraw(volume, currency, payer_fee, payer_processing_duration)
 *             except TypeError:
 *                 raise tpz_exception.AccountError('payer_account has no implementation '             # <<<<<<<<<<<<<<
 *                                                  'payer_account.withdraw(volume, currency, payer_fee, '
 *                                                  'payer_processing_duration)')
 */
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2435, __pyx_L38_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2435, __pyx_L38_except_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_8 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_kp_u_payer_account_has_no_implementat) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u_payer_account_has_no_implementat);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2435, __pyx_L38_except_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __PYX_ERR(0, 2435, __pyx_L38_except_error)
      }
      goto __pyx_L38_except_error;
      __pyx_L38_except_error:;

      /* "trapeza/account/fx_account.pyx":2432
 *             payer_account.withdraw(volume, currency)
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 payer_account.withdraw(volume, currency, payer_fee, payer_processing_duration)
 *             except TypeError:
 */
      __Pyx_XGIVEREF(__pyx_t_1);
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
      goto __pyx_L1_error;
      __pyx_L41_try_end:;
    }
  }
  __pyx_L31:;

  /* "trapeza/account/fx_account.pyx":2439
 *                                                  'payer_processing_duration)')
 * 
 *         return self.c_collect(volume, currency.encode(), fee_volume, fee_currency.encode(), fee_exec_duration,             # <<<<<<<<<<<<<<
 *                               payee_processing_duration)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_collect); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (unlikely(__pyx_v_currency == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2439, __pyx_L1_error)
  }
  __pyx_t_8 = PyUnicode_AsEncodedString(__pyx_v_currency, NULL, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_fee_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_5 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "trapeza/account/fx_account.pyx":2440
 * 
 *         return self.c_collect(volume, currency.encode(), fee_volume, fee_currency.encode(), fee_exec_duration,
 *                               payee_processing_duration)             # <<<<<<<<<<<<<<
 * 
 *     def transfer(self, payee_account, double volume, str currency, payee_fee=False, payer_fee=False,
 */
  __pyx_t_4 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_14)) {
    PyObject *__pyx_temp[7] = {__pyx_t_4, __pyx_t_12, __pyx_t_8, __pyx_v_fee_volume, __pyx_t_5, __pyx_v_fee_exec_duration, __pyx_v_payee_processing_duration};
    __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 6+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2439, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
    PyObject *__pyx_temp[7] = {__pyx_t_4, __pyx_t_12, __pyx_t_8, __pyx_v_fee_volume, __pyx_t_5, __pyx_v_fee_exec_duration, __pyx_v_payee_processing_duration};
    __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 6+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2439, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(6+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_8);
    __Pyx_INCREF(__pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_v_fee_volume);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_fee_exec_duration);
    __Pyx_GIVEREF(__pyx_v_fee_exec_duration);
    PyTuple_SET_ITEM(__pyx_t_10, 4+__pyx_t_9, __pyx_v_fee_exec_duration);
    __Pyx_INCREF(__pyx_v_payee_processing_duration);
    __Pyx_GIVEREF(__pyx_v_payee_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_10, 5+__pyx_t_9, __pyx_v_payee_processing_duration);
    __pyx_t_12 = 0;
    __pyx_t_8 = 0;
    __pyx_t_5 = 0;
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_r = __pyx_t_11;
  __pyx_t_11 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":2299
 *                               fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def collect(self, payer_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                 payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.collect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fee_volume);
  __Pyx_XDECREF(__pyx_v_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_exec_duration);
  __Pyx_XDECREF(__pyx_v_payee_processing_duration);
  __Pyx_XDECREF(__pyx_v_payer_processing_duration);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2442
 *                               payee_processing_duration)
 * 
 *     def transfer(self, payee_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                  payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_95transfer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_94transfer[] = "\n        Transfers payment volume in given currency from this:account to payee account.\n        Furthermore, processing duration (e.g. transmission time of messages in real-life systems, broker execution,\n        etc.) can be modelled.\n        Fees can be defined either as function or float for payer and payee. If payee_fee=None and payer_fee=None, then\n        the standard and globally set fees of self._fee['deposit'] and self._fee['withdraw'] (which are set at __init__)\n        will be applied. If None (default), no fees will be applied\n\n        If payee_fee or payee_processing_duration shall be applied, then payee class must implement\n        payee_account.deposit(volume, currency, payee_fee, payee_processing_duration)\n\n        Coverage analysis is conducted with default arguments of withdraw() and deposit()\n        (e.g. coverage='except', instant_float_fee=False)\n\n        !!! If execution is not instant (e.g. processing_duration is not None), both accounts have to call .tick() to\n            make transaction take effect on both accounts. It is not sufficient to just only .tick() one account !!!\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param payee_account: class trapeza.account.base_account.BaseAccount (or derived class) object\n        :param volume: float, >= 0\n                       volume of currency\n        :param currency: str\n        :param payee_fee: dependent on payee class implementation of payee_account.deposit()\n                          default=False\n\n                          (!) if not {None, False, 0}:\n                            payee_account.deposit(volume, currency, payee_fee, payee_processing_duration) is called\n                            to deposit transaction volume (and to bill fees if necessary)\n        :param payer_fee: {None, False, func, float}, default=False\n                          fee setting for payer account\n\n                          None: self._fee['withdraw'""] is applied which is set at __init__. Default at __init__ is\n                                not applying any fees. See docstring of self.__init__ and docstring of class for\n                                further information about globally applied fees and how to set self._fee['withdraw'].\n                                Call signature will be parsed to:\n                                    fee(volume, 1, currency, currency, processing_duration)\n                          False: no fees at all applied, even if self._fee['withdraw'] is set (overrides globally\n                                 set fees: self._fee['withdraw'] will be temporarily ignored for this one transaction)\n                          func: alternative function to calculate fees is applied with signature (self._fee['withdraw']\n                                will be ignored for this one transaction and func will be applied instead)\n                                fee_volume, fee_currency, fee_exec_time\n                                     = fee(volume, price, base, quote, processing_duration)\n                                     = fee(volume, 1, currency, currency, processing_duration)\n                                price is set/ hard coded to 1 (induced by withdraw()/ deposit())\n                                base and quote are set/ hard coded to param:currency (induced by withdraw()/ deposit())\n                          float: constant fee is applied and billed in param:currency at the same time as the transfer\n                                 transaction takes effect (e.g. when payer_processing_duration is not 0)\n        :param payee_processing_duration: int or None, default=None\n                                          processing time (delay) in time base units of internal clock until transaction\n                                          takes effect on account's depot\n                                          time of execution/ billing = self.clock + processing_duration""\n                                          None is equivalent to 0 in behavior\n\n                                         (!) if not {None, 0}:\n                                            payee_account.deposit(volume, currency, payee_fee,\n                                                                  payee_processing_duration)\n                                            is called (make sure, this method is implemented at payee_account)\n                                         else:\n                                            payee_account.deposit(volume, currency) is called\n        :param payer_processing_duration: int or None, default=None\n                                          processing time (delay) in time base units of internal clock until transaction\n                                          takes effect on account's depot\n                                          time of execution/ billing = self.clock + processing_duration\n                                          None is equivalent to 0 in behavior\n        :return: confirmation states --> 0: processing (processing_duration), 1: executed/ billed\n        :raises: TypeError: if volume, currency, processing_duration not of specified type\n                 trapeza.exception.CoverageError: if coverage not sufficient (transaction or fee).\n                                                  Coverage analysis is set to 'except' (see docstring of self.deposit()\n                                                  or self.withdraw()).\n                                                  Coverage is only checked at payer account.\n                 NotImplementedError: if payer_fee not in {None, False, func, float}\n                 trapeza.exception.PositionNAError: if currency (str) or fee_currency (str) from payer_fee is not\n                                                    in self.depot.keys()\n                 trapeza.exception.AccountError: if payee_account is not derived\n                       ""                          from trapeza.account.base_account.BaseAccount\n                 ValueError: if volume < 0\n                 if exception raised, then no transactions have been billed (no change in heap or depot,\n                 nothing happened)\n                 additional exceptions may be risen by payee_account\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_95transfer = {"transfer", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_95transfer, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_94transfer};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_95transfer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_payee_account = 0;
  double __pyx_v_volume;
  PyObject *__pyx_v_currency = 0;
  PyObject *__pyx_v_payee_fee = 0;
  PyObject *__pyx_v_payer_fee = 0;
  PyObject *__pyx_v_payee_processing_duration = 0;
  PyObject *__pyx_v_payer_processing_duration = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("transfer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_payee_account,&__pyx_n_s_volume,&__pyx_n_s_currency,&__pyx_n_s_payee_fee,&__pyx_n_s_payer_fee,&__pyx_n_s_payee_processing_duration,&__pyx_n_s_payer_processing_duration,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    values[4] = ((PyObject *)((PyObject *)Py_False));
    values[5] = ((PyObject *)((PyObject *)Py_False));

    /* "trapeza/account/fx_account.pyx":2443
 * 
 *     def transfer(self, payee_account, double volume, str currency, payee_fee=False, payer_fee=False,
 *                  payee_processing_duration=None, payer_processing_duration=None):             # <<<<<<<<<<<<<<
 *         """
 *         Transfers payment volume in given currency from this:account to payee account.
 */
    values[6] = ((PyObject *)((PyObject *)Py_None));
    values[7] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payee_account)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("transfer", 0, 4, 8, 1); __PYX_ERR(0, 2442, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("transfer", 0, 4, 8, 2); __PYX_ERR(0, 2442, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("transfer", 0, 4, 8, 3); __PYX_ERR(0, 2442, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payee_fee);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payer_fee);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payee_processing_duration);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_payer_processing_duration);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "transfer") < 0)) __PYX_ERR(0, 2442, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_payee_account = values[1];
    __pyx_v_volume = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_volume == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2442, __pyx_L3_error)
    __pyx_v_currency = ((PyObject*)values[3]);
    __pyx_v_payee_fee = values[4];
    __pyx_v_payer_fee = values[5];
    __pyx_v_payee_processing_duration = values[6];
    __pyx_v_payer_processing_duration = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("transfer", 0, 4, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2442, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyUnicode_Type), 1, "currency", 1))) __PYX_ERR(0, 2442, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_94transfer(__pyx_self, __pyx_v_self, __pyx_v_payee_account, __pyx_v_volume, __pyx_v_currency, __pyx_v_payee_fee, __pyx_v_payer_fee, __pyx_v_payee_processing_duration, __pyx_v_payer_processing_duration);

  /* "trapeza/account/fx_account.pyx":2442
 *                               payee_processing_duration)
 * 
 *     def transfer(self, payee_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                  payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_94transfer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_payee_account, double __pyx_v_volume, PyObject *__pyx_v_currency, PyObject *__pyx_v_payee_fee, PyObject *__pyx_v_payer_fee, PyObject *__pyx_v_payee_processing_duration, PyObject *__pyx_v_payer_processing_duration) {
  PyObject *__pyx_v_fee_volume = NULL;
  PyObject *__pyx_v_fee_currency = NULL;
  PyObject *__pyx_v_fee_exec_duration = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  double __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transfer", 0);
  __Pyx_INCREF(__pyx_v_payee_processing_duration);
  __Pyx_INCREF(__pyx_v_payer_processing_duration);

  /* "trapeza/account/fx_account.pyx":2526
 *         """
 *         # >>>sanity check
 *         try:             # <<<<<<<<<<<<<<
 *             if not issubclass(payee_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payee_account)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":2527
 *         # >>>sanity check
 *         try:
 *             if not issubclass(payee_account.__class__, BaseAccount):             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.AccountError(payee_account)
 *         except TypeError:
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_payee_account, __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2527, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_BaseAccount); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2527, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_IsSubclass(__pyx_t_4, __pyx_t_5); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 2527, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0);
      if (unlikely(__pyx_t_7)) {

        /* "trapeza/account/fx_account.pyx":2528
 *         try:
 *             if not issubclass(payee_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payee_account)             # <<<<<<<<<<<<<<
 *         except TypeError:
 *             raise tpz_exception.AccountError(payee_account)
 */
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2528, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2528, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_4, __pyx_v_payee_account) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_payee_account);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2528, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(0, 2528, __pyx_L3_error)

        /* "trapeza/account/fx_account.pyx":2527
 *         # >>>sanity check
 *         try:
 *             if not issubclass(payee_account.__class__, BaseAccount):             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.AccountError(payee_account)
 *         except TypeError:
 */
      }

      /* "trapeza/account/fx_account.pyx":2526
 *         """
 *         # >>>sanity check
 *         try:             # <<<<<<<<<<<<<<
 *             if not issubclass(payee_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payee_account)
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "trapeza/account/fx_account.pyx":2529
 *             if not issubclass(payee_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payee_account)
 *         except TypeError:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.AccountError(payee_account)
 *         except tpz_exception.AccountError:
 */
    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
    if (__pyx_t_9) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 2529, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_4);

      /* "trapeza/account/fx_account.pyx":2530
 *                 raise tpz_exception.AccountError(payee_account)
 *         except TypeError:
 *             raise tpz_exception.AccountError(payee_account)             # <<<<<<<<<<<<<<
 *         except tpz_exception.AccountError:
 *             raise tpz_exception.AccountError(payee_account)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2530, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2530, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      __pyx_t_10 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_11, __pyx_v_payee_account) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_payee_account);
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2530, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 2530, __pyx_L5_except_error)
    }

    /* "trapeza/account/fx_account.pyx":2531
 *         except TypeError:
 *             raise tpz_exception.AccountError(payee_account)
 *         except tpz_exception.AccountError:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.AccountError(payee_account)
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_8, &__pyx_t_5);
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2531, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2531, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_9 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_12);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_ErrRestore(__pyx_t_4, __pyx_t_8, __pyx_t_5);
    __pyx_t_4 = 0; __pyx_t_8 = 0; __pyx_t_5 = 0;
    if (__pyx_t_9) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 2531, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_4);

      /* "trapeza/account/fx_account.pyx":2532
 *             raise tpz_exception.AccountError(payee_account)
 *         except tpz_exception.AccountError:
 *             raise tpz_exception.AccountError(payee_account)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2532, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2532, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_12 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_10, __pyx_v_payee_account) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_payee_account);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2532, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_12, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __PYX_ERR(0, 2532, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "trapeza/account/fx_account.pyx":2526
 *         """
 *         # >>>sanity check
 *         try:             # <<<<<<<<<<<<<<
 *             if not issubclass(payee_account.__class__, BaseAccount):
 *                 raise tpz_exception.AccountError(payee_account)
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":2534
 *             raise tpz_exception.AccountError(payee_account)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if payee_account == self:
 *                 raise tpz_exception.AccountError(payee_account)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_1);
    /*try:*/ {

      /* "trapeza/account/fx_account.pyx":2535
 * 
 *         try:
 *             if payee_account == self:             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.AccountError(payee_account)
 *         except TypeError:
 */
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_payee_account, __pyx_v_self, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2535, __pyx_L14_error)
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2535, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__pyx_t_7)) {

        /* "trapeza/account/fx_account.pyx":2536
 *         try:
 *             if payee_account == self:
 *                 raise tpz_exception.AccountError(payee_account)             # <<<<<<<<<<<<<<
 *         except TypeError:
 *             raise tpz_exception.AccountError(payee_account)
 */
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2536, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2536, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_8, __pyx_v_payee_account) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_payee_account);
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2536, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 2536, __pyx_L14_error)

        /* "trapeza/account/fx_account.pyx":2535
 * 
 *         try:
 *             if payee_account == self:             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.AccountError(payee_account)
 *         except TypeError:
 */
      }

      /* "trapeza/account/fx_account.pyx":2534
 *             raise tpz_exception.AccountError(payee_account)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if payee_account == self:
 *                 raise tpz_exception.AccountError(payee_account)
 */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L19_try_end;
    __pyx_L14_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "trapeza/account/fx_account.pyx":2537
 *             if payee_account == self:
 *                 raise tpz_exception.AccountError(payee_account)
 *         except TypeError:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.AccountError(payee_account)
 *         except tpz_exception.AccountError:
 */
    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
    if (__pyx_t_9) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_8) < 0) __PYX_ERR(0, 2537, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_8);

      /* "trapeza/account/fx_account.pyx":2538
 *                 raise tpz_exception.AccountError(payee_account)
 *         except TypeError:
 *             raise tpz_exception.AccountError(payee_account)             # <<<<<<<<<<<<<<
 *         except tpz_exception.AccountError:
 *             raise tpz_exception.AccountError(payee_account)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2538, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2538, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      __pyx_t_12 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_11, __pyx_v_payee_account) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_payee_account);
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2538, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_12, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __PYX_ERR(0, 2538, __pyx_L16_except_error)
    }

    /* "trapeza/account/fx_account.pyx":2539
 *         except TypeError:
 *             raise tpz_exception.AccountError(payee_account)
 *         except tpz_exception.AccountError:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.AccountError(payee_account)
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_5, &__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2539, __pyx_L16_except_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2539, __pyx_L16_except_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_9 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_8, __pyx_t_10);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_ErrRestore(__pyx_t_8, __pyx_t_5, __pyx_t_4);
    __pyx_t_8 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0;
    if (__pyx_t_9) {
      __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_8) < 0) __PYX_ERR(0, 2539, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_8);

      /* "trapeza/account/fx_account.pyx":2540
 *             raise tpz_exception.AccountError(payee_account)
 *         except tpz_exception.AccountError:
 *             raise tpz_exception.AccountError(payee_account)             # <<<<<<<<<<<<<<
 * 
 *         # >>>parsing
 */
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2540, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2540, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_10 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_v_payee_account) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_payee_account);
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2540, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 2540, __pyx_L16_except_error)
    }
    goto __pyx_L16_except_error;
    __pyx_L16_except_error:;

    /* "trapeza/account/fx_account.pyx":2534
 *             raise tpz_exception.AccountError(payee_account)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if payee_account == self:
 *                 raise tpz_exception.AccountError(payee_account)
 */
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
    goto __pyx_L1_error;
    __pyx_L19_try_end:;
  }

  /* "trapeza/account/fx_account.pyx":2543
 * 
 *         # >>>parsing
 *         if payer_processing_duration is None:             # <<<<<<<<<<<<<<
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:
 */
  __pyx_t_7 = (__pyx_v_payer_processing_duration == Py_None);
  __pyx_t_6 = (__pyx_t_7 != 0);
  if (__pyx_t_6) {

    /* "trapeza/account/fx_account.pyx":2544
 *         # >>>parsing
 *         if payer_processing_duration is None:
 *             payer_processing_duration = 0             # <<<<<<<<<<<<<<
 *         if payee_processing_duration is None:
 *             payee_processing_duration = 0
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_DECREF_SET(__pyx_v_payer_processing_duration, __pyx_int_0);

    /* "trapeza/account/fx_account.pyx":2543
 * 
 *         # >>>parsing
 *         if payer_processing_duration is None:             # <<<<<<<<<<<<<<
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:
 */
  }

  /* "trapeza/account/fx_account.pyx":2545
 *         if payer_processing_duration is None:
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:             # <<<<<<<<<<<<<<
 *             payee_processing_duration = 0
 * 
 */
  __pyx_t_6 = (__pyx_v_payee_processing_duration == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "trapeza/account/fx_account.pyx":2546
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:
 *             payee_processing_duration = 0             # <<<<<<<<<<<<<<
 * 
 *         # >>>type checking
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_DECREF_SET(__pyx_v_payee_processing_duration, __pyx_int_0);

    /* "trapeza/account/fx_account.pyx":2545
 *         if payer_processing_duration is None:
 *             payer_processing_duration = 0
 *         if payee_processing_duration is None:             # <<<<<<<<<<<<<<
 *             payee_processing_duration = 0
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2549
 * 
 *         # >>>type checking
 *         check_types([volume, currency, payer_processing_duration, payee_processing_duration],             # <<<<<<<<<<<<<<
 *                     [float, str, int, int],
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_check_types); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = PyList_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_4);
  PyList_SET_ITEM(__pyx_t_10, 0, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_currency);
  __Pyx_GIVEREF(__pyx_v_currency);
  PyList_SET_ITEM(__pyx_t_10, 1, __pyx_v_currency);
  __Pyx_INCREF(__pyx_v_payer_processing_duration);
  __Pyx_GIVEREF(__pyx_v_payer_processing_duration);
  PyList_SET_ITEM(__pyx_t_10, 2, __pyx_v_payer_processing_duration);
  __Pyx_INCREF(__pyx_v_payee_processing_duration);
  __Pyx_GIVEREF(__pyx_v_payee_processing_duration);
  PyList_SET_ITEM(__pyx_t_10, 3, __pyx_v_payee_processing_duration);
  __pyx_t_4 = 0;

  /* "trapeza/account/fx_account.pyx":2550
 *         # >>>type checking
 *         check_types([volume, currency, payer_processing_duration, payee_processing_duration],
 *                     [float, str, int, int],             # <<<<<<<<<<<<<<
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],
 *                     self._c_ignore_type_checking)
 */
  __pyx_t_4 = PyList_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_4, 1, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_4, 2, ((PyObject *)(&PyInt_Type)));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_4, 3, ((PyObject *)(&PyInt_Type)));

  /* "trapeza/account/fx_account.pyx":2551
 *         check_types([volume, currency, payer_processing_duration, payee_processing_duration],
 *                     [float, str, int, int],
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],             # <<<<<<<<<<<<<<
 *                     self._c_ignore_type_checking)
 *         self._check_alt_fee(payer_fee, 'payer_fee')  # only check payer fee structure, payee fee structure unknown
 */
  __pyx_t_11 = PyList_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_n_u_volume);
  __Pyx_GIVEREF(__pyx_n_u_volume);
  PyList_SET_ITEM(__pyx_t_11, 0, __pyx_n_u_volume);
  __Pyx_INCREF(__pyx_n_u_currency);
  __Pyx_GIVEREF(__pyx_n_u_currency);
  PyList_SET_ITEM(__pyx_t_11, 1, __pyx_n_u_currency);
  __Pyx_INCREF(__pyx_n_u_payer_processing_duration);
  __Pyx_GIVEREF(__pyx_n_u_payer_processing_duration);
  PyList_SET_ITEM(__pyx_t_11, 2, __pyx_n_u_payer_processing_duration);
  __Pyx_INCREF(__pyx_n_u_payee_processing_duration);
  __Pyx_GIVEREF(__pyx_n_u_payee_processing_duration);
  PyList_SET_ITEM(__pyx_t_11, 3, __pyx_n_u_payee_processing_duration);

  /* "trapeza/account/fx_account.pyx":2552
 *                     [float, str, int, int],
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],
 *                     self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         self._check_alt_fee(payer_fee, 'payer_fee')  # only check payer fee structure, payee fee structure unknown
 * 
 */
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[5] = {__pyx_t_13, __pyx_t_10, __pyx_t_4, __pyx_t_11, __pyx_t_12};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[5] = {__pyx_t_13, __pyx_t_10, __pyx_t_4, __pyx_t_11, __pyx_t_12};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_9, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_9, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_9, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_9, __pyx_t_12);
    __pyx_t_10 = 0;
    __pyx_t_4 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":2553
 *                     ['volume', 'currency', 'payer_processing_duration', 'payee_processing_duration'],
 *                     self._c_ignore_type_checking)
 *         self._check_alt_fee(payer_fee, 'payer_fee')  # only check payer fee structure, payee fee structure unknown             # <<<<<<<<<<<<<<
 * 
 *         if volume < 0:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_check_alt_fee); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2553, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_14 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_payer_fee, __pyx_n_u_payer_fee};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2553, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_v_payer_fee, __pyx_n_u_payer_fee};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2553, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2553, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_14) {
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_14); __pyx_t_14 = NULL;
    }
    __Pyx_INCREF(__pyx_v_payer_fee);
    __Pyx_GIVEREF(__pyx_v_payer_fee);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_9, __pyx_v_payer_fee);
    __Pyx_INCREF(__pyx_n_u_payer_fee);
    __Pyx_GIVEREF(__pyx_n_u_payer_fee);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_9, __pyx_n_u_payer_fee);
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2553, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":2555
 *         self._check_alt_fee(payer_fee, 'payer_fee')  # only check payer fee structure, payee fee structure unknown
 * 
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError
 * 
 */
  __pyx_t_7 = ((__pyx_v_volume < 0.0) != 0);
  if (unlikely(__pyx_t_7)) {

    /* "trapeza/account/fx_account.pyx":2556
 * 
 *         if volume < 0:
 *             raise ValueError             # <<<<<<<<<<<<<<
 * 
 *         # >>>coverage check withdrawal and fees
 */
    __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
    __PYX_ERR(0, 2556, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2555
 *         self._check_alt_fee(payer_fee, 'payer_fee')  # only check payer fee structure, payee fee structure unknown
 * 
 *         if volume < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2562
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=payer_fee, volume=volume, current_rate=1,             # <<<<<<<<<<<<<<
 *                                              base=currency, quote=currency,
 *                                              processing_duration=payer_processing_duration)
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_eval_fee); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_action_type, __pyx_n_u_withdraw) < 0) __PYX_ERR(0, 2562, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_alt_fee, __pyx_v_payer_fee) < 0) __PYX_ERR(0, 2562, __pyx_L1_error)
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_volume, __pyx_t_12) < 0) __PYX_ERR(0, 2562, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_current_rate, __pyx_int_1) < 0) __PYX_ERR(0, 2562, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2563
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=payer_fee, volume=volume, current_rate=1,
 *                                              base=currency, quote=currency,             # <<<<<<<<<<<<<<
 *                                              processing_duration=payer_processing_duration)
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == currency)), currency.encode(),
 */
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_base, __pyx_v_currency) < 0) __PYX_ERR(0, 2562, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_quote, __pyx_v_currency) < 0) __PYX_ERR(0, 2562, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2564
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=payer_fee, volume=volume, current_rate=1,
 *                                              base=currency, quote=currency,
 *                                              processing_duration=payer_processing_duration)             # <<<<<<<<<<<<<<
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == currency)), currency.encode(),
 *                                self._c_clock + max(fee_exec_duration, payer_processing_duration))
 */
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_processing_duration, __pyx_v_payer_processing_duration) < 0) __PYX_ERR(0, 2562, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2562
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=payer_fee, volume=volume, current_rate=1,             # <<<<<<<<<<<<<<
 *                                              base=currency, quote=currency,
 *                                              processing_duration=payer_processing_duration)
 */
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
    PyObject* sequence = __pyx_t_12;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2560, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_14 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_14 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_14);
    #else
    __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_14 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    #endif
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_15 = Py_TYPE(__pyx_t_11)->tp_iternext;
    index = 0; __pyx_t_5 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_5)) goto __pyx_L28_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 1; __pyx_t_8 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L28_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_8);
    index = 2; __pyx_t_14 = __pyx_t_15(__pyx_t_11); if (unlikely(!__pyx_t_14)) goto __pyx_L28_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_14);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_11), 3) < 0) __PYX_ERR(0, 2560, __pyx_L1_error)
    __pyx_t_15 = NULL;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    goto __pyx_L29_unpacking_done;
    __pyx_L28_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_15 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2560, __pyx_L1_error)
    __pyx_L29_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2560
 *         # >>>coverage check withdrawal and fees
 *         # only check payer
 *         (fee_volume,             # <<<<<<<<<<<<<<
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='withdraw', alt_fee=payer_fee, volume=volume, current_rate=1,
 */
  __pyx_v_fee_volume = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_fee_currency = __pyx_t_8;
  __pyx_t_8 = 0;
  __pyx_v_fee_exec_duration = __pyx_t_14;
  __pyx_t_14 = 0;

  /* "trapeza/account/fx_account.pyx":2565
 *                                              base=currency, quote=currency,
 *                                              processing_duration=payer_processing_duration)
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == currency)), currency.encode(),             # <<<<<<<<<<<<<<
 *                                self._c_clock + max(fee_exec_duration, payer_processing_duration))
 *         if fee_volume > 0:
 */
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_check_coverage); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_8 = PyObject_RichCompare(__pyx_v_fee_currency, __pyx_v_currency, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __pyx_t_5 = PyNumber_Multiply(__pyx_v_fee_volume, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_16 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_7trapeza_11arithmetics_11arithmetics_c_precision_add(__pyx_v_volume, __pyx_t_16)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(__pyx_v_currency == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2565, __pyx_L1_error)
  }
  __pyx_t_8 = PyUnicode_AsEncodedString(__pyx_v_currency, NULL, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "trapeza/account/fx_account.pyx":2566
 *                                              processing_duration=payer_processing_duration)
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == currency)), currency.encode(),
 *                                self._c_clock + max(fee_exec_duration, payer_processing_duration))             # <<<<<<<<<<<<<<
 *         if fee_volume > 0:
 *             self._c_check_coverage(fee_volume, fee_currency.encode(), self._c_clock + fee_exec_duration)
 */
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_clock); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_v_payer_processing_duration);
  __pyx_t_4 = __pyx_v_payer_processing_duration;
  __Pyx_INCREF(__pyx_v_fee_exec_duration);
  __pyx_t_10 = __pyx_v_fee_exec_duration;
  __pyx_t_17 = PyObject_RichCompare(__pyx_t_4, __pyx_t_10, Py_GT); __Pyx_XGOTREF(__pyx_t_17); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  if (__pyx_t_7) {
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_13 = __pyx_t_4;
  } else {
    __Pyx_INCREF(__pyx_t_10);
    __pyx_t_13 = __pyx_t_10;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_t_11, __pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_14)) {
    PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_5, __pyx_t_8, __pyx_t_4};
    __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
    PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_5, __pyx_t_8, __pyx_t_4};
    __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_4);
    __pyx_t_5 = 0;
    __pyx_t_8 = 0;
    __pyx_t_4 = 0;
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "trapeza/account/fx_account.pyx":2567
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == currency)), currency.encode(),
 *                                self._c_clock + max(fee_exec_duration, payer_processing_duration))
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self._c_check_coverage(fee_volume, fee_currency.encode(), self._c_clock + fee_exec_duration)
 * 
 */
  __pyx_t_12 = PyObject_RichCompare(__pyx_v_fee_volume, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2567, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 2567, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_7) {

    /* "trapeza/account/fx_account.pyx":2568
 *                                self._c_clock + max(fee_exec_duration, payer_processing_duration))
 *         if fee_volume > 0:
 *             self._c_check_coverage(fee_volume, fee_currency.encode(), self._c_clock + fee_exec_duration)             # <<<<<<<<<<<<<<
 * 
 *         # >>>deposit at payee account
 */
    __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_check_coverage); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_fee_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_11 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_clock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyNumber_Add(__pyx_t_4, __pyx_v_fee_exec_duration); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_14);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_14, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_fee_volume, __pyx_t_11, __pyx_t_8};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2568, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_fee_volume, __pyx_t_11, __pyx_t_8};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2568, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_fee_volume);
      __Pyx_GIVEREF(__pyx_v_fee_volume);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_v_fee_volume);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_9, __pyx_t_8);
      __pyx_t_11 = 0;
      __pyx_t_8 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_5, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "trapeza/account/fx_account.pyx":2567
 *         self._c_check_coverage(c_precision_add(volume, fee_volume * (fee_currency == currency)), currency.encode(),
 *                                self._c_clock + max(fee_exec_duration, payer_processing_duration))
 *         if fee_volume > 0:             # <<<<<<<<<<<<<<
 *             self._c_check_coverage(fee_volume, fee_currency.encode(), self._c_clock + fee_exec_duration)
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2573
 *         # if payee cannot cover deposit fee, then this line will (hopefully) throw an error, such that the next line
 *         # won't proceed and no false transaction at the own account will be incurred
 *         if payee_processing_duration == 0 and (payee_fee is False or payee_fee is None or payee_fee == 0):             # <<<<<<<<<<<<<<
 *             payee_account.deposit(volume, currency)
 *         else:
 */
  __pyx_t_12 = __Pyx_PyInt_EqObjC(__pyx_v_payee_processing_duration, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_6 = (__pyx_v_payee_fee == Py_False);
  __pyx_t_18 = (__pyx_t_6 != 0);
  if (!__pyx_t_18) {
  } else {
    __pyx_t_7 = __pyx_t_18;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_18 = (__pyx_v_payee_fee == Py_None);
  __pyx_t_6 = (__pyx_t_18 != 0);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L32_bool_binop_done;
  }
  __pyx_t_12 = __Pyx_PyInt_EqObjC(__pyx_v_payee_fee, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 2573, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_7 = __pyx_t_6;
  __pyx_L32_bool_binop_done:;
  if (__pyx_t_7) {

    /* "trapeza/account/fx_account.pyx":2574
 *         # won't proceed and no false transaction at the own account will be incurred
 *         if payee_processing_duration == 0 and (payee_fee is False or payee_fee is None or payee_fee == 0):
 *             payee_account.deposit(volume, currency)             # <<<<<<<<<<<<<<
 *         else:
 *             try:
 */
    __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_payee_account, __pyx_n_s_deposit); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_14);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_14, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_5, __pyx_v_currency};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2574, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_5, __pyx_v_currency};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2574, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2574, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_5);
      __Pyx_INCREF(__pyx_v_currency);
      __Pyx_GIVEREF(__pyx_v_currency);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_v_currency);
      __pyx_t_5 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2574, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

    /* "trapeza/account/fx_account.pyx":2573
 *         # if payee cannot cover deposit fee, then this line will (hopefully) throw an error, such that the next line
 *         # won't proceed and no false transaction at the own account will be incurred
 *         if payee_processing_duration == 0 and (payee_fee is False or payee_fee is None or payee_fee == 0):             # <<<<<<<<<<<<<<
 *             payee_account.deposit(volume, currency)
 *         else:
 */
    goto __pyx_L31;
  }

  /* "trapeza/account/fx_account.pyx":2576
 *             payee_account.deposit(volume, currency)
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 payee_account.deposit(volume, currency, payee_fee, payee_processing_duration)
 *             except TypeError:
 */
  /*else*/ {
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_3);
      /*try:*/ {

        /* "trapeza/account/fx_account.pyx":2577
 *         else:
 *             try:
 *                 payee_account.deposit(volume, currency, payee_fee, payee_processing_duration)             # <<<<<<<<<<<<<<
 *             except TypeError:
 *                 tpz_exception.AccountError('payee_account has no implementation '
 */
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_payee_account, __pyx_n_s_deposit); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2577, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_11 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2577, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_5 = NULL;
        __pyx_t_9 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_14);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_14, function);
            __pyx_t_9 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_11, __pyx_v_currency, __pyx_v_payee_fee, __pyx_v_payee_processing_duration};
          __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2577, __pyx_L36_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[5] = {__pyx_t_5, __pyx_t_11, __pyx_v_currency, __pyx_v_payee_fee, __pyx_v_payee_processing_duration};
          __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2577, __pyx_L36_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2577, __pyx_L36_error)
          __Pyx_GOTREF(__pyx_t_8);
          if (__pyx_t_5) {
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_t_11);
          __Pyx_INCREF(__pyx_v_currency);
          __Pyx_GIVEREF(__pyx_v_currency);
          PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_v_currency);
          __Pyx_INCREF(__pyx_v_payee_fee);
          __Pyx_GIVEREF(__pyx_v_payee_fee);
          PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_9, __pyx_v_payee_fee);
          __Pyx_INCREF(__pyx_v_payee_processing_duration);
          __Pyx_GIVEREF(__pyx_v_payee_processing_duration);
          PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_9, __pyx_v_payee_processing_duration);
          __pyx_t_11 = 0;
          __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_8, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2577, __pyx_L36_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "trapeza/account/fx_account.pyx":2576
 *             payee_account.deposit(volume, currency)
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 payee_account.deposit(volume, currency, payee_fee, payee_processing_duration)
 *             except TypeError:
 */
      }
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L41_try_end;
      __pyx_L36_error:;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "trapeza/account/fx_account.pyx":2578
 *             try:
 *                 payee_account.deposit(volume, currency, payee_fee, payee_processing_duration)
 *             except TypeError:             # <<<<<<<<<<<<<<
 *                 tpz_exception.AccountError('payee_account has no implementation '
 *                                            'payee_account.deposit(volume, currency, payee_fee, '
 */
      __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_9) {
        __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_14, &__pyx_t_8) < 0) __PYX_ERR(0, 2578, __pyx_L38_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_GOTREF(__pyx_t_8);

        /* "trapeza/account/fx_account.pyx":2579
 *                 payee_account.deposit(volume, currency, payee_fee, payee_processing_duration)
 *             except TypeError:
 *                 tpz_exception.AccountError('payee_account has no implementation '             # <<<<<<<<<<<<<<
 *                                            'payee_account.deposit(volume, currency, payee_fee, '
 *                                            'payee_processing_duration)')
 */
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2579, __pyx_L38_except_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_AccountError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2579, __pyx_L38_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_5)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_11 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u_payee_account_has_no_implementat) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_payee_account_has_no_implementat);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2579, __pyx_L38_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L37_exception_handled;
      }
      goto __pyx_L38_except_error;
      __pyx_L38_except_error:;

      /* "trapeza/account/fx_account.pyx":2576
 *             payee_account.deposit(volume, currency)
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 payee_account.deposit(volume, currency, payee_fee, payee_processing_duration)
 *             except TypeError:
 */
      __Pyx_XGIVEREF(__pyx_t_1);
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
      goto __pyx_L1_error;
      __pyx_L37_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_1);
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
      __pyx_L41_try_end:;
    }
  }
  __pyx_L31:;

  /* "trapeza/account/fx_account.pyx":2583
 *                                            'payee_processing_duration)')
 * 
 *         return self.c_transfer(volume, currency.encode(), fee_volume, fee_currency.encode(), fee_exec_duration,             # <<<<<<<<<<<<<<
 *                                payer_processing_duration)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_transfer); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (unlikely(__pyx_v_currency == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2583, __pyx_L1_error)
  }
  __pyx_t_11 = PyUnicode_AsEncodedString(__pyx_v_currency, NULL, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_fee_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_13 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_4 = (__pyx_t_13) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_13) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "trapeza/account/fx_account.pyx":2584
 * 
 *         return self.c_transfer(volume, currency.encode(), fee_volume, fee_currency.encode(), fee_exec_duration,
 *                                payer_processing_duration)             # <<<<<<<<<<<<<<
 * 
 *     def buy(self, double volume_base, double ask_price, str base, str quote, fee=None, processing_duration=None,
 */
  __pyx_t_5 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_14)) {
    PyObject *__pyx_temp[7] = {__pyx_t_5, __pyx_t_12, __pyx_t_11, __pyx_v_fee_volume, __pyx_t_4, __pyx_v_fee_exec_duration, __pyx_v_payer_processing_duration};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 6+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2583, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
    PyObject *__pyx_temp[7] = {__pyx_t_5, __pyx_t_12, __pyx_t_11, __pyx_v_fee_volume, __pyx_t_4, __pyx_v_fee_exec_duration, __pyx_v_payer_processing_duration};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_9, 6+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2583, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_13 = PyTuple_New(6+__pyx_t_9); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_9, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_9, __pyx_t_11);
    __Pyx_INCREF(__pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_v_fee_volume);
    PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_9, __pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_9, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_fee_exec_duration);
    __Pyx_GIVEREF(__pyx_v_fee_exec_duration);
    PyTuple_SET_ITEM(__pyx_t_13, 4+__pyx_t_9, __pyx_v_fee_exec_duration);
    __Pyx_INCREF(__pyx_v_payer_processing_duration);
    __Pyx_GIVEREF(__pyx_v_payer_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_13, 5+__pyx_t_9, __pyx_v_payer_processing_duration);
    __pyx_t_12 = 0;
    __pyx_t_11 = 0;
    __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_13, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_r = __pyx_t_8;
  __pyx_t_8 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":2442
 *                               payee_processing_duration)
 * 
 *     def transfer(self, payee_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                  payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.transfer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fee_volume);
  __Pyx_XDECREF(__pyx_v_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_exec_duration);
  __Pyx_XDECREF(__pyx_v_payee_processing_duration);
  __Pyx_XDECREF(__pyx_v_payer_processing_duration);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2586
 *                                payer_processing_duration)
 * 
 *     def buy(self, double volume_base, double ask_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *             str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_97buy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_96buy[] = "\n        Buy base|quote pair at ask_price. Give quote and receive base: quote->base, see docstring of class for further\n        information about notation convention.\n\n        Volume is given in BASE currency.\n\n        Furthermore, processing duration (e.g. transmission time of messages in real-life systems, broker execution,\n        etc.) can be modelled.\n        Fees can be defined either as function or float. If fee is float, then a separate currency in which to bill fees\n        can be defined. Additionally, if fees are float, fees can be withdrawn immediately even though transaction\n        might take some processing duration. This is controlled via instant_float_fee (bool).\n        If fee=float and float_fee_currency=None, then fees are applied in BASE currency.\n        Additionally, the withdrawal part of the buy transaction can be conducted instantly independent of the\n        processing_duration, which can be controlled via instant_withdrawal.\n\n        Buy transaction is split into a withdrawal of volume in quote currency and a deposit of volume in base currency.\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param volume_base: float, >= 0\n                            volume of BASE currency\n        :param base: str,\n                     base currency\n        :param ask_price: float\n                          current base|quote bid (FX notation, see docstring of class regarding notation conventions)\n        :param quote: str,\n                      quote currency\n        :param fee: {func, False, None, float}, default=None\n                        fee setting for buy transaction\n\n                        None: self._fee['buy'] is applied which is set at __init__. Default at __init__ is\n                              not applying any fees. See docstring of self.__init__ and docstring of class for\n                              further information about globally applied fees and how to set self._fee['bu""y']\n                        False: no fees at all applied, even if self._fee['buy'] is set (overrides globally set fees:\n                               self._fee['buy'] will be temporarily ignored for this one transaction)\n                        func: alternative function to self._fee is applied (self._fee['buy'] will be ignored\n                              for this one transaction and func will be applied instead)\n                              Must follow call signature:\n                                  fee_volume, fee_currency, fee_exec_time\n                                       = fee(volume, price, base, quote, processing_duration)\n                        float: constant fee is applied and billed in param:float_fee_currency\n                               if instant_float_fee = False: fee is billed at the same time as set by\n                                                             param:processing_duration (same time step when\n                                                             transaction takes effect on account's depot)\n                               if instant_float_fee = True: fee is billed instantly independent from\n                                                            param:processing_duration of transaction\n        :param processing_duration: int or None, default=None\n                                    processing time (delay) in time base units of internal clock until transaction takes\n                                    effect on account's depot\n                                    time of execution/ billing = self.clock + processing_duration\n                                    None is equivalent to 0 in behavior\n        :param coverage: {'partial', 'except', 'ignore', 'debit'}, default='except'\n                                   Controls exception behavior in case of coverage violation.\n                                   This coverage analysis checks whether transaction is conductible in principal (e.g.\n       ""                            if currently account's depot position is sufficient right now) but does not check\n                                   against marked but not yet billed transactions.\n\n                                   'partial': partial fulfilment as far as possible (including fees).\n                                              Withdrawal volume of buying transaction will be reduced s.t. that coverage\n                                              conditions are met.\n                                              This means, if withdrawal volume + fees is greater than current depot\n                                              position, then withdrawal volume will be reduced, such that no debiting\n                                              in account's depot positions occurs. If volume and fees are not in the\n                                              same currency, this reduction is only performed on the volume (fees might\n                                              still cause a coverage violation), amount of fees stays untouched then.\n                                              volume is reduced to meet initially calculated fees, fees are not\n                                              adapted to reduced volume (guessing interdependency would be hard), s.t.\n                                              more fees might be payed than according to reduced volume.\n                                              This does not guarantee transaction fulfillment, as this just checks\n                                              current depot but does not check against marked but not yet billed\n                                              (delayed) transactions, which is done independently of this\n                                              coverage check.\n                                              If withdrawal volume has to be reduced, then depositing volume is adapted\n                                              accordingly"".\n                                   'except': raises trapeza.exception.CoverageError if coverage is violated, which is\n                                             the case if withdrawal (including fees) is\n                                             greater than current depot position (in same currency as volume)\n                                   'debit': temporarily deactivates coverage check of current depot position as well as\n                                            coverage check of marked but not yet booked transactions. If\n                                            prohibit_debiting is set to False at __init__(), then negative (debt)\n                                            positions are possible, else a trapeza.exception.CoverageError will be\n                                            thrown at time of execution.\n                                   'ignore': buy order is not fulfilled but ignored instead if coverage violation occurs\n\n                                    Coverage checking of current depot position is done independently of\n                                    self.check_marked_coverage, which additionally checks against marked but not yet\n                                    filled future transactions (e.g. if self.check_marked_coverage is set to\n                                    'min_backward' or 'max_forward).\n                                    'debit' deactivates coverage check regarding future marked, not yet filled\n                                    transactions as well as coverage check of current depot positions for this one\n                                    transaction (see above).\n        :param instant_withdrawal: bool, default=False\n                                   if True, volume in quote currency is withdrawn instantly,\n                                        but depositing volume in base currency is done after processing_duration.\n                                        This argument does not ""affect at which time step fees will be billed (which\n                                        is only affected via processing_time (when fee is a func or self._fee['buy']\n                                        is applied), fee and instant_float_fee).\n                                   if False, processing_time is applied to both withdrawal and depositing\n        :param instant_float_fee: bool, default=False\n                                  ONLY APPLIES if fee = float, else ignored\n                                  if True, fees are withdrawn instantly independent of processing_duration. This does\n                                    not affect processing duration of withdrawing param:volume.\n                                  if False, fees are billed at the same time as withdrawing param:volume given by the\n                                    processing duration.\n        :param float_fee_currency: {str, None}, default=None\n                                   currency type to bill fee if fee=float, else ignored\n                                   if None or ignored, float_fee_currency is set to param:base,\n                                   else float_fee_currency is set to param:base if fee is False, None or func\n        :return: int\n                 confirmation states --> -1: ignored, 0: processing (processing_duration), 1: executed/ billed\n        :raises: trapeza.exception.PositionNAError: if quote (str) or float_fee_currency (str) is\n                                                    not in self.depot.keys()\n                 TypeError: if base, quote, volume, float_fee_currency or ask_price not of specified type\n                 NotImplementedError: if coverage not in {'partial', 'except', 'ignore', 'debit'} or\n                                      fee not in {func, False, None, float}\n                 trapeza.exception.CoverageError: if coverage not sufficient (transaction or fee) depending on\n                                              ""    coverage and if checking of marked transaction\n                                                  (self.check_marked_coverage) is switched on\n                 ValueError: if volume < 0\n        :TODO: when coverage='partial', than recalculate fees according to reducing volume to meet coverage\n        :TODO:  volume-depot + f(volume-x) -x = 0 --> min\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_97buy = {"buy", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_97buy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_96buy};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_97buy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  double __pyx_v_volume_base;
  double __pyx_v_ask_price;
  PyObject *__pyx_v_base = 0;
  PyObject *__pyx_v_quote = 0;
  PyObject *__pyx_v_fee = 0;
  PyObject *__pyx_v_processing_duration = 0;
  PyObject *__pyx_v_coverage = 0;
  PyObject *__pyx_v_instant_withdrawal = 0;
  PyObject *__pyx_v_instant_float_fee = 0;
  PyObject *__pyx_v_float_fee_currency = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("buy (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_volume_base,&__pyx_n_s_ask_price,&__pyx_n_s_base,&__pyx_n_s_quote,&__pyx_n_s_fee_2,&__pyx_n_s_processing_duration,&__pyx_n_s_coverage,&__pyx_n_s_instant_withdrawal,&__pyx_n_s_instant_float_fee,&__pyx_n_s_float_fee_currency,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
    values[5] = ((PyObject *)((PyObject *)Py_None));
    values[6] = ((PyObject *)((PyObject *)Py_None));
    values[7] = ((PyObject*)((PyObject*)__pyx_n_u_except));

    /* "trapeza/account/fx_account.pyx":2587
 * 
 *     def buy(self, double volume_base, double ask_price, str base, str quote, fee=None, processing_duration=None,
 *             str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):             # <<<<<<<<<<<<<<
 *         """
 *         Buy base|quote pair at ask_price. Give quote and receive base: quote->base, see docstring of class for further
 */
    values[8] = ((PyObject *)((PyObject *)Py_False));
    values[9] = ((PyObject *)((PyObject *)Py_False));
    values[10] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 11, 1); __PYX_ERR(0, 2586, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ask_price)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 11, 2); __PYX_ERR(0, 2586, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 11, 3); __PYX_ERR(0, 2586, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quote)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 11, 4); __PYX_ERR(0, 2586, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_2);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coverage);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_withdrawal);
          if (value) { values[8] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_float_fee);
          if (value) { values[9] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_float_fee_currency);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "buy") < 0)) __PYX_ERR(0, 2586, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_volume_base = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_volume_base == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2586, __pyx_L3_error)
    __pyx_v_ask_price = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_ask_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2586, __pyx_L3_error)
    __pyx_v_base = ((PyObject*)values[3]);
    __pyx_v_quote = ((PyObject*)values[4]);
    __pyx_v_fee = values[5];
    __pyx_v_processing_duration = values[6];
    __pyx_v_coverage = ((PyObject*)values[7]);
    __pyx_v_instant_withdrawal = values[8];
    __pyx_v_instant_float_fee = values[9];
    __pyx_v_float_fee_currency = values[10];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2586, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.buy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyUnicode_Type), 1, "base", 1))) __PYX_ERR(0, 2586, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_quote), (&PyUnicode_Type), 1, "quote", 1))) __PYX_ERR(0, 2586, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coverage), (&PyUnicode_Type), 1, "coverage", 1))) __PYX_ERR(0, 2587, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_96buy(__pyx_self, __pyx_v_self, __pyx_v_volume_base, __pyx_v_ask_price, __pyx_v_base, __pyx_v_quote, __pyx_v_fee, __pyx_v_processing_duration, __pyx_v_coverage, __pyx_v_instant_withdrawal, __pyx_v_instant_float_fee, __pyx_v_float_fee_currency);

  /* "trapeza/account/fx_account.pyx":2586
 *                                payer_processing_duration)
 * 
 *     def buy(self, double volume_base, double ask_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *             str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_96buy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_volume_base, double __pyx_v_ask_price, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, PyObject *__pyx_v_fee, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_coverage, PyObject *__pyx_v_instant_withdrawal, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_float_fee_currency) {
  PyObject *__pyx_v_parsed_fee_currency = NULL;
  PyObject *__pyx_v_fee_volume = NULL;
  PyObject *__pyx_v_fee_currency = NULL;
  PyObject *__pyx_v_fee_exec_duration = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("buy", 0);
  __Pyx_INCREF(__pyx_v_processing_duration);
  __Pyx_INCREF(__pyx_v_instant_float_fee);

  /* "trapeza/account/fx_account.pyx":2713
 *         (parsed_fee_currency,
 *          instant_float_fee,
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, base, fee,             # <<<<<<<<<<<<<<
 *                                                                        'buy_fee', instant_float_fee,
 *                                                                        processing_duration)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_fee_and_transaction_param); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "trapeza/account/fx_account.pyx":2715
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, base, fee,
 *                                                                        'buy_fee', instant_float_fee,
 *                                                                        processing_duration)             # <<<<<<<<<<<<<<
 * 
 *         # >>>sanity and type checking
 */
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_3, __pyx_v_float_fee_currency, __pyx_v_base, __pyx_v_fee, __pyx_n_u_buy_fee, __pyx_v_instant_float_fee, __pyx_v_processing_duration};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2713, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_3, __pyx_v_float_fee_currency, __pyx_v_base, __pyx_v_fee, __pyx_n_u_buy_fee, __pyx_v_instant_float_fee, __pyx_v_processing_duration};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2713, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(6+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2713, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_float_fee_currency);
    __Pyx_GIVEREF(__pyx_v_float_fee_currency);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_float_fee_currency);
    __Pyx_INCREF(__pyx_v_base);
    __Pyx_GIVEREF(__pyx_v_base);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_base);
    __Pyx_INCREF(__pyx_v_fee);
    __Pyx_GIVEREF(__pyx_v_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_fee);
    __Pyx_INCREF(__pyx_n_u_buy_fee);
    __Pyx_GIVEREF(__pyx_n_u_buy_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_n_u_buy_fee);
    __Pyx_INCREF(__pyx_v_instant_float_fee);
    __Pyx_GIVEREF(__pyx_v_instant_float_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_v_instant_float_fee);
    __Pyx_INCREF(__pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_v_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_processing_duration);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2713, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2711, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 2; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) __PYX_ERR(0, 2711, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2711, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2711
 *         """
 *         # >>>parsing inputs
 *         (parsed_fee_currency,             # <<<<<<<<<<<<<<
 *          instant_float_fee,
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, base, fee,
 */
  __pyx_v_parsed_fee_currency = __pyx_t_2;
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_instant_float_fee, __pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_processing_duration, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "trapeza/account/fx_account.pyx":2718
 * 
 *         # >>>sanity and type checking
 *         if volume_base < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Buy volume in {} is < 0.'.format(quote))
 * 
 */
  __pyx_t_8 = ((__pyx_v_volume_base < 0.0) != 0);
  if (unlikely(__pyx_t_8)) {

    /* "trapeza/account/fx_account.pyx":2719
 *         # >>>sanity and type checking
 *         if volume_base < 0:
 *             raise ValueError('Buy volume in {} is < 0.'.format(quote))             # <<<<<<<<<<<<<<
 * 
 *         check_types([base, quote, volume_base, ask_price, parsed_fee_currency, processing_duration,
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Buy_volume_in_is_0, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_quote) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_quote);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2719, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2718
 * 
 *         # >>>sanity and type checking
 *         if volume_base < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Buy volume in {} is < 0.'.format(quote))
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2721
 *             raise ValueError('Buy volume in {} is < 0.'.format(quote))
 * 
 *         check_types([base, quote, volume_base, ask_price, parsed_fee_currency, processing_duration,             # <<<<<<<<<<<<<<
 *                      instant_withdrawal, instant_float_fee, coverage],
 *                     [str, str, float, float, str, int, bool, bool, str],
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_check_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_volume_base); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_ask_price); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "trapeza/account/fx_account.pyx":2722
 * 
 *         check_types([base, quote, volume_base, ask_price, parsed_fee_currency, processing_duration,
 *                      instant_withdrawal, instant_float_fee, coverage],             # <<<<<<<<<<<<<<
 *                     [str, str, float, float, str, int, bool, bool, str],
 *                     ['base', 'quote', 'volume', 'ask_price', 'float_fee_currency', 'processing_duration',
 */
  __pyx_t_6 = PyList_New(9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_base);
  __Pyx_GIVEREF(__pyx_v_base);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_base);
  __Pyx_INCREF(__pyx_v_quote);
  __Pyx_GIVEREF(__pyx_v_quote);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_v_quote);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_6, 3, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_parsed_fee_currency);
  __Pyx_GIVEREF(__pyx_v_parsed_fee_currency);
  PyList_SET_ITEM(__pyx_t_6, 4, __pyx_v_parsed_fee_currency);
  __Pyx_INCREF(__pyx_v_processing_duration);
  __Pyx_GIVEREF(__pyx_v_processing_duration);
  PyList_SET_ITEM(__pyx_t_6, 5, __pyx_v_processing_duration);
  __Pyx_INCREF(__pyx_v_instant_withdrawal);
  __Pyx_GIVEREF(__pyx_v_instant_withdrawal);
  PyList_SET_ITEM(__pyx_t_6, 6, __pyx_v_instant_withdrawal);
  __Pyx_INCREF(__pyx_v_instant_float_fee);
  __Pyx_GIVEREF(__pyx_v_instant_float_fee);
  PyList_SET_ITEM(__pyx_t_6, 7, __pyx_v_instant_float_fee);
  __Pyx_INCREF(__pyx_v_coverage);
  __Pyx_GIVEREF(__pyx_v_coverage);
  PyList_SET_ITEM(__pyx_t_6, 8, __pyx_v_coverage);
  __pyx_t_5 = 0;
  __pyx_t_2 = 0;

  /* "trapeza/account/fx_account.pyx":2723
 *         check_types([base, quote, volume_base, ask_price, parsed_fee_currency, processing_duration,
 *                      instant_withdrawal, instant_float_fee, coverage],
 *                     [str, str, float, float, str, int, bool, bool, str],             # <<<<<<<<<<<<<<
 *                     ['base', 'quote', 'volume', 'ask_price', 'float_fee_currency', 'processing_duration',
 *                      'instant_withdrawal', 'instant_float_fee', 'coverage'], self._c_ignore_type_checking)
 */
  __pyx_t_2 = PyList_New(9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_2, 3, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 4, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_2, 5, ((PyObject *)(&PyInt_Type)));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_2, 6, ((PyObject*)&PyBool_Type));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_2, 7, ((PyObject*)&PyBool_Type));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 8, ((PyObject *)(&PyUnicode_Type)));

  /* "trapeza/account/fx_account.pyx":2724
 *                      instant_withdrawal, instant_float_fee, coverage],
 *                     [str, str, float, float, str, int, bool, bool, str],
 *                     ['base', 'quote', 'volume', 'ask_price', 'float_fee_currency', 'processing_duration',             # <<<<<<<<<<<<<<
 *                      'instant_withdrawal', 'instant_float_fee', 'coverage'], self._c_ignore_type_checking)
 *         self._c_isin_depot(quote.encode())
 */
  __pyx_t_5 = PyList_New(9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_base);
  __Pyx_GIVEREF(__pyx_n_u_base);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_base);
  __Pyx_INCREF(__pyx_n_u_quote);
  __Pyx_GIVEREF(__pyx_n_u_quote);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_n_u_quote);
  __Pyx_INCREF(__pyx_n_u_volume);
  __Pyx_GIVEREF(__pyx_n_u_volume);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_n_u_volume);
  __Pyx_INCREF(__pyx_n_u_ask_price);
  __Pyx_GIVEREF(__pyx_n_u_ask_price);
  PyList_SET_ITEM(__pyx_t_5, 3, __pyx_n_u_ask_price);
  __Pyx_INCREF(__pyx_n_u_float_fee_currency);
  __Pyx_GIVEREF(__pyx_n_u_float_fee_currency);
  PyList_SET_ITEM(__pyx_t_5, 4, __pyx_n_u_float_fee_currency);
  __Pyx_INCREF(__pyx_n_u_processing_duration);
  __Pyx_GIVEREF(__pyx_n_u_processing_duration);
  PyList_SET_ITEM(__pyx_t_5, 5, __pyx_n_u_processing_duration);
  __Pyx_INCREF(__pyx_n_u_instant_withdrawal);
  __Pyx_GIVEREF(__pyx_n_u_instant_withdrawal);
  PyList_SET_ITEM(__pyx_t_5, 6, __pyx_n_u_instant_withdrawal);
  __Pyx_INCREF(__pyx_n_u_instant_float_fee);
  __Pyx_GIVEREF(__pyx_n_u_instant_float_fee);
  PyList_SET_ITEM(__pyx_t_5, 7, __pyx_n_u_instant_float_fee);
  __Pyx_INCREF(__pyx_n_u_coverage);
  __Pyx_GIVEREF(__pyx_n_u_coverage);
  PyList_SET_ITEM(__pyx_t_5, 8, __pyx_n_u_coverage);

  /* "trapeza/account/fx_account.pyx":2725
 *                     [str, str, float, float, str, int, bool, bool, str],
 *                     ['base', 'quote', 'volume', 'ask_price', 'float_fee_currency', 'processing_duration',
 *                      'instant_withdrawal', 'instant_float_fee', 'coverage'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         self._c_isin_depot(quote.encode())
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_6, __pyx_t_2, __pyx_t_5, __pyx_t_9};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2721, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_6, __pyx_t_2, __pyx_t_5, __pyx_t_9};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2721, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2721, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_4, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_4, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_4, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_4, __pyx_t_9);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_9 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2721, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "trapeza/account/fx_account.pyx":2726
 *                     ['base', 'quote', 'volume', 'ask_price', 'float_fee_currency', 'processing_duration',
 *                      'instant_withdrawal', 'instant_float_fee', 'coverage'], self._c_ignore_type_checking)
 *         self._c_isin_depot(quote.encode())             # <<<<<<<<<<<<<<
 * 
 *         # >>>evaluate fees
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_isin_depot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_quote == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2726, __pyx_L1_error)
  }
  __pyx_t_11 = PyUnicode_AsEncodedString(__pyx_v_quote, NULL, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_9, __pyx_t_11) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_11);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "trapeza/account/fx_account.pyx":2732
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='buy', alt_fee=fee, volume=volume_base,             # <<<<<<<<<<<<<<
 *                                              current_rate=ask_price, base=parsed_fee_currency, quote=quote,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_eval_fee); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_action_type, __pyx_n_u_buy) < 0) __PYX_ERR(0, 2732, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_alt_fee, __pyx_v_fee) < 0) __PYX_ERR(0, 2732, __pyx_L1_error)
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_volume_base); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_volume, __pyx_t_11) < 0) __PYX_ERR(0, 2732, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "trapeza/account/fx_account.pyx":2733
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='buy', alt_fee=fee, volume=volume_base,
 *                                              current_rate=ask_price, base=parsed_fee_currency, quote=quote,             # <<<<<<<<<<<<<<
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 * 
 */
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_ask_price); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2733, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_current_rate, __pyx_t_11) < 0) __PYX_ERR(0, 2732, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_base, __pyx_v_parsed_fee_currency) < 0) __PYX_ERR(0, 2732, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_quote, __pyx_v_quote) < 0) __PYX_ERR(0, 2732, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2734
 *          fee_exec_duration) = self._eval_fee(action_type='buy', alt_fee=fee, volume=volume_base,
 *                                              current_rate=ask_price, base=parsed_fee_currency, quote=quote,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))             # <<<<<<<<<<<<<<
 * 
 *         # >>>handle coverage exception induced by fees
 */
  __pyx_t_11 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_instant_float_fee, 1, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = PyNumber_Multiply(__pyx_v_processing_duration, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_processing_duration, __pyx_t_9) < 0) __PYX_ERR(0, 2732, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "trapeza/account/fx_account.pyx":2732
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='buy', alt_fee=fee, volume=volume_base,             # <<<<<<<<<<<<<<
 *                                              current_rate=ask_price, base=parsed_fee_currency, quote=quote,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 */
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
    PyObject* sequence = __pyx_t_9;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2730, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2730, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2730, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2730, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2730, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_11 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_11)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_11);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_5), 3) < 0) __PYX_ERR(0, 2730, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L7_unpacking_done;
    __pyx_L6_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2730, __pyx_L1_error)
    __pyx_L7_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2730
 *         # >>>evaluate fees
 *         # volume is in quote currency
 *         (fee_volume,             # <<<<<<<<<<<<<<
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='buy', alt_fee=fee, volume=volume_base,
 */
  __pyx_v_fee_volume = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_fee_currency = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_fee_exec_duration = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "trapeza/account/fx_account.pyx":2737
 * 
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'partial', 'debit', 'ignore']:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')
 * 
 */
  __Pyx_INCREF(__pyx_v_coverage);
  __pyx_t_12 = __pyx_v_coverage;
  __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_except, Py_NE)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 2737, __pyx_L1_error)
  __pyx_t_14 = (__pyx_t_13 != 0);
  if (__pyx_t_14) {
  } else {
    __pyx_t_8 = __pyx_t_14;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_14 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_partial, Py_NE)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 2737, __pyx_L1_error)
  __pyx_t_13 = (__pyx_t_14 != 0);
  if (__pyx_t_13) {
  } else {
    __pyx_t_8 = __pyx_t_13;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_debit, Py_NE)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 2737, __pyx_L1_error)
  __pyx_t_14 = (__pyx_t_13 != 0);
  if (__pyx_t_14) {
  } else {
    __pyx_t_8 = __pyx_t_14;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_14 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_ignore, Py_NE)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 2737, __pyx_L1_error)
  __pyx_t_13 = (__pyx_t_14 != 0);
  __pyx_t_8 = __pyx_t_13;
  __pyx_L9_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_13 = (__pyx_t_8 != 0);
  if (unlikely(__pyx_t_13)) {

    /* "trapeza/account/fx_account.pyx":2738
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'partial', 'debit', 'ignore']:
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')             # <<<<<<<<<<<<<<
 * 
 *         return self.c_buy(volume_base, ask_price, base.encode(), quote.encode(), fee_volume, fee_currency.encode(),
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2738, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2738, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2737
 * 
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'partial', 'debit', 'ignore']:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2740
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')
 * 
 *         return self.c_buy(volume_base, ask_price, base.encode(), quote.encode(), fee_volume, fee_currency.encode(),             # <<<<<<<<<<<<<<
 *                           fee_exec_duration, processing_duration, coverage.encode(),
 *                           instant_withdrawal, instant_float_fee)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_buy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_volume_base); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_ask_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_base == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2740, __pyx_L1_error)
  }
  __pyx_t_5 = PyUnicode_AsEncodedString(__pyx_v_base, NULL, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(__pyx_v_quote == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2740, __pyx_L1_error)
  }
  __pyx_t_2 = PyUnicode_AsEncodedString(__pyx_v_quote, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_fee_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  __pyx_t_6 = (__pyx_t_15) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_15) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "trapeza/account/fx_account.pyx":2741
 * 
 *         return self.c_buy(volume_base, ask_price, base.encode(), quote.encode(), fee_volume, fee_currency.encode(),
 *                           fee_exec_duration, processing_duration, coverage.encode(),             # <<<<<<<<<<<<<<
 *                           instant_withdrawal, instant_float_fee)
 * 
 */
  if (unlikely(__pyx_v_coverage == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2741, __pyx_L1_error)
  }
  __pyx_t_10 = PyUnicode_AsEncodedString(__pyx_v_coverage, NULL, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);

  /* "trapeza/account/fx_account.pyx":2742
 *         return self.c_buy(volume_base, ask_price, base.encode(), quote.encode(), fee_volume, fee_currency.encode(),
 *                           fee_exec_duration, processing_duration, coverage.encode(),
 *                           instant_withdrawal, instant_float_fee)             # <<<<<<<<<<<<<<
 * 
 *     def sell(self, double volume_base, double bid_price, str base, str quote, fee=None, processing_duration=None,
 */
  __pyx_t_15 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_11)) {
    PyObject *__pyx_temp[12] = {__pyx_t_15, __pyx_t_3, __pyx_t_1, __pyx_t_5, __pyx_t_2, __pyx_v_fee_volume, __pyx_t_6, __pyx_v_fee_exec_duration, __pyx_v_processing_duration, __pyx_t_10, __pyx_v_instant_withdrawal, __pyx_v_instant_float_fee};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_4, 11+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2740, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
    PyObject *__pyx_temp[12] = {__pyx_t_15, __pyx_t_3, __pyx_t_1, __pyx_t_5, __pyx_t_2, __pyx_v_fee_volume, __pyx_t_6, __pyx_v_fee_exec_duration, __pyx_v_processing_duration, __pyx_t_10, __pyx_v_instant_withdrawal, __pyx_v_instant_float_fee};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_4, 11+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2740, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  {
    __pyx_t_16 = PyTuple_New(11+__pyx_t_4); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    if (__pyx_t_15) {
      __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_4, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_4, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_4, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_16, 3+__pyx_t_4, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_v_fee_volume);
    PyTuple_SET_ITEM(__pyx_t_16, 4+__pyx_t_4, __pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_16, 5+__pyx_t_4, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_fee_exec_duration);
    __Pyx_GIVEREF(__pyx_v_fee_exec_duration);
    PyTuple_SET_ITEM(__pyx_t_16, 6+__pyx_t_4, __pyx_v_fee_exec_duration);
    __Pyx_INCREF(__pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_v_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_16, 7+__pyx_t_4, __pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_16, 8+__pyx_t_4, __pyx_t_10);
    __Pyx_INCREF(__pyx_v_instant_withdrawal);
    __Pyx_GIVEREF(__pyx_v_instant_withdrawal);
    PyTuple_SET_ITEM(__pyx_t_16, 9+__pyx_t_4, __pyx_v_instant_withdrawal);
    __Pyx_INCREF(__pyx_v_instant_float_fee);
    __Pyx_GIVEREF(__pyx_v_instant_float_fee);
    PyTuple_SET_ITEM(__pyx_t_16, 10+__pyx_t_4, __pyx_v_instant_float_fee);
    __pyx_t_3 = 0;
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_10 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_16, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":2586
 *                                payer_processing_duration)
 * 
 *     def buy(self, double volume_base, double ask_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *             str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.buy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parsed_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_volume);
  __Pyx_XDECREF(__pyx_v_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_exec_duration);
  __Pyx_XDECREF(__pyx_v_processing_duration);
  __Pyx_XDECREF(__pyx_v_instant_float_fee);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2744
 *                           instant_withdrawal, instant_float_fee)
 * 
 *     def sell(self, double volume_base, double bid_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *              str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_99sell(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_98sell[] = "\n        Sell base|quote pair at bid_price. Give base and receive quote: base->quote, see docstring of class for further\n        information about notation convention.\n\n        Volume is given in BASE currency.\n\n        Furthermore, processing duration (e.g. transmission time of messages in real-life systems, broker execution,\n        etc.) can be modelled.\n        Fees can be defined either as function or float. If fee is float, then a separate currency in which to bill fees\n        can be defined. Additionally, if fees are float, fees can be withdrawn immediately even though transaction\n        might take some processing duration. This is controlled via instant_float_fee (bool).\n        If fee=float and float_fee_currency=None, then fees are applied in BASE currency.\n        Additionally, the withdrawal part of the sell transaction can be conducted instantly independent of the\n        processing_duration, which can be controlled via instant_withdrawal.\n\n        Sell transaction is split into a withdrawal of volume in base currency and a deposit of volume in\n        quote currency.\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param volume_base: float, >= 0\n                            volume of BASE currency\n        :param base: str,\n                     base currency\n        :param bid_price: float\n                          current base|quote ask (FX notation, see docstring of class regarding notation conventions)\n        :param quote: str,\n                      quote currency\n        :param fee: {func, False, None, float}, default=None\n                        fee setting for sell transaction\n\n                        None: self._fee['sell'] is applied which is set at __init__. Default at __init__ is\n                              not applying any fees. See docstring of self.__init__ and docstring of class for\n                              further information about globally applied fees and how to set"" self._fee['sell']\n                        False: no fees at all applied, even if self._fee['sell'] is set (overrides globally set fees:\n                               self._fee['sell'] will be temporarily ignored for this one transaction)\n                        func: alternative function to self._fee is applied (self._fee['sell'] will be ignored\n                              for this one transaction and func will be applied instead)\n                              Must follow call signature:\n                                  fee_volume, fee_currency, fee_exec_time\n                                       = fee(volume, price, base, quote, processing_duration)\n                        float: constant fee is applied and billed in param:float_fee_currency\n                               if instant_float_fee = False: fee is billed at the same time as set by\n                                                             param:processing_duration (same time step when\n                                                             transaction takes effect on account's depot)\n                               if instant_float_fee = True: fee is billed instantly independent from\n                                                            param:processing_duration of transaction\n        :param processing_duration: int or None, default=None\n                                    processing time (delay) in time base units of internal clock until transaction takes\n                                    effect on account's depot\n                                    time of execution/ billing = self.clock + processing_duration\n                                    None is equivalent to 0 in behavior\n        :param coverage: {'partial', 'except', 'ignore', 'debit'}, default='except'\n                                   Controls exception behavior in case of coverage violation.\n                                   This coverage analysis checks whether transaction is conductible in princi""pal (e.g.\n                                   if currently account's depot position is sufficient right now) but does not check\n                                   against marked but not yet billed transactions.\n\n                                   'partial': partial fulfilment as far as possible (including fees).\n                                              Withdrawal volume of sell transaction will be reduced s.t. that coverage\n                                              conditions are met.\n                                              This means, if withdrawal volume + fees is greater than current depot\n                                              position, then withdrawal volume will be reduced, such that no debiting\n                                              in account's depot positions occurs. If volume and fees are not in the\n                                              same currency, this reduction is only performed on the volume (fees might\n                                              still cause a coverage violation), amount of fees stays untouched then.\n                                              volume is reduced to meet initially calculated fees, fees are not\n                                              adapted to reduced volume (guessing interdependency would be hard), s.t.\n                                              more fees might be payed than according to reduced volume.\n                                              This does not guarantee transaction fulfillment, as this just checks\n                                              current depot but does not check against marked but not yet billed\n                                              (delayed) transactions, which is done independently of this\n                                              coverage check.\n                                              If withdrawal volume has to be reduced, then depositing volume is adapted\n                                         ""     accordingly.\n                                   'except': raises trapeza.exception.CoverageError if coverage is violated, which is\n                                             the case if withdrawal (including fees) is\n                                             greater than current depot position (in same currency as volume)\n                                   'debit': temporarily deactivates coverage check of current depot position as well as\n                                            coverage check of marked but not yet booked transactions. If\n                                            prohibit_debiting is set to False at __init__(), then negative (debt)\n                                            positions are possible, else a trapeza.exception.CoverageError will be\n                                            thrown at time of execution.\n                                   'ignore': sell order is not fulfilled but ignored instead if coverage\n                                             violation occurs\n\n                                    Coverage checking of current depot position is done independently of\n                                    self.check_marked_coverage, which additionally checks against marked but not yet\n                                    filled future transactions (e.g. if self.check_marked_coverage is set to\n                                    'min_backward' or 'max_forward).\n                                    'debit' deactivates coverage check regarding future marked, not yet filled\n                                    transactions as well as coverage check of current depot positions for this one\n                                    transaction (see above).\n        :param instant_withdrawal: bool, default=False\n                                   if True, volume in base currency is withdrawn instantly,\n                                        but depositing volume in quote currency is done after processing_duration.""\n                                        This argument does not affect at which time step fees will be billed (which\n                                        is only affected via processing_time (when fee is a func or\n                                        self._fee['sell'] is applied), fee and instant_float_fee).\n                                   if False, processing_time is applied to both withdrawal and depositing\n        :param instant_float_fee: bool, default=False\n                                  ONLY APPLIES if fee = float, else ignored\n                                  if True, fees are withdrawn instantly independent of processing_duration. This does\n                                    not affect processing duration of withdrawing param:volume.\n                                  if False, fees are billed at the same time as withdrawing param:volume given by the\n                                    processing duration.\n        :param float_fee_currency: {str, None}, default=None\n                                   currency type to bill fee if fee=float, else ignored\n                                   if None or ignored, float_fee_currency is set to param:base,\n                                   else float_fee_currency is set to param:base if fee is False, None or func\n        :return: int\n                 confirmation states --> -1: ignored, 0: processing (processing_duration), 1: executed/ billed\n        :raises: trapeza.exception.PositionNAError: if base (str) or float_fee_currency (str) is\n                                                    not in self.depot.keys()\n                 TypeError: if base, quote, volume, float_fee_currency or bid_price not of specified type\n                 NotImplementedError: if coverage not in {'partial', 'except', 'ignore', 'debit'} or\n                                      fee not in {func, False, None, float}\n                 trapeza.exception.CoverageError: if coverage not sufficient (transaction or ""fee) depending on\n                                                  coverage and if checking of marked transaction\n                                                  (self.check_marked_coverage) is switched on\n                 ValueError: if volume < 0\n        :TODO: when coverage='partial', than recalculate fees according to reducing volume to meet coverage\n        :TODO:  volume-depot + f(volume-x) -x = 0 --> min\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_99sell = {"sell", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_99sell, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_98sell};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_99sell(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  double __pyx_v_volume_base;
  double __pyx_v_bid_price;
  PyObject *__pyx_v_base = 0;
  PyObject *__pyx_v_quote = 0;
  PyObject *__pyx_v_fee = 0;
  PyObject *__pyx_v_processing_duration = 0;
  PyObject *__pyx_v_coverage = 0;
  PyObject *__pyx_v_instant_withdrawal = 0;
  PyObject *__pyx_v_instant_float_fee = 0;
  PyObject *__pyx_v_float_fee_currency = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sell (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_volume_base,&__pyx_n_s_bid_price,&__pyx_n_s_base,&__pyx_n_s_quote,&__pyx_n_s_fee_2,&__pyx_n_s_processing_duration,&__pyx_n_s_coverage,&__pyx_n_s_instant_withdrawal,&__pyx_n_s_instant_float_fee,&__pyx_n_s_float_fee_currency,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
    values[5] = ((PyObject *)((PyObject *)Py_None));
    values[6] = ((PyObject *)((PyObject *)Py_None));
    values[7] = ((PyObject*)((PyObject*)__pyx_n_u_except));

    /* "trapeza/account/fx_account.pyx":2745
 * 
 *     def sell(self, double volume_base, double bid_price, str base, str quote, fee=None, processing_duration=None,
 *              str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):             # <<<<<<<<<<<<<<
 *         """
 *         Sell base|quote pair at bid_price. Give base and receive quote: base->quote, see docstring of class for further
 */
    values[8] = ((PyObject *)((PyObject *)Py_False));
    values[9] = ((PyObject *)((PyObject *)Py_False));
    values[10] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 11, 1); __PYX_ERR(0, 2744, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bid_price)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 11, 2); __PYX_ERR(0, 2744, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 11, 3); __PYX_ERR(0, 2744, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quote)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 11, 4); __PYX_ERR(0, 2744, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fee_2);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_processing_duration);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coverage);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_withdrawal);
          if (value) { values[8] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_instant_float_fee);
          if (value) { values[9] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_float_fee_currency);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sell") < 0)) __PYX_ERR(0, 2744, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_volume_base = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_volume_base == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2744, __pyx_L3_error)
    __pyx_v_bid_price = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_bid_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2744, __pyx_L3_error)
    __pyx_v_base = ((PyObject*)values[3]);
    __pyx_v_quote = ((PyObject*)values[4]);
    __pyx_v_fee = values[5];
    __pyx_v_processing_duration = values[6];
    __pyx_v_coverage = ((PyObject*)values[7]);
    __pyx_v_instant_withdrawal = values[8];
    __pyx_v_instant_float_fee = values[9];
    __pyx_v_float_fee_currency = values[10];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2744, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.sell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyUnicode_Type), 1, "base", 1))) __PYX_ERR(0, 2744, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_quote), (&PyUnicode_Type), 1, "quote", 1))) __PYX_ERR(0, 2744, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coverage), (&PyUnicode_Type), 1, "coverage", 1))) __PYX_ERR(0, 2745, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_98sell(__pyx_self, __pyx_v_self, __pyx_v_volume_base, __pyx_v_bid_price, __pyx_v_base, __pyx_v_quote, __pyx_v_fee, __pyx_v_processing_duration, __pyx_v_coverage, __pyx_v_instant_withdrawal, __pyx_v_instant_float_fee, __pyx_v_float_fee_currency);

  /* "trapeza/account/fx_account.pyx":2744
 *                           instant_withdrawal, instant_float_fee)
 * 
 *     def sell(self, double volume_base, double bid_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *              str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_98sell(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_volume_base, double __pyx_v_bid_price, PyObject *__pyx_v_base, PyObject *__pyx_v_quote, PyObject *__pyx_v_fee, PyObject *__pyx_v_processing_duration, PyObject *__pyx_v_coverage, PyObject *__pyx_v_instant_withdrawal, PyObject *__pyx_v_instant_float_fee, PyObject *__pyx_v_float_fee_currency) {
  PyObject *__pyx_v_parsed_fee_currency = NULL;
  PyObject *__pyx_v_fee_volume = NULL;
  PyObject *__pyx_v_fee_currency = NULL;
  PyObject *__pyx_v_fee_exec_duration = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sell", 0);
  __Pyx_INCREF(__pyx_v_processing_duration);
  __Pyx_INCREF(__pyx_v_instant_float_fee);

  /* "trapeza/account/fx_account.pyx":2875
 *         (parsed_fee_currency,
 *          instant_float_fee,
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, base, fee,             # <<<<<<<<<<<<<<
 *                                                                        'sell_fee', instant_float_fee,
 *                                                                        processing_duration)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_fee_and_transaction_param); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "trapeza/account/fx_account.pyx":2877
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, base, fee,
 *                                                                        'sell_fee', instant_float_fee,
 *                                                                        processing_duration)             # <<<<<<<<<<<<<<
 * 
 *         # >>>sanity and type checking
 */
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_3, __pyx_v_float_fee_currency, __pyx_v_base, __pyx_v_fee, __pyx_n_u_sell_fee, __pyx_v_instant_float_fee, __pyx_v_processing_duration};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2875, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_3, __pyx_v_float_fee_currency, __pyx_v_base, __pyx_v_fee, __pyx_n_u_sell_fee, __pyx_v_instant_float_fee, __pyx_v_processing_duration};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 6+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2875, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(6+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2875, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_float_fee_currency);
    __Pyx_GIVEREF(__pyx_v_float_fee_currency);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_float_fee_currency);
    __Pyx_INCREF(__pyx_v_base);
    __Pyx_GIVEREF(__pyx_v_base);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_base);
    __Pyx_INCREF(__pyx_v_fee);
    __Pyx_GIVEREF(__pyx_v_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_fee);
    __Pyx_INCREF(__pyx_n_u_sell_fee);
    __Pyx_GIVEREF(__pyx_n_u_sell_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_n_u_sell_fee);
    __Pyx_INCREF(__pyx_v_instant_float_fee);
    __Pyx_GIVEREF(__pyx_v_instant_float_fee);
    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_v_instant_float_fee);
    __Pyx_INCREF(__pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_v_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_processing_duration);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2875, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2873, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2873, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2873, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2873, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2873, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 2; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) __PYX_ERR(0, 2873, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2873, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2873
 * 
 *         # >>>parsing inputs
 *         (parsed_fee_currency,             # <<<<<<<<<<<<<<
 *          instant_float_fee,
 *          processing_duration) = self._parse_fee_and_transaction_params(float_fee_currency, base, fee,
 */
  __pyx_v_parsed_fee_currency = __pyx_t_2;
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_instant_float_fee, __pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_processing_duration, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "trapeza/account/fx_account.pyx":2880
 * 
 *         # >>>sanity and type checking
 *         if volume_base < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sell volume in {} is < 0.'.format(base))
 * 
 */
  __pyx_t_8 = ((__pyx_v_volume_base < 0.0) != 0);
  if (unlikely(__pyx_t_8)) {

    /* "trapeza/account/fx_account.pyx":2881
 *         # >>>sanity and type checking
 *         if volume_base < 0:
 *             raise ValueError('Sell volume in {} is < 0.'.format(base))             # <<<<<<<<<<<<<<
 * 
 *         check_types([base, quote, volume_base, bid_price, parsed_fee_currency, processing_duration,
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Sell_volume_in_is_0, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_base) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_base);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2881, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 2881, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2880
 * 
 *         # >>>sanity and type checking
 *         if volume_base < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError('Sell volume in {} is < 0.'.format(base))
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2883
 *             raise ValueError('Sell volume in {} is < 0.'.format(base))
 * 
 *         check_types([base, quote, volume_base, bid_price, parsed_fee_currency, processing_duration,             # <<<<<<<<<<<<<<
 *                      instant_withdrawal, instant_float_fee, coverage],
 *                     [str, str, float, float, str, int, bool, bool, str],
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_check_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_volume_base); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_bid_price); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "trapeza/account/fx_account.pyx":2884
 * 
 *         check_types([base, quote, volume_base, bid_price, parsed_fee_currency, processing_duration,
 *                      instant_withdrawal, instant_float_fee, coverage],             # <<<<<<<<<<<<<<
 *                     [str, str, float, float, str, int, bool, bool, str],
 *                     ['base', 'quote', 'volume', 'bid_price', 'float_fee_currency', 'processing_duration',
 */
  __pyx_t_6 = PyList_New(9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_base);
  __Pyx_GIVEREF(__pyx_v_base);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_base);
  __Pyx_INCREF(__pyx_v_quote);
  __Pyx_GIVEREF(__pyx_v_quote);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_v_quote);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_2);
  PyList_SET_ITEM(__pyx_t_6, 3, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_parsed_fee_currency);
  __Pyx_GIVEREF(__pyx_v_parsed_fee_currency);
  PyList_SET_ITEM(__pyx_t_6, 4, __pyx_v_parsed_fee_currency);
  __Pyx_INCREF(__pyx_v_processing_duration);
  __Pyx_GIVEREF(__pyx_v_processing_duration);
  PyList_SET_ITEM(__pyx_t_6, 5, __pyx_v_processing_duration);
  __Pyx_INCREF(__pyx_v_instant_withdrawal);
  __Pyx_GIVEREF(__pyx_v_instant_withdrawal);
  PyList_SET_ITEM(__pyx_t_6, 6, __pyx_v_instant_withdrawal);
  __Pyx_INCREF(__pyx_v_instant_float_fee);
  __Pyx_GIVEREF(__pyx_v_instant_float_fee);
  PyList_SET_ITEM(__pyx_t_6, 7, __pyx_v_instant_float_fee);
  __Pyx_INCREF(__pyx_v_coverage);
  __Pyx_GIVEREF(__pyx_v_coverage);
  PyList_SET_ITEM(__pyx_t_6, 8, __pyx_v_coverage);
  __pyx_t_5 = 0;
  __pyx_t_2 = 0;

  /* "trapeza/account/fx_account.pyx":2885
 *         check_types([base, quote, volume_base, bid_price, parsed_fee_currency, processing_duration,
 *                      instant_withdrawal, instant_float_fee, coverage],
 *                     [str, str, float, float, str, int, bool, bool, str],             # <<<<<<<<<<<<<<
 *                     ['base', 'quote', 'volume', 'bid_price', 'float_fee_currency', 'processing_duration',
 *                      'instant_withdrawal', 'instant_float_fee', 'coverage'], self._c_ignore_type_checking)
 */
  __pyx_t_2 = PyList_New(9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_2, 3, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 4, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyList_SET_ITEM(__pyx_t_2, 5, ((PyObject *)(&PyInt_Type)));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_2, 6, ((PyObject*)&PyBool_Type));
  __Pyx_INCREF(((PyObject*)&PyBool_Type));
  __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
  PyList_SET_ITEM(__pyx_t_2, 7, ((PyObject*)&PyBool_Type));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_2, 8, ((PyObject *)(&PyUnicode_Type)));

  /* "trapeza/account/fx_account.pyx":2886
 *                      instant_withdrawal, instant_float_fee, coverage],
 *                     [str, str, float, float, str, int, bool, bool, str],
 *                     ['base', 'quote', 'volume', 'bid_price', 'float_fee_currency', 'processing_duration',             # <<<<<<<<<<<<<<
 *                      'instant_withdrawal', 'instant_float_fee', 'coverage'], self._c_ignore_type_checking)
 *         self._c_isin_depot(base.encode())
 */
  __pyx_t_5 = PyList_New(9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_base);
  __Pyx_GIVEREF(__pyx_n_u_base);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_base);
  __Pyx_INCREF(__pyx_n_u_quote);
  __Pyx_GIVEREF(__pyx_n_u_quote);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_n_u_quote);
  __Pyx_INCREF(__pyx_n_u_volume);
  __Pyx_GIVEREF(__pyx_n_u_volume);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_n_u_volume);
  __Pyx_INCREF(__pyx_n_u_bid_price);
  __Pyx_GIVEREF(__pyx_n_u_bid_price);
  PyList_SET_ITEM(__pyx_t_5, 3, __pyx_n_u_bid_price);
  __Pyx_INCREF(__pyx_n_u_float_fee_currency);
  __Pyx_GIVEREF(__pyx_n_u_float_fee_currency);
  PyList_SET_ITEM(__pyx_t_5, 4, __pyx_n_u_float_fee_currency);
  __Pyx_INCREF(__pyx_n_u_processing_duration);
  __Pyx_GIVEREF(__pyx_n_u_processing_duration);
  PyList_SET_ITEM(__pyx_t_5, 5, __pyx_n_u_processing_duration);
  __Pyx_INCREF(__pyx_n_u_instant_withdrawal);
  __Pyx_GIVEREF(__pyx_n_u_instant_withdrawal);
  PyList_SET_ITEM(__pyx_t_5, 6, __pyx_n_u_instant_withdrawal);
  __Pyx_INCREF(__pyx_n_u_instant_float_fee);
  __Pyx_GIVEREF(__pyx_n_u_instant_float_fee);
  PyList_SET_ITEM(__pyx_t_5, 7, __pyx_n_u_instant_float_fee);
  __Pyx_INCREF(__pyx_n_u_coverage);
  __Pyx_GIVEREF(__pyx_n_u_coverage);
  PyList_SET_ITEM(__pyx_t_5, 8, __pyx_n_u_coverage);

  /* "trapeza/account/fx_account.pyx":2887
 *                     [str, str, float, float, str, int, bool, bool, str],
 *                     ['base', 'quote', 'volume', 'bid_price', 'float_fee_currency', 'processing_duration',
 *                      'instant_withdrawal', 'instant_float_fee', 'coverage'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         self._c_isin_depot(base.encode())
 * 
 */
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2887, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_6, __pyx_t_2, __pyx_t_5, __pyx_t_9};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2883, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[5] = {__pyx_t_10, __pyx_t_6, __pyx_t_2, __pyx_t_5, __pyx_t_9};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2883, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2883, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_4, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_4, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_4, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_4, __pyx_t_9);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_9 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2883, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "trapeza/account/fx_account.pyx":2888
 *                     ['base', 'quote', 'volume', 'bid_price', 'float_fee_currency', 'processing_duration',
 *                      'instant_withdrawal', 'instant_float_fee', 'coverage'], self._c_ignore_type_checking)
 *         self._c_isin_depot(base.encode())             # <<<<<<<<<<<<<<
 * 
 *         # >>>evaluate fees
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_isin_depot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_base == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2888, __pyx_L1_error)
  }
  __pyx_t_11 = PyUnicode_AsEncodedString(__pyx_v_base, NULL, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_9, __pyx_t_11) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_11);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "trapeza/account/fx_account.pyx":2893
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='sell', alt_fee=fee, volume=volume_base, current_rate=bid_price,             # <<<<<<<<<<<<<<
 *                                              base=parsed_fee_currency, quote=quote,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_eval_fee); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_action_type, __pyx_n_u_sell) < 0) __PYX_ERR(0, 2893, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_alt_fee, __pyx_v_fee) < 0) __PYX_ERR(0, 2893, __pyx_L1_error)
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_volume_base); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_volume, __pyx_t_11) < 0) __PYX_ERR(0, 2893, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_bid_price); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_current_rate, __pyx_t_11) < 0) __PYX_ERR(0, 2893, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "trapeza/account/fx_account.pyx":2894
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='sell', alt_fee=fee, volume=volume_base, current_rate=bid_price,
 *                                              base=parsed_fee_currency, quote=quote,             # <<<<<<<<<<<<<<
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 * 
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_base, __pyx_v_parsed_fee_currency) < 0) __PYX_ERR(0, 2893, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_quote, __pyx_v_quote) < 0) __PYX_ERR(0, 2893, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2895
 *          fee_exec_duration) = self._eval_fee(action_type='sell', alt_fee=fee, volume=volume_base, current_rate=bid_price,
 *                                              base=parsed_fee_currency, quote=quote,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))             # <<<<<<<<<<<<<<
 * 
 *         # >>>handle coverage exception induced by fees
 */
  __pyx_t_11 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_instant_float_fee, 1, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = PyNumber_Multiply(__pyx_v_processing_duration, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_processing_duration, __pyx_t_9) < 0) __PYX_ERR(0, 2893, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "trapeza/account/fx_account.pyx":2893
 *         (fee_volume,
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='sell', alt_fee=fee, volume=volume_base, current_rate=bid_price,             # <<<<<<<<<<<<<<
 *                                              base=parsed_fee_currency, quote=quote,
 *                                              processing_duration=processing_duration * (1 - instant_float_fee))
 */
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
    PyObject* sequence = __pyx_t_9;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2891, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_11 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_11)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_11);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_5), 3) < 0) __PYX_ERR(0, 2891, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L7_unpacking_done;
    __pyx_L6_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2891, __pyx_L1_error)
    __pyx_L7_unpacking_done:;
  }

  /* "trapeza/account/fx_account.pyx":2891
 * 
 *         # >>>evaluate fees
 *         (fee_volume,             # <<<<<<<<<<<<<<
 *          fee_currency,
 *          fee_exec_duration) = self._eval_fee(action_type='sell', alt_fee=fee, volume=volume_base, current_rate=bid_price,
 */
  __pyx_v_fee_volume = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_fee_currency = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_fee_exec_duration = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "trapeza/account/fx_account.pyx":2898
 * 
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'partial', 'debit', 'ignore']:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')
 * 
 */
  __Pyx_INCREF(__pyx_v_coverage);
  __pyx_t_12 = __pyx_v_coverage;
  __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_except, Py_NE)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 2898, __pyx_L1_error)
  __pyx_t_14 = (__pyx_t_13 != 0);
  if (__pyx_t_14) {
  } else {
    __pyx_t_8 = __pyx_t_14;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_14 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_partial, Py_NE)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 2898, __pyx_L1_error)
  __pyx_t_13 = (__pyx_t_14 != 0);
  if (__pyx_t_13) {
  } else {
    __pyx_t_8 = __pyx_t_13;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_debit, Py_NE)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 2898, __pyx_L1_error)
  __pyx_t_14 = (__pyx_t_13 != 0);
  if (__pyx_t_14) {
  } else {
    __pyx_t_8 = __pyx_t_14;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_14 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_ignore, Py_NE)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 2898, __pyx_L1_error)
  __pyx_t_13 = (__pyx_t_14 != 0);
  __pyx_t_8 = __pyx_t_13;
  __pyx_L9_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_13 = (__pyx_t_8 != 0);
  if (unlikely(__pyx_t_13)) {

    /* "trapeza/account/fx_account.pyx":2899
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'partial', 'debit', 'ignore']:
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')             # <<<<<<<<<<<<<<
 * 
 *         return self.c_sell(volume_base, bid_price, base.encode(), quote.encode(), fee_volume, fee_currency.encode(),
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2899, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __PYX_ERR(0, 2899, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2898
 * 
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'partial', 'debit', 'ignore']:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2901
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')
 * 
 *         return self.c_sell(volume_base, bid_price, base.encode(), quote.encode(), fee_volume, fee_currency.encode(),             # <<<<<<<<<<<<<<
 *                            fee_exec_duration, processing_duration, coverage.encode(),
 *                            instant_withdrawal, instant_float_fee)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_sell); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2901, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_volume_base); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2901, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_bid_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2901, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_base == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2901, __pyx_L1_error)
  }
  __pyx_t_5 = PyUnicode_AsEncodedString(__pyx_v_base, NULL, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2901, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(__pyx_v_quote == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2901, __pyx_L1_error)
  }
  __pyx_t_2 = PyUnicode_AsEncodedString(__pyx_v_quote, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2901, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_fee_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2901, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  __pyx_t_6 = (__pyx_t_15) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_15) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2901, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "trapeza/account/fx_account.pyx":2902
 * 
 *         return self.c_sell(volume_base, bid_price, base.encode(), quote.encode(), fee_volume, fee_currency.encode(),
 *                            fee_exec_duration, processing_duration, coverage.encode(),             # <<<<<<<<<<<<<<
 *                            instant_withdrawal, instant_float_fee)
 * 
 */
  if (unlikely(__pyx_v_coverage == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2902, __pyx_L1_error)
  }
  __pyx_t_10 = PyUnicode_AsEncodedString(__pyx_v_coverage, NULL, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2902, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);

  /* "trapeza/account/fx_account.pyx":2903
 *         return self.c_sell(volume_base, bid_price, base.encode(), quote.encode(), fee_volume, fee_currency.encode(),
 *                            fee_exec_duration, processing_duration, coverage.encode(),
 *                            instant_withdrawal, instant_float_fee)             # <<<<<<<<<<<<<<
 * 
 *     def tick(self, clock=None):
 */
  __pyx_t_15 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_11)) {
    PyObject *__pyx_temp[12] = {__pyx_t_15, __pyx_t_3, __pyx_t_1, __pyx_t_5, __pyx_t_2, __pyx_v_fee_volume, __pyx_t_6, __pyx_v_fee_exec_duration, __pyx_v_processing_duration, __pyx_t_10, __pyx_v_instant_withdrawal, __pyx_v_instant_float_fee};
    __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_4, 11+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2901, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
    PyObject *__pyx_temp[12] = {__pyx_t_15, __pyx_t_3, __pyx_t_1, __pyx_t_5, __pyx_t_2, __pyx_v_fee_volume, __pyx_t_6, __pyx_v_fee_exec_duration, __pyx_v_processing_duration, __pyx_t_10, __pyx_v_instant_withdrawal, __pyx_v_instant_float_fee};
    __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_4, 11+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2901, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  {
    __pyx_t_16 = PyTuple_New(11+__pyx_t_4); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    if (__pyx_t_15) {
      __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_4, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_4, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_4, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_16, 3+__pyx_t_4, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_v_fee_volume);
    PyTuple_SET_ITEM(__pyx_t_16, 4+__pyx_t_4, __pyx_v_fee_volume);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_16, 5+__pyx_t_4, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_fee_exec_duration);
    __Pyx_GIVEREF(__pyx_v_fee_exec_duration);
    PyTuple_SET_ITEM(__pyx_t_16, 6+__pyx_t_4, __pyx_v_fee_exec_duration);
    __Pyx_INCREF(__pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_v_processing_duration);
    PyTuple_SET_ITEM(__pyx_t_16, 7+__pyx_t_4, __pyx_v_processing_duration);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_16, 8+__pyx_t_4, __pyx_t_10);
    __Pyx_INCREF(__pyx_v_instant_withdrawal);
    __Pyx_GIVEREF(__pyx_v_instant_withdrawal);
    PyTuple_SET_ITEM(__pyx_t_16, 9+__pyx_t_4, __pyx_v_instant_withdrawal);
    __Pyx_INCREF(__pyx_v_instant_float_fee);
    __Pyx_GIVEREF(__pyx_v_instant_float_fee);
    PyTuple_SET_ITEM(__pyx_t_16, 10+__pyx_t_4, __pyx_v_instant_float_fee);
    __pyx_t_3 = 0;
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_10 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_16, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":2744
 *                           instant_withdrawal, instant_float_fee)
 * 
 *     def sell(self, double volume_base, double bid_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *              str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.sell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parsed_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_volume);
  __Pyx_XDECREF(__pyx_v_fee_currency);
  __Pyx_XDECREF(__pyx_v_fee_exec_duration);
  __Pyx_XDECREF(__pyx_v_processing_duration);
  __Pyx_XDECREF(__pyx_v_instant_float_fee);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2905
 *                            instant_withdrawal, instant_float_fee)
 * 
 *     def tick(self, clock=None):             # <<<<<<<<<<<<<<
 *         """
 *         If clock=None, then counts internal clock up by one time base unit.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_101tick(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_100tick[] = "\n        If clock=None, then counts internal clock up by one time base unit.\n        Else internal clock is set to param:clock as new internal time step.\n        Executes exec_heap (see stack automaton logic implemented as heap data structure described in docstring of\n        class) after new clock time is set, e.g. executing all due transactions, which were delayed due to processing\n        times. All transactions on heap, whose execution times (defined as time step of instructing transaction +\n        processing duration) are less than the new clock time, will be executed from oldest to newest up to the new\n        clock time. Transactions allocated in the future w.r.t. the new clock time will of course not be executed but\n        remain on the heap until they are due (w.r.t internal clock).\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param clock: {int >= 0, None}, default=None\n                      if clock=None, then count up by one. If clock is integer, set internal clock to param:clock.\n        :return: int, current (freshly set) clock time\n        :raises: TypeError: if clock is not int or clock < 0\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_101tick = {"tick", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_101tick, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_100tick};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_101tick(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_clock = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tick (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_clock,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_clock);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tick") < 0)) __PYX_ERR(0, 2905, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_clock = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tick", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2905, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.tick", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_100tick(__pyx_self, __pyx_v_self, __pyx_v_clock);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_100tick(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_clock) {
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  char const *__pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tick", 0);
  __Pyx_INCREF(__pyx_v_clock);

  /* "trapeza/account/fx_account.pyx":2923
 *         :raises: TypeError: if clock is not int or clock < 0
 *         """
 *         if clock is None:             # <<<<<<<<<<<<<<
 *             clock = self._c_clock + 1
 *         elif not self._c_ignore_type_checking:
 */
  __pyx_t_1 = (__pyx_v_clock == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "trapeza/account/fx_account.pyx":2924
 *         """
 *         if clock is None:
 *             clock = self._c_clock + 1             # <<<<<<<<<<<<<<
 *         elif not self._c_ignore_type_checking:
 *             try:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_clock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2924, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2924, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_clock, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "trapeza/account/fx_account.pyx":2923
 *         :raises: TypeError: if clock is not int or clock < 0
 *         """
 *         if clock is None:             # <<<<<<<<<<<<<<
 *             clock = self._c_clock + 1
 *         elif not self._c_ignore_type_checking:
 */
    goto __pyx_L3;
  }

  /* "trapeza/account/fx_account.pyx":2925
 *         if clock is None:
 *             clock = self._c_clock + 1
 *         elif not self._c_ignore_type_checking:             # <<<<<<<<<<<<<<
 *             try:
 *                 if 0 <= clock == int(clock):
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2925, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2925, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = ((!__pyx_t_2) != 0);
  if (__pyx_t_1) {

    /* "trapeza/account/fx_account.pyx":2926
 *             clock = self._c_clock + 1
 *         elif not self._c_ignore_type_checking:
 *             try:             # <<<<<<<<<<<<<<
 *                 if 0 <= clock == int(clock):
 *                     pass
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      /*try:*/ {

        /* "trapeza/account/fx_account.pyx":2927
 *         elif not self._c_ignore_type_checking:
 *             try:
 *                 if 0 <= clock == int(clock):             # <<<<<<<<<<<<<<
 *                     pass
 *                 else:
 */
        __pyx_t_4 = PyObject_RichCompare(__pyx_int_0, __pyx_v_clock, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2927, __pyx_L4_error)
        if (__Pyx_PyObject_IsTrue(__pyx_t_4)) {
          __Pyx_DECREF(__pyx_t_4);
          __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_clock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2927, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = PyObject_RichCompare(__pyx_v_clock, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2927, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2927, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (likely(__pyx_t_1)) {
          goto __pyx_L10;
        }

        /* "trapeza/account/fx_account.pyx":2930
 *                     pass
 *                 else:
 *                     raise TypeError('clock has to be int >= 0.')             # <<<<<<<<<<<<<<
 *             except Exception as e:
 *                 raise e
 */
        /*else*/ {
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2930, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_Raise(__pyx_t_4, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __PYX_ERR(0, 2930, __pyx_L4_error)
        }
        __pyx_L10:;

        /* "trapeza/account/fx_account.pyx":2926
 *             clock = self._c_clock + 1
 *         elif not self._c_ignore_type_checking:
 *             try:             # <<<<<<<<<<<<<<
 *                 if 0 <= clock == int(clock):
 *                     pass
 */
      }
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L9_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "trapeza/account/fx_account.pyx":2931
 *                 else:
 *                     raise TypeError('clock has to be int >= 0.')
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 raise e
 * 
 */
      __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
      if (__pyx_t_8) {
        __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.tick", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 2931, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __pyx_v_e = __pyx_t_3;
        /*try:*/ {

          /* "trapeza/account/fx_account.pyx":2932
 *                     raise TypeError('clock has to be int >= 0.')
 *             except Exception as e:
 *                 raise e             # <<<<<<<<<<<<<<
 * 
 *         return self.c_tick(clock)
 */
          __Pyx_Raise(__pyx_v_e, 0, 0, 0);
          __PYX_ERR(0, 2932, __pyx_L16_error)
        }

        /* "trapeza/account/fx_account.pyx":2931
 *                 else:
 *                     raise TypeError('clock has to be int >= 0.')
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 raise e
 * 
 */
        /*finally:*/ {
          __pyx_L16_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
            if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
            if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_15);
            __Pyx_XGOTREF(__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_17);
            __pyx_t_8 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
            {
              __Pyx_DECREF(__pyx_v_e);
              __pyx_v_e = NULL;
            }
            if (PY_MAJOR_VERSION >= 3) {
              __Pyx_XGIVEREF(__pyx_t_15);
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
            }
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
            __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
            goto __pyx_L6_except_error;
          }
        }
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;

      /* "trapeza/account/fx_account.pyx":2926
 *             clock = self._c_clock + 1
 *         elif not self._c_ignore_type_checking:
 *             try:             # <<<<<<<<<<<<<<
 *                 if 0 <= clock == int(clock):
 *                     pass
 */
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L1_error;
      __pyx_L9_try_end:;
    }

    /* "trapeza/account/fx_account.pyx":2925
 *         if clock is None:
 *             clock = self._c_clock + 1
 *         elif not self._c_ignore_type_checking:             # <<<<<<<<<<<<<<
 *             try:
 *                 if 0 <= clock == int(clock):
 */
  }
  __pyx_L3:;

  /* "trapeza/account/fx_account.pyx":2934
 *                 raise e
 * 
 *         return self.c_tick(clock)             # <<<<<<<<<<<<<<
 * 
 *     def update_exchange_rate(self, double rate, str base, str quote):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_tick); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_9 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_clock) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_clock);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_9;
  __pyx_t_9 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":2905
 *                            instant_withdrawal, instant_float_fee)
 * 
 *     def tick(self, clock=None):             # <<<<<<<<<<<<<<
 *         """
 *         If clock=None, then counts internal clock up by one time base unit.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.tick", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XDECREF(__pyx_v_clock);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2936
 *         return self.c_tick(clock)
 * 
 *     def update_exchange_rate(self, double rate, str base, str quote):             # <<<<<<<<<<<<<<
 *         """
 *         It is highly recommended not to use this class method, but use self.batch_update_exchange_rates instead!
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_103update_exchange_rate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_102update_exchange_rate[] = "\n        It is highly recommended not to use this class method, but use self.batch_update_exchange_rates instead!\n\n\n        Update and/ or add exchange rate (within self.exchange_rates dictionary) for base|quote pair in\n        self.exchange_rates dictionary.\n        Use FX direct notation, see docstring of class for further information on notation convention.\n\n        It's sufficient enough, to just provide base|quote ratio. quote|base ratio does not have to be added separately\n        and will be calculated automatically.\n\n        This method updates the class attribute self.exchange_rates (just one entry at a time).\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param rate: float,\n                     use FX direct notation of base|quote pair, see docstring of class for further information\n        :param base: str\n        :param quote: str\n        :return: None\n        :raises: TypeError if parameters do not match specified types\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_103update_exchange_rate = {"update_exchange_rate", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_103update_exchange_rate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_102update_exchange_rate};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_103update_exchange_rate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  double __pyx_v_rate;
  PyObject *__pyx_v_base = 0;
  PyObject *__pyx_v_quote = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update_exchange_rate (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_rate,&__pyx_n_s_base,&__pyx_n_s_quote,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rate)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("update_exchange_rate", 1, 4, 4, 1); __PYX_ERR(0, 2936, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("update_exchange_rate", 1, 4, 4, 2); __PYX_ERR(0, 2936, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quote)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("update_exchange_rate", 1, 4, 4, 3); __PYX_ERR(0, 2936, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "update_exchange_rate") < 0)) __PYX_ERR(0, 2936, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_self = values[0];
    __pyx_v_rate = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_rate == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2936, __pyx_L3_error)
    __pyx_v_base = ((PyObject*)values[2]);
    __pyx_v_quote = ((PyObject*)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("update_exchange_rate", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2936, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.update_exchange_rate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyUnicode_Type), 1, "base", 1))) __PYX_ERR(0, 2936, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_quote), (&PyUnicode_Type), 1, "quote", 1))) __PYX_ERR(0, 2936, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_102update_exchange_rate(__pyx_self, __pyx_v_self, __pyx_v_rate, __pyx_v_base, __pyx_v_quote);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_102update_exchange_rate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_rate, PyObject *__pyx_v_base, PyObject *__pyx_v_quote) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("update_exchange_rate", 0);

  /* "trapeza/account/fx_account.pyx":2960
 *         """
 *         # >>>type check
 *         check_types([rate, base, quote], [float, str, str], ['rate', 'base', 'quote'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *         self.c_update_exchange_rate(rate, base.encode(), quote.encode())
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_rate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_base);
  __Pyx_GIVEREF(__pyx_v_base);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_v_base);
  __Pyx_INCREF(__pyx_v_quote);
  __Pyx_GIVEREF(__pyx_v_quote);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_v_quote);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)(&PyFloat_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_3, 1, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_3, 2, ((PyObject *)(&PyUnicode_Type)));
  __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_rate);
  __Pyx_GIVEREF(__pyx_n_u_rate);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_rate);
  __Pyx_INCREF(__pyx_n_u_base);
  __Pyx_GIVEREF(__pyx_n_u_base);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_n_u_base);
  __Pyx_INCREF(__pyx_n_u_quote);
  __Pyx_GIVEREF(__pyx_n_u_quote);
  PyList_SET_ITEM(__pyx_t_5, 2, __pyx_n_u_quote);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_4, __pyx_t_3, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2960, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_4, __pyx_t_3, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2960, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2960, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, __pyx_t_6);
    __pyx_t_4 = 0;
    __pyx_t_3 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2960, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":2962
 *         check_types([rate, base, quote], [float, str, str], ['rate', 'base', 'quote'], self._c_ignore_type_checking)
 * 
 *         self.c_update_exchange_rate(rate, base.encode(), quote.encode())             # <<<<<<<<<<<<<<
 * 
 *     def batch_update_exchange_rates(self, list_rates, list_base_quote_pairs):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_update_exchange_rate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = PyFloat_FromDouble(__pyx_v_rate); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (unlikely(__pyx_v_base == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2962, __pyx_L1_error)
  }
  __pyx_t_6 = PyUnicode_AsEncodedString(__pyx_v_base, NULL, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (unlikely(__pyx_v_quote == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 2962, __pyx_L1_error)
  }
  __pyx_t_5 = PyUnicode_AsEncodedString(__pyx_v_quote, NULL, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_9, __pyx_t_6, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2962, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_9, __pyx_t_6, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2962, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2962, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_8, __pyx_t_5);
    __pyx_t_9 = 0;
    __pyx_t_6 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2962, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":2936
 *         return self.c_tick(clock)
 * 
 *     def update_exchange_rate(self, double rate, str base, str quote):             # <<<<<<<<<<<<<<
 *         """
 *         It is highly recommended not to use this class method, but use self.batch_update_exchange_rates instead!
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.update_exchange_rate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":2964
 *         self.c_update_exchange_rate(rate, base.encode(), quote.encode())
 * 
 *     def batch_update_exchange_rates(self, list_rates, list_base_quote_pairs):             # <<<<<<<<<<<<<<
 *         """
 *         Performs batch update of exchange rates of multiple currency pairs (or assets), whereas
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_105batch_update_exchange_rates(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_104batch_update_exchange_rates[] = "\n        Performs batch update of exchange rates of multiple currency pairs (or assets), whereas\n        self.update_exchange_rate() only updates one exchange rate pair at once.\n        It's sufficient enough, to just provide base|quote ratio. quote|base ratio does not have to be added separately\n        and will be calculated automatically.\n\n        If one wants to call self.total_balance() without arguments, then this method has to be called beforehand.\n\n        It is highly recommended, that all pairs, which are also present within depot (as single positions not as pairs\n        directly), are present in the update arguments of this method. Otherwise self.total_balance() might throw an\n        exception in certain circumstances! The safest way is to not use this method at all but call\n        self.total_balance() with appropriate input data argument!\n\n        This method updates the class attribute self.exchange_rates.\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param list_rates: list of floats,\n                           exchange rate of base|quote pair\n                           Rate is given in FX direct notation of base|quote, see docstring of class for further\n                           information on notation convention (simply speaking: just plug in official exchange rates\n                           from base|quote pair which one can find on any website providing financial data)\n        :param list_base_quote_pairs: list of tuples(base, quote),\n                                     base|quote pair in FX direct notation, see docstring of class\n                                     base: str\n                                     quote: str\n        :return: None\n        :raises: TypeError if parameters do not match specified types\n                 IndexError: if lists don't have same length\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_105batch_update_exchange_rates = {"batch_update_exchange_rates", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_105batch_update_exchange_rates, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_104batch_update_exchange_rates};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_105batch_update_exchange_rates(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_list_rates = 0;
  PyObject *__pyx_v_list_base_quote_pairs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("batch_update_exchange_rates (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_list_rates,&__pyx_n_s_list_base_quote_pairs,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_list_rates)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_update_exchange_rates", 1, 3, 3, 1); __PYX_ERR(0, 2964, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_list_base_quote_pairs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_update_exchange_rates", 1, 3, 3, 2); __PYX_ERR(0, 2964, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "batch_update_exchange_rates") < 0)) __PYX_ERR(0, 2964, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_list_rates = values[1];
    __pyx_v_list_base_quote_pairs = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("batch_update_exchange_rates", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2964, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.batch_update_exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_104batch_update_exchange_rates(__pyx_self, __pyx_v_self, __pyx_v_list_rates, __pyx_v_list_base_quote_pairs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_104batch_update_exchange_rates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_list_rates, PyObject *__pyx_v_list_base_quote_pairs) {
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("batch_update_exchange_rates", 0);

  /* "trapeza/account/fx_account.pyx":2995
 *                  IndexError: if lists don't have same length
 *         """
 *         if not (len(list_rates) == len(list_base_quote_pairs)):             # <<<<<<<<<<<<<<
 *             raise IndexError('Lists must have same length.')
 * 
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_list_rates); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2995, __pyx_L1_error)
  __pyx_t_2 = PyObject_Length(__pyx_v_list_base_quote_pairs); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2995, __pyx_L1_error)
  __pyx_t_3 = ((!((__pyx_t_1 == __pyx_t_2) != 0)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "trapeza/account/fx_account.pyx":2996
 *         """
 *         if not (len(list_rates) == len(list_base_quote_pairs)):
 *             raise IndexError('Lists must have same length.')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(len(list_rates)):
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2996, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2996, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":2995
 *                  IndexError: if lists don't have same length
 *         """
 *         if not (len(list_rates) == len(list_base_quote_pairs)):             # <<<<<<<<<<<<<<
 *             raise IndexError('Lists must have same length.')
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":2998
 *             raise IndexError('Lists must have same length.')
 * 
 *         for i in range(len(list_rates)):             # <<<<<<<<<<<<<<
 *             # noinspection PyUnresolvedReferences
 *             check_types([list_rates[i], list_base_quote_pairs[i]], [float, tuple],
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_list_rates); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2998, __pyx_L1_error)
  __pyx_t_1 = __pyx_t_2;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_1; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "trapeza/account/fx_account.pyx":3000
 *         for i in range(len(list_rates)):
 *             # noinspection PyUnresolvedReferences
 *             check_types([list_rates[i], list_base_quote_pairs[i]], [float, tuple],             # <<<<<<<<<<<<<<
 *                         ['list_rates must contain floats or ints', 'list_base_quote_pairs must contain tuples'],
 *                         self._c_ignore_type_checking)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_check_types); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3000, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_list_rates, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3000, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_list_base_quote_pairs, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3000, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = PyList_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3000, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_7);
    PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyList_SET_ITEM(__pyx_t_9, 1, __pyx_t_8);
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3000, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
    PyList_SET_ITEM(__pyx_t_8, 0, ((PyObject *)(&PyFloat_Type)));
    __Pyx_INCREF(((PyObject *)(&PyTuple_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type)));
    PyList_SET_ITEM(__pyx_t_8, 1, ((PyObject *)(&PyTuple_Type)));

    /* "trapeza/account/fx_account.pyx":3001
 *             # noinspection PyUnresolvedReferences
 *             check_types([list_rates[i], list_base_quote_pairs[i]], [float, tuple],
 *                         ['list_rates must contain floats or ints', 'list_base_quote_pairs must contain tuples'],             # <<<<<<<<<<<<<<
 *                         self._c_ignore_type_checking)
 *         return self.c_batch_update_exchange_rates(list_rates, list_base_quote_pairs)
 */
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3001, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_kp_u_list_rates_must_contain_floats_o);
    __Pyx_GIVEREF(__pyx_kp_u_list_rates_must_contain_floats_o);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_list_rates_must_contain_floats_o);
    __Pyx_INCREF(__pyx_kp_u_list_base_quote_pairs_must_conta);
    __Pyx_GIVEREF(__pyx_kp_u_list_base_quote_pairs_must_conta);
    PyList_SET_ITEM(__pyx_t_7, 1, __pyx_kp_u_list_base_quote_pairs_must_conta);

    /* "trapeza/account/fx_account.pyx":3002
 *             check_types([list_rates[i], list_base_quote_pairs[i]], [float, tuple],
 *                         ['list_rates must contain floats or ints', 'list_base_quote_pairs must contain tuples'],
 *                         self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 *         return self.c_batch_update_exchange_rates(list_rates, list_base_quote_pairs)
 * 
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3002, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_9, __pyx_t_8, __pyx_t_7, __pyx_t_10};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 4+__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3000, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_9, __pyx_t_8, __pyx_t_7, __pyx_t_10};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 4+__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3000, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(4+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3000, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_12, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_12, __pyx_t_10);
      __pyx_t_9 = 0;
      __pyx_t_8 = 0;
      __pyx_t_7 = 0;
      __pyx_t_10 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_13, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3000, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "trapeza/account/fx_account.pyx":3003
 *                         ['list_rates must contain floats or ints', 'list_base_quote_pairs must contain tuples'],
 *                         self._c_ignore_type_checking)
 *         return self.c_batch_update_exchange_rates(list_rates, list_base_quote_pairs)             # <<<<<<<<<<<<<<
 * 
 *     def total_balance(self, exchange_rates=None, reference_currency=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_batch_update_exchange_rates); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_13 = NULL;
  __pyx_t_12 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_12 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_list_rates, __pyx_v_list_base_quote_pairs};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3003, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_list_rates, __pyx_v_list_base_quote_pairs};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3003, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3003, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_INCREF(__pyx_v_list_rates);
    __Pyx_GIVEREF(__pyx_v_list_rates);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_12, __pyx_v_list_rates);
    __Pyx_INCREF(__pyx_v_list_base_quote_pairs);
    __Pyx_GIVEREF(__pyx_v_list_base_quote_pairs);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_12, __pyx_v_list_base_quote_pairs);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3003, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":2964
 *         self.c_update_exchange_rate(rate, base.encode(), quote.encode())
 * 
 *     def batch_update_exchange_rates(self, list_rates, list_base_quote_pairs):             # <<<<<<<<<<<<<<
 *         """
 *         Performs batch update of exchange rates of multiple currency pairs (or assets), whereas
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.batch_update_exchange_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":3005
 *         return self.c_batch_update_exchange_rates(list_rates, list_base_quote_pairs)
 * 
 *     def total_balance(self, exchange_rates=None, reference_currency=None):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates current value of all assets within self.depot in reference currency.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_107total_balance(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_106total_balance[] = "\n        Calculates current value of all assets within self.depot in reference currency.\n\n        If exchange_rate=None, then self.batch_update_exchange_rates() has to be called beforehand.\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param exchange_rates: {dict, None}, default=None\n                               if None, self.exchange_rates will be used (if set at initialization)\n\n                               !!! call self.batch_update_exchange_rate before calling this\n                                   function if param:exchange_rate=None !!!\n\n                               exchange_rates are given in base|quote FX direct notation, see docstring of class for\n                               further information on notation convention (simply speaking: just plug in official\n                               exchange rates from base|quote pair which one can find on any website providing\n                               financial data)\n\n                               key: tuple of (str, str)\n                                    (base, quote) --> (from_currency, to_currency)\n                                    All currencies contained in self.depot can be interpreted as base.\n                                    reference currency (or self.reference_currency if reference_currency=None) can be\n                                    interpreted as quote.\n\n                                    base: str\n                                    quote: str\n\n                                    Furthermore, it does not matter if data is provided as (base, quote) or\n                                    (quote, base), inverting is done automatically internally.\n                                    Supplying exchange rate data as one of the two tuple variants is sufficient (user\n                                    does not have to supply base|quote and quote|base, but just one of them).\n                               value: float,""\n                                      exchange_rate of base|quote pair\n\n                               It's sufficient enough, to just provide base|quote ratio.\n                               quote|base ratio does not have to be added separately and is calculated automatically.\n        :param reference_currency: {str, None}, default=None\n                                   if None, reference_currency is set to self.reference_currency\n        :return: float\n        :raises: KeyError: if exchange_rates does not include all currencies listed in account depot\n                 TypeError: if parameters do not match specified types\n                 ValueError: if exchange rates of base|quote and 1/quote|base do not match up\n                 trapeza.exception.OperatingError: if this method is called with exchange_rate=None and exchange rates\n                                                   have not been updated otherwise beforehand\n                                                   (e.g. self.batch_update_exchange_rates)\n                                                   or\n                                                   if somehow else both exchange_rate=None and self.exchange_rates=None\n        TODO: assume exchange_rate=0 if currency not in data (?) -> safer not to implement this convention\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_107total_balance = {"total_balance", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_107total_balance, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_106total_balance};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_107total_balance(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_exchange_rates = 0;
  PyObject *__pyx_v_reference_currency = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("total_balance (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_exchange_rates,&__pyx_n_s_reference_currency,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)((PyObject *)Py_None));
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exchange_rates);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reference_currency);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "total_balance") < 0)) __PYX_ERR(0, 3005, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_exchange_rates = values[1];
    __pyx_v_reference_currency = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("total_balance", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3005, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.total_balance", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_106total_balance(__pyx_self, __pyx_v_self, __pyx_v_exchange_rates, __pyx_v_reference_currency);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_106total_balance(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_exchange_rates, PyObject *__pyx_v_reference_currency) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("total_balance", 0);
  __Pyx_INCREF(__pyx_v_exchange_rates);
  __Pyx_INCREF(__pyx_v_reference_currency);

  /* "trapeza/account/fx_account.pyx":3056
 *         """
 *         # >>>check if exchange rates have been updated if internal exchange rates are taken for calculations
 *         if not self._c_is_exchange_rate_updated and exchange_rates is None:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.OperatingError('Exchange rates have not been updated before calling. Please call '
 *                                                'self.batch_update_exchange_rates beforehand.')
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_is_exchange_rate_updated); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 3056, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = ((!__pyx_t_3) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_exchange_rates == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "trapeza/account/fx_account.pyx":3057
 *         # >>>check if exchange rates have been updated if internal exchange rates are taken for calculations
 *         if not self._c_is_exchange_rate_updated and exchange_rates is None:
 *             raise tpz_exception.OperatingError('Exchange rates have not been updated before calling. Please call '             # <<<<<<<<<<<<<<
 *                                                'self.batch_update_exchange_rates beforehand.')
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3057, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_OperatingError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3057, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_kp_u_Exchange_rates_have_not_been_upd) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_u_Exchange_rates_have_not_been_upd);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3057, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 3057, __pyx_L1_error)

    /* "trapeza/account/fx_account.pyx":3056
 *         """
 *         # >>>check if exchange rates have been updated if internal exchange rates are taken for calculations
 *         if not self._c_is_exchange_rate_updated and exchange_rates is None:             # <<<<<<<<<<<<<<
 *             raise tpz_exception.OperatingError('Exchange rates have not been updated before calling. Please call '
 *                                                'self.batch_update_exchange_rates beforehand.')
 */
  }

  /* "trapeza/account/fx_account.pyx":3061
 * 
 *         # >>>parsing
 *         if reference_currency is None:             # <<<<<<<<<<<<<<
 *             reference_currency = self._c_reference_currency.decode()    # self.reference_currency
 * 
 */
  __pyx_t_1 = (__pyx_v_reference_currency == Py_None);
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "trapeza/account/fx_account.pyx":3062
 *         # >>>parsing
 *         if reference_currency is None:
 *             reference_currency = self._c_reference_currency.decode()    # self.reference_currency             # <<<<<<<<<<<<<<
 * 
 *         if exchange_rates is None:
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_reference_currency); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3062, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_decode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3062, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3062, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_reference_currency, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "trapeza/account/fx_account.pyx":3061
 * 
 *         # >>>parsing
 *         if reference_currency is None:             # <<<<<<<<<<<<<<
 *             reference_currency = self._c_reference_currency.decode()    # self.reference_currency
 * 
 */
  }

  /* "trapeza/account/fx_account.pyx":3064
 *             reference_currency = self._c_reference_currency.decode()    # self.reference_currency
 * 
 *         if exchange_rates is None:             # <<<<<<<<<<<<<<
 *             exchange_rates = self._c_exchange_rates
 *         else:
 */
  __pyx_t_3 = (__pyx_v_exchange_rates == Py_None);
  __pyx_t_1 = (__pyx_t_3 != 0);
  if (__pyx_t_1) {

    /* "trapeza/account/fx_account.pyx":3065
 * 
 *         if exchange_rates is None:
 *             exchange_rates = self._c_exchange_rates             # <<<<<<<<<<<<<<
 *         else:
 *             # >>>type check
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_exchange_rates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3065, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_exchange_rates, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "trapeza/account/fx_account.pyx":3064
 *             reference_currency = self._c_reference_currency.decode()    # self.reference_currency
 * 
 *         if exchange_rates is None:             # <<<<<<<<<<<<<<
 *             exchange_rates = self._c_exchange_rates
 *         else:
 */
    goto __pyx_L7;
  }

  /* "trapeza/account/fx_account.pyx":3068
 *         else:
 *             # >>>type check
 *             if len(exchange_rates) == 0:             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.OperatingError('Exchange rates contain empty dict.')
 * 
 */
  /*else*/ {
    __pyx_t_7 = PyObject_Length(__pyx_v_exchange_rates); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3068, __pyx_L1_error)
    __pyx_t_1 = ((__pyx_t_7 == 0) != 0);
    if (unlikely(__pyx_t_1)) {

      /* "trapeza/account/fx_account.pyx":3069
 *             # >>>type check
 *             if len(exchange_rates) == 0:
 *                 raise tpz_exception.OperatingError('Exchange rates contain empty dict.')             # <<<<<<<<<<<<<<
 * 
 *             exchange_rates = self._parse_exchange_rates(exchange_rates, self._c_ignore_type_checking)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_tpz_exception); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3069, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_OperatingError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3069, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_kp_u_Exchange_rates_contain_empty_dic) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_u_Exchange_rates_contain_empty_dic);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3069, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 3069, __pyx_L1_error)

      /* "trapeza/account/fx_account.pyx":3068
 *         else:
 *             # >>>type check
 *             if len(exchange_rates) == 0:             # <<<<<<<<<<<<<<
 *                 raise tpz_exception.OperatingError('Exchange rates contain empty dict.')
 * 
 */
    }

    /* "trapeza/account/fx_account.pyx":3071
 *                 raise tpz_exception.OperatingError('Exchange rates contain empty dict.')
 * 
 *             exchange_rates = self._parse_exchange_rates(exchange_rates, self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *         check_types([reference_currency, exchange_rates], [str, dict],
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_parse_exchange_rates); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3071, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3071, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_exchange_rates, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3071, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_exchange_rates, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3071, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3071, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(__pyx_v_exchange_rates);
      __Pyx_GIVEREF(__pyx_v_exchange_rates);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_exchange_rates);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3071, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_exchange_rates, __pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L7:;

  /* "trapeza/account/fx_account.pyx":3073
 *             exchange_rates = self._parse_exchange_rates(exchange_rates, self._c_ignore_type_checking)
 * 
 *         check_types([reference_currency, exchange_rates], [str, dict],             # <<<<<<<<<<<<<<
 *                     ['reference_currency', 'exchange_rates dict'], self._c_ignore_type_checking)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_check_types); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3073, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_10 = PyList_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3073, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_INCREF(__pyx_v_reference_currency);
  __Pyx_GIVEREF(__pyx_v_reference_currency);
  PyList_SET_ITEM(__pyx_t_10, 0, __pyx_v_reference_currency);
  __Pyx_INCREF(__pyx_v_exchange_rates);
  __Pyx_GIVEREF(__pyx_v_exchange_rates);
  PyList_SET_ITEM(__pyx_t_10, 1, __pyx_v_exchange_rates);
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3073, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_5, 0, ((PyObject *)(&PyUnicode_Type)));
  __Pyx_INCREF(((PyObject *)(&PyDict_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyDict_Type)));
  PyList_SET_ITEM(__pyx_t_5, 1, ((PyObject *)(&PyDict_Type)));

  /* "trapeza/account/fx_account.pyx":3074
 * 
 *         check_types([reference_currency, exchange_rates], [str, dict],
 *                     ['reference_currency', 'exchange_rates dict'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *         return self.c_total_balance(exchange_rates, reference_currency.encode())
 */
  __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_n_u_reference_currency);
  __Pyx_GIVEREF(__pyx_n_u_reference_currency);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_u_reference_currency);
  __Pyx_INCREF(__pyx_kp_u_exchange_rates_dict);
  __Pyx_GIVEREF(__pyx_kp_u_exchange_rates_dict);
  PyList_SET_ITEM(__pyx_t_8, 1, __pyx_kp_u_exchange_rates_dict);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[5] = {__pyx_t_12, __pyx_t_10, __pyx_t_5, __pyx_t_8, __pyx_t_11};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3073, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[5] = {__pyx_t_12, __pyx_t_10, __pyx_t_5, __pyx_t_8, __pyx_t_11};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 4+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3073, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  {
    __pyx_t_13 = PyTuple_New(4+__pyx_t_9); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3073, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    if (__pyx_t_12) {
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_9, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_9, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_9, __pyx_t_11);
    __pyx_t_10 = 0;
    __pyx_t_5 = 0;
    __pyx_t_8 = 0;
    __pyx_t_11 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3073, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "trapeza/account/fx_account.pyx":3076
 *                     ['reference_currency', 'exchange_rates dict'], self._c_ignore_type_checking)
 * 
 *         return self.c_total_balance(exchange_rates, reference_currency.encode())             # <<<<<<<<<<<<<<
 * 
 *     def position(self, str currency):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_total_balance); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3076, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_reference_currency, __pyx_n_s_encode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3076, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  __pyx_t_13 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3076, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_exchange_rates, __pyx_t_13};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3076, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_v_exchange_rates, __pyx_t_13};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3076, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_11) {
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_11); __pyx_t_11 = NULL;
    }
    __Pyx_INCREF(__pyx_v_exchange_rates);
    __Pyx_GIVEREF(__pyx_v_exchange_rates);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_v_exchange_rates);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_13);
    __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":3005
 *         return self.c_batch_update_exchange_rates(list_rates, list_base_quote_pairs)
 * 
 *     def total_balance(self, exchange_rates=None, reference_currency=None):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates current value of all assets within self.depot in reference currency.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.total_balance", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_exchange_rates);
  __Pyx_XDECREF(__pyx_v_reference_currency);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "trapeza/account/fx_account.pyx":3078
 *         return self.c_total_balance(exchange_rates, reference_currency.encode())
 * 
 *     def position(self, str currency):             # <<<<<<<<<<<<<<
 *         """
 *         Returns position size of given currency.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_109position(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_108position[] = "\n        Returns position size of given currency.\n        (Does not need any update of exchange rate previous to calling this method)\n\n        This is a wrapper around the underlying C++ implementation.\n\n        :param currency: str\n        :return: position: float, volume of currency\n        :raises: TypeError: if parameters do not match specified types\n        ";
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_109position = {"position", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_109position, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_9FXAccount_108position};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_9FXAccount_109position(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_currency = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("position (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_currency,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("position", 1, 2, 2, 1); __PYX_ERR(0, 3078, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "position") < 0)) __PYX_ERR(0, 3078, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_currency = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("position", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 3078, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.position", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyUnicode_Type), 1, "currency", 1))) __PYX_ERR(0, 3078, __pyx_L1_error)
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_9FXAccount_108position(__pyx_self, __pyx_v_self, __pyx_v_currency);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_9FXAccount_108position(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_currency) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("position", 0);

  /* "trapeza/account/fx_account.pyx":3089
 *         :raises: TypeError: if parameters do not match specified types
 *         """
 *         check_types([currency], [str], ['currency'], self._c_ignore_type_checking)             # <<<<<<<<<<<<<<
 * 
 *         return self.c_position(currency.encode())
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_currency);
  __Pyx_GIVEREF(__pyx_v_currency);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_currency);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)(&PyUnicode_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyUnicode_Type)));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyUnicode_Type)));
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_currency);
  __Pyx_GIVEREF(__pyx_n_u_currency);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_u_currency);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_ignore_type_checking); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3089, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3089, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3089, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, __pyx_t_6);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3089, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":3091
 *         check_types([currency], [str], ['currency'], self._c_ignore_type_checking)
 * 
 *         return self.c_position(currency.encode())             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_c_position); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_currency == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 3091, __pyx_L1_error)
  }
  __pyx_t_9 = PyUnicode_AsEncodedString(__pyx_v_currency, NULL, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_9);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "trapeza/account/fx_account.pyx":3078
 *         return self.c_total_balance(exchange_rates, reference_currency.encode())
 * 
 *     def position(self, str currency):             # <<<<<<<<<<<<<<
 *         """
 *         Returns position size of given currency.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("trapeza.account.fx_account.FXAccount.position", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_cFXAccount(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_3__pyx_unpickle_cFXAccount(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7trapeza_7account_10fx_account_3__pyx_unpickle_cFXAccount = {"__pyx_unpickle_cFXAccount", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_3__pyx_unpickle_cFXAccount, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7trapeza_7account_10fx_account_3__pyx_unpickle_cFXAccount(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_cFXAccount (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_cFXAccount", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_cFXAccount", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_cFXAccount") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_cFXAccount", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("trapeza.account.fx_account.__pyx_unpickle_cFXAccount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7trapeza_7account_10fx_account_2__pyx_unpickle_cFXAccount(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7trapeza_7account_10fx_account_2__pyx_unpickle_cFXAccount(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_cFXAccount", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xf142c4f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf142c4f = (_c_check_marked_coverage, _c_clock, _c_depot, _c_exchange_rates, _c_fee, _c_ignore_type_checking, _c_is_exchange_rate_updated, _c_is_heap, _c_prohibit_debiting, _c_reference_currency, vec_heap))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xf142c4f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xf142c4f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf142c4f = (_c_check_marked_coverage, _c_clock, _c_depot, _c_exchange_rates, _c_fee, _c_ignore_type_checking, _c_is_exchange_rate_updated, _c_is_heap, _c_prohibit_debiting, _c_reference_currency, vec_heap))" % __pyx_checksum)
 *     __pyx_result = cFXAccount.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xf142c4f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf142c4f = (_c_check_marked_coverage, _c_clock, _c_depot, _c_exchange_rates, _c_fee, _c_ignore_type_checking, _c_is_exchange_rate_updated, _c_is_heap, _c_prohibit_debiting, _c_reference_currency, vec_heap))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = cFXAccount.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xf1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xf142c4f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf142c4f = (_c_check_marked_coverage, _c_clock, _c_depot, _c_exchange_rates, _c_fee, _c_ignore_type_checking, _c_is_exchange_rate_updated, _c_is_heap, _c_prohibit_debiting, _c_reference_currency, vec_heap))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf142c4f = (_c_check_marked_coverage, _c_clock, _c_depot, _c_exchange_rates, _c_fee, _c_ignore_type_checking, _c_is_exchange_rate_updated, _c_is_heap, _c_prohibit_debiting, _c_reference_currency, vec_heap))" % __pyx_checksum)
 *     __pyx_result = cFXAccount.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_cFXAccount__set_state(<cFXAccount> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7trapeza_7account_10fx_account_cFXAccount), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf142c4f = (_c_check_marked_coverage, _c_clock, _c_depot, _c_exchange_rates, _c_fee, _c_ignore_type_checking, _c_is_exchange_rate_updated, _c_is_heap, _c_prohibit_debiting, _c_reference_currency, vec_heap))" % __pyx_checksum)
 *     __pyx_result = cFXAccount.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_cFXAccount__set_state(<cFXAccount> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = cFXAccount.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_cFXAccount__set_state(<cFXAccount> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_cFXAccount__set_state(cFXAccount __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_7trapeza_7account_10fx_account___pyx_unpickle_cFXAccount__set_state(((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf142c4f = (_c_check_marked_coverage, _c_clock, _c_depot, _c_exchange_rates, _c_fee, _c_ignore_type_checking, _c_is_exchange_rate_updated, _c_is_heap, _c_prohibit_debiting, _c_reference_currency, vec_heap))" % __pyx_checksum)
 *     __pyx_result = cFXAccount.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_cFXAccount__set_state(<cFXAccount> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_cFXAccount__set_state(<cFXAccount> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_cFXAccount__set_state(cFXAccount __pyx_result, tuple __pyx_state):
 *     __pyx_result._c_check_marked_coverage = __pyx_state[0]; __pyx_result._c_clock = __pyx_state[1]; __pyx_result._c_depot = __pyx_state[2]; __pyx_result._c_exchange_rates = __pyx_state[3]; __pyx_result._c_fee = __pyx_state[4]; __pyx_result._c_ignore_type_checking = __pyx_state[5]; __pyx_result._c_is_exchange_rate_updated = __pyx_state[6]; __pyx_result._c_is_heap = __pyx_state[7]; __pyx_result._c_prohibit_debiting = __pyx_state[8]; __pyx_result._c_reference_currency = __pyx_state[9]; __pyx_result.vec_heap = __pyx_state[10]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_cFXAccount(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("trapeza.account.fx_account.__pyx_unpickle_cFXAccount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_cFXAccount__set_state(<cFXAccount> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_cFXAccount__set_state(cFXAccount __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._c_check_marked_coverage = __pyx_state[0]; __pyx_result._c_clock = __pyx_state[1]; __pyx_result._c_depot = __pyx_state[2]; __pyx_result._c_exchange_rates = __pyx_state[3]; __pyx_result._c_fee = __pyx_state[4]; __pyx_result._c_ignore_type_checking = __pyx_state[5]; __pyx_result._c_is_exchange_rate_updated = __pyx_state[6]; __pyx_result._c_is_heap = __pyx_state[7]; __pyx_result._c_prohibit_debiting = __pyx_state[8]; __pyx_result._c_reference_currency = __pyx_state[9]; __pyx_result.vec_heap = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_7trapeza_7account_10fx_account___pyx_unpickle_cFXAccount__set_state(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  short __pyx_t_2;
  long __pyx_t_3;
  bool __pyx_t_4;
  std::string __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_cFXAccount__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_cFXAccount__set_state(cFXAccount __pyx_result, tuple __pyx_state):
 *     __pyx_result._c_check_marked_coverage = __pyx_state[0]; __pyx_result._c_clock = __pyx_state[1]; __pyx_result._c_depot = __pyx_state[2]; __pyx_result._c_exchange_rates = __pyx_state[3]; __pyx_result._c_fee = __pyx_state[4]; __pyx_result._c_ignore_type_checking = __pyx_state[5]; __pyx_result._c_is_exchange_rate_updated = __pyx_state[6]; __pyx_result._c_is_heap = __pyx_state[7]; __pyx_result._c_prohibit_debiting = __pyx_state[8]; __pyx_result._c_reference_currency = __pyx_state[9]; __pyx_result.vec_heap = __pyx_state[10]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[11])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_short(__pyx_t_1); if (unlikely((__pyx_t_2 == (short)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_c_check_marked_coverage = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_3 == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_c_clock = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_c_depot);
  __Pyx_DECREF(__pyx_v___pyx_result->_c_depot);
  __pyx_v___pyx_result->_c_depot = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_c_exchange_rates);
  __Pyx_DECREF(__pyx_v___pyx_result->_c_exchange_rates);
  __pyx_v___pyx_result->_c_exchange_rates = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_c_fee);
  __Pyx_DECREF(__pyx_v___pyx_result->_c_fee);
  __pyx_v___pyx_result->_c_fee = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_c_ignore_type_checking = __pyx_t_4;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_c_is_exchange_rate_updated = __pyx_t_4;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_c_is_heap = __pyx_t_4;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_c_prohibit_debiting = __pyx_t_4;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_c_reference_currency = __pyx_t_5;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->vec_heap);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->vec_heap));
  __pyx_v___pyx_result->vec_heap = ((struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_cFXAccount__set_state(cFXAccount __pyx_result, tuple __pyx_state):
 *     __pyx_result._c_check_marked_coverage = __pyx_state[0]; __pyx_result._c_clock = __pyx_state[1]; __pyx_result._c_depot = __pyx_state[2]; __pyx_result._c_exchange_rates = __pyx_state[3]; __pyx_result._c_fee = __pyx_state[4]; __pyx_result._c_ignore_type_checking = __pyx_state[5]; __pyx_result._c_is_exchange_rate_updated = __pyx_state[6]; __pyx_result._c_is_heap = __pyx_state[7]; __pyx_result._c_prohibit_debiting = __pyx_state[8]; __pyx_result._c_reference_currency = __pyx_state[9]; __pyx_result.vec_heap = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[11])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 13, __pyx_L1_error)
  }
  __pyx_t_7 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_8 = ((__pyx_t_7 > 11) != 0);
  if (__pyx_t_8) {
  } else {
    __pyx_t_6 = __pyx_t_8;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_8 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_9 = (__pyx_t_8 != 0);
  __pyx_t_6 = __pyx_t_9;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_6) {

    /* "(tree fragment)":14
 *     __pyx_result._c_check_marked_coverage = __pyx_state[0]; __pyx_result._c_clock = __pyx_state[1]; __pyx_result._c_depot = __pyx_state[2]; __pyx_result._c_exchange_rates = __pyx_state[3]; __pyx_result._c_fee = __pyx_state[4]; __pyx_result._c_ignore_type_checking = __pyx_state[5]; __pyx_result._c_is_exchange_rate_updated = __pyx_state[6]; __pyx_result._c_is_heap = __pyx_state[7]; __pyx_result._c_prohibit_debiting = __pyx_state[8]; __pyx_result._c_reference_currency = __pyx_state[9]; __pyx_result.vec_heap = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[11])             # <<<<<<<<<<<<<<
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_update); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 14, __pyx_L1_error)
    }
    __pyx_t_10 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10);
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_cFXAccount__set_state(cFXAccount __pyx_result, tuple __pyx_state):
 *     __pyx_result._c_check_marked_coverage = __pyx_state[0]; __pyx_result._c_clock = __pyx_state[1]; __pyx_result._c_depot = __pyx_state[2]; __pyx_result._c_exchange_rates = __pyx_state[3]; __pyx_result._c_fee = __pyx_state[4]; __pyx_result._c_ignore_type_checking = __pyx_state[5]; __pyx_result._c_is_exchange_rate_updated = __pyx_state[6]; __pyx_result._c_is_heap = __pyx_state[7]; __pyx_result._c_prohibit_debiting = __pyx_state[8]; __pyx_result._c_reference_currency = __pyx_state[9]; __pyx_result.vec_heap = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[11])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_cFXAccount__set_state(<cFXAccount> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_cFXAccount__set_state(cFXAccount __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._c_check_marked_coverage = __pyx_state[0]; __pyx_result._c_clock = __pyx_state[1]; __pyx_result._c_depot = __pyx_state[2]; __pyx_result._c_exchange_rates = __pyx_state[3]; __pyx_result._c_fee = __pyx_state[4]; __pyx_result._c_ignore_type_checking = __pyx_state[5]; __pyx_result._c_is_exchange_rate_updated = __pyx_state[6]; __pyx_result._c_is_heap = __pyx_state[7]; __pyx_result._c_prohibit_debiting = __pyx_state[8]; __pyx_result._c_reference_currency = __pyx_state[9]; __pyx_result.vec_heap = __pyx_state[10]
 *     if len(__pyx_state) > 11 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("trapeza.account.fx_account.__pyx_unpickle_cFXAccount__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":31
 * 
 * @cname("__pyx_convert_PyObject_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyObject_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyObject_string_to_py_std__in_string", 0);

  /* "string.to_py":32
 * @cname("__pyx_convert_PyObject_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyObject_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * cdef extern from *:
 *     cdef object __Pyx_PyUnicode_FromStringAndSize(const char*, size_t)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":31
 * 
 * @cname("__pyx_convert_PyObject_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyObject_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyObject_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":37
 * 
 * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyUnicode_string_to_py_std__in_string", 0);

  /* "string.to_py":38
 * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * cdef extern from *:
 *     cdef object __Pyx_PyStr_FromStringAndSize(const char*, size_t)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyUnicode_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":37
 * 
 * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyUnicode_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":43
 * 
 * @cname("__pyx_convert_PyStr_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyStr_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyStr_string_to_py_std__in_string", 0);

  /* "string.to_py":44
 * @cname("__pyx_convert_PyStr_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyStr_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * cdef extern from *:
 *     cdef object __Pyx_PyBytes_FromStringAndSize(const char*, size_t)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyStr_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":43
 * 
 * @cname("__pyx_convert_PyStr_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyStr_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyStr_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":49
 * 
 * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyBytes_string_to_py_std__in_string", 0);

  /* "string.to_py":50
 * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * cdef extern from *:
 *     cdef object __Pyx_PyByteArray_FromStringAndSize(const char*, size_t)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":49
 * 
 * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyBytes_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":55
 * 
 * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())
 * 
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyByteArray_string_to_py_std__in_string", 0);

  /* "string.to_py":56
 * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyByteArray_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":55
 * 
 * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyByteArray_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.from_py":13
 * 
 * @cname("__pyx_convert_string_from_py_std__in_string")
 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t length = 0
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)
 */

static std::string __pyx_convert_string_from_py_std__in_string(PyObject *__pyx_v_o) {
  Py_ssize_t __pyx_v_length;
  char const *__pyx_v_data;
  std::string __pyx_r;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_string_from_py_std__in_string", 0);

  /* "string.from_py":14
 * @cname("__pyx_convert_string_from_py_std__in_string")
 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *:
 *     cdef Py_ssize_t length = 0             # <<<<<<<<<<<<<<
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)
 *     return string(data, length)
 */
  __pyx_v_length = 0;

  /* "string.from_py":15
 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *:
 *     cdef Py_ssize_t length = 0
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)             # <<<<<<<<<<<<<<
 *     return string(data, length)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_AsStringAndSize(__pyx_v_o, (&__pyx_v_length)); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_v_data = __pyx_t_1;

  /* "string.from_py":16
 *     cdef Py_ssize_t length = 0
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)
 *     return string(data, length)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = std::string(__pyx_v_data, __pyx_v_length);
  goto __pyx_L0;

  /* "string.from_py":13
 * 
 * @cname("__pyx_convert_string_from_py_std__in_string")
 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t length = 0
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("string.from_py.__pyx_convert_string_from_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_7trapeza_7account_10fx_account_cFXAccount __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount;

static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account_cFXAccount(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)o);
  p->__pyx_vtab = __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount;
  new((void*)&(p->_c_reference_currency)) std::string();
  p->_c_depot = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_c_fee = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_c_exchange_rates = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->vec_heap = ((struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_7trapeza_7account_10fx_account_cFXAccount(PyObject *o) {
  struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *p = (struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  __Pyx_call_destructor(p->_c_reference_currency);
  Py_CLEAR(p->_c_depot);
  Py_CLEAR(p->_c_fee);
  Py_CLEAR(p->_c_exchange_rates);
  Py_CLEAR(p->vec_heap);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_7trapeza_7account_10fx_account_cFXAccount(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *p = (struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)o;
  if (p->_c_depot) {
    e = (*v)(p->_c_depot, a); if (e) return e;
  }
  if (p->_c_fee) {
    e = (*v)(p->_c_fee, a); if (e) return e;
  }
  if (p->_c_exchange_rates) {
    e = (*v)(p->_c_exchange_rates, a); if (e) return e;
  }
  if (p->vec_heap) {
    e = (*v)(((PyObject *)p->vec_heap), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7trapeza_7account_10fx_account_cFXAccount(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *p = (struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *)o;
  tmp = ((PyObject*)p->_c_depot);
  p->_c_depot = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_c_fee);
  p->_c_fee = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_c_exchange_rates);
  p->_c_exchange_rates = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->vec_heap);
  p->vec_heap = ((struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_is_heap(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_is_heap(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_10_c_is_heap_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_is_exchange_rate_updated(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_is_exchange_rate_updated(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27_c_is_exchange_rate_updated_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_prohibit_debiting(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_prohibit_debiting(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_20_c_prohibit_debiting_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_reference_currency(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_reference_currency(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21_c_reference_currency_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_depot(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_depot(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_3__set__(o, v);
  }
  else {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_depot_5__del__(o);
  }
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_fee(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_fee(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_3__set__(o, v);
  }
  else {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_6_c_fee_5__del__(o);
  }
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_exchange_rates(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_exchange_rates(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_3__set__(o, v);
  }
  else {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17_c_exchange_rates_5__del__(o);
  }
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_ignore_type_checking(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_23_c_ignore_type_checking_1__get__(o);
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_clock(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_clock(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8_c_clock_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_check_marked_coverage(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_check_marked_coverage(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_24_c_check_marked_coverage_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount_vec_heap(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_1__get__(o);
}

static int __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount_vec_heap(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_3__set__(o, v);
  }
  else {
    return __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_8vec_heap_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_7trapeza_7account_10fx_account_cFXAccount[] = {
  {"_c__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_3_c__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_2_c__init__},
  {"_c_reset", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_5_c_reset, METH_NOARGS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_4_c_reset},
  {"_c_check_coverage", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_7_c_check_coverage, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_6_c_check_coverage},
  {"_c_isin_depot", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_9_c_isin_depot, METH_O, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_8_c_isin_depot},
  {"c_sell", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_11c_sell, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_10c_sell},
  {"c_buy", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_13c_buy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_12c_buy},
  {"c_transfer", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_15c_transfer, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_14c_transfer},
  {"c_collect", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_17c_collect, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_16c_collect},
  {"c_deposit", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_19c_deposit, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_18c_deposit},
  {"c_withdraw", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_21c_withdraw, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_20c_withdraw},
  {"c_tick", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_23c_tick, METH_O, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_22c_tick},
  {"c_update_exchange_rate", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_25c_update_exchange_rate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_24c_update_exchange_rate},
  {"c_batch_update_exchange_rates", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_27c_batch_update_exchange_rates, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_26c_batch_update_exchange_rates},
  {"c_total_balance", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_29c_total_balance, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_28c_total_balance},
  {"c_position", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_31c_position, METH_O, __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount_30c_position},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_33__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_35__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_7trapeza_7account_10fx_account_cFXAccount[] = {
  {(char *)"_c_is_heap", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_is_heap, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_is_heap, (char *)0, 0},
  {(char *)"_c_is_exchange_rate_updated", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_is_exchange_rate_updated, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_is_exchange_rate_updated, (char *)0, 0},
  {(char *)"_c_prohibit_debiting", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_prohibit_debiting, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_prohibit_debiting, (char *)0, 0},
  {(char *)"_c_reference_currency", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_reference_currency, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_reference_currency, (char *)0, 0},
  {(char *)"_c_depot", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_depot, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_depot, (char *)0, 0},
  {(char *)"_c_fee", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_fee, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_fee, (char *)0, 0},
  {(char *)"_c_exchange_rates", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_exchange_rates, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_exchange_rates, (char *)0, 0},
  {(char *)"_c_ignore_type_checking", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_ignore_type_checking, 0, (char *)0, 0},
  {(char *)"_c_clock", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_clock, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_clock, (char *)0, 0},
  {(char *)"_c_check_marked_coverage", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount__c_check_marked_coverage, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount__c_check_marked_coverage, (char *)0, 0},
  {(char *)"vec_heap", __pyx_getprop_7trapeza_7account_10fx_account_10cFXAccount_vec_heap, __pyx_setprop_7trapeza_7account_10fx_account_10cFXAccount_vec_heap, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_7trapeza_7account_10fx_account_cFXAccount = {
  PyVarObject_HEAD_INIT(0, 0)
  "trapeza.account.fx_account.cFXAccount", /*tp_name*/
  sizeof(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7trapeza_7account_10fx_account_cFXAccount, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n    This is a C++ implementation via cython and gets wrapped by FXAccount class. This class tries to stay in C++ space\n    as long as possible to avoid unnecessary type casting to Python data types. The internal heap (cf. stack automaton\n    logic) is implemented via a C++ heap vector.\n    Please refer to the docstrings of FXAccount for detailed descriptions. Details might differ slightly, but the\n    overall logic idea is the same and this class gets wrapped by FXAccount anyhow. This class is never called directly\n    by the user, so detailed docstrings do not make that much sense here.\n\n    TODO: map instead of dict (not really an advantage as Python's dict is already well optimized)\n    TODO: check if turning string to char* makes sense\n    ", /*tp_doc*/
  __pyx_tp_traverse_7trapeza_7account_10fx_account_cFXAccount, /*tp_traverse*/
  __pyx_tp_clear_7trapeza_7account_10fx_account_cFXAccount, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_7trapeza_7account_10fx_account_cFXAccount, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_7trapeza_7account_10fx_account_cFXAccount, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_7trapeza_7account_10fx_account_10cFXAccount_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_7trapeza_7account_10fx_account_cFXAccount, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct__depot[8];
static int __pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct__depot = 0;

static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct__depot(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct__depot > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot)))) {
    o = (PyObject*)__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct__depot[--__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct__depot];
    memset(o, 0, sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct__depot(PyObject *o) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct__depot < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot)))) {
    __pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct__depot[__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct__depot++] = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct__depot(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *)o;
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7trapeza_7account_10fx_account___pyx_scope_struct__depot(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct__depot = {
  PyVarObject_HEAD_INIT(0, 0)
  "trapeza.account.fx_account.__pyx_scope_struct__depot", /*tp_name*/
  sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct__depot), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct__depot, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct__depot, /*tp_traverse*/
  __pyx_tp_clear_7trapeza_7account_10fx_account___pyx_scope_struct__depot, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct__depot, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr[--__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_k);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr)))) {
    __pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr[__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_k) {
    e = (*v)(p->__pyx_v_k, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "trapeza.account.fx_account.__pyx_scope_struct_1_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee[8];
static int __pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee = 0;

static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee)))) {
    o = (PyObject*)__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee[--__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee];
    memset(o, 0, sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee(PyObject *o) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee)))) {
    __pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee[__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee++] = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *)o;
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee = {
  PyVarObject_HEAD_INIT(0, 0)
  "trapeza.account.fx_account.__pyx_scope_struct_2__fee", /*tp_name*/
  sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee, /*tp_traverse*/
  __pyx_tp_clear_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr[8];
static int __pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr = 0;

static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr)))) {
    o = (PyObject*)__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr[--__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr(PyObject *o) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_k);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr)))) {
    __pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr[__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr++] = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_k) {
    e = (*v)(p->__pyx_v_k, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "trapeza.account.fx_account.__pyx_scope_struct_3_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates[8];
static int __pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates = 0;

static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates)))) {
    o = (PyObject*)__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates[--__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates];
    memset(o, 0, sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates(PyObject *o) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates)))) {
    __pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates[__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates++] = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *)o;
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates = {
  PyVarObject_HEAD_INIT(0, 0)
  "trapeza.account.fx_account.__pyx_scope_struct_4_exchange_rates", /*tp_name*/
  sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates, /*tp_traverse*/
  __pyx_tp_clear_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr[8];
static int __pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr = 0;

static PyObject *__pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr)))) {
    o = (PyObject*)__pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr[--__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr(PyObject *o) {
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_k);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr)))) {
    __pyx_freelist_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr[__pyx_freecount_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr++] = ((struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_k) {
    e = (*v)(p->__pyx_v_k, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "trapeza.account.fx_account.__pyx_scope_struct_5_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {"fx_null_fee", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7trapeza_7account_10fx_account_1fx_null_fee, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7trapeza_7account_10fx_account_fx_null_fee},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_fx_account(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_fx_account},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "fx_account",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_AccountError, __pyx_k_AccountError, sizeof(__pyx_k_AccountError), 0, 0, 1, 1},
  {&__pyx_kp_u_Auto_converting_withdraw_and_dep, __pyx_k_Auto_converting_withdraw_and_dep, sizeof(__pyx_k_Auto_converting_withdraw_and_dep), 0, 1, 0, 0},
  {&__pyx_n_s_BaseAccount, __pyx_k_BaseAccount, sizeof(__pyx_k_BaseAccount), 0, 0, 1, 1},
  {&__pyx_kp_u_Buy_volume_in_is_0, __pyx_k_Buy_volume_in_is_0, sizeof(__pyx_k_Buy_volume_in_is_0), 0, 1, 0, 0},
  {&__pyx_kp_u_Checking_of_marked_but_not_yet_b, __pyx_k_Checking_of_marked_but_not_yet_b, sizeof(__pyx_k_Checking_of_marked_but_not_yet_b), 0, 1, 0, 0},
  {&__pyx_n_s_CoverageError, __pyx_k_CoverageError, sizeof(__pyx_k_CoverageError), 0, 0, 1, 1},
  {&__pyx_kp_u_Debiting_into_negative_positions, __pyx_k_Debiting_into_negative_positions, sizeof(__pyx_k_Debiting_into_negative_positions), 0, 1, 0, 0},
  {&__pyx_kp_s_Derived_from_BaseAccount_This_i, __pyx_k_Derived_from_BaseAccount_This_i, sizeof(__pyx_k_Derived_from_BaseAccount_This_i), 0, 0, 1, 0},
  {&__pyx_kp_u_Exchange_rates_contain_empty_dic, __pyx_k_Exchange_rates_contain_empty_dic, sizeof(__pyx_k_Exchange_rates_contain_empty_dic), 0, 1, 0, 0},
  {&__pyx_kp_u_Exchange_rates_have_not_been_upd, __pyx_k_Exchange_rates_have_not_been_upd, sizeof(__pyx_k_Exchange_rates_have_not_been_upd), 0, 1, 0, 0},
  {&__pyx_kp_u_Exchange_rates_of_base_quote_and, __pyx_k_Exchange_rates_of_base_quote_and, sizeof(__pyx_k_Exchange_rates_of_base_quote_and), 0, 1, 0, 0},
  {&__pyx_n_s_FXAccount, __pyx_k_FXAccount, sizeof(__pyx_k_FXAccount), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount___init, __pyx_k_FXAccount___init, sizeof(__pyx_k_FXAccount___init), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__check_alt_fee, __pyx_k_FXAccount__check_alt_fee, sizeof(__pyx_k_FXAccount__check_alt_fee), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__check_coverage, __pyx_k_FXAccount__check_coverage, sizeof(__pyx_k_FXAccount__check_coverage), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__check_is_valid_fee_fu, __pyx_k_FXAccount__check_is_valid_fee_fu, sizeof(__pyx_k_FXAccount__check_is_valid_fee_fu), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__cum_sum_heap, __pyx_k_FXAccount__cum_sum_heap, sizeof(__pyx_k_FXAccount__cum_sum_heap), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__cum_sum_marked_debit, __pyx_k_FXAccount__cum_sum_marked_debit, sizeof(__pyx_k_FXAccount__cum_sum_marked_debit), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__cum_sum_marked_fund, __pyx_k_FXAccount__cum_sum_marked_fund, sizeof(__pyx_k_FXAccount__cum_sum_marked_fund), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__eval_fee, __pyx_k_FXAccount__eval_fee, sizeof(__pyx_k_FXAccount__eval_fee), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__fee, __pyx_k_FXAccount__fee, sizeof(__pyx_k_FXAccount__fee), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__fee_locals_genexpr, __pyx_k_FXAccount__fee_locals_genexpr, sizeof(__pyx_k_FXAccount__fee_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__fill_fee, __pyx_k_FXAccount__fill_fee, sizeof(__pyx_k_FXAccount__fill_fee), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__full_reset, __pyx_k_FXAccount__full_reset, sizeof(__pyx_k_FXAccount__full_reset), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__ignore_type_checking, __pyx_k_FXAccount__ignore_type_checking, sizeof(__pyx_k_FXAccount__ignore_type_checking), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__parse_depot, __pyx_k_FXAccount__parse_depot, sizeof(__pyx_k_FXAccount__parse_depot), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__parse_exchange_rates, __pyx_k_FXAccount__parse_exchange_rates, sizeof(__pyx_k_FXAccount__parse_exchange_rates), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__parse_exec_heap, __pyx_k_FXAccount__parse_exec_heap, sizeof(__pyx_k_FXAccount__parse_exec_heap), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__parse_fee_and_transac, __pyx_k_FXAccount__parse_fee_and_transac, sizeof(__pyx_k_FXAccount__parse_fee_and_transac), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__parse_fees, __pyx_k_FXAccount__parse_fees, sizeof(__pyx_k_FXAccount__parse_fees), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount__reset, __pyx_k_FXAccount__reset, sizeof(__pyx_k_FXAccount__reset), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_batch_update_exchange, __pyx_k_FXAccount_batch_update_exchange, sizeof(__pyx_k_FXAccount_batch_update_exchange), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_buy, __pyx_k_FXAccount_buy, sizeof(__pyx_k_FXAccount_buy), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_check_marked_coverage, __pyx_k_FXAccount_check_marked_coverage, sizeof(__pyx_k_FXAccount_check_marked_coverage), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_clock, __pyx_k_FXAccount_clock, sizeof(__pyx_k_FXAccount_clock), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_collect, __pyx_k_FXAccount_collect, sizeof(__pyx_k_FXAccount_collect), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_deposit, __pyx_k_FXAccount_deposit, sizeof(__pyx_k_FXAccount_deposit), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_depot, __pyx_k_FXAccount_depot, sizeof(__pyx_k_FXAccount_depot), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_depot_locals_genexpr, __pyx_k_FXAccount_depot_locals_genexpr, sizeof(__pyx_k_FXAccount_depot_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_exchange_rates, __pyx_k_FXAccount_exchange_rates, sizeof(__pyx_k_FXAccount_exchange_rates), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_exchange_rates_locals, __pyx_k_FXAccount_exchange_rates_locals, sizeof(__pyx_k_FXAccount_exchange_rates_locals), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_exec_heap, __pyx_k_FXAccount_exec_heap, sizeof(__pyx_k_FXAccount_exec_heap), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_is_exchange_rate_updat, __pyx_k_FXAccount_is_exchange_rate_updat, sizeof(__pyx_k_FXAccount_is_exchange_rate_updat), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_position, __pyx_k_FXAccount_position, sizeof(__pyx_k_FXAccount_position), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_prohibit_debiting, __pyx_k_FXAccount_prohibit_debiting, sizeof(__pyx_k_FXAccount_prohibit_debiting), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_reference_currency, __pyx_k_FXAccount_reference_currency, sizeof(__pyx_k_FXAccount_reference_currency), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_sell, __pyx_k_FXAccount_sell, sizeof(__pyx_k_FXAccount_sell), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_tick, __pyx_k_FXAccount_tick, sizeof(__pyx_k_FXAccount_tick), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_total_balance, __pyx_k_FXAccount_total_balance, sizeof(__pyx_k_FXAccount_total_balance), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_transfer, __pyx_k_FXAccount_transfer, sizeof(__pyx_k_FXAccount_transfer), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_update_exchange_rate, __pyx_k_FXAccount_update_exchange_rate, sizeof(__pyx_k_FXAccount_update_exchange_rate), 0, 0, 1, 1},
  {&__pyx_n_s_FXAccount_withdraw, __pyx_k_FXAccount_withdraw, sizeof(__pyx_k_FXAccount_withdraw), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xf1, __pyx_k_Incompatible_checksums_s_vs_0xf1, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xf1), 0, 0, 1, 0},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_kp_u_Internal_clock_must_be_set_to_0, __pyx_k_Internal_clock_must_be_set_to_0, sizeof(__pyx_k_Internal_clock_must_be_set_to_0), 0, 1, 0, 0},
  {&__pyx_kp_u_Internal_logic_error_Value_in_un, __pyx_k_Internal_logic_error_Value_in_un, sizeof(__pyx_k_Internal_logic_error_Value_in_un), 0, 1, 0, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_kp_u_Lists_must_have_same_length, __pyx_k_Lists_must_have_same_length, sizeof(__pyx_k_Lists_must_have_same_length), 0, 1, 0, 0},
  {&__pyx_n_s_NameError, __pyx_k_NameError, sizeof(__pyx_k_NameError), 0, 0, 1, 1},
  {&__pyx_kp_u_Negative_depot_position_detected, __pyx_k_Negative_depot_position_detected, sizeof(__pyx_k_Negative_depot_position_detected), 0, 1, 0, 0},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_kp_u_Only_integers_for_setting_intern, __pyx_k_Only_integers_for_setting_intern, sizeof(__pyx_k_Only_integers_for_setting_intern), 0, 1, 0, 0},
  {&__pyx_n_s_OperatingError, __pyx_k_OperatingError, sizeof(__pyx_k_OperatingError), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_PositionNAError, __pyx_k_PositionNAError, sizeof(__pyx_k_PositionNAError), 0, 0, 1, 1},
  {&__pyx_n_s_ProtectedDict, __pyx_k_ProtectedDict, sizeof(__pyx_k_ProtectedDict), 0, 0, 1, 1},
  {&__pyx_n_s_ProtectedExecHeap, __pyx_k_ProtectedExecHeap, sizeof(__pyx_k_ProtectedExecHeap), 0, 0, 1, 1},
  {&__pyx_kp_u_Sell_volume_in_is_0, __pyx_k_Sell_volume_in_is_0, sizeof(__pyx_k_Sell_volume_in_is_0), 0, 1, 0, 0},
  {&__pyx_kp_u_Single_entry_to_exec_heap_consis, __pyx_k_Single_entry_to_exec_heap_consis, sizeof(__pyx_k_Single_entry_to_exec_heap_consis), 0, 1, 0, 0},
  {&__pyx_kp_u_Transaction_not_feasible_even_th, __pyx_k_Transaction_not_feasible_even_th, sizeof(__pyx_k_Transaction_not_feasible_even_th), 0, 1, 0, 0},
  {&__pyx_kp_u_Transaction_not_feasible_even_th_2, __pyx_k_Transaction_not_feasible_even_th_2, sizeof(__pyx_k_Transaction_not_feasible_even_th_2), 0, 1, 0, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_u_When_setting_exec_heap_manually, __pyx_k_When_setting_exec_heap_manually, sizeof(__pyx_k_When_setting_exec_heap_manually), 0, 1, 0, 0},
  {&__pyx_n_u_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 1, 0, 1},
  {&__pyx_n_u_Y, __pyx_k_Y, sizeof(__pyx_k_Y), 0, 1, 0, 1},
  {&__pyx_kp_u__19, __pyx_k__19, sizeof(__pyx_k__19), 0, 1, 0, 0},
  {&__pyx_n_s__93, __pyx_k__93, sizeof(__pyx_k__93), 0, 0, 1, 1},
  {&__pyx_n_s_action_func, __pyx_k_action_func, sizeof(__pyx_k_action_func), 0, 0, 1, 1},
  {&__pyx_n_s_action_func_type, __pyx_k_action_func_type, sizeof(__pyx_k_action_func_type), 0, 0, 1, 1},
  {&__pyx_kp_u_action_func_type_must_be_c_withd, __pyx_k_action_func_type_must_be_c_withd, sizeof(__pyx_k_action_func_type_must_be_c_withd), 0, 1, 0, 0},
  {&__pyx_n_s_action_type, __pyx_k_action_type, sizeof(__pyx_k_action_type), 0, 0, 1, 1},
  {&__pyx_n_s_alt_fee, __pyx_k_alt_fee, sizeof(__pyx_k_alt_fee), 0, 0, 1, 1},
  {&__pyx_n_s_alt_fee_error_msg, __pyx_k_alt_fee_error_msg, sizeof(__pyx_k_alt_fee_error_msg), 0, 0, 1, 1},
  {&__pyx_kp_u_alt_fee_must_be_in_None_False_fu, __pyx_k_alt_fee_must_be_in_None_False_fu, sizeof(__pyx_k_alt_fee_must_be_in_None_False_fu), 0, 1, 0, 0},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_ask_price, __pyx_k_ask_price, sizeof(__pyx_k_ask_price), 0, 0, 1, 1},
  {&__pyx_n_u_ask_price, __pyx_k_ask_price, sizeof(__pyx_k_ask_price), 0, 1, 0, 1},
  {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
  {&__pyx_n_u_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 1, 0, 1},
  {&__pyx_n_u_base_currency, __pyx_k_base_currency, sizeof(__pyx_k_base_currency), 0, 1, 0, 1},
  {&__pyx_n_s_batch_update_exchange_rates, __pyx_k_batch_update_exchange_rates, sizeof(__pyx_k_batch_update_exchange_rates), 0, 0, 1, 1},
  {&__pyx_n_s_bid_price, __pyx_k_bid_price, sizeof(__pyx_k_bid_price), 0, 0, 1, 1},
  {&__pyx_n_u_bid_price, __pyx_k_bid_price, sizeof(__pyx_k_bid_price), 0, 1, 0, 1},
  {&__pyx_n_b_buy, __pyx_k_buy, sizeof(__pyx_k_buy), 0, 0, 0, 1},
  {&__pyx_n_s_buy, __pyx_k_buy, sizeof(__pyx_k_buy), 0, 0, 1, 1},
  {&__pyx_n_u_buy, __pyx_k_buy, sizeof(__pyx_k_buy), 0, 1, 0, 1},
  {&__pyx_n_u_buy_fee, __pyx_k_buy_fee, sizeof(__pyx_k_buy_fee), 0, 1, 0, 1},
  {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
  {&__pyx_n_s_cFXAccount, __pyx_k_cFXAccount, sizeof(__pyx_k_cFXAccount), 0, 0, 1, 1},
  {&__pyx_n_s_c__init, __pyx_k_c__init, sizeof(__pyx_k_c__init), 0, 0, 1, 1},
  {&__pyx_n_s_c_batch_update_exchange_rates, __pyx_k_c_batch_update_exchange_rates, sizeof(__pyx_k_c_batch_update_exchange_rates), 0, 0, 1, 1},
  {&__pyx_n_s_c_buy, __pyx_k_c_buy, sizeof(__pyx_k_c_buy), 0, 0, 1, 1},
  {&__pyx_n_s_c_check_coverage, __pyx_k_c_check_coverage, sizeof(__pyx_k_c_check_coverage), 0, 0, 1, 1},
  {&__pyx_n_s_c_check_marked_coverage, __pyx_k_c_check_marked_coverage, sizeof(__pyx_k_c_check_marked_coverage), 0, 0, 1, 1},
  {&__pyx_n_s_c_clock, __pyx_k_c_clock, sizeof(__pyx_k_c_clock), 0, 0, 1, 1},
  {&__pyx_n_s_c_collect, __pyx_k_c_collect, sizeof(__pyx_k_c_collect), 0, 0, 1, 1},
  {&__pyx_n_b_c_deposit, __pyx_k_c_deposit, sizeof(__pyx_k_c_deposit), 0, 0, 0, 1},
  {&__pyx_n_s_c_deposit, __pyx_k_c_deposit, sizeof(__pyx_k_c_deposit), 0, 0, 1, 1},
  {&__pyx_n_u_c_deposit, __pyx_k_c_deposit, sizeof(__pyx_k_c_deposit), 0, 1, 0, 1},
  {&__pyx_n_s_c_depot, __pyx_k_c_depot, sizeof(__pyx_k_c_depot), 0, 0, 1, 1},
  {&__pyx_n_s_c_exchange_rates, __pyx_k_c_exchange_rates, sizeof(__pyx_k_c_exchange_rates), 0, 0, 1, 1},
  {&__pyx_n_s_c_fee, __pyx_k_c_fee, sizeof(__pyx_k_c_fee), 0, 0, 1, 1},
  {&__pyx_n_s_c_ignore_type_checking, __pyx_k_c_ignore_type_checking, sizeof(__pyx_k_c_ignore_type_checking), 0, 0, 1, 1},
  {&__pyx_n_s_c_is_exchange_rate_updated, __pyx_k_c_is_exchange_rate_updated, sizeof(__pyx_k_c_is_exchange_rate_updated), 0, 0, 1, 1},
  {&__pyx_n_s_c_isin_depot, __pyx_k_c_isin_depot, sizeof(__pyx_k_c_isin_depot), 0, 0, 1, 1},
  {&__pyx_n_s_c_position, __pyx_k_c_position, sizeof(__pyx_k_c_position), 0, 0, 1, 1},
  {&__pyx_n_s_c_prohibit_debiting, __pyx_k_c_prohibit_debiting, sizeof(__pyx_k_c_prohibit_debiting), 0, 0, 1, 1},
  {&__pyx_n_s_c_reference_currency, __pyx_k_c_reference_currency, sizeof(__pyx_k_c_reference_currency), 0, 0, 1, 1},
  {&__pyx_n_s_c_reset, __pyx_k_c_reset, sizeof(__pyx_k_c_reset), 0, 0, 1, 1},
  {&__pyx_n_s_c_sell, __pyx_k_c_sell, sizeof(__pyx_k_c_sell), 0, 0, 1, 1},
  {&__pyx_n_s_c_tick, __pyx_k_c_tick, sizeof(__pyx_k_c_tick), 0, 0, 1, 1},
  {&__pyx_n_s_c_total_balance, __pyx_k_c_total_balance, sizeof(__pyx_k_c_total_balance), 0, 0, 1, 1},
  {&__pyx_n_s_c_transfer, __pyx_k_c_transfer, sizeof(__pyx_k_c_transfer), 0, 0, 1, 1},
  {&__pyx_n_s_c_update_exchange_rate, __pyx_k_c_update_exchange_rate, sizeof(__pyx_k_c_update_exchange_rate), 0, 0, 1, 1},
  {&__pyx_n_b_c_withdraw, __pyx_k_c_withdraw, sizeof(__pyx_k_c_withdraw), 0, 0, 0, 1},
  {&__pyx_n_s_c_withdraw, __pyx_k_c_withdraw, sizeof(__pyx_k_c_withdraw), 0, 0, 1, 1},
  {&__pyx_n_u_c_withdraw, __pyx_k_c_withdraw, sizeof(__pyx_k_c_withdraw), 0, 1, 0, 1},
  {&__pyx_n_s_callable, __pyx_k_callable, sizeof(__pyx_k_callable), 0, 0, 1, 1},
  {&__pyx_n_s_check_alt_fee, __pyx_k_check_alt_fee, sizeof(__pyx_k_check_alt_fee), 0, 0, 1, 1},
  {&__pyx_n_s_check_coverage, __pyx_k_check_coverage, sizeof(__pyx_k_check_coverage), 0, 0, 1, 1},
  {&__pyx_n_s_check_is_valid_fee_func, __pyx_k_check_is_valid_fee_func, sizeof(__pyx_k_check_is_valid_fee_func), 0, 0, 1, 1},
  {&__pyx_n_s_check_marked_coverage, __pyx_k_check_marked_coverage, sizeof(__pyx_k_check_marked_coverage), 0, 0, 1, 1},
  {&__pyx_kp_u_check_marked_coverage_must_be_in, __pyx_k_check_marked_coverage_must_be_in, sizeof(__pyx_k_check_marked_coverage_must_be_in), 0, 1, 0, 0},
  {&__pyx_n_s_check_types, __pyx_k_check_types, sizeof(__pyx_k_check_types), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_clock, __pyx_k_clock, sizeof(__pyx_k_clock), 0, 0, 1, 1},
  {&__pyx_n_u_clock, __pyx_k_clock, sizeof(__pyx_k_clock), 0, 1, 0, 1},
  {&__pyx_kp_u_clock_has_to_be_int_0, __pyx_k_clock_has_to_be_int_0, sizeof(__pyx_k_clock_has_to_be_int_0), 0, 1, 0, 0},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_collect, __pyx_k_collect, sizeof(__pyx_k_collect), 0, 0, 1, 1},
  {&__pyx_n_s_coverage, __pyx_k_coverage, sizeof(__pyx_k_coverage), 0, 0, 1, 1},
  {&__pyx_n_u_coverage, __pyx_k_coverage, sizeof(__pyx_k_coverage), 0, 1, 0, 1},
  {&__pyx_kp_u_coverage_must_be_except_debit, __pyx_k_coverage_must_be_except_debit, sizeof(__pyx_k_coverage_must_be_except_debit), 0, 1, 0, 0},
  {&__pyx_kp_u_coverage_must_be_except_partial, __pyx_k_coverage_must_be_except_partial, sizeof(__pyx_k_coverage_must_be_except_partial), 0, 1, 0, 0},
  {&__pyx_kp_u_coverage_must_be_in_except_parti, __pyx_k_coverage_must_be_in_except_parti, sizeof(__pyx_k_coverage_must_be_in_except_parti), 0, 1, 0, 0},
  {&__pyx_n_s_cum_sum_heap, __pyx_k_cum_sum_heap, sizeof(__pyx_k_cum_sum_heap), 0, 0, 1, 1},
  {&__pyx_n_s_cum_sum_heap_2, __pyx_k_cum_sum_heap_2, sizeof(__pyx_k_cum_sum_heap_2), 0, 0, 1, 1},
  {&__pyx_n_s_cum_sum_marked_debit, __pyx_k_cum_sum_marked_debit, sizeof(__pyx_k_cum_sum_marked_debit), 0, 0, 1, 1},
  {&__pyx_n_s_cum_sum_marked_debit_2, __pyx_k_cum_sum_marked_debit_2, sizeof(__pyx_k_cum_sum_marked_debit_2), 0, 0, 1, 1},
  {&__pyx_n_s_cum_sum_marked_fund, __pyx_k_cum_sum_marked_fund, sizeof(__pyx_k_cum_sum_marked_fund), 0, 0, 1, 1},
  {&__pyx_n_s_cum_sum_marked_fund_2, __pyx_k_cum_sum_marked_fund_2, sizeof(__pyx_k_cum_sum_marked_fund_2), 0, 0, 1, 1},
  {&__pyx_n_s_currency, __pyx_k_currency, sizeof(__pyx_k_currency), 0, 0, 1, 1},
  {&__pyx_n_u_currency, __pyx_k_currency, sizeof(__pyx_k_currency), 0, 1, 0, 1},
  {&__pyx_kp_u_currency_in_depot, __pyx_k_currency_in_depot, sizeof(__pyx_k_currency_in_depot), 0, 1, 0, 0},
  {&__pyx_kp_u_currency_volume_in_depot, __pyx_k_currency_volume_in_depot, sizeof(__pyx_k_currency_volume_in_depot), 0, 1, 0, 0},
  {&__pyx_n_s_current_rate, __pyx_k_current_rate, sizeof(__pyx_k_current_rate), 0, 0, 1, 1},
  {&__pyx_n_b_debit, __pyx_k_debit, sizeof(__pyx_k_debit), 0, 0, 0, 1},
  {&__pyx_n_u_debit, __pyx_k_debit, sizeof(__pyx_k_debit), 0, 1, 0, 1},
  {&__pyx_n_s_debit_amount, __pyx_k_debit_amount, sizeof(__pyx_k_debit_amount), 0, 0, 1, 1},
  {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
  {&__pyx_n_b_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 0, 1},
  {&__pyx_n_s_default_float_currency, __pyx_k_default_float_currency, sizeof(__pyx_k_default_float_currency), 0, 0, 1, 1},
  {&__pyx_n_s_deleter, __pyx_k_deleter, sizeof(__pyx_k_deleter), 0, 0, 1, 1},
  {&__pyx_n_b_deposit, __pyx_k_deposit, sizeof(__pyx_k_deposit), 0, 0, 0, 1},
  {&__pyx_n_s_deposit, __pyx_k_deposit, sizeof(__pyx_k_deposit), 0, 0, 1, 1},
  {&__pyx_n_u_deposit, __pyx_k_deposit, sizeof(__pyx_k_deposit), 0, 1, 0, 1},
  {&__pyx_n_u_deposit_fee, __pyx_k_deposit_fee, sizeof(__pyx_k_deposit_fee), 0, 1, 0, 1},
  {&__pyx_n_s_depot, __pyx_k_depot, sizeof(__pyx_k_depot), 0, 0, 1, 1},
  {&__pyx_n_u_depot, __pyx_k_depot, sizeof(__pyx_k_depot), 0, 1, 0, 1},
  {&__pyx_n_u_depot_setter, __pyx_k_depot_setter, sizeof(__pyx_k_depot_setter), 0, 1, 0, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
  {&__pyx_n_s_element, __pyx_k_element, sizeof(__pyx_k_element), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_eval_fee, __pyx_k_eval_fee, sizeof(__pyx_k_eval_fee), 0, 0, 1, 1},
  {&__pyx_n_b_except, __pyx_k_except, sizeof(__pyx_k_except), 0, 0, 0, 1},
  {&__pyx_n_u_except, __pyx_k_except, sizeof(__pyx_k_except), 0, 1, 0, 1},
  {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1},
  {&__pyx_n_u_exchange_rate_currency, __pyx_k_exchange_rate_currency, sizeof(__pyx_k_exchange_rate_currency), 0, 1, 0, 1},
  {&__pyx_n_u_exchange_rate_key_tuple, __pyx_k_exchange_rate_key_tuple, sizeof(__pyx_k_exchange_rate_key_tuple), 0, 1, 0, 1},
  {&__pyx_n_u_exchange_rate_value, __pyx_k_exchange_rate_value, sizeof(__pyx_k_exchange_rate_value), 0, 1, 0, 1},
  {&__pyx_n_s_exchange_rates, __pyx_k_exchange_rates, sizeof(__pyx_k_exchange_rates), 0, 0, 1, 1},
  {&__pyx_n_u_exchange_rates, __pyx_k_exchange_rates, sizeof(__pyx_k_exchange_rates), 0, 1, 0, 1},
  {&__pyx_kp_u_exchange_rates_dict, __pyx_k_exchange_rates_dict, sizeof(__pyx_k_exchange_rates_dict), 0, 1, 0, 0},
  {&__pyx_kp_u_exchange_rates_does_not_include, __pyx_k_exchange_rates_does_not_include, sizeof(__pyx_k_exchange_rates_does_not_include), 0, 1, 0, 0},
  {&__pyx_n_u_exchange_rates_setter, __pyx_k_exchange_rates_setter, sizeof(__pyx_k_exchange_rates_setter), 0, 1, 0, 1},
  {&__pyx_n_s_exec_heap, __pyx_k_exec_heap, sizeof(__pyx_k_exec_heap), 0, 0, 1, 1},
  {&__pyx_n_u_exec_heap, __pyx_k_exec_heap, sizeof(__pyx_k_exec_heap), 0, 1, 0, 1},
  {&__pyx_kp_u_exec_heap_must_be_either_list_of, __pyx_k_exec_heap_must_be_either_list_of, sizeof(__pyx_k_exec_heap_must_be_either_list_of), 0, 1, 0, 0},
  {&__pyx_n_s_f_key, __pyx_k_f_key, sizeof(__pyx_k_f_key), 0, 0, 1, 1},
  {&__pyx_n_s_fee, __pyx_k_fee, sizeof(__pyx_k_fee), 0, 0, 1, 1},
  {&__pyx_n_s_fee_2, __pyx_k_fee_2, sizeof(__pyx_k_fee_2), 0, 0, 1, 1},
  {&__pyx_n_s_fee_amount, __pyx_k_fee_amount, sizeof(__pyx_k_fee_amount), 0, 0, 1, 1},
  {&__pyx_n_u_fee_amount, __pyx_k_fee_amount, sizeof(__pyx_k_fee_amount), 0, 1, 0, 1},
  {&__pyx_n_s_fee_buy, __pyx_k_fee_buy, sizeof(__pyx_k_fee_buy), 0, 0, 1, 1},
  {&__pyx_n_u_fee_buy, __pyx_k_fee_buy, sizeof(__pyx_k_fee_buy), 0, 1, 0, 1},
  {&__pyx_n_s_fee_currency, __pyx_k_fee_currency, sizeof(__pyx_k_fee_currency), 0, 0, 1, 1},
  {&__pyx_n_u_fee_currency, __pyx_k_fee_currency, sizeof(__pyx_k_fee_currency), 0, 1, 0, 1},
  {&__pyx_n_s_fee_deposit, __pyx_k_fee_deposit, sizeof(__pyx_k_fee_deposit), 0, 0, 1, 1},
  {&__pyx_n_u_fee_deposit, __pyx_k_fee_deposit, sizeof(__pyx_k_fee_deposit), 0, 1, 0, 1},
  {&__pyx_n_s_fee_dict, __pyx_k_fee_dict, sizeof(__pyx_k_fee_dict), 0, 0, 1, 1},
  {&__pyx_n_u_fee_dict, __pyx_k_fee_dict, sizeof(__pyx_k_fee_dict), 0, 1, 0, 1},
  {&__pyx_n_s_fee_exec_duration, __pyx_k_fee_exec_duration, sizeof(__pyx_k_fee_exec_duration), 0, 0, 1, 1},
  {&__pyx_n_s_fee_keys, __pyx_k_fee_keys, sizeof(__pyx_k_fee_keys), 0, 0, 1, 1},
  {&__pyx_n_u_fee_processing_duration, __pyx_k_fee_processing_duration, sizeof(__pyx_k_fee_processing_duration), 0, 1, 0, 1},
  {&__pyx_n_s_fee_sell, __pyx_k_fee_sell, sizeof(__pyx_k_fee_sell), 0, 0, 1, 1},
  {&__pyx_n_u_fee_sell, __pyx_k_fee_sell, sizeof(__pyx_k_fee_sell), 0, 1, 0, 1},
  {&__pyx_kp_u_fee_setter_argument_must_be_dic, __pyx_k_fee_setter_argument_must_be_dic, sizeof(__pyx_k_fee_setter_argument_must_be_dic), 0, 1, 0, 0},
  {&__pyx_n_s_fee_tmp_dict, __pyx_k_fee_tmp_dict, sizeof(__pyx_k_fee_tmp_dict), 0, 0, 1, 1},
  {&__pyx_n_s_fee_volume, __pyx_k_fee_volume, sizeof(__pyx_k_fee_volume), 0, 0, 1, 1},
  {&__pyx_n_s_fee_withdraw, __pyx_k_fee_withdraw, sizeof(__pyx_k_fee_withdraw), 0, 0, 1, 1},
  {&__pyx_n_u_fee_withdraw, __pyx_k_fee_withdraw, sizeof(__pyx_k_fee_withdraw), 0, 1, 0, 1},
  {&__pyx_n_s_fill_fee, __pyx_k_fill_fee, sizeof(__pyx_k_fill_fee), 0, 0, 1, 1},
  {&__pyx_n_s_float_fee_currency, __pyx_k_float_fee_currency, sizeof(__pyx_k_float_fee_currency), 0, 0, 1, 1},
  {&__pyx_n_u_float_fee_currency, __pyx_k_float_fee_currency, sizeof(__pyx_k_float_fee_currency), 0, 1, 0, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_forward_coverage, __pyx_k_forward_coverage, sizeof(__pyx_k_forward_coverage), 0, 0, 1, 1},
  {&__pyx_n_s_full_reset, __pyx_k_full_reset, sizeof(__pyx_k_full_reset), 0, 0, 1, 1},
  {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1},
  {&__pyx_n_s_fx_null_fee, __pyx_k_fx_null_fee, sizeof(__pyx_k_fx_null_fee), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_s_has_risen, __pyx_k_has_risen, sizeof(__pyx_k_has_risen), 0, 0, 1, 1},
  {&__pyx_n_s_has_warn, __pyx_k_has_warn, sizeof(__pyx_k_has_warn), 0, 0, 1, 1},
  {&__pyx_n_u_heap_action_type, __pyx_k_heap_action_type, sizeof(__pyx_k_heap_action_type), 0, 1, 0, 1},
  {&__pyx_n_u_heap_coverage, __pyx_k_heap_coverage, sizeof(__pyx_k_heap_coverage), 0, 1, 0, 1},
  {&__pyx_n_u_heap_currency, __pyx_k_heap_currency, sizeof(__pyx_k_heap_currency), 0, 1, 0, 1},
  {&__pyx_n_u_heap_time, __pyx_k_heap_time, sizeof(__pyx_k_heap_time), 0, 1, 0, 1},
  {&__pyx_n_u_heap_volume, __pyx_k_heap_volume, sizeof(__pyx_k_heap_volume), 0, 1, 0, 1},
  {&__pyx_n_s_heapify, __pyx_k_heapify, sizeof(__pyx_k_heapify), 0, 0, 1, 1},
  {&__pyx_n_s_heapq, __pyx_k_heapq, sizeof(__pyx_k_heapq), 0, 0, 1, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_u_ignore, __pyx_k_ignore, sizeof(__pyx_k_ignore), 0, 1, 0, 1},
  {&__pyx_n_s_ignore_type_checking, __pyx_k_ignore_type_checking, sizeof(__pyx_k_ignore_type_checking), 0, 0, 1, 1},
  {&__pyx_n_u_ignore_type_checking, __pyx_k_ignore_type_checking, sizeof(__pyx_k_ignore_type_checking), 0, 1, 0, 1},
  {&__pyx_n_s_ignore_type_checking_2, __pyx_k_ignore_type_checking_2, sizeof(__pyx_k_ignore_type_checking_2), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_inp, __pyx_k_inp, sizeof(__pyx_k_inp), 0, 0, 1, 1},
  {&__pyx_n_u_inp, __pyx_k_inp, sizeof(__pyx_k_inp), 0, 1, 0, 1},
  {&__pyx_n_s_instant_float_fee, __pyx_k_instant_float_fee, sizeof(__pyx_k_instant_float_fee), 0, 0, 1, 1},
  {&__pyx_n_u_instant_float_fee, __pyx_k_instant_float_fee, sizeof(__pyx_k_instant_float_fee), 0, 1, 0, 1},
  {&__pyx_n_s_instant_withdrawal, __pyx_k_instant_withdrawal, sizeof(__pyx_k_instant_withdrawal), 0, 0, 1, 1},
  {&__pyx_n_u_instant_withdrawal, __pyx_k_instant_withdrawal, sizeof(__pyx_k_instant_withdrawal), 0, 1, 0, 1},
  {&__pyx_n_s_is_exchange_rate_updated, __pyx_k_is_exchange_rate_updated, sizeof(__pyx_k_is_exchange_rate_updated), 0, 0, 1, 1},
  {&__pyx_n_u_is_exchange_rate_updated_setter, __pyx_k_is_exchange_rate_updated_setter, sizeof(__pyx_k_is_exchange_rate_updated_setter), 0, 1, 0, 1},
  {&__pyx_n_s_issubset, __pyx_k_issubset, sizeof(__pyx_k_issubset), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
  {&__pyx_n_s_list_base_quote_pair, __pyx_k_list_base_quote_pair, sizeof(__pyx_k_list_base_quote_pair), 0, 0, 1, 1},
  {&__pyx_n_s_list_base_quote_pairs, __pyx_k_list_base_quote_pairs, sizeof(__pyx_k_list_base_quote_pairs), 0, 0, 1, 1},
  {&__pyx_kp_u_list_base_quote_pairs_must_conta, __pyx_k_list_base_quote_pairs_must_conta, sizeof(__pyx_k_list_base_quote_pairs_must_conta), 0, 1, 0, 0},
  {&__pyx_n_s_list_rates, __pyx_k_list_rates, sizeof(__pyx_k_list_rates), 0, 0, 1, 1},
  {&__pyx_kp_u_list_rates_must_contain_floats_o, __pyx_k_list_rates_must_contain_floats_o, sizeof(__pyx_k_list_rates_must_contain_floats_o), 0, 1, 0, 0},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_marked_coverage, __pyx_k_marked_coverage, sizeof(__pyx_k_marked_coverage), 0, 0, 1, 1},
  {&__pyx_n_u_max_forward, __pyx_k_max_forward, sizeof(__pyx_k_max_forward), 0, 1, 0, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_u_min_backward, __pyx_k_min_backward, sizeof(__pyx_k_min_backward), 0, 1, 0, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_kp_u_must_be_of_type_None_bool_float, __pyx_k_must_be_of_type_None_bool_float, sizeof(__pyx_k_must_be_of_type_None_bool_float), 0, 1, 0, 0},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_kp_u_or_are_not_included_in_exchange, __pyx_k_or_are_not_included_in_exchange, sizeof(__pyx_k_or_are_not_included_in_exchange), 0, 1, 0, 0},
  {&__pyx_n_s_parse_depot, __pyx_k_parse_depot, sizeof(__pyx_k_parse_depot), 0, 0, 1, 1},
  {&__pyx_n_s_parse_exchange_rates, __pyx_k_parse_exchange_rates, sizeof(__pyx_k_parse_exchange_rates), 0, 0, 1, 1},
  {&__pyx_n_s_parse_exec_heap, __pyx_k_parse_exec_heap, sizeof(__pyx_k_parse_exec_heap), 0, 0, 1, 1},
  {&__pyx_n_s_parse_fee_and_transaction_param, __pyx_k_parse_fee_and_transaction_param, sizeof(__pyx_k_parse_fee_and_transaction_param), 0, 0, 1, 1},
  {&__pyx_n_s_parse_fees, __pyx_k_parse_fees, sizeof(__pyx_k_parse_fees), 0, 0, 1, 1},
  {&__pyx_n_s_parsed_fee_currency, __pyx_k_parsed_fee_currency, sizeof(__pyx_k_parsed_fee_currency), 0, 0, 1, 1},
  {&__pyx_n_u_partial, __pyx_k_partial, sizeof(__pyx_k_partial), 0, 1, 0, 1},
  {&__pyx_n_s_payee_account, __pyx_k_payee_account, sizeof(__pyx_k_payee_account), 0, 0, 1, 1},
  {&__pyx_kp_u_payee_account_has_no_implementat, __pyx_k_payee_account_has_no_implementat, sizeof(__pyx_k_payee_account_has_no_implementat), 0, 1, 0, 0},
  {&__pyx_n_s_payee_fee, __pyx_k_payee_fee, sizeof(__pyx_k_payee_fee), 0, 0, 1, 1},
  {&__pyx_n_s_payee_fee_currency, __pyx_k_payee_fee_currency, sizeof(__pyx_k_payee_fee_currency), 0, 0, 1, 1},
  {&__pyx_n_s_payee_fee_exec_duration, __pyx_k_payee_fee_exec_duration, sizeof(__pyx_k_payee_fee_exec_duration), 0, 0, 1, 1},
  {&__pyx_n_s_payee_fee_volume, __pyx_k_payee_fee_volume, sizeof(__pyx_k_payee_fee_volume), 0, 0, 1, 1},
  {&__pyx_n_s_payee_processing_duration, __pyx_k_payee_processing_duration, sizeof(__pyx_k_payee_processing_duration), 0, 0, 1, 1},
  {&__pyx_n_u_payee_processing_duration, __pyx_k_payee_processing_duration, sizeof(__pyx_k_payee_processing_duration), 0, 1, 0, 1},
  {&__pyx_n_s_payer_account, __pyx_k_payer_account, sizeof(__pyx_k_payer_account), 0, 0, 1, 1},
  {&__pyx_kp_u_payer_account_has_no_implementat, __pyx_k_payer_account_has_no_implementat, sizeof(__pyx_k_payer_account_has_no_implementat), 0, 1, 0, 0},
  {&__pyx_n_s_payer_fee, __pyx_k_payer_fee, sizeof(__pyx_k_payer_fee), 0, 0, 1, 1},
  {&__pyx_n_u_payer_fee, __pyx_k_payer_fee, sizeof(__pyx_k_payer_fee), 0, 1, 0, 1},
  {&__pyx_n_s_payer_fee_currency, __pyx_k_payer_fee_currency, sizeof(__pyx_k_payer_fee_currency), 0, 0, 1, 1},
  {&__pyx_n_s_payer_fee_exec_duration, __pyx_k_payer_fee_exec_duration, sizeof(__pyx_k_payer_fee_exec_duration), 0, 0, 1, 1},
  {&__pyx_n_s_payer_fee_volume, __pyx_k_payer_fee_volume, sizeof(__pyx_k_payer_fee_volume), 0, 0, 1, 1},
  {&__pyx_n_s_payer_processing_duration, __pyx_k_payer_processing_duration, sizeof(__pyx_k_payer_processing_duration), 0, 0, 1, 1},
  {&__pyx_n_u_payer_processing_duration, __pyx_k_payer_processing_duration, sizeof(__pyx_k_payer_processing_duration), 0, 1, 0, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_position, __pyx_k_position, sizeof(__pyx_k_position), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_price, __pyx_k_price, sizeof(__pyx_k_price), 0, 0, 1, 1},
  {&__pyx_n_s_processing_duration, __pyx_k_processing_duration, sizeof(__pyx_k_processing_duration), 0, 0, 1, 1},
  {&__pyx_n_u_processing_duration, __pyx_k_processing_duration, sizeof(__pyx_k_processing_duration), 0, 1, 0, 1},
  {&__pyx_n_s_prohibit_debiting, __pyx_k_prohibit_debiting, sizeof(__pyx_k_prohibit_debiting), 0, 0, 1, 1},
  {&__pyx_n_u_prohibit_debiting, __pyx_k_prohibit_debiting, sizeof(__pyx_k_prohibit_debiting), 0, 1, 0, 1},
  {&__pyx_n_u_prohibit_debiting_setter, __pyx_k_prohibit_debiting_setter, sizeof(__pyx_k_prohibit_debiting_setter), 0, 1, 0, 1},
  {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_cFXAccount, __pyx_k_pyx_unpickle_cFXAccount, sizeof(__pyx_k_pyx_unpickle_cFXAccount), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_quote, __pyx_k_quote, sizeof(__pyx_k_quote), 0, 0, 1, 1},
  {&__pyx_n_u_quote, __pyx_k_quote, sizeof(__pyx_k_quote), 0, 1, 0, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_rate, __pyx_k_rate, sizeof(__pyx_k_rate), 0, 0, 1, 1},
  {&__pyx_n_u_rate, __pyx_k_rate, sizeof(__pyx_k_rate), 0, 1, 0, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_reference_currency, __pyx_k_reference_currency, sizeof(__pyx_k_reference_currency), 0, 0, 1, 1},
  {&__pyx_n_u_reference_currency, __pyx_k_reference_currency, sizeof(__pyx_k_reference_currency), 0, 1, 0, 1},
  {&__pyx_n_s_reset, __pyx_k_reset, sizeof(__pyx_k_reset), 0, 0, 1, 1},
  {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
  {&__pyx_n_s_sample_key, __pyx_k_sample_key, sizeof(__pyx_k_sample_key), 0, 0, 1, 1},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_b_sell, __pyx_k_sell, sizeof(__pyx_k_sell), 0, 0, 0, 1},
  {&__pyx_n_s_sell, __pyx_k_sell, sizeof(__pyx_k_sell), 0, 0, 1, 1},
  {&__pyx_n_u_sell, __pyx_k_sell, sizeof(__pyx_k_sell), 0, 1, 0, 1},
  {&__pyx_n_u_sell_fee, __pyx_k_sell_fee, sizeof(__pyx_k_sell_fee), 0, 1, 0, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_setter, __pyx_k_setter, sizeof(__pyx_k_setter), 0, 0, 1, 1},
  {&__pyx_n_s_staticmethod, __pyx_k_staticmethod, sizeof(__pyx_k_staticmethod), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_tick, __pyx_k_tick, sizeof(__pyx_k_tick), 0, 0, 1, 1},
  {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1},
  {&__pyx_n_s_time_step, __pyx_k_time_step, sizeof(__pyx_k_time_step), 0, 0, 1, 1},
  {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1},
  {&__pyx_n_s_total_balance, __pyx_k_total_balance, sizeof(__pyx_k_total_balance), 0, 0, 1, 1},
  {&__pyx_n_s_tpz_exception, __pyx_k_tpz_exception, sizeof(__pyx_k_tpz_exception), 0, 0, 1, 1},
  {&__pyx_n_s_transfer, __pyx_k_transfer, sizeof(__pyx_k_transfer), 0, 0, 1, 1},
  {&__pyx_n_s_trapeza, __pyx_k_trapeza, sizeof(__pyx_k_trapeza), 0, 0, 1, 1},
  {&__pyx_n_s_trapeza_account_base_account, __pyx_k_trapeza_account_base_account, sizeof(__pyx_k_trapeza_account_base_account), 0, 0, 1, 1},
  {&__pyx_n_s_trapeza_account_fx_account, __pyx_k_trapeza_account_fx_account, sizeof(__pyx_k_trapeza_account_fx_account), 0, 0, 1, 1},
  {&__pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_k_trapeza_account_fx_account_pyx, sizeof(__pyx_k_trapeza_account_fx_account_pyx), 0, 0, 1, 0},
  {&__pyx_n_s_trapeza_utils, __pyx_k_trapeza_utils, sizeof(__pyx_k_trapeza_utils), 0, 0, 1, 1},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_update_exchange_rate, __pyx_k_update_exchange_rate, sizeof(__pyx_k_update_exchange_rate), 0, 0, 1, 1},
  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
  {&__pyx_n_s_vec_heap, __pyx_k_vec_heap, sizeof(__pyx_k_vec_heap), 0, 0, 1, 1},
  {&__pyx_n_s_virtual_deposit, __pyx_k_virtual_deposit, sizeof(__pyx_k_virtual_deposit), 0, 0, 1, 1},
  {&__pyx_n_s_volume, __pyx_k_volume, sizeof(__pyx_k_volume), 0, 0, 1, 1},
  {&__pyx_n_u_volume, __pyx_k_volume, sizeof(__pyx_k_volume), 0, 1, 0, 1},
  {&__pyx_n_s_volume_base, __pyx_k_volume_base, sizeof(__pyx_k_volume_base), 0, 0, 1, 1},
  {&__pyx_kp_u_volume_must_be_grater_than_0, __pyx_k_volume_must_be_grater_than_0, sizeof(__pyx_k_volume_must_be_grater_than_0), 0, 1, 0, 0},
  {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1},
  {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1},
  {&__pyx_n_b_withdraw, __pyx_k_withdraw, sizeof(__pyx_k_withdraw), 0, 0, 0, 1},
  {&__pyx_n_s_withdraw, __pyx_k_withdraw, sizeof(__pyx_k_withdraw), 0, 0, 1, 1},
  {&__pyx_n_u_withdraw, __pyx_k_withdraw, sizeof(__pyx_k_withdraw), 0, 1, 0, 1},
  {&__pyx_n_u_withdrawal_fee, __pyx_k_withdrawal_fee, sizeof(__pyx_k_withdrawal_fee), 0, 1, 0, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) __PYX_ERR(0, 1187, __pyx_L1_error)
  __pyx_builtin_staticmethod = __Pyx_GetBuiltinName(__pyx_n_s_staticmethod); if (!__pyx_builtin_staticmethod) __PYX_ERR(0, 1655, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 229, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 934, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 1015, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 1248, __pyx_L1_error)
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 1620, __pyx_L1_error)
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(0, 1711, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 1725, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 1842, __pyx_L1_error)
  __pyx_builtin_NameError = __Pyx_GetBuiltinName(__pyx_n_s_NameError); if (!__pyx_builtin_NameError) __PYX_ERR(0, 1947, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "trapeza/account/fx_account.pyx":1015
 *                 if is_base_quote_notation and is_quote_base_notation:
 *                     if ex_rate != c_precision_divide(1, inv_ex_rate):
 *                         raise ValueError('Exchange rates of base|quote and 1/quote|base do not match up.')             # <<<<<<<<<<<<<<
 *             else:
 *                 # already in reference currency, so just add
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_Exchange_rates_of_base_quote_and); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 1015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "trapeza/account/fx_account.pyx":1248
 *             self._c_check_marked_coverage = inp
 *         else:
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')             # <<<<<<<<<<<<<<
 *     @check_marked_coverage.deleter
 *     def check_marked_coverage(self):
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_u_check_marked_coverage_must_be_in); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 1248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "trapeza/account/fx_account.pyx":1270
 *         try:
 *             if inp < 0:
 *                 raise ValueError('Internal clock must be set to >=0.')             # <<<<<<<<<<<<<<
 *             elif not int(inp) == inp:
 *                 raise TypeError('Only integers for setting internal clock.')
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_u_Internal_clock_must_be_set_to_0); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 1270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "trapeza/account/fx_account.pyx":1272
 *                 raise ValueError('Internal clock must be set to >=0.')
 *             elif not int(inp) == inp:
 *                 raise TypeError('Only integers for setting internal clock.')             # <<<<<<<<<<<<<<
 *             else:
 *                 self._c_clock = inp
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_Only_integers_for_setting_intern); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "trapeza/account/fx_account.pyx":1343
 *                                            self._c_ignore_type_checking)
 *         except TypeError:
 *             raise TypeError('_fee setter argument must be dict with fee["buy"], fee["sell"], fee["deposit"] '             # <<<<<<<<<<<<<<
 *                             'and fee["withdraw"]. See docstring of FXAccount for further information about fee '
 *                             'handling.')
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_fee_setter_argument_must_be_dic); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 1343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "trapeza/account/fx_account.pyx":1649
 *         :raises: TypeError
 *         """
 *         result = func(1, 1, 'X', 'Y', 1)             # <<<<<<<<<<<<<<
 *         if len(result) != 3:
 *             raise TypeError
 */
  __pyx_tuple__17 = PyTuple_Pack(5, __pyx_int_1, __pyx_int_1, __pyx_n_u_X, __pyx_n_u_Y, __pyx_int_1); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 1649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "trapeza/account/fx_account.pyx":1703
 *                 elif not list(exec_heap) == exec_heap:
 *                     has_risen = True
 *                     raise TypeError('exec_heap must be either list of list, tuples of lists, tuple of a single entry'             # <<<<<<<<<<<<<<
 *                                     'to exec_heap or list of single entry to exec_heap. Single entry to exec_heap'
 *                                     'consists of: [int:time, str:action_func, float:volume, str:currency, '
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_u_exec_heap_must_be_either_list_of); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 1703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "trapeza/account/fx_account.pyx":1753
 *                                     '"deposit", got {}'.format(element[1]))
 *                 if element[4] not in ['except', 'partial', 'debit', 'ignore']:
 *                     raise ValueError('coverage must be in ["except", "partial", "debit", "ignore"]')             # <<<<<<<<<<<<<<
 *                 check_types([element[0], element[1], element[2], element[3], element[4]],
 *                             [int, str, float, str, str],
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_u_coverage_must_be_in_except_parti); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 1753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "trapeza/account/fx_account.pyx":1890
 * 
 *         if float_fee_currency is None:
 *             raise NotImplementedError('alt_fee must be in {None, False, func, Float')             # <<<<<<<<<<<<<<
 * 
 *         if processing_duration is None:
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_u_alt_fee_must_be_in_None_False_fu); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 1890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "trapeza/account/fx_account.pyx":2155
 *         # >>>sanity and type checking
 *         if volume < 0:
 *             raise ValueError('volume must be grater than 0.')             # <<<<<<<<<<<<<<
 * 
 *         check_types([volume, currency, processing_duration, parsed_fee_currency, instant_float_fee, coverage],
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_u_volume_must_be_grater_than_0); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 2155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "trapeza/account/fx_account.pyx":2172
 *         # >>>handle coverage exception
 *         if coverage not in ['except', 'partial', 'debit']:
 *             raise NotImplementedError('coverage must be {"except", "partial", "debit"}.')             # <<<<<<<<<<<<<<
 * 
 *         return self.c_withdraw(volume, currency.encode(), processing_duration, fee_volume, fee_currency.encode(),
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_u_coverage_must_be_except_partial); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 2172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "trapeza/account/fx_account.pyx":2294
 *         # >>>handle coverage exception induced by fees
 *         if coverage not in ['except', 'debit']:
 *             raise NotImplementedError('coverage must be {"except", "debit"}.')             # <<<<<<<<<<<<<<
 * 
 *         return self.c_deposit(volume, currency.encode(), processing_duration, fee_volume, fee_currency.encode(),
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u_coverage_must_be_except_debit); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 2294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "trapeza/account/fx_account.pyx":2930
 *                     pass
 *                 else:
 *                     raise TypeError('clock has to be int >= 0.')             # <<<<<<<<<<<<<<
 *             except Exception as e:
 *                 raise e
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_u_clock_has_to_be_int_0); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 2930, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "trapeza/account/fx_account.pyx":2996
 *         """
 *         if not (len(list_rates) == len(list_base_quote_pairs)):
 *             raise IndexError('Lists must have same length.')             # <<<<<<<<<<<<<<
 * 
 *         for i in range(len(list_rates)):
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_u_Lists_must_have_same_length); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 2996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "trapeza/account/fx_account.pyx":1188
 * 
 *     @property
 *     def exec_heap(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns internal heap of delayed transactions. Internally the heap is implemented as C++ vector int the
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 1188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
  __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_exec_heap, 1188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 1188, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1202
 *         return ProtectedExecHeap(self.vec_heap.tolist())
 *     @exec_heap.setter
 *     def exec_heap(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internal heap (and underlying C++ vector implementation). See getter method for further information.
 */
  __pyx_tuple__29 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_inp); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 1202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);
  __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_exec_heap, 1202, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 1202, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1211
 *         self.vec_heap = cFXWrapperVectorHeap(inp)
 *     @exec_heap.deleter
 *     def exec_heap(self):             # <<<<<<<<<<<<<<
 *         del self.exec_heap
 * 
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);
  __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_exec_heap, 1211, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 1211, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1215
 * 
 *     @property
 *     def check_marked_coverage(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns status of self.check_marked_coverage which denotes how coverage analysis is conducted for marked but
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);
  __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_check_marked_coverage, 1215, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 1215, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1231
 *                                               'set to an invalid value.')
 *     @check_marked_coverage.setter
 *     def check_marked_coverage(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set type of coverage analysis.
 */
  __pyx_tuple__35 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_inp); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
  __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_check_marked_coverage, 1231, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 1231, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1250
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *     @check_marked_coverage.deleter
 *     def check_marked_coverage(self):             # <<<<<<<<<<<<<<
 *         del self.check_marked_coverage
 * 
 */
  __pyx_tuple__37 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 1250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);
  __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_check_marked_coverage, 1250, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 1250, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1254
 * 
 *     @property
 *     def clock(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current internal clock.
 */
  __pyx_tuple__39 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 1254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);
  __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_clock, 1254, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 1254, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1261
 *         return self._c_clock
 *     @clock.setter
 *     def clock(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set current internal clock. It is not recommended to manually set internal clock, but use self.tick() instead.
 */
  __pyx_tuple__41 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_inp, __pyx_n_s_e); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 1261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
  __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_clock, 1261, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 1261, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1278
 *             raise e
 *     @clock.deleter
 *     def clock(self):             # <<<<<<<<<<<<<<
 *         del self.clock
 * 
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 1278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);
  __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_clock, 1278, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 1278, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1282
 * 
 *     @property
 *     def _ignore_type_checking(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns whether type checking is ignored or not.
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 1282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);
  __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_ignore_type_checking_2, 1282, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 1282, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1291
 * 
 *     @property
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current depot and it's positions. Returned dict is not manipulable/ mutable. Use setter method instead.
 */
  __pyx_tuple__47 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 1291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);
  __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_depot, 1291, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 1291, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1298
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_depot.items())
 *     @depot.setter
 *     def depot(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set depot by providing a complete dict of all new positions
 */
  __pyx_tuple__49 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_inp); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 1298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);
  __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_depot, 1298, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 1298, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1308
 *         self._c_depot = self._parse_depot(inp, self._c_ignore_type_checking)
 *     @depot.deleter
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         del self.depot
 * 
 */
  __pyx_tuple__51 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 1308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);
  __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_depot, 1308, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 1308, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1312
 * 
 *     @property
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current set fees. Returned dict is not manipulable/ mutable. Use setter method instead.
 */
  __pyx_tuple__53 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 1312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);
  __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_fee, 1312, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 1312, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1319
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_fee.items())
 *     @_fee.setter
 *     def _fee(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new fees by providing a dict. Dict can contain keys:{'sell', 'buy', 'withdraw', 'deposit'}. If one of the
 */
  __pyx_tuple__55 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_inp, __pyx_n_s_fee_tmp_dict, __pyx_n_s_fee_keys, __pyx_n_s_f_key); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 1319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);
  __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_fee, 1319, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 1319, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1351
 *                             'handling.')
 *     @_fee.deleter
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         del self._fee
 * 
 */
  __pyx_tuple__57 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 1351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);
  __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_fee, 1351, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 1351, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1355
 * 
 *     @property
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns current exchange rates (which was previously provided by self.tick(...), self.update_exchange_rate(...)
 */
  __pyx_tuple__59 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 1355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);
  __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_exchange_rates, 1355, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 1355, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1363
 *         return ProtectedDict(((k[0].decode(), k[1].decode()), v) for k, v in self._c_exchange_rates.items())
 *     @exchange_rates.setter
 *     def exchange_rates(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new exchange rates as complete dict of all currency pairs. Must contain all currency pairs which are also
 */
  __pyx_tuple__61 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_inp); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 1363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);
  __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_exchange_rates, 1363, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) __PYX_ERR(0, 1363, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1376
 *         self._c_exchange_rates = self._parse_exchange_rates(inp, self._c_ignore_type_checking)
 *     @exchange_rates.deleter
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         del self.exchange_rates
 * 
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 1376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);
  __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_exchange_rates, 1376, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) __PYX_ERR(0, 1376, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1380
 * 
 *     @property
 *     def reference_currency(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return reference currency used for calculating total balance/ value of depot and fees.
 */
  __pyx_tuple__65 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 1380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);
  __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_reference_currency, 1380, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) __PYX_ERR(0, 1380, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1387
 *         return self._c_reference_currency.decode()
 *     @reference_currency.setter
 *     def reference_currency(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new reference currency.
 */
  __pyx_tuple__67 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_inp); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 1387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);
  __pyx_codeobj__68 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_reference_currency, 1387, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__68)) __PYX_ERR(0, 1387, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1397
 *         self._c_reference_currency = inp.encode()
 *     @reference_currency.deleter
 *     def reference_currency(self):             # <<<<<<<<<<<<<<
 *         del self.reference_currency
 * 
 */
  __pyx_tuple__69 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 1397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);
  __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_reference_currency, 1397, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) __PYX_ERR(0, 1397, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1401
 * 
 *     @property
 *     def is_exchange_rate_updated(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns whether internal exchange rates have been updated and self.total_balance() is ready to be called.
 */
  __pyx_tuple__71 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 1401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);
  __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_is_exchange_rate_updated, 1401, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) __PYX_ERR(0, 1401, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1408
 *         return self._c_is_exchange_rate_updated
 *     @is_exchange_rate_updated.setter
 *     def is_exchange_rate_updated(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internal status whether exchange rates have been updated and self.total_balance() is
 */
  __pyx_tuple__73 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_inp); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 1408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);
  __pyx_codeobj__74 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_is_exchange_rate_updated, 1408, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__74)) __PYX_ERR(0, 1408, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1419
 *         self._c_is_exchange_rate_updated = inp
 *     @is_exchange_rate_updated.deleter
 *     def is_exchange_rate_updated(self):             # <<<<<<<<<<<<<<
 *         del self.is_exchange_rate_updated
 * 
 */
  __pyx_tuple__75 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);
  __pyx_codeobj__76 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_is_exchange_rate_updated, 1419, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__76)) __PYX_ERR(0, 1419, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1423
 * 
 *     @property
 *     def prohibit_debiting(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return whether debiting of account is allowed or not.
 */
  __pyx_tuple__77 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);
  __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_prohibit_debiting, 1423, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) __PYX_ERR(0, 1423, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1430
 *         return self._c_prohibit_debiting
 *     @prohibit_debiting.setter
 *     def prohibit_debiting(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internally whether debiting of account is allowed. It is not recommended to set this value manually as it
 */
  __pyx_tuple__79 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_inp); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 1430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);
  __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_prohibit_debiting, 1430, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) __PYX_ERR(0, 1430, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1441
 *         self._c_prohibit_debiting = inp
 *     @prohibit_debiting.deleter
 *     def prohibit_debiting(self):             # <<<<<<<<<<<<<<
 *         del self.prohibit_debiting
 * 
 */
  __pyx_tuple__81 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 1441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);
  __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_prohibit_debiting, 1441, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) __PYX_ERR(0, 1441, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1444
 *         del self.prohibit_debiting
 * 
 *     def __init__(self, reference_currency, depot=None,             # <<<<<<<<<<<<<<
 *                  fee_buy=False, fee_sell=False, fee_deposit=False, fee_withdraw=False,
 *                  exec_heap=None, long clock=0, exchange_rates=None, marked_coverage='min_backward',
 */
  __pyx_tuple__83 = PyTuple_Pack(14, __pyx_n_s_self, __pyx_n_s_reference_currency, __pyx_n_s_depot, __pyx_n_s_fee_buy, __pyx_n_s_fee_sell, __pyx_n_s_fee_deposit, __pyx_n_s_fee_withdraw, __pyx_n_s_exec_heap, __pyx_n_s_clock, __pyx_n_s_exchange_rates, __pyx_n_s_marked_coverage, __pyx_n_s_prohibit_debiting, __pyx_n_s_ignore_type_checking, __pyx_n_s_fee_dict); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 1444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);
  __pyx_codeobj__84 = (PyObject*)__Pyx_PyCode_New(13, 0, 14, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_init, 1444, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__84)) __PYX_ERR(0, 1444, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1623
 *                          marked_coverage, prohibit_debiting, ignore_type_checking)
 * 
 *     def _full_reset(self):             # <<<<<<<<<<<<<<
 *         """
 *         Resets account with depot=None, fee_x=False (e.g. fee_buy), check_marked_coverage='min_backward', empty heap,
 */
  __pyx_tuple__85 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(0, 1623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);
  __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__85, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_full_reset, 1623, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) __PYX_ERR(0, 1623, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1632
 *         self.__init__(self._c_reference_currency.decode())
 * 
 *     def _reset(self):             # <<<<<<<<<<<<<<
 *         """
 *         Resets account but retains reference_currency, check_marked_coverage, prohibit_debiting, ignore_type_checking
 */
  __pyx_tuple__87 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 1632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);
  __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_reset, 1632, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) __PYX_ERR(0, 1632, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1641
 *         self._c_reset()
 * 
 *     def _check_is_valid_fee_func(self, func):             # <<<<<<<<<<<<<<
 *         """
 *         Checks if function is a valid function for fees and complies with following signature
 */
  __pyx_tuple__89 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_func, __pyx_n_s_result); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 1641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);
  __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__89, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_check_is_valid_fee_func, 1641, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) __PYX_ERR(0, 1641, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1656
 * 
 *     @staticmethod
 *     def _parse_depot(depot, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks init arguments
 */
  __pyx_tuple__91 = PyTuple_Pack(6, __pyx_n_s_depot, __pyx_n_s_ignore_type_checking, __pyx_n_s_currency, __pyx_n_s_volume, __pyx_n_s_k, __pyx_n_s_v); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 1656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);
  __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__91, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_parse_depot, 1656, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) __PYX_ERR(0, 1656, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1677
 * 
 *     @staticmethod
 *     def _parse_exec_heap(exec_heap, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks if provided (heap) list is valid as internal execution heap
 */
  __pyx_tuple__94 = PyTuple_Pack(7, __pyx_n_s_exec_heap, __pyx_n_s_ignore_type_checking, __pyx_n_s_has_warn, __pyx_n_s_has_risen, __pyx_n_s__93, __pyx_n_s_i, __pyx_n_s_element); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 1677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);
  __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__94, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_parse_exec_heap, 1677, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) __PYX_ERR(0, 1677, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1760
 *         return exec_heap
 * 
 *     def _parse_fees(self, fee_buy, fee_sell, fee_deposit, fee_withdraw, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks fees. Uses standard fee function (equivalent to not applying any fees) if argument is set
 */
  __pyx_tuple__96 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_fee_buy, __pyx_n_s_fee_sell, __pyx_n_s_fee_deposit, __pyx_n_s_fee_withdraw, __pyx_n_s_ignore_type_checking, __pyx_n_s_fee); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 1760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);
  __pyx_codeobj__97 = (PyObject*)__Pyx_PyCode_New(6, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__96, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_parse_fees, 1760, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__97)) __PYX_ERR(0, 1760, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1801
 * 
 *     @staticmethod
 *     def _parse_exchange_rates(exchange_rates, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks exchange rates.
 */
  __pyx_tuple__98 = PyTuple_Pack(5, __pyx_n_s_exchange_rates, __pyx_n_s_ignore_type_checking, __pyx_n_s_sample_key, __pyx_n_s_k, __pyx_n_s_v); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(0, 1801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);
  __pyx_codeobj__99 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__98, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_parse_exchange_rates, 1801, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__99)) __PYX_ERR(0, 1801, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1824
 * 
 *     @staticmethod
 *     def _check_alt_fee(alt_fee, str alt_fee_error_msg):             # <<<<<<<<<<<<<<
 *         """
 *         Checks if param:alt_fee is of type {None, False, callable, float}. If alt_fee is callable method, method
 */
  __pyx_tuple__100 = PyTuple_Pack(2, __pyx_n_s_alt_fee, __pyx_n_s_alt_fee_error_msg); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(0, 1824, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);
  __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__100, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_check_alt_fee, 1824, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) __PYX_ERR(0, 1824, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1852
 * 
 *     @staticmethod
 *     def _parse_fee_and_transaction_params(float_fee_currency,             # <<<<<<<<<<<<<<
 *                                           str default_float_currency,
 *                                           alt_fee, str alt_fee_error_msg, instant_float_fee,
 */
  __pyx_tuple__102 = PyTuple_Pack(6, __pyx_n_s_float_fee_currency, __pyx_n_s_default_float_currency, __pyx_n_s_alt_fee, __pyx_n_s_alt_fee_error_msg, __pyx_n_s_instant_float_fee, __pyx_n_s_processing_duration); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(0, 1852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);
  __pyx_codeobj__103 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__102, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_parse_fee_and_transaction_param, 1852, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__103)) __PYX_ERR(0, 1852, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1896
 *         return float_fee_currency, instant_float_fee, processing_duration
 * 
 *     def _check_coverage(self, debit_amount, currency, time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */
  __pyx_tuple__104 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_debit_amount, __pyx_n_s_currency, __pyx_n_s_time_step); if (unlikely(!__pyx_tuple__104)) __PYX_ERR(0, 1896, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);
  __pyx_codeobj__105 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__104, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_check_coverage, 1896, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__105)) __PYX_ERR(0, 1896, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1911
 *         return self._c_check_coverage(debit_amount, currency.encode(), time_step)
 * 
 *     def _eval_fee(self, str action_type, alt_fee, double volume, double current_rate, str base, str quote,             # <<<<<<<<<<<<<<
 *                   processing_duration):
 *         """
 */
  __pyx_tuple__106 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_action_type, __pyx_n_s_alt_fee, __pyx_n_s_volume, __pyx_n_s_current_rate, __pyx_n_s_base, __pyx_n_s_quote, __pyx_n_s_processing_duration, __pyx_n_s_fee_amount, __pyx_n_s_fee_currency, __pyx_n_s_fee_exec_duration); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(0, 1911, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);
  __pyx_codeobj__107 = (PyObject*)__Pyx_PyCode_New(8, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__106, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_eval_fee, 1911, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__107)) __PYX_ERR(0, 1911, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1961
 *         return fee_amount, fee_currency, fee_exec_duration
 * 
 *     def _cum_sum_heap(self, currency, action_func_type, long time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */
  __pyx_tuple__108 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_currency, __pyx_n_s_action_func_type, __pyx_n_s_time_step); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(0, 1961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_GIVEREF(__pyx_tuple__108);
  __pyx_codeobj__109 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__108, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_cum_sum_heap_2, 1961, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__109)) __PYX_ERR(0, 1961, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1985
 *         return self.vec_heap.cum_sum_heap(currency.encode(), action_func_type.encode(), time_step, self._c_clock)
 * 
 *     def _cum_sum_marked_fund(self, currency, long time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */
  __pyx_tuple__110 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_currency, __pyx_n_s_time_step); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 1985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);
  __pyx_codeobj__111 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__110, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_cum_sum_marked_fund_2, 1985, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__111)) __PYX_ERR(0, 1985, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":1996
 *         return self.vec_heap.cum_sum_marked_fund(currency.encode(), time_step, self._c_clock)
 * 
 *     def _cum_sum_marked_debit(self, currency, time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */
  __pyx_tuple__112 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_currency, __pyx_n_s_time_step); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(0, 1996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__112);
  __Pyx_GIVEREF(__pyx_tuple__112);
  __pyx_codeobj__113 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__112, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_cum_sum_marked_debit_2, 1996, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__113)) __PYX_ERR(0, 1996, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2007
 *         return self.vec_heap.cum_sum_marked_debit(currency.encode(), time_step, self._c_clock)
 * 
 *     def _fill_fee(self, action_type, alt_fee, volume, price, base, quote, processing_duration,             # <<<<<<<<<<<<<<
 *                   forward_coverage='except'):
 *         """
 */
  __pyx_tuple__114 = PyTuple_Pack(12, __pyx_n_s_self, __pyx_n_s_action_type, __pyx_n_s_alt_fee, __pyx_n_s_volume, __pyx_n_s_price, __pyx_n_s_base, __pyx_n_s_quote, __pyx_n_s_processing_duration, __pyx_n_s_forward_coverage, __pyx_n_s_fee_volume, __pyx_n_s_fee_currency, __pyx_n_s_fee_exec_duration); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(0, 2007, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);
  __pyx_codeobj__115 = (PyObject*)__Pyx_PyCode_New(9, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__114, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_fill_fee, 2007, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__115)) __PYX_ERR(0, 2007, __pyx_L1_error)
  __pyx_tuple__116 = PyTuple_Pack(1, ((PyObject*)__pyx_n_u_except)); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(0, 2007, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__116);
  __Pyx_GIVEREF(__pyx_tuple__116);

  /* "trapeza/account/fx_account.pyx":2043
 *         return fee_volume, fee_currency, fee_exec_duration
 * 
 *     def withdraw(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                  float_fee_currency=None):
 *         """
 */
  __pyx_tuple__117 = PyTuple_Pack(12, __pyx_n_s_self, __pyx_n_s_volume, __pyx_n_s_currency, __pyx_n_s_fee_2, __pyx_n_s_processing_duration, __pyx_n_s_coverage, __pyx_n_s_instant_float_fee, __pyx_n_s_float_fee_currency, __pyx_n_s_parsed_fee_currency, __pyx_n_s_fee_volume, __pyx_n_s_fee_currency, __pyx_n_s_fee_exec_duration); if (unlikely(!__pyx_tuple__117)) __PYX_ERR(0, 2043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__117);
  __Pyx_GIVEREF(__pyx_tuple__117);
  __pyx_codeobj__118 = (PyObject*)__Pyx_PyCode_New(8, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__117, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_withdraw, 2043, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__118)) __PYX_ERR(0, 2043, __pyx_L1_error)
  __pyx_tuple__119 = PyTuple_Pack(5, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject*)__pyx_n_u_except), ((PyObject *)Py_False), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__119)) __PYX_ERR(0, 2043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__119);
  __Pyx_GIVEREF(__pyx_tuple__119);

  /* "trapeza/account/fx_account.pyx":2177
 *                                fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def deposit(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                 float_fee_currency=None):
 *         """
 */
  __pyx_tuple__120 = PyTuple_Pack(12, __pyx_n_s_self, __pyx_n_s_volume, __pyx_n_s_currency, __pyx_n_s_fee_2, __pyx_n_s_processing_duration, __pyx_n_s_coverage, __pyx_n_s_instant_float_fee, __pyx_n_s_float_fee_currency, __pyx_n_s_parsed_fee_currency, __pyx_n_s_fee_volume, __pyx_n_s_fee_currency, __pyx_n_s_fee_exec_duration); if (unlikely(!__pyx_tuple__120)) __PYX_ERR(0, 2177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);
  __pyx_codeobj__121 = (PyObject*)__Pyx_PyCode_New(8, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__120, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_deposit, 2177, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__121)) __PYX_ERR(0, 2177, __pyx_L1_error)
  __pyx_tuple__122 = PyTuple_Pack(5, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject*)__pyx_n_u_except), ((PyObject *)Py_False), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__122)) __PYX_ERR(0, 2177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);

  /* "trapeza/account/fx_account.pyx":2299
 *                               fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def collect(self, payer_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                 payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */
  __pyx_tuple__123 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_payer_account, __pyx_n_s_volume, __pyx_n_s_currency, __pyx_n_s_payee_fee, __pyx_n_s_payer_fee, __pyx_n_s_payee_processing_duration, __pyx_n_s_payer_processing_duration, __pyx_n_s_fee_volume, __pyx_n_s_fee_currency, __pyx_n_s_fee_exec_duration); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(0, 2299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__123);
  __Pyx_GIVEREF(__pyx_tuple__123);
  __pyx_codeobj__124 = (PyObject*)__Pyx_PyCode_New(8, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__123, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_collect, 2299, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__124)) __PYX_ERR(0, 2299, __pyx_L1_error)
  __pyx_tuple__125 = PyTuple_Pack(4, ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_None), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__125)) __PYX_ERR(0, 2299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__125);
  __Pyx_GIVEREF(__pyx_tuple__125);

  /* "trapeza/account/fx_account.pyx":2442
 *                               payee_processing_duration)
 * 
 *     def transfer(self, payee_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                  payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */
  __pyx_tuple__126 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_payee_account, __pyx_n_s_volume, __pyx_n_s_currency, __pyx_n_s_payee_fee, __pyx_n_s_payer_fee, __pyx_n_s_payee_processing_duration, __pyx_n_s_payer_processing_duration, __pyx_n_s_fee_volume, __pyx_n_s_fee_currency, __pyx_n_s_fee_exec_duration); if (unlikely(!__pyx_tuple__126)) __PYX_ERR(0, 2442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__126);
  __Pyx_GIVEREF(__pyx_tuple__126);
  __pyx_codeobj__127 = (PyObject*)__Pyx_PyCode_New(8, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__126, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_transfer, 2442, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__127)) __PYX_ERR(0, 2442, __pyx_L1_error)
  __pyx_tuple__128 = PyTuple_Pack(4, ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_None), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__128)) __PYX_ERR(0, 2442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__128);
  __Pyx_GIVEREF(__pyx_tuple__128);

  /* "trapeza/account/fx_account.pyx":2586
 *                                payer_processing_duration)
 * 
 *     def buy(self, double volume_base, double ask_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *             str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */
  __pyx_tuple__129 = PyTuple_Pack(15, __pyx_n_s_self, __pyx_n_s_volume_base, __pyx_n_s_ask_price, __pyx_n_s_base, __pyx_n_s_quote, __pyx_n_s_fee_2, __pyx_n_s_processing_duration, __pyx_n_s_coverage, __pyx_n_s_instant_withdrawal, __pyx_n_s_instant_float_fee, __pyx_n_s_float_fee_currency, __pyx_n_s_parsed_fee_currency, __pyx_n_s_fee_volume, __pyx_n_s_fee_currency, __pyx_n_s_fee_exec_duration); if (unlikely(!__pyx_tuple__129)) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__129);
  __Pyx_GIVEREF(__pyx_tuple__129);
  __pyx_codeobj__130 = (PyObject*)__Pyx_PyCode_New(11, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__129, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_buy, 2586, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__130)) __PYX_ERR(0, 2586, __pyx_L1_error)
  __pyx_tuple__131 = PyTuple_Pack(6, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject*)__pyx_n_u_except), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__131)) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__131);
  __Pyx_GIVEREF(__pyx_tuple__131);

  /* "trapeza/account/fx_account.pyx":2744
 *                           instant_withdrawal, instant_float_fee)
 * 
 *     def sell(self, double volume_base, double bid_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *              str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */
  __pyx_tuple__132 = PyTuple_Pack(15, __pyx_n_s_self, __pyx_n_s_volume_base, __pyx_n_s_bid_price, __pyx_n_s_base, __pyx_n_s_quote, __pyx_n_s_fee_2, __pyx_n_s_processing_duration, __pyx_n_s_coverage, __pyx_n_s_instant_withdrawal, __pyx_n_s_instant_float_fee, __pyx_n_s_float_fee_currency, __pyx_n_s_parsed_fee_currency, __pyx_n_s_fee_volume, __pyx_n_s_fee_currency, __pyx_n_s_fee_exec_duration); if (unlikely(!__pyx_tuple__132)) __PYX_ERR(0, 2744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);
  __pyx_codeobj__133 = (PyObject*)__Pyx_PyCode_New(11, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__132, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_sell, 2744, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__133)) __PYX_ERR(0, 2744, __pyx_L1_error)
  __pyx_tuple__134 = PyTuple_Pack(6, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject*)__pyx_n_u_except), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__134)) __PYX_ERR(0, 2744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__134);
  __Pyx_GIVEREF(__pyx_tuple__134);

  /* "trapeza/account/fx_account.pyx":2905
 *                            instant_withdrawal, instant_float_fee)
 * 
 *     def tick(self, clock=None):             # <<<<<<<<<<<<<<
 *         """
 *         If clock=None, then counts internal clock up by one time base unit.
 */
  __pyx_tuple__135 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_clock, __pyx_n_s_e); if (unlikely(!__pyx_tuple__135)) __PYX_ERR(0, 2905, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__135);
  __Pyx_GIVEREF(__pyx_tuple__135);
  __pyx_codeobj__136 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__135, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_tick, 2905, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__136)) __PYX_ERR(0, 2905, __pyx_L1_error)
  __pyx_tuple__137 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__137)) __PYX_ERR(0, 2905, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__137);
  __Pyx_GIVEREF(__pyx_tuple__137);

  /* "trapeza/account/fx_account.pyx":2936
 *         return self.c_tick(clock)
 * 
 *     def update_exchange_rate(self, double rate, str base, str quote):             # <<<<<<<<<<<<<<
 *         """
 *         It is highly recommended not to use this class method, but use self.batch_update_exchange_rates instead!
 */
  __pyx_tuple__138 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_rate, __pyx_n_s_base, __pyx_n_s_quote); if (unlikely(!__pyx_tuple__138)) __PYX_ERR(0, 2936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__138);
  __Pyx_GIVEREF(__pyx_tuple__138);
  __pyx_codeobj__139 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__138, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_update_exchange_rate, 2936, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__139)) __PYX_ERR(0, 2936, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":2964
 *         self.c_update_exchange_rate(rate, base.encode(), quote.encode())
 * 
 *     def batch_update_exchange_rates(self, list_rates, list_base_quote_pairs):             # <<<<<<<<<<<<<<
 *         """
 *         Performs batch update of exchange rates of multiple currency pairs (or assets), whereas
 */
  __pyx_tuple__140 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_list_rates, __pyx_n_s_list_base_quote_pairs, __pyx_n_s_i); if (unlikely(!__pyx_tuple__140)) __PYX_ERR(0, 2964, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__140);
  __Pyx_GIVEREF(__pyx_tuple__140);
  __pyx_codeobj__141 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__140, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_batch_update_exchange_rates, 2964, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__141)) __PYX_ERR(0, 2964, __pyx_L1_error)

  /* "trapeza/account/fx_account.pyx":3005
 *         return self.c_batch_update_exchange_rates(list_rates, list_base_quote_pairs)
 * 
 *     def total_balance(self, exchange_rates=None, reference_currency=None):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates current value of all assets within self.depot in reference currency.
 */
  __pyx_tuple__142 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_exchange_rates, __pyx_n_s_reference_currency); if (unlikely(!__pyx_tuple__142)) __PYX_ERR(0, 3005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__142);
  __Pyx_GIVEREF(__pyx_tuple__142);
  __pyx_codeobj__143 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__142, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_total_balance, 3005, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__143)) __PYX_ERR(0, 3005, __pyx_L1_error)
  __pyx_tuple__144 = PyTuple_Pack(2, ((PyObject *)Py_None), ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__144)) __PYX_ERR(0, 3005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__144);
  __Pyx_GIVEREF(__pyx_tuple__144);

  /* "trapeza/account/fx_account.pyx":3078
 *         return self.c_total_balance(exchange_rates, reference_currency.encode())
 * 
 *     def position(self, str currency):             # <<<<<<<<<<<<<<
 *         """
 *         Returns position size of given currency.
 */
  __pyx_tuple__145 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_currency); if (unlikely(!__pyx_tuple__145)) __PYX_ERR(0, 3078, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__145);
  __Pyx_GIVEREF(__pyx_tuple__145);
  __pyx_codeobj__146 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__145, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trapeza_account_fx_account_pyx, __pyx_n_s_position, 3078, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__146)) __PYX_ERR(0, 3078, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle_cFXAccount(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__147 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__147)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__147);
  __Pyx_GIVEREF(__pyx_tuple__147);
  __pyx_codeobj__148 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__147, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_cFXAccount, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__148)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_keys.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PySet_Type_issubset.type = (PyObject*)&PySet_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_252980303 = PyInt_FromLong(252980303L); if (unlikely(!__pyx_int_252980303)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("fx_null_fee", (void (*)(void))__pyx_f_7trapeza_7account_10fx_account_fx_null_fee, "PyObject *(double, double, PyObject *, PyObject *, long, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount = &__pyx_vtable_7trapeza_7account_10fx_account_cFXAccount;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._c_check_debiting = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_check_debiting;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._c_issue_corruption_warning = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_issue_corruption_warning;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._c_confirmation = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, long))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_confirmation;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._c_fill_fee = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, long, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee *__pyx_optional_args))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_fill_fee;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._execute_heap = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__execute_heap;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._c_isin_depot_quiet = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, std::string))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_isin_depot_quiet;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._c__init__ = (void (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, std::string, PyObject *, PyObject *, PyObject *, long, PyObject *, short, bool, bool, int __pyx_skip_dispatch))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c__init__;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._c_reset = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, int __pyx_skip_dispatch))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_reset;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._c_check_coverage = (double (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, long, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage *__pyx_optional_args))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_check_coverage;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount._c_isin_depot = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, std::string, int __pyx_skip_dispatch))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount__c_isin_depot;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_sell = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, double, std::string, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_sell *__pyx_optional_args))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_sell;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_buy = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, double, std::string, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_buy *__pyx_optional_args))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_buy;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_transfer = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_transfer *__pyx_optional_args))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_transfer;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_collect = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_collect *__pyx_optional_args))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_collect;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_deposit = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, long, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_deposit *__pyx_optional_args))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_deposit;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_withdraw = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, int __pyx_skip_dispatch, struct __pyx_opt_args_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw *__pyx_optional_args))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_withdraw;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_tick = (long (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, long, int __pyx_skip_dispatch))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_tick;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_update_exchange_rate = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, double, std::string, std::string, int __pyx_skip_dispatch))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_update_exchange_rate;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_batch_update_exchange_rates = (short (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_batch_update_exchange_rates;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_total_balance = (double (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, PyObject *, std::string, int __pyx_skip_dispatch))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_total_balance;
  __pyx_vtable_7trapeza_7account_10fx_account_cFXAccount.c_position = (double (*)(struct __pyx_obj_7trapeza_7account_10fx_account_cFXAccount *, std::string, int __pyx_skip_dispatch))__pyx_f_7trapeza_7account_10fx_account_10cFXAccount_c_position;
  if (PyType_Ready(&__pyx_type_7trapeza_7account_10fx_account_cFXAccount) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_7trapeza_7account_10fx_account_cFXAccount.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_7trapeza_7account_10fx_account_cFXAccount.tp_dictoffset && __pyx_type_7trapeza_7account_10fx_account_cFXAccount.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_7trapeza_7account_10fx_account_cFXAccount.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7trapeza_7account_10fx_account_cFXAccount, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 32, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_7trapeza_7account_10fx_account_10cFXAccount___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_7trapeza_7account_10fx_account_10cFXAccount___init__.doc = __pyx_doc_7trapeza_7account_10fx_account_10cFXAccount___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7trapeza_7account_10fx_account_10cFXAccount___init__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_7trapeza_7account_10fx_account_cFXAccount.tp_dict, __pyx_vtabptr_7trapeza_7account_10fx_account_cFXAccount) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_cFXAccount, (PyObject *)&__pyx_type_7trapeza_7account_10fx_account_cFXAccount) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7trapeza_7account_10fx_account_cFXAccount) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  __pyx_ptype_7trapeza_7account_10fx_account_cFXAccount = &__pyx_type_7trapeza_7account_10fx_account_cFXAccount;
  if (PyType_Ready(&__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct__depot) < 0) __PYX_ERR(0, 1291, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct__depot.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct__depot.tp_dictoffset && __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct__depot.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct__depot.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct__depot = &__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct__depot;
  if (PyType_Ready(&__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr) < 0) __PYX_ERR(0, 1296, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr.tp_dictoffset && __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr = &__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_1_genexpr;
  if (PyType_Ready(&__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee) < 0) __PYX_ERR(0, 1312, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee.tp_dictoffset && __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee = &__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_2__fee;
  if (PyType_Ready(&__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr) < 0) __PYX_ERR(0, 1317, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr.tp_dictoffset && __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr = &__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_3_genexpr;
  if (PyType_Ready(&__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates) < 0) __PYX_ERR(0, 1355, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates.tp_dictoffset && __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates = &__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_4_exchange_rates;
  if (PyType_Ready(&__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr) < 0) __PYX_ERR(0, 1361, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr.tp_dictoffset && __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr = &__pyx_type_7trapeza_7account_10fx_account___pyx_scope_struct_5_genexpr;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule("trapeza.account.execution_heap"); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap = __Pyx_ImportType(__pyx_t_1, "trapeza.account.execution_heap", "cFXWrapperVectorHeap", sizeof(struct __pyx_obj_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap) __PYX_ERR(3, 23, __pyx_L1_error)
  __pyx_vtabptr_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap = (struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap*)__Pyx_GetVtable(__pyx_ptype_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap->tp_dict); if (unlikely(!__pyx_vtabptr_7trapeza_7account_14execution_heap_cFXWrapperVectorHeap)) __PYX_ERR(3, 23, __pyx_L1_error)
  __pyx_ptype_7trapeza_7account_14execution_heap_DictKeysToVec = __Pyx_ImportType(__pyx_t_1, "trapeza.account.execution_heap", "DictKeysToVec", sizeof(struct __pyx_obj_7trapeza_7account_14execution_heap_DictKeysToVec), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7trapeza_7account_14execution_heap_DictKeysToVec) __PYX_ERR(3, 40, __pyx_L1_error)
  __pyx_vtabptr_7trapeza_7account_14execution_heap_DictKeysToVec = (struct __pyx_vtabstruct_7trapeza_7account_14execution_heap_DictKeysToVec*)__Pyx_GetVtable(__pyx_ptype_7trapeza_7account_14execution_heap_DictKeysToVec->tp_dict); if (unlikely(!__pyx_vtabptr_7trapeza_7account_14execution_heap_DictKeysToVec)) __PYX_ERR(3, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __pyx_t_1 = PyImport_ImportModule("trapeza.arithmetics.arithmetics"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "c_precision_add", (void **)&__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_add, "__pyx_t_7trapeza_11arithmetics_11arithmetics_c_precision_t") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "c_precision_subtract", (void **)&__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_subtract, "__pyx_t_7trapeza_11arithmetics_11arithmetics_c_precision_t") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "c_precision_multiply", (void **)&__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_multiply, "__pyx_t_7trapeza_11arithmetics_11arithmetics_c_precision_t") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "c_precision_divide", (void **)&__pyx_vp_7trapeza_11arithmetics_11arithmetics_c_precision_divide, "__pyx_t_7trapeza_11arithmetics_11arithmetics_c_precision_t") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initfx_account(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initfx_account(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_fx_account(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_fx_account(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_fx_account(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  std::string __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'fx_account' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_fx_account(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("fx_account", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_trapeza__account__fx_account) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "trapeza.account.fx_account")) {
      if (unlikely(PyDict_SetItemString(modules, "trapeza.account.fx_account", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  if (unlikely(__Pyx_modinit_function_export_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_variable_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_function_import_code();
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "trapeza/account/fx_account.pyx":3
 * # distutils: language=c++
 * 
 * import heapq             # <<<<<<<<<<<<<<
 * import warnings
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_heapq, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_heapq, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":4
 * 
 * import heapq
 * import warnings             # <<<<<<<<<<<<<<
 * 
 * import cython
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_warnings, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":13
 * from trapeza.arithmetics.arithmetics cimport c_precision_add, c_precision_subtract, c_precision_multiply, c_precision_divide
 * 
 * from trapeza.account.base_account import BaseAccount             # <<<<<<<<<<<<<<
 * from trapeza.utils import check_types, ProtectedDict, ProtectedExecHeap
 * from trapeza import exception as tpz_exception
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_BaseAccount);
  __Pyx_GIVEREF(__pyx_n_s_BaseAccount);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_BaseAccount);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_trapeza_account_base_account, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_BaseAccount); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_BaseAccount, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "trapeza/account/fx_account.pyx":14
 * 
 * from trapeza.account.base_account import BaseAccount
 * from trapeza.utils import check_types, ProtectedDict, ProtectedExecHeap             # <<<<<<<<<<<<<<
 * from trapeza import exception as tpz_exception
 * 
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_check_types);
  __Pyx_GIVEREF(__pyx_n_s_check_types);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_check_types);
  __Pyx_INCREF(__pyx_n_s_ProtectedDict);
  __Pyx_GIVEREF(__pyx_n_s_ProtectedDict);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_ProtectedDict);
  __Pyx_INCREF(__pyx_n_s_ProtectedExecHeap);
  __Pyx_GIVEREF(__pyx_n_s_ProtectedExecHeap);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_ProtectedExecHeap);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_trapeza_utils, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_check_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_check_types, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ProtectedDict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ProtectedDict, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_ProtectedExecHeap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ProtectedExecHeap, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":15
 * from trapeza.account.base_account import BaseAccount
 * from trapeza.utils import check_types, ProtectedDict, ProtectedExecHeap
 * from trapeza import exception as tpz_exception             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_exception);
  __Pyx_GIVEREF(__pyx_n_s_exception);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_exception);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_trapeza, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_tpz_exception, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "trapeza/account/fx_account.pyx":313
 *     @cython.wraparound(False)
 *     cdef short _c_fill_fee(self, double fee_volume, string fee_currency, long fee_exec_duration,
 *                            string forward_coverage=b'except') except -1:             # <<<<<<<<<<<<<<
 *         """
 *         See FXAccount for docstring information.
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 313, __pyx_L1_error)
  __pyx_k_ = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":377
 *     @cython.wraparound(False)
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,             # <<<<<<<<<<<<<<
 *                    string coverage=b'except', bool_t instant_withdrawal=False,
 *                    bool_t instant_float_fee=False) except -9999:
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 377, __pyx_L1_error)
  __pyx_k__2 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":378
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,             # <<<<<<<<<<<<<<
 *                    bool_t instant_float_fee=False) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  __pyx_k__3 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":377
 *     @cython.wraparound(False)
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,             # <<<<<<<<<<<<<<
 *                    string coverage=b'except', bool_t instant_withdrawal=False,
 *                    bool_t instant_float_fee=False) except -9999:
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 377, __pyx_L1_error)
  __pyx_k__2 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":378
 *     cpdef short c_sell(self, double volume, double bid_price, string base, string quote, double fee_volume=0,
 *                    string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                    string coverage=b'except', bool_t instant_withdrawal=False,             # <<<<<<<<<<<<<<
 *                    bool_t instant_float_fee=False) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  __pyx_k__3 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":480
 *     @cython.wraparound(False)
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,             # <<<<<<<<<<<<<<
 *                       string coverage=b'except', bool_t instant_withdrawal=False,
 *                       bool_t instant_float_fee=False) except -9999:
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 480, __pyx_L1_error)
  __pyx_k__4 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":481
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,             # <<<<<<<<<<<<<<
 *                       bool_t instant_float_fee=False) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 481, __pyx_L1_error)
  __pyx_k__5 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":480
 *     @cython.wraparound(False)
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,             # <<<<<<<<<<<<<<
 *                       string coverage=b'except', bool_t instant_withdrawal=False,
 *                       bool_t instant_float_fee=False) except -9999:
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 480, __pyx_L1_error)
  __pyx_k__4 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":481
 *     cpdef short c_buy(self, double volume, double ask_price, string base, string quote, double fee_volume=0,
 *                       string fee_currency=b'default', long fee_exec_duration=0, long processing_duration=0,
 *                       string coverage=b'except', bool_t instant_withdrawal=False,             # <<<<<<<<<<<<<<
 *                       bool_t instant_float_fee=False) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 481, __pyx_L1_error)
  __pyx_k__5 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":585
 *     @cython.wraparound(False)
 *     cpdef short c_transfer(self, double volume, string currency,
 *                          double payer_fee_volume=0, string payer_fee_currency=b'default',             # <<<<<<<<<<<<<<
 *                          long payer_fee_exec_duration=0, long payer_processing_duration=0) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 585, __pyx_L1_error)
  __pyx_k__6 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":584
 *     # noinspection DuplicatedCode
 *     @cython.wraparound(False)
 *     cpdef short c_transfer(self, double volume, string currency,             # <<<<<<<<<<<<<<
 *                          double payer_fee_volume=0, string payer_fee_currency=b'default',
 *                          long payer_fee_exec_duration=0, long payer_processing_duration=0) except -9999:
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 585, __pyx_L1_error)
  __pyx_k__6 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":612
 *     @cython.wraparound(False)
 *     cpdef short c_collect(self, double volume, string currency,
 *                         double payee_fee_volume=0, string payee_fee_currency=b'default', long payee_fee_exec_duration=0,             # <<<<<<<<<<<<<<
 *                         long payee_processing_duration=0) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 612, __pyx_L1_error)
  __pyx_k__7 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":611
 *     # noinspection DuplicatedCode
 *     @cython.wraparound(False)
 *     cpdef short c_collect(self, double volume, string currency,             # <<<<<<<<<<<<<<
 *                         double payee_fee_volume=0, string payee_fee_currency=b'default', long payee_fee_exec_duration=0,
 *                         long payee_processing_duration=0) except -9999:
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 612, __pyx_L1_error)
  __pyx_k__7 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":640
 *     @cython.wraparound(False)
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,
 *                         string fee_currency=b'default', long fee_exec_duration=0,             # <<<<<<<<<<<<<<
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 640, __pyx_L1_error)
  __pyx_k__8 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":641
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,
 *                         string fee_currency=b'default', long fee_exec_duration=0,
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.deposit for further information.
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 641, __pyx_L1_error)
  __pyx_k__9 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":640
 *     @cython.wraparound(False)
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,
 *                         string fee_currency=b'default', long fee_exec_duration=0,             # <<<<<<<<<<<<<<
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 640, __pyx_L1_error)
  __pyx_k__8 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":641
 *     cpdef short c_deposit(self, double volume, string currency, long processing_duration, double fee_volume=0,
 *                         string fee_currency=b'default', long fee_exec_duration=0,
 *                         string coverage=b'except', bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.deposit for further information.
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 641, __pyx_L1_error)
  __pyx_k__9 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":782
 *     @cython.wraparound(False)
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,
 *                          string fee_currency=b'default', long fee_exec_duration=0,             # <<<<<<<<<<<<<<
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 782, __pyx_L1_error)
  __pyx_k__10 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":783
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,
 *                          string fee_currency=b'default', long fee_exec_duration=0,
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.withdraw for further information.
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 783, __pyx_L1_error)
  __pyx_k__11 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":782
 *     @cython.wraparound(False)
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,
 *                          string fee_currency=b'default', long fee_exec_duration=0,             # <<<<<<<<<<<<<<
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:
 *         """
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_default); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 782, __pyx_L1_error)
  __pyx_k__10 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":783
 *     cpdef short c_withdraw(self, double volume, string currency, long processing_duration=0, double fee_volume=0,
 *                          string fee_currency=b'default', long fee_exec_duration=0,
 *                          string coverage=b'except', bool_t instant_float_fee=False) except -9999:             # <<<<<<<<<<<<<<
 *         """
 *         C++ implementation via cython. Is wrapped by FXAccount. See FXAccount.withdraw for further information.
 */
  __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_n_b_except); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 783, __pyx_L1_error)
  __pyx_k__11 = __pyx_t_3;

  /* "trapeza/account/fx_account.pyx":1043
 * 
 * # noinspection PyAbstractClass,PyAttributeOutsideInit,PyTypeChecker
 * class FXAccount(cFXAccount, BaseAccount):             # <<<<<<<<<<<<<<
 *     """
 *     Derived from BaseAccount. This implementation is meant to model transactions and mechanisms specific to the
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_BaseAccount); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_7trapeza_7account_10fx_account_cFXAccount));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_7trapeza_7account_10fx_account_cFXAccount));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_ptype_7trapeza_7account_10fx_account_cFXAccount));
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_FXAccount, __pyx_n_s_FXAccount, (PyObject *) NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_kp_s_Derived_from_BaseAccount_This_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "trapeza/account/fx_account.pyx":1188
 * 
 *     @property
 *     def exec_heap(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns internal heap of delayed transactions. Internally the heap is implemented as C++ vector int the
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_1exec_heap, 0, __pyx_n_s_FXAccount_exec_heap, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "trapeza/account/fx_account.pyx":1187
 *     """
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def exec_heap(self):
 *         """
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_exec_heap, __pyx_t_7) < 0) __PYX_ERR(0, 1188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1201
 *         """
 *         return ProtectedExecHeap(self.vec_heap.tolist())
 *     @exec_heap.setter             # <<<<<<<<<<<<<<
 *     def exec_heap(self, inp):
 *         """
 */
  __pyx_t_6 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_exec_heap);
  if (unlikely(!__pyx_t_6)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_exec_heap);
  }
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_setter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1202
 *         return ProtectedExecHeap(self.vec_heap.tolist())
 *     @exec_heap.setter
 *     def exec_heap(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internal heap (and underlying C++ vector implementation). See getter method for further information.
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_3exec_heap, 0, __pyx_n_s_FXAccount_exec_heap, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_exec_heap, __pyx_t_7) < 0) __PYX_ERR(0, 1202, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1210
 *         inp = self._parse_exec_heap(inp, self._c_ignore_type_checking)
 *         self.vec_heap = cFXWrapperVectorHeap(inp)
 *     @exec_heap.deleter             # <<<<<<<<<<<<<<
 *     def exec_heap(self):
 *         del self.exec_heap
 */
  __pyx_t_8 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_exec_heap);
  if (unlikely(!__pyx_t_8)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_exec_heap);
  }
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_deleter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1211
 *         self.vec_heap = cFXWrapperVectorHeap(inp)
 *     @exec_heap.deleter
 *     def exec_heap(self):             # <<<<<<<<<<<<<<
 *         del self.exec_heap
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_5exec_heap, 0, __pyx_n_s_FXAccount_exec_heap, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_exec_heap, __pyx_t_7) < 0) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1215
 * 
 *     @property
 *     def check_marked_coverage(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns status of self.check_marked_coverage which denotes how coverage analysis is conducted for marked but
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_7check_marked_coverage, 0, __pyx_n_s_FXAccount_check_marked_coverage, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "trapeza/account/fx_account.pyx":1214
 *         del self.exec_heap
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def check_marked_coverage(self):
 *         """
 */
  __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_check_marked_coverage, __pyx_t_6) < 0) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1230
 *             raise tpz_exception.OperatingError('Internal logic error. Value in underlying c-implementation (cython) is '
 *                                               'set to an invalid value.')
 *     @check_marked_coverage.setter             # <<<<<<<<<<<<<<
 *     def check_marked_coverage(self, inp):
 *         """
 */
  __pyx_t_7 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_check_marked_coverage);
  if (unlikely(!__pyx_t_7)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_check_marked_coverage);
  }
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_setter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1231
 *                                               'set to an invalid value.')
 *     @check_marked_coverage.setter
 *     def check_marked_coverage(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set type of coverage analysis.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_9check_marked_coverage, 0, __pyx_n_s_FXAccount_check_marked_coverage, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_check_marked_coverage, __pyx_t_6) < 0) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1249
 *         else:
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *     @check_marked_coverage.deleter             # <<<<<<<<<<<<<<
 *     def check_marked_coverage(self):
 *         del self.check_marked_coverage
 */
  __pyx_t_8 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_check_marked_coverage);
  if (unlikely(!__pyx_t_8)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_check_marked_coverage);
  }
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_deleter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1250
 *             raise TypeError('check_marked_coverage must be in {None, False, "max_forward", "min_backward"}.')
 *     @check_marked_coverage.deleter
 *     def check_marked_coverage(self):             # <<<<<<<<<<<<<<
 *         del self.check_marked_coverage
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_11check_marked_coverage, 0, __pyx_n_s_FXAccount_check_marked_coverage, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_check_marked_coverage, __pyx_t_6) < 0) __PYX_ERR(0, 1250, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1254
 * 
 *     @property
 *     def clock(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current internal clock.
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_13clock, 0, __pyx_n_s_FXAccount_clock, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__40)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1254, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "trapeza/account/fx_account.pyx":1253
 *         del self.check_marked_coverage
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def clock(self):
 *         """
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_clock, __pyx_t_7) < 0) __PYX_ERR(0, 1254, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1260
 *         """
 *         return self._c_clock
 *     @clock.setter             # <<<<<<<<<<<<<<
 *     def clock(self, inp):
 *         """
 */
  __pyx_t_6 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_clock);
  if (unlikely(!__pyx_t_6)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_clock);
  }
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_setter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1261
 *         return self._c_clock
 *     @clock.setter
 *     def clock(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set current internal clock. It is not recommended to manually set internal clock, but use self.tick() instead.
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_15clock, 0, __pyx_n_s_FXAccount_clock, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__42)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_clock, __pyx_t_7) < 0) __PYX_ERR(0, 1261, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1277
 *         except Exception as e:
 *             raise e
 *     @clock.deleter             # <<<<<<<<<<<<<<
 *     def clock(self):
 *         del self.clock
 */
  __pyx_t_8 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_clock);
  if (unlikely(!__pyx_t_8)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_clock);
  }
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_deleter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1278
 *             raise e
 *     @clock.deleter
 *     def clock(self):             # <<<<<<<<<<<<<<
 *         del self.clock
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_17clock, 0, __pyx_n_s_FXAccount_clock, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__44)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_clock, __pyx_t_7) < 0) __PYX_ERR(0, 1278, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1282
 * 
 *     @property
 *     def _ignore_type_checking(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns whether type checking is ignored or not.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_19_ignore_type_checking, 0, __pyx_n_s_FXAccount__ignore_type_checking, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__46)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "trapeza/account/fx_account.pyx":1281
 *         del self.clock
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def _ignore_type_checking(self):
 *         """
 */
  __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1281, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_ignore_type_checking_2, __pyx_t_6) < 0) __PYX_ERR(0, 1282, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1291
 * 
 *     @property
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current depot and it's positions. Returned dict is not manipulable/ mutable. Use setter method instead.
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_21depot, 0, __pyx_n_s_FXAccount_depot, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__48)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "trapeza/account/fx_account.pyx":1290
 *         return self._c_ignore_type_checking
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def depot(self):
 *         """
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_depot, __pyx_t_7) < 0) __PYX_ERR(0, 1291, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1297
 *         """
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_depot.items())
 *     @depot.setter             # <<<<<<<<<<<<<<
 *     def depot(self, inp):
 *         """
 */
  __pyx_t_6 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_depot);
  if (unlikely(!__pyx_t_6)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_depot);
  }
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_setter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1298
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_depot.items())
 *     @depot.setter
 *     def depot(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set depot by providing a complete dict of all new positions
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_23depot, 0, __pyx_n_s_FXAccount_depot, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__50)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_depot, __pyx_t_7) < 0) __PYX_ERR(0, 1298, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1307
 *         check_types([inp], [dict], ['depot_setter'], self._c_ignore_type_checking)
 *         self._c_depot = self._parse_depot(inp, self._c_ignore_type_checking)
 *     @depot.deleter             # <<<<<<<<<<<<<<
 *     def depot(self):
 *         del self.depot
 */
  __pyx_t_8 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_depot);
  if (unlikely(!__pyx_t_8)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_depot);
  }
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_deleter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1308
 *         self._c_depot = self._parse_depot(inp, self._c_ignore_type_checking)
 *     @depot.deleter
 *     def depot(self):             # <<<<<<<<<<<<<<
 *         del self.depot
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_25depot, 0, __pyx_n_s_FXAccount_depot, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__52)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_depot, __pyx_t_7) < 0) __PYX_ERR(0, 1308, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1312
 * 
 *     @property
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return current set fees. Returned dict is not manipulable/ mutable. Use setter method instead.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_27_fee, 0, __pyx_n_s_FXAccount__fee, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "trapeza/account/fx_account.pyx":1311
 *         del self.depot
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def _fee(self):
 *         """
 */
  __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_fee, __pyx_t_6) < 0) __PYX_ERR(0, 1312, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1318
 *         """
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_fee.items())
 *     @_fee.setter             # <<<<<<<<<<<<<<
 *     def _fee(self, inp):
 *         """
 */
  __pyx_t_7 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_fee);
  if (unlikely(!__pyx_t_7)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_fee);
  }
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_setter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1319
 *         return ProtectedDict((k.decode(), v) for k, v in self._c_fee.items())
 *     @_fee.setter
 *     def _fee(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new fees by providing a dict. Dict can contain keys:{'sell', 'buy', 'withdraw', 'deposit'}. If one of the
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_29_fee, 0, __pyx_n_s_FXAccount__fee, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__56)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_fee, __pyx_t_6) < 0) __PYX_ERR(0, 1319, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1350
 *                             'and fee["withdraw"]. See docstring of FXAccount for further information about fee '
 *                             'handling.')
 *     @_fee.deleter             # <<<<<<<<<<<<<<
 *     def _fee(self):
 *         del self._fee
 */
  __pyx_t_8 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_fee);
  if (unlikely(!__pyx_t_8)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_fee);
  }
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_deleter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1351
 *                             'handling.')
 *     @_fee.deleter
 *     def _fee(self):             # <<<<<<<<<<<<<<
 *         del self._fee
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_31_fee, 0, __pyx_n_s_FXAccount__fee, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_fee, __pyx_t_6) < 0) __PYX_ERR(0, 1351, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1355
 * 
 *     @property
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns current exchange rates (which was previously provided by self.tick(...), self.update_exchange_rate(...)
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_33exchange_rates, 0, __pyx_n_s_FXAccount_exchange_rates, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__60)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "trapeza/account/fx_account.pyx":1354
 *         del self._fee
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def exchange_rates(self):
 *         """
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_exchange_rates, __pyx_t_7) < 0) __PYX_ERR(0, 1355, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1362
 *         """
 *         return ProtectedDict(((k[0].decode(), k[1].decode()), v) for k, v in self._c_exchange_rates.items())
 *     @exchange_rates.setter             # <<<<<<<<<<<<<<
 *     def exchange_rates(self, inp):
 *         """
 */
  __pyx_t_6 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_exchange_rates);
  if (unlikely(!__pyx_t_6)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_exchange_rates);
  }
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_setter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1363
 *         return ProtectedDict(((k[0].decode(), k[1].decode()), v) for k, v in self._c_exchange_rates.items())
 *     @exchange_rates.setter
 *     def exchange_rates(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new exchange rates as complete dict of all currency pairs. Must contain all currency pairs which are also
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_35exchange_rates, 0, __pyx_n_s_FXAccount_exchange_rates, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__62)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_exchange_rates, __pyx_t_7) < 0) __PYX_ERR(0, 1363, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1375
 *         check_types([inp], [dict], ['exchange_rates_setter'], self._c_ignore_type_checking)
 *         self._c_exchange_rates = self._parse_exchange_rates(inp, self._c_ignore_type_checking)
 *     @exchange_rates.deleter             # <<<<<<<<<<<<<<
 *     def exchange_rates(self):
 *         del self.exchange_rates
 */
  __pyx_t_8 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_exchange_rates);
  if (unlikely(!__pyx_t_8)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_exchange_rates);
  }
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_deleter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1376
 *         self._c_exchange_rates = self._parse_exchange_rates(inp, self._c_ignore_type_checking)
 *     @exchange_rates.deleter
 *     def exchange_rates(self):             # <<<<<<<<<<<<<<
 *         del self.exchange_rates
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_37exchange_rates, 0, __pyx_n_s_FXAccount_exchange_rates, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__64)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_exchange_rates, __pyx_t_7) < 0) __PYX_ERR(0, 1376, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1380
 * 
 *     @property
 *     def reference_currency(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return reference currency used for calculating total balance/ value of depot and fees.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_39reference_currency, 0, __pyx_n_s_FXAccount_reference_currency, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__66)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "trapeza/account/fx_account.pyx":1379
 *         del self.exchange_rates
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def reference_currency(self):
 *         """
 */
  __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_reference_currency, __pyx_t_6) < 0) __PYX_ERR(0, 1380, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1386
 *         """
 *         return self._c_reference_currency.decode()
 *     @reference_currency.setter             # <<<<<<<<<<<<<<
 *     def reference_currency(self, inp):
 *         """
 */
  __pyx_t_7 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_reference_currency);
  if (unlikely(!__pyx_t_7)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_reference_currency);
  }
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_setter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1387
 *         return self._c_reference_currency.decode()
 *     @reference_currency.setter
 *     def reference_currency(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set new reference currency.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_41reference_currency, 0, __pyx_n_s_FXAccount_reference_currency, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__68)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_reference_currency, __pyx_t_6) < 0) __PYX_ERR(0, 1387, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1396
 *         check_types([inp], [str], ['inp'])
 *         self._c_reference_currency = inp.encode()
 *     @reference_currency.deleter             # <<<<<<<<<<<<<<
 *     def reference_currency(self):
 *         del self.reference_currency
 */
  __pyx_t_8 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_reference_currency);
  if (unlikely(!__pyx_t_8)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_reference_currency);
  }
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_deleter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1397
 *         self._c_reference_currency = inp.encode()
 *     @reference_currency.deleter
 *     def reference_currency(self):             # <<<<<<<<<<<<<<
 *         del self.reference_currency
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_43reference_currency, 0, __pyx_n_s_FXAccount_reference_currency, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__70)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_reference_currency, __pyx_t_6) < 0) __PYX_ERR(0, 1397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1401
 * 
 *     @property
 *     def is_exchange_rate_updated(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns whether internal exchange rates have been updated and self.total_balance() is ready to be called.
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_45is_exchange_rate_updated, 0, __pyx_n_s_FXAccount_is_exchange_rate_updat, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__72)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "trapeza/account/fx_account.pyx":1400
 *         del self.reference_currency
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def is_exchange_rate_updated(self):
 *         """
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_is_exchange_rate_updated, __pyx_t_7) < 0) __PYX_ERR(0, 1401, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1407
 *         """
 *         return self._c_is_exchange_rate_updated
 *     @is_exchange_rate_updated.setter             # <<<<<<<<<<<<<<
 *     def is_exchange_rate_updated(self, inp):
 *         """
 */
  __pyx_t_6 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_is_exchange_rate_updated);
  if (unlikely(!__pyx_t_6)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_is_exchange_rate_updated);
  }
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_setter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1408
 *         return self._c_is_exchange_rate_updated
 *     @is_exchange_rate_updated.setter
 *     def is_exchange_rate_updated(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internal status whether exchange rates have been updated and self.total_balance() is
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_47is_exchange_rate_updated, 0, __pyx_n_s_FXAccount_is_exchange_rate_updat, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__74)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_is_exchange_rate_updated, __pyx_t_7) < 0) __PYX_ERR(0, 1408, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1418
 *         check_types([inp], [bool], ['is_exchange_rate_updated_setter'])
 *         self._c_is_exchange_rate_updated = inp
 *     @is_exchange_rate_updated.deleter             # <<<<<<<<<<<<<<
 *     def is_exchange_rate_updated(self):
 *         del self.is_exchange_rate_updated
 */
  __pyx_t_8 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_is_exchange_rate_updated);
  if (unlikely(!__pyx_t_8)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_is_exchange_rate_updated);
  }
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_deleter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1419
 *         self._c_is_exchange_rate_updated = inp
 *     @is_exchange_rate_updated.deleter
 *     def is_exchange_rate_updated(self):             # <<<<<<<<<<<<<<
 *         del self.is_exchange_rate_updated
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_49is_exchange_rate_updated, 0, __pyx_n_s_FXAccount_is_exchange_rate_updat, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__76)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_is_exchange_rate_updated, __pyx_t_7) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1423
 * 
 *     @property
 *     def prohibit_debiting(self):             # <<<<<<<<<<<<<<
 *         """
 *         Return whether debiting of account is allowed or not.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_51prohibit_debiting, 0, __pyx_n_s_FXAccount_prohibit_debiting, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__78)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "trapeza/account/fx_account.pyx":1422
 *         del self.is_exchange_rate_updated
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def prohibit_debiting(self):
 *         """
 */
  __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_prohibit_debiting, __pyx_t_6) < 0) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1429
 *         """
 *         return self._c_prohibit_debiting
 *     @prohibit_debiting.setter             # <<<<<<<<<<<<<<
 *     def prohibit_debiting(self, inp):
 *         """
 */
  __pyx_t_7 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_prohibit_debiting);
  if (unlikely(!__pyx_t_7)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_prohibit_debiting);
  }
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_setter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1430
 *         return self._c_prohibit_debiting
 *     @prohibit_debiting.setter
 *     def prohibit_debiting(self, inp):             # <<<<<<<<<<<<<<
 *         """
 *         Set internally whether debiting of account is allowed. It is not recommended to set this value manually as it
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_53prohibit_debiting, 0, __pyx_n_s_FXAccount_prohibit_debiting, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__80)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_prohibit_debiting, __pyx_t_6) < 0) __PYX_ERR(0, 1430, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1440
 *         check_types([inp], [bool], ['prohibit_debiting_setter'])
 *         self._c_prohibit_debiting = inp
 *     @prohibit_debiting.deleter             # <<<<<<<<<<<<<<
 *     def prohibit_debiting(self):
 *         del self.prohibit_debiting
 */
  __pyx_t_8 = PyObject_GetItem(__pyx_t_4, __pyx_n_s_prohibit_debiting);
  if (unlikely(!__pyx_t_8)) {
    PyErr_Clear();
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_prohibit_debiting);
  }
  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_deleter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "trapeza/account/fx_account.pyx":1441
 *         self._c_prohibit_debiting = inp
 *     @prohibit_debiting.deleter
 *     def prohibit_debiting(self):             # <<<<<<<<<<<<<<
 *         del self.prohibit_debiting
 * 
 */
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_55prohibit_debiting, 0, __pyx_n_s_FXAccount_prohibit_debiting, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__82)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_prohibit_debiting, __pyx_t_6) < 0) __PYX_ERR(0, 1441, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1446
 *     def __init__(self, reference_currency, depot=None,
 *                  fee_buy=False, fee_sell=False, fee_deposit=False, fee_withdraw=False,
 *                  exec_heap=None, long clock=0, exchange_rates=None, marked_coverage='min_backward',             # <<<<<<<<<<<<<<
 *                  prohibit_debiting=False, ignore_type_checking=False):
 *         """
 */
  __pyx_t_6 = __Pyx_PyInt_From_long(((long)0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "trapeza/account/fx_account.pyx":1444
 *         del self.prohibit_debiting
 * 
 *     def __init__(self, reference_currency, depot=None,             # <<<<<<<<<<<<<<
 *                  fee_buy=False, fee_sell=False, fee_deposit=False, fee_withdraw=False,
 *                  exec_heap=None, long clock=0, exchange_rates=None, marked_coverage='min_backward',
 */
  __pyx_t_7 = PyTuple_New(11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject *)Py_False));
  __Pyx_GIVEREF(((PyObject *)Py_False));
  PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)Py_False));
  __Pyx_INCREF(((PyObject *)Py_False));
  __Pyx_GIVEREF(((PyObject *)Py_False));
  PyTuple_SET_ITEM(__pyx_t_7, 2, ((PyObject *)Py_False));
  __Pyx_INCREF(((PyObject *)Py_False));
  __Pyx_GIVEREF(((PyObject *)Py_False));
  PyTuple_SET_ITEM(__pyx_t_7, 3, ((PyObject *)Py_False));
  __Pyx_INCREF(((PyObject *)Py_False));
  __Pyx_GIVEREF(((PyObject *)Py_False));
  PyTuple_SET_ITEM(__pyx_t_7, 4, ((PyObject *)Py_False));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_7, 5, ((PyObject *)Py_None));
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_7, 6, __pyx_t_6);
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_7, 7, ((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject*)__pyx_n_u_min_backward));
  __Pyx_GIVEREF(((PyObject*)__pyx_n_u_min_backward));
  PyTuple_SET_ITEM(__pyx_t_7, 8, ((PyObject*)__pyx_n_u_min_backward));
  __Pyx_INCREF(((PyObject *)Py_False));
  __Pyx_GIVEREF(((PyObject *)Py_False));
  PyTuple_SET_ITEM(__pyx_t_7, 9, ((PyObject *)Py_False));
  __Pyx_INCREF(((PyObject *)Py_False));
  __Pyx_GIVEREF(((PyObject *)Py_False));
  PyTuple_SET_ITEM(__pyx_t_7, 10, ((PyObject *)Py_False));
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_57__init__, 0, __pyx_n_s_FXAccount___init, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__84)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_t_6);
  PyList_Append(__pyx_t_5, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_6, __pyx_t_7);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_init, __pyx_t_6) < 0) __PYX_ERR(0, 1444, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1623
 *                          marked_coverage, prohibit_debiting, ignore_type_checking)
 * 
 *     def _full_reset(self):             # <<<<<<<<<<<<<<
 *         """
 *         Resets account with depot=None, fee_x=False (e.g. fee_buy), check_marked_coverage='min_backward', empty heap,
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_59_full_reset, 0, __pyx_n_s_FXAccount__full_reset, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__86)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_full_reset, __pyx_t_6) < 0) __PYX_ERR(0, 1623, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1632
 *         self.__init__(self._c_reference_currency.decode())
 * 
 *     def _reset(self):             # <<<<<<<<<<<<<<
 *         """
 *         Resets account but retains reference_currency, check_marked_coverage, prohibit_debiting, ignore_type_checking
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_61_reset, 0, __pyx_n_s_FXAccount__reset, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__88)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_reset, __pyx_t_6) < 0) __PYX_ERR(0, 1632, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1641
 *         self._c_reset()
 * 
 *     def _check_is_valid_fee_func(self, func):             # <<<<<<<<<<<<<<
 *         """
 *         Checks if function is a valid function for fees and complies with following signature
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_63_check_is_valid_fee_func, 0, __pyx_n_s_FXAccount__check_is_valid_fee_fu, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__90)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_check_is_valid_fee_func, __pyx_t_6) < 0) __PYX_ERR(0, 1641, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1656
 * 
 *     @staticmethod
 *     def _parse_depot(depot, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks init arguments
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_65_parse_depot, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_FXAccount__parse_depot, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__92)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "trapeza/account/fx_account.pyx":1655
 *                     ['fee_amount', 'fee_currency', 'fee_processing_duration'], self._c_ignore_type_checking)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _parse_depot(depot, ignore_type_checking):
 *         """
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_parse_depot, __pyx_t_7) < 0) __PYX_ERR(0, 1656, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1677
 * 
 *     @staticmethod
 *     def _parse_exec_heap(exec_heap, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks if provided (heap) list is valid as internal execution heap
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_67_parse_exec_heap, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_FXAccount__parse_exec_heap, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__95)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "trapeza/account/fx_account.pyx":1676
 *         return depot
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _parse_exec_heap(exec_heap, ignore_type_checking):
 *         """
 */
  __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1676, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_parse_exec_heap, __pyx_t_6) < 0) __PYX_ERR(0, 1677, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1760
 *         return exec_heap
 * 
 *     def _parse_fees(self, fee_buy, fee_sell, fee_deposit, fee_withdraw, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks fees. Uses standard fee function (equivalent to not applying any fees) if argument is set
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_69_parse_fees, 0, __pyx_n_s_FXAccount__parse_fees, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__97)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_parse_fees, __pyx_t_6) < 0) __PYX_ERR(0, 1760, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1801
 * 
 *     @staticmethod
 *     def _parse_exchange_rates(exchange_rates, ignore_type_checking):             # <<<<<<<<<<<<<<
 *         """
 *         Parses and checks exchange rates.
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_71_parse_exchange_rates, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_FXAccount__parse_exchange_rates, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__99)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "trapeza/account/fx_account.pyx":1800
 *         return _fee
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _parse_exchange_rates(exchange_rates, ignore_type_checking):
 *         """
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1800, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_parse_exchange_rates, __pyx_t_7) < 0) __PYX_ERR(0, 1801, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1824
 * 
 *     @staticmethod
 *     def _check_alt_fee(alt_fee, str alt_fee_error_msg):             # <<<<<<<<<<<<<<
 *         """
 *         Checks if param:alt_fee is of type {None, False, callable, float}. If alt_fee is callable method, method
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_73_check_alt_fee, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_FXAccount__check_alt_fee, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__101)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1824, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "trapeza/account/fx_account.pyx":1823
 *         return exchange_rates
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _check_alt_fee(alt_fee, str alt_fee_error_msg):
 *         """
 */
  __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1823, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_check_alt_fee, __pyx_t_6) < 0) __PYX_ERR(0, 1824, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "trapeza/account/fx_account.pyx":1852
 * 
 *     @staticmethod
 *     def _parse_fee_and_transaction_params(float_fee_currency,             # <<<<<<<<<<<<<<
 *                                           str default_float_currency,
 *                                           alt_fee, str alt_fee_error_msg, instant_float_fee,
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_75_parse_fee_and_transaction_params, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_FXAccount__parse_fee_and_transac, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__103)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "trapeza/account/fx_account.pyx":1851
 *                                       'float or func and not of type {}'.format(alt_fee_error_msg, type(alt_fee)))
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _parse_fee_and_transaction_params(float_fee_currency,
 *                                           str default_float_currency,
 */
  __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_parse_fee_and_transaction_param, __pyx_t_7) < 0) __PYX_ERR(0, 1852, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1896
 *         return float_fee_currency, instant_float_fee, processing_duration
 * 
 *     def _check_coverage(self, debit_amount, currency, time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_77_check_coverage, 0, __pyx_n_s_FXAccount__check_coverage, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__105)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1896, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_check_coverage, __pyx_t_7) < 0) __PYX_ERR(0, 1896, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1911
 *         return self._c_check_coverage(debit_amount, currency.encode(), time_step)
 * 
 *     def _eval_fee(self, str action_type, alt_fee, double volume, double current_rate, str base, str quote,             # <<<<<<<<<<<<<<
 *                   processing_duration):
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_79_eval_fee, 0, __pyx_n_s_FXAccount__eval_fee, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__107)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1911, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_eval_fee, __pyx_t_7) < 0) __PYX_ERR(0, 1911, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1961
 *         return fee_amount, fee_currency, fee_exec_duration
 * 
 *     def _cum_sum_heap(self, currency, action_func_type, long time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_81_cum_sum_heap, 0, __pyx_n_s_FXAccount__cum_sum_heap, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__109)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_cum_sum_heap_2, __pyx_t_7) < 0) __PYX_ERR(0, 1961, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1985
 *         return self.vec_heap.cum_sum_heap(currency.encode(), action_func_type.encode(), time_step, self._c_clock)
 * 
 *     def _cum_sum_marked_fund(self, currency, long time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_83_cum_sum_marked_fund, 0, __pyx_n_s_FXAccount__cum_sum_marked_fund, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__111)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_cum_sum_marked_fund_2, __pyx_t_7) < 0) __PYX_ERR(0, 1985, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1996
 *         return self.vec_heap.cum_sum_marked_fund(currency.encode(), time_step, self._c_clock)
 * 
 *     def _cum_sum_marked_debit(self, currency, time_step):             # <<<<<<<<<<<<<<
 *         """
 *         Only used for unit testing. Thin wrapper for underlying C++ implementation.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_85_cum_sum_marked_debit, 0, __pyx_n_s_FXAccount__cum_sum_marked_debit, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__113)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_cum_sum_marked_debit_2, __pyx_t_7) < 0) __PYX_ERR(0, 1996, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2007
 *         return self.vec_heap.cum_sum_marked_debit(currency.encode(), time_step, self._c_clock)
 * 
 *     def _fill_fee(self, action_type, alt_fee, volume, price, base, quote, processing_duration,             # <<<<<<<<<<<<<<
 *                   forward_coverage='except'):
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_87_fill_fee, 0, __pyx_n_s_FXAccount__fill_fee, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__115)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2007, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__116);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_fill_fee, __pyx_t_7) < 0) __PYX_ERR(0, 2007, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2043
 *         return fee_volume, fee_currency, fee_exec_duration
 * 
 *     def withdraw(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                  float_fee_currency=None):
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_89withdraw, 0, __pyx_n_s_FXAccount_withdraw, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__118)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__119);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_withdraw, __pyx_t_7) < 0) __PYX_ERR(0, 2043, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2177
 *                                fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def deposit(self, volume, currency, fee=None, processing_duration=None, coverage='except', instant_float_fee=False,             # <<<<<<<<<<<<<<
 *                 float_fee_currency=None):
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_91deposit, 0, __pyx_n_s_FXAccount_deposit, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__121)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__122);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_deposit, __pyx_t_7) < 0) __PYX_ERR(0, 2177, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2299
 *                               fee_exec_duration, coverage.encode(), instant_float_fee)
 * 
 *     def collect(self, payer_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                 payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_93collect, 0, __pyx_n_s_FXAccount_collect, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__124)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__125);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_collect, __pyx_t_7) < 0) __PYX_ERR(0, 2299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2442
 *                               payee_processing_duration)
 * 
 *     def transfer(self, payee_account, double volume, str currency, payee_fee=False, payer_fee=False,             # <<<<<<<<<<<<<<
 *                  payee_processing_duration=None, payer_processing_duration=None):
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_95transfer, 0, __pyx_n_s_FXAccount_transfer, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__127)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__128);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_transfer, __pyx_t_7) < 0) __PYX_ERR(0, 2442, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2586
 *                                payer_processing_duration)
 * 
 *     def buy(self, double volume_base, double ask_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *             str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_97buy, 0, __pyx_n_s_FXAccount_buy, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__130)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__131);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_buy, __pyx_t_7) < 0) __PYX_ERR(0, 2586, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2744
 *                           instant_withdrawal, instant_float_fee)
 * 
 *     def sell(self, double volume_base, double bid_price, str base, str quote, fee=None, processing_duration=None,             # <<<<<<<<<<<<<<
 *              str coverage='except', instant_withdrawal=False, instant_float_fee=False, float_fee_currency=None):
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_99sell, 0, __pyx_n_s_FXAccount_sell, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__133)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__134);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_sell, __pyx_t_7) < 0) __PYX_ERR(0, 2744, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2905
 *                            instant_withdrawal, instant_float_fee)
 * 
 *     def tick(self, clock=None):             # <<<<<<<<<<<<<<
 *         """
 *         If clock=None, then counts internal clock up by one time base unit.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_101tick, 0, __pyx_n_s_FXAccount_tick, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__136)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2905, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__137);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_tick, __pyx_t_7) < 0) __PYX_ERR(0, 2905, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2936
 *         return self.c_tick(clock)
 * 
 *     def update_exchange_rate(self, double rate, str base, str quote):             # <<<<<<<<<<<<<<
 *         """
 *         It is highly recommended not to use this class method, but use self.batch_update_exchange_rates instead!
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_103update_exchange_rate, 0, __pyx_n_s_FXAccount_update_exchange_rate, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__139)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_update_exchange_rate, __pyx_t_7) < 0) __PYX_ERR(0, 2936, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":2964
 *         self.c_update_exchange_rate(rate, base.encode(), quote.encode())
 * 
 *     def batch_update_exchange_rates(self, list_rates, list_base_quote_pairs):             # <<<<<<<<<<<<<<
 *         """
 *         Performs batch update of exchange rates of multiple currency pairs (or assets), whereas
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_105batch_update_exchange_rates, 0, __pyx_n_s_FXAccount_batch_update_exchange, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__141)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2964, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_batch_update_exchange_rates, __pyx_t_7) < 0) __PYX_ERR(0, 2964, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":3005
 *         return self.c_batch_update_exchange_rates(list_rates, list_base_quote_pairs)
 * 
 *     def total_balance(self, exchange_rates=None, reference_currency=None):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates current value of all assets within self.depot in reference currency.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_107total_balance, 0, __pyx_n_s_FXAccount_total_balance, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__143)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_7, __pyx_tuple__144);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_total_balance, __pyx_t_7) < 0) __PYX_ERR(0, 3005, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":3078
 *         return self.c_total_balance(exchange_rates, reference_currency.encode())
 * 
 *     def position(self, str currency):             # <<<<<<<<<<<<<<
 *         """
 *         Returns position size of given currency.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7trapeza_7account_10fx_account_9FXAccount_109position, 0, __pyx_n_s_FXAccount_position, NULL, __pyx_n_s_trapeza_account_fx_account, __pyx_d, ((PyObject *)__pyx_codeobj__146)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3078, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_position, __pyx_t_7) < 0) __PYX_ERR(0, 3078, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "trapeza/account/fx_account.pyx":1043
 * 
 * # noinspection PyAbstractClass,PyAttributeOutsideInit,PyTypeChecker
 * class FXAccount(cFXAccount, BaseAccount):             # <<<<<<<<<<<<<<
 *     """
 *     Derived from BaseAccount. This implementation is meant to model transactions and mechanisms specific to the
 */
  __pyx_t_7 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_FXAccount, __pyx_t_1, __pyx_t_4, NULL, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (__Pyx_CyFunction_InitClassCell(__pyx_t_5, __pyx_t_7) < 0) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_FXAccount, __pyx_t_7) < 0) __PYX_ERR(0, 1043, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_cFXAccount(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7trapeza_7account_10fx_account_3__pyx_unpickle_cFXAccount, NULL, __pyx_n_s_trapeza_account_fx_account); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_cFXAccount, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "trapeza/account/fx_account.pyx":1
 * # distutils: language=c++             # <<<<<<<<<<<<<<
 * 
 * import heapq
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "string.from_py":13
 * 
 * @cname("__pyx_convert_string_from_py_std__in_string")
 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t length = 0
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init trapeza.account.fx_account", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init trapeza.account.fx_account");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* ArgTypeTest */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (__Pyx_PyFastCFunction_Check(func)) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* DictGetItem */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* decode_c_bytes */
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    if (unlikely((start < 0) | (stop < 0))) {
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    if (stop > length)
        stop = length;
    if (unlikely(stop <= start))
        return __Pyx_NewRef(__pyx_empty_unicode);
    length = stop - start;
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* IterFinish */
static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* PyObjectGetMethod */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod0 */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method = NULL, *result = NULL;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_CallOneArg(method, obj);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) goto bad;
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

/* RaiseNeedMoreValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* RaiseTooManyValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* UnpackItemEndCheck */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* RaiseNoneIterError */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* UnpackTupleError */
static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
    if (t == Py_None) {
      __Pyx_RaiseNoneNotIterableError();
    } else if (PyTuple_GET_SIZE(t) < index) {
      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
    } else {
      __Pyx_RaiseTooManyValuesError(index);
    }
}

/* UnpackTuple2 */
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
        PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
    PyObject *value1 = NULL, *value2 = NULL;
#if CYTHON_COMPILING_IN_PYPY
    value1 = PySequence_ITEM(tuple, 0);  if (unlikely(!value1)) goto bad;
    value2 = PySequence_ITEM(tuple, 1);  if (unlikely(!value2)) goto bad;
#else
    value1 = PyTuple_GET_ITEM(tuple, 0);  Py_INCREF(value1);
    value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
#endif
    if (decref_tuple) {
        Py_DECREF(tuple);
    }
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
#if CYTHON_COMPILING_IN_PYPY
bad:
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
#endif
}
static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                       int has_known_size, int decref_tuple) {
    Py_ssize_t index;
    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
    iternextfunc iternext;
    iter = PyObject_GetIter(tuple);
    if (unlikely(!iter)) goto bad;
    if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
    iternext = Py_TYPE(iter)->tp_iternext;
    value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
    value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
    if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
    Py_DECREF(iter);
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
unpacking_failed:
    if (!has_known_size && __Pyx_IterFinish() == 0)
        __Pyx_RaiseNeedMoreValuesError(index);
bad:
    Py_XDECREF(iter);
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
}

/* dict_iter */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_source_is_dict) {
    is_dict = is_dict || likely(PyDict_CheckExact(iterable));
    *p_source_is_dict = is_dict;
    if (is_dict) {
#if !CYTHON_COMPILING_IN_PYPY
        *p_orig_length = PyDict_Size(iterable);
        Py_INCREF(iterable);
        return iterable;
#elif PY_MAJOR_VERSION >= 3
        static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
        PyObject **pp = NULL;
        if (method_name) {
            const char *name = PyUnicode_AsUTF8(method_name);
            if (strcmp(name, "iteritems") == 0) pp = &py_items;
            else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
            else if (strcmp(name, "itervalues") == 0) pp = &py_values;
            if (pp) {
                if (!*pp) {
                    *pp = PyUnicode_FromString(name + 4);
                    if (!*pp)
                        return NULL;
                }
                method_name = *pp;
            }
        }
#endif
    }
    *p_orig_length = 0;
    if (method_name) {
        PyObject* iter;
        iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
        if (!iterable)
            return NULL;
#if !CYTHON_COMPILING_IN_PYPY
        if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
            return iterable;
#endif
        iter = PyObject_GetIter(iterable);
        Py_DECREF(iterable);
        return iter;
    }
    return PyObject_GetIter(iterable);
}
static CYTHON_INLINE int __Pyx_dict_iter_next(
        PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
        PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
    PyObject* next_item;
#if !CYTHON_COMPILING_IN_PYPY
    if (source_is_dict) {
        PyObject *key, *value;
        if (unlikely(orig_length != PyDict_Size(iter_obj))) {
            PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
            return -1;
        }
        if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
            return 0;
        }
        if (pitem) {
            PyObject* tuple = PyTuple_New(2);
            if (unlikely(!tuple)) {
                return -1;
            }
            Py_INCREF(key);
            Py_INCREF(value);
            PyTuple_SET_ITEM(tuple, 0, key);
            PyTuple_SET_ITEM(tuple, 1, value);
            *pitem = tuple;
        } else {
            if (pkey) {
                Py_INCREF(key);
                *pkey = key;
            }
            if (pvalue) {
                Py_INCREF(value);
                *pvalue = value;
            }
        }
        return 1;
    } else if (PyTuple_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyTuple_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else if (PyList_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyList_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else
#endif
    {
        next_item = PyIter_Next(iter_obj);
        if (unlikely(!next_item)) {
            return __Pyx_IterFinish();
        }
    }
    if (pitem) {
        *pitem = next_item;
    } else if (pkey && pvalue) {
        if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
            return -1;
    } else if (pkey) {
        *pkey = next_item;
    } else {
        *pvalue = next_item;
    }
    return 1;
}

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* GetTopmostException */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* UnpackUnboundCMethod */
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod0 */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_ASSUME_SAFE_MACROS
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

/* py_dict_keys */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_keys, d);
    else
        return PyDict_Keys(d);
}

/* CallUnboundCMethod1 */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* GetAttr3 */
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* PyObjectSetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* PyIntCompare */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        int unequal;
        unsigned long uintval;
        Py_ssize_t size = Py_SIZE(op1);
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        if (intval == 0) {
            if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
        } else if (intval < 0) {
            if (size >= 0)
                Py_RETURN_FALSE;
            intval = -intval;
            size = -size;
        } else {
            if (size <= 0)
                Py_RETURN_FALSE;
        }
        uintval = (unsigned long) intval;
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 4)) {
            unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 3)) {
            unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 2)) {
            unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 1)) {
            unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
            unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
        if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
        if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    return (
        PyObject_RichCompare(op1, op2, Py_EQ));
}

/* BytesEquals */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        #if PY_MAJOR_VERSION < 3
        Py_XDECREF(owned_ref);
        #endif
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = *type;
    exc_info->exc_value = *value;
    exc_info->exc_traceback = *tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    #endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* None */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* ObjectGetItem */
#if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* PyIntCompare */
static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
    if (op1 == op2) {
        Py_RETURN_FALSE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a != b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        int unequal;
        unsigned long uintval;
        Py_ssize_t size = Py_SIZE(op1);
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        if (intval == 0) {
            if (size != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
        } else if (intval < 0) {
            if (size >= 0)
                Py_RETURN_TRUE;
            intval = -intval;
            size = -size;
        } else {
            if (size <= 0)
                Py_RETURN_TRUE;
        }
        uintval = (unsigned long) intval;
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 4)) {
            unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 3)) {
            unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 2)) {
            unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 1)) {
            unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
            unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
        if (unequal != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
        if ((double)a != (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    return (
        PyObject_RichCompare(op1, op2, Py_NE));
}

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* SetItemInt */
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
#else
    if (is_list || PySequence_Check(o))
#endif
    {
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        const long a = intval;
        long x;
        long b = PyInt_AS_LONG(op2);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op2))) {
        const long a = intval;
        long b, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG lla = intval;
        PY_LONG_LONG llb, llx;
#endif
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            b = likely(size) ? digits[0] : 0;
            if (size == -1) b = -b;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op2)) {
        const long a = intval;
        double b = PyFloat_AS_DOUBLE(op2);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* Import */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* HasAttr */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* PyObject_GenericGetAttrNoDict */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* SetVTable */
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* PyObjectGetAttrStrNoError */
static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
}

/* SetupReduce */
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
            if (likely(reduce_cython)) {
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
            } else if (reduce == object_reduce || PyErr_Occurred()) {
                goto __PYX_BAD;
            }
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
                if (likely(setstate_cython)) {
                    ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                    ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                } else if (!setstate || PyErr_Occurred()) {
                    goto __PYX_BAD;
                }
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto __PYX_GOOD;
__PYX_BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* TypeImport */
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* GetVTable */
static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* CalculateMetaclass */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

/* FetchCommonType */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunctionShared */
#include <structmember.h>
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
                                       PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    if (unlikely(op == NULL))
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults_size = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
#if PY_MAJOR_VERSION < 3
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
#endif
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__pyx_CyFunctionType == NULL)) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (unlikely(!m->defaults))
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    m->defaults_size = size;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* CythonFunction */
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    PyObject *op = __Pyx_CyFunction_Init(
        PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
        ml, flags, qualname, closure, module, globals, code
    );
    if (likely(op)) {
        PyObject_GC_Track(op);
    }
    return op;
}

/* Py3ClassCreate */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

/* CyFunctionClassCell */
static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj) {
    Py_ssize_t i, count = PyList_GET_SIZE(cyfunctions);
    for (i = 0; i < count; i++) {
        __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *)
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            PyList_GET_ITEM(cyfunctions, i);
#else
            PySequence_ITEM(cyfunctions, i);
        if (unlikely(!m))
            return -1;
#endif
        Py_INCREF(classobj);
        m->func_classobj = classobj;
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
        Py_DECREF((PyObject*)m);
#endif
    }
    return 0;
}

/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

static PyObject* __pyx_convert__to_py_struct____pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct(struct __pyx_t_7trapeza_7account_14execution_heap_fx_heap_element_struct s) {
  PyObject* res;
  PyObject* member;
  res = __Pyx_PyDict_NewPresized(5); if (unlikely(!res)) return NULL;
  member = __Pyx_PyInt_From_long(s.time); if (unlikely(!member)) goto bad;
  if (unlikely(PyDict_SetItem(res, __pyx_n_s_time, member) < 0)) goto bad;
  Py_DECREF(member);
  member = __pyx_convert_PyObject_string_to_py_std__in_string(s.action_func); if (unlikely(!member)) goto bad;
  if (unlikely(PyDict_SetItem(res, __pyx_n_s_action_func, member) < 0)) goto bad;
  Py_DECREF(member);
  member = PyFloat_FromDouble(s.volume); if (unlikely(!member)) goto bad;
  if (unlikely(PyDict_SetItem(res, __pyx_n_s_volume, member) < 0)) goto bad;
  Py_DECREF(member);
  member = __pyx_convert_PyObject_string_to_py_std__in_string(s.currency); if (unlikely(!member)) goto bad;
  if (unlikely(PyDict_SetItem(res, __pyx_n_s_currency, member) < 0)) goto bad;
  Py_DECREF(member);
  member = __pyx_convert_PyObject_string_to_py_std__in_string(s.coverage); if (unlikely(!member)) goto bad;
  if (unlikely(PyDict_SetItem(res, __pyx_n_s_coverage, member) < 0)) goto bad;
  Py_DECREF(member);
  return res;
  bad:
  Py_XDECREF(member);
  Py_DECREF(res);
  return NULL;
}
/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_short(short value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const short neg_one = (short) -1, const_zero = (short) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(short) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(short) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(short) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(short) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(short) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(short),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE short __Pyx_PyInt_As_short(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const short neg_one = (short) -1, const_zero = (short) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(short) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(short, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (short) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (short) 0;
                case  1: __PYX_VERIFY_RETURN_INT(short, digit, digits[0])
                case 2:
                    if (8 * sizeof(short) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) >= 2 * PyLong_SHIFT) {
                            return (short) (((((short)digits[1]) << PyLong_SHIFT) | (short)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(short) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) >= 3 * PyLong_SHIFT) {
                            return (short) (((((((short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(short) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) >= 4 * PyLong_SHIFT) {
                            return (short) (((((((((short)digits[3]) << PyLong_SHIFT) | (short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (short) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(short) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(short, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(short) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(short, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (short) 0;
                case -1: __PYX_VERIFY_RETURN_INT(short, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(short,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(short) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 2 * PyLong_SHIFT) {
                            return (short) (((short)-1)*(((((short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(short) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 2 * PyLong_SHIFT) {
                            return (short) ((((((short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(short) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 3 * PyLong_SHIFT) {
                            return (short) (((short)-1)*(((((((short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(short) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 3 * PyLong_SHIFT) {
                            return (short) ((((((((short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(short) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 4 * PyLong_SHIFT) {
                            return (short) (((short)-1)*(((((((((short)digits[3]) << PyLong_SHIFT) | (short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(short) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 4 * PyLong_SHIFT) {
                            return (short) ((((((((((short)digits[3]) << PyLong_SHIFT) | (short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(short) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(short, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(short) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(short, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            short val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (short) -1;
        }
    } else {
        short val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (short) -1;
        val = __Pyx_PyInt_As_short(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to short");
    return (short) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to short");
    return (short) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* PyObjectCallMethod1 */
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* CoroutineBase */
#include <structmember.h>
#include <frameobject.h>
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (!ev) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#if PY_VERSION_HEX >= 0x030300A0
        else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
        }
#endif
        else if (unlikely(PyTuple_Check(ev))) {
            if (PyTuple_GET_SIZE(ev) >= 1) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                value = PyTuple_GET_ITEM(ev, 0);
                Py_INCREF(value);
#else
                value = PySequence_ITEM(ev, 0);
#endif
            } else {
                Py_INCREF(Py_None);
                value = Py_None;
            }
            Py_DECREF(ev);
        }
        else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PySequence_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
static CYTHON_INLINE
void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *t, *v, *tb;
    t = exc_state->exc_type;
    v = exc_state->exc_value;
    tb = exc_state->exc_traceback;
    exc_state->exc_type = NULL;
    exc_state->exc_value = NULL;
    exc_state->exc_traceback = NULL;
    Py_XDECREF(t);
    Py_XDECREF(v);
    Py_XDECREF(tb);
}
#define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
        msg = "coroutine already executing";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
        msg = "async generator already executing";
    #endif
    } else {
        msg = "generator already executing";
    }
    PyErr_SetString(PyExc_ValueError, msg);
}
#define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check(gen)) {
        msg = "can't send non-None value to a just-started coroutine";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact(gen)) {
        msg = "can't send non-None value to a just-started async generator";
    #endif
    } else {
        msg = "can't send non-None value to a just-started generator";
    }
    PyErr_SetString(PyExc_TypeError, msg);
}
#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
    #ifdef __Pyx_Coroutine_USED
    if (!closing && __Pyx_Coroutine_Check(gen)) {
        PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
    } else
    #endif
    if (value) {
        #ifdef __Pyx_AsyncGen_USED
        if (__Pyx_AsyncGen_CheckExact(gen))
            PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
        else
        #endif
        PyErr_SetNone(PyExc_StopIteration);
    }
}
static
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
    __Pyx_PyThreadState_declare
    PyThreadState *tstate;
    __Pyx_ExcInfoStruct *exc_state;
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            return __Pyx_Coroutine_NotStartedError((PyObject*)self);
        }
    }
    if (unlikely(self->resume_label == -1)) {
        return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
    }
#if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    tstate = __pyx_tstate;
#else
    tstate = __Pyx_PyThreadState_Current;
#endif
    exc_state = &self->gi_exc_state;
    if (exc_state->exc_type) {
        #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
        #else
        if (exc_state->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
        #endif
    }
#if CYTHON_USE_EXC_INFO_STACK
    exc_state->previous_item = tstate->exc_info;
    tstate->exc_info = exc_state;
#else
    if (exc_state->exc_type) {
        __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(exc_state);
        __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    }
#endif
    self->is_running = 1;
    retval = self->body((PyObject *) self, tstate, value);
    self->is_running = 0;
#if CYTHON_USE_EXC_INFO_STACK
    exc_state = &self->gi_exc_state;
    tstate->exc_info = exc_state->previous_item;
    exc_state->previous_item = NULL;
    __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
#endif
    return retval;
}
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *exc_tb = exc_state->exc_traceback;
    if (likely(exc_tb)) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
        PyFrameObject *f = tb->tb_frame;
        Py_CLEAR(f->f_back);
#endif
    }
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
    if (unlikely(!retval)) {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        if (!__Pyx_PyErr_Occurred()) {
            PyObject *exc = PyExc_StopIteration;
            #ifdef __Pyx_AsyncGen_USED
            if (__Pyx_AsyncGen_CheckExact(gen))
                exc = __Pyx_PyExc_StopAsyncIteration;
            #endif
            __Pyx_PyErr_SetNone(exc);
        }
    }
    return retval;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
static CYTHON_INLINE
PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
#if PY_VERSION_HEX <= 0x030A00A1
    return _PyGen_Send(gen, arg);
#else
    PyObject *result;
    if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
        if (PyAsyncGen_CheckExact(gen)) {
            assert(result == Py_None);
            PyErr_SetNone(PyExc_StopAsyncIteration);
        }
        else if (result == Py_None) {
            PyErr_SetNone(PyExc_StopIteration);
        }
        else {
            _PyGen_SetStopIterationValue(result);
        }
        Py_CLEAR(result);
    }
    return result;
#endif
}
#endif
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
    ret = __Pyx_Coroutine_SendEx(gen, val, 0);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_AsyncGen_USED
        if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
            ret = __Pyx_async_gen_asend_send(yf, value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyCoro_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        {
            if (value == Py_None)
                ret = Py_TYPE(yf)->tp_iternext(yf);
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        retval = __Pyx_Coroutine_FinishDelegation(gen);
    } else {
        retval = __Pyx_Coroutine_SendEx(gen, value, 0);
    }
    return __Pyx_Coroutine_MethodReturn(self, retval);
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_Check(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    if (__Pyx_CoroutineAwait_CheckExact(yf)) {
        retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_AsyncGen_USED
    if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
        retval = __Pyx_async_gen_asend_close(yf, NULL);
    } else
    if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
        retval = __Pyx_async_gen_athrow_close(yf, NULL);
    } else
    #endif
    {
        PyObject *meth;
        gen->is_running = 1;
        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, Py_None);
        } else
        #endif
            ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Coroutine_FinishDelegation(gen);
    }
    return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
}
static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) {
    return __Pyx_Coroutine_Close(self);
}
static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
    if (unlikely(retval)) {
        const char *msg;
        Py_DECREF(retval);
        if ((0)) {
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_Coroutine_Check(self)) {
            msg = "coroutine ignored GeneratorExit";
        #endif
        #ifdef __Pyx_AsyncGen_USED
        } else if (__Pyx_AsyncGen_CheckExact(self)) {
#if PY_VERSION_HEX < 0x03060000
            msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
#else
            msg = "async generator ignored GeneratorExit";
#endif
        #endif
        } else {
            msg = "generator ignored GeneratorExit";
        }
        PyErr_SetString(PyExc_RuntimeError, msg);
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
                                        PyObject *args, int close_on_genexit) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
            goto throw_here;
        }
        gen->is_running = 1;
        if (0
        #ifdef __Pyx_Generator_USED
            || __Pyx_Generator_CheckExact(yf)
        #endif
        #ifdef __Pyx_Coroutine_USED
            || __Pyx_Coroutine_Check(yf)
        #endif
            ) {
            ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
            ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
        #endif
        } else {
            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Coroutine_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            if (likely(args)) {
                ret = PyObject_CallObject(meth, args);
            } else {
                ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
            }
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(self, ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    PyObject *typ;
    PyObject *val = NULL;
    PyObject *tb = NULL;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
}
static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
    Py_VISIT(exc_state->exc_type);
    Py_VISIT(exc_state->exc_value);
    Py_VISIT(exc_state->exc_traceback);
    return 0;
}
static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
}
static int __Pyx_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
    }
#endif
    Py_CLEAR(gen->gi_code);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    Py_CLEAR(gen->gi_modulename);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label >= 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        /* We have to handle this case for asynchronous generators
           right here, because this code has to be between UNTRACK
           and GC_Del. */
        Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
    }
#endif
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label < 0) {
        return;
    }
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt == 0);
    __Pyx_SET_REFCNT(self, 1);
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
        PyObject *finalizer = agen->ag_finalizer;
        if (finalizer && !agen->ag_closed) {
            PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
            if (unlikely(!res)) {
                PyErr_WriteUnraisable(self);
            } else {
                Py_DECREF(res);
            }
            __Pyx_ErrRestore(error_type, error_value, error_traceback);
            return;
        }
    }
#endif
    if (unlikely(gen->resume_label == 0 && !error_value)) {
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Generator_USED
    if (!__Pyx_Generator_CheckExact(self))
#endif
        {
        PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
        if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
            PyErr_WriteUnraisable(self);
#else
        {PyObject *msg;
        char *cmsg;
        #if CYTHON_COMPILING_IN_PYPY
        msg = NULL;
        cmsg = (char*) "coroutine was never awaited";
        #else
        char *cname;
        PyObject *qualname;
        qualname = gen->gi_qualname;
        cname = PyString_AS_STRING(qualname);
        msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
        if (unlikely(!msg)) {
            PyErr_Clear();
            cmsg = (char*) "coroutine was never awaited";
        } else {
            cmsg = PyString_AS_STRING(msg);
        }
        #endif
        if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
            PyErr_WriteUnraisable(self);
        Py_XDECREF(msg);}
#endif
        PyObject_GC_Track(self);
        }
#endif
    } else {
        PyObject *res = __Pyx_Coroutine_Close(self);
        if (unlikely(!res)) {
            if (PyErr_Occurred())
                PyErr_WriteUnraisable(self);
        } else {
            Py_DECREF(res);
        }
    }
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt > 0);
    if (--self->ob_refcnt == 0) {
        return;
    }
    {
        Py_ssize_t refcnt = self->ob_refcnt;
        _Py_NewReference(self);
        __Pyx_SET_REFCNT(self, refcnt);
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(self->ob_type) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    _Py_DEC_REFTOTAL;
#endif
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_name;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_name;
    Py_INCREF(value);
    self->gi_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_qualname;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
            PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (unlikely(!gen))
        return NULL;
    return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->gi_exc_state.exc_type = NULL;
    gen->gi_exc_state.exc_value = NULL;
    gen->gi_exc_state.exc_traceback = NULL;
#if CYTHON_USE_EXC_INFO_STACK
    gen->gi_exc_state.previous_item = NULL;
#endif
    gen->gi_weakreflist = NULL;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    Py_XINCREF(module_name);
    gen->gi_modulename = module_name;
    Py_XINCREF(code);
    gen->gi_code = code;
    PyObject_GC_Track(gen);
    return gen;
}

/* PatchModuleWithCoroutine */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    int result;
    PyObject *globals, *result_obj;
    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
    #ifdef __Pyx_Coroutine_USED
        (PyObject*)__pyx_CoroutineType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_generator_type",
    #ifdef __Pyx_Generator_USED
        (PyObject*)__pyx_GeneratorType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
    if (unlikely(!result_obj)) goto ignore;
    Py_DECREF(result_obj);
    Py_DECREF(globals);
    return module;
ignore:
    Py_XDECREF(globals);
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    py_code++;
#endif
    return module;
}

/* PatchGeneratorABC */
#ifndef CYTHON_REGISTER_ABCS
#define CYTHON_REGISTER_ABCS 1
#endif
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
static PyObject* __Pyx_patch_abc_module(PyObject *module);
static PyObject* __Pyx_patch_abc_module(PyObject *module) {
    module = __Pyx_Coroutine_patch_module(
        module, ""
"if _cython_generator_type is not None:\n"
"    try: Generator = _module.Generator\n"
"    except AttributeError: pass\n"
"    else: Generator.register(_cython_generator_type)\n"
"if _cython_coroutine_type is not None:\n"
"    try: Coroutine = _module.Coroutine\n"
"    except AttributeError: pass\n"
"    else: Coroutine.register(_cython_coroutine_type)\n"
    );
    return module;
}
#endif
static int __Pyx_patch_abc(void) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    static int abc_patched = 0;
    if (CYTHON_REGISTER_ABCS && !abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_MAJOR_VERSION >= 3) ?
                        "Cython module failed to register with collections.abc module" :
                        "Cython module failed to register with collections module"), 1) < 0)) {
                return -1;
            }
        } else {
            module = __Pyx_patch_abc_module(module);
            abc_patched = 1;
            if (unlikely(!module))
                return -1;
            Py_DECREF(module);
        }
        module = PyImport_ImportModule("backports_abc");
        if (module) {
            module = __Pyx_patch_abc_module(module);
            Py_XDECREF(module);
        }
        if (!module) {
            PyErr_Clear();
        }
    }
#else
    if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
#endif
    return 0;
}

/* Generator */
static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
    {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
    {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",
    sizeof(__pyx_CoroutineObject),
    0,
    (destructor) __Pyx_Coroutine_dealloc,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
    0,
    (traverseproc) __Pyx_Coroutine_traverse,
    0,
    0,
    offsetof(__pyx_CoroutineObject, gi_weakreflist),
    0,
    (iternextfunc) __Pyx_Generator_Next,
    __pyx_Generator_methods,
    __pyx_Generator_memberlist,
    __pyx_Generator_getsets,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if CYTHON_USE_TP_FINALIZE
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if CYTHON_USE_TP_FINALIZE
    __Pyx_Coroutine_del,
#elif PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (unlikely(!__pyx_GeneratorType)) {
        return -1;
    }
    return 0;
}

/* CheckBinaryVersion */
static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* FunctionExport */
static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

/* VoidPtrImport */
#ifndef __PYX_HAVE_RT_ImportVoidPtr
#define __PYX_HAVE_RT_ImportVoidPtr
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, name);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C variable %.200s",
                PyModule_GetName(module), name);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    *p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, desc);
        goto bad;
    }
    *p = PyCObject_AsVoidPtr(cobj);}
#endif
    if (!(*p))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* InitStrings */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
