Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
beem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
beem
Commits
6abe6823
Commit
6abe6823
authored
7 years ago
by
Fabian Schuh
Browse files
Options
Downloads
Patches
Plain Diff
[class] MarginCall -> UdpateCallOrder
parent
0122cb00
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bitshares/account.py
+3
-1
3 additions, 1 deletion
bitshares/account.py
bitshares/notify.py
+4
-13
4 additions, 13 deletions
bitshares/notify.py
bitshares/price.py
+2
-2
2 additions, 2 deletions
bitshares/price.py
bitsharesapi/websocket.py
+5
-4
5 additions, 4 deletions
bitsharesapi/websocket.py
with
14 additions
and
20 deletions
bitshares/account.py
+
3
−
1
View file @
6abe6823
...
@@ -254,4 +254,6 @@ class AccountUpdate(dict):
...
@@ -254,4 +254,6 @@ class AccountUpdate(dict):
:class:`bitshares.account.Account` from this class, you can
:class:`bitshares.account.Account` from this class, you can
use the ``account`` attribute.
use the ``account`` attribute.
"""
"""
return
Account
(
self
[
"
owner
"
])
account
=
Account
(
self
[
"
owner
"
])
account
.
refresh
()
return
account
This diff is collapsed.
Click to expand it.
bitshares/notify.py
+
4
−
13
View file @
6abe6823
...
@@ -3,7 +3,7 @@ from events import Events
...
@@ -3,7 +3,7 @@ from events import Events
from
bitsharesapi.websocket
import
BitSharesWebsocket
from
bitsharesapi.websocket
import
BitSharesWebsocket
from
bitshares.instance
import
shared_bitshares_instance
from
bitshares.instance
import
shared_bitshares_instance
from
bitshares.market
import
Market
from
bitshares.market
import
Market
from
bitshares.price
import
Order
,
FilledOrder
,
MarginCall
from
bitshares.price
import
Order
,
FilledOrder
,
UpdateCallOrder
from
bitshares.account
import
Account
,
AccountUpdate
from
bitshares.account
import
Account
,
AccountUpdate
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
# logging.basicConfig(level=logging.DEBUG)
# logging.basicConfig(level=logging.DEBUG)
...
@@ -81,15 +81,6 @@ class Notify(Events):
...
@@ -81,15 +81,6 @@ class Notify(Events):
market
[
"
quote
"
][
"
id
"
],
market
[
"
quote
"
][
"
id
"
],
])
])
# Accounts
account_ids
=
[]
for
account_name
in
accounts
:
account
=
Account
(
account_name
,
bitshares_instance
=
self
.
bitshares
)
account_ids
.
append
(
account
[
"
id
"
])
# Callbacks
# Callbacks
if
on_tx
:
if
on_tx
:
self
.
on_tx
+=
on_tx
self
.
on_tx
+=
on_tx
...
@@ -107,7 +98,7 @@ class Notify(Events):
...
@@ -107,7 +98,7 @@ class Notify(Events):
urls
=
self
.
bitshares
.
rpc
.
urls
,
urls
=
self
.
bitshares
.
rpc
.
urls
,
user
=
self
.
bitshares
.
rpc
.
user
,
user
=
self
.
bitshares
.
rpc
.
user
,
password
=
self
.
bitshares
.
rpc
.
password
,
password
=
self
.
bitshares
.
rpc
.
password
,
accounts
=
account
_id
s
,
accounts
=
accounts
,
markets
=
market_ids
,
markets
=
market_ids
,
objects
=
objects
,
objects
=
objects
,
on_tx
=
on_tx
,
on_tx
=
on_tx
,
...
@@ -123,7 +114,7 @@ class Notify(Events):
...
@@ -123,7 +114,7 @@ class Notify(Events):
* :class:`bitshares.price.Order` or
* :class:`bitshares.price.Order` or
* :class:`bitshares.price.FilledOrder` or
* :class:`bitshares.price.FilledOrder` or
* :class:`bitshares.price.
MarginCall
`
* :class:`bitshares.price.
UpdateCallOrder
`
Also possible are limit order updates (margin calls)
Also possible are limit order updates (margin calls)
...
@@ -150,7 +141,7 @@ class Notify(Events):
...
@@ -150,7 +141,7 @@ class Notify(Events):
elif
"
for_sale
"
in
i
and
"
sell_price
"
in
i
:
elif
"
for_sale
"
in
i
and
"
sell_price
"
in
i
:
self
.
on_market
(
Order
(
i
))
self
.
on_market
(
Order
(
i
))
elif
"
collateral
"
in
i
and
"
call_price
"
in
i
:
elif
"
collateral
"
in
i
and
"
call_price
"
in
i
:
self
.
on_market
(
MarginCall
(
i
))
self
.
on_market
(
UpdateCallOrder
(
i
))
else
:
else
:
if
i
:
if
i
:
log
.
error
(
log
.
error
(
...
...
This diff is collapsed.
Click to expand it.
bitshares/price.py
+
2
−
2
View file @
6abe6823
...
@@ -466,7 +466,7 @@ class FilledOrder(Price):
...
@@ -466,7 +466,7 @@ class FilledOrder(Price):
__str__
=
__repr__
__str__
=
__repr__
class
MarginCall
(
Price
):
class
UpdateCallOrder
(
Price
):
"""
This class inherits :class:`bitshares.price.Price` but has the ``base``
"""
This class inherits :class:`bitshares.price.Price` but has the ``base``
and ``quote`` Amounts not only be used to represent the **call
and ``quote`` Amounts not only be used to represent the **call
price** (as a ratio of base and quote).
price** (as a ratio of base and quote).
...
@@ -478,7 +478,7 @@ class MarginCall(Price):
...
@@ -478,7 +478,7 @@ class MarginCall(Price):
self
.
bitshares
=
bitshares_instance
or
shared_bitshares_instance
()
self
.
bitshares
=
bitshares_instance
or
shared_bitshares_instance
()
if
isinstance
(
call
,
dict
)
and
"
call_price
"
in
call
:
if
isinstance
(
call
,
dict
)
and
"
call_price
"
in
call
:
super
(
MarginCall
,
self
).
__init__
(
super
(
UpdateCallOrder
,
self
).
__init__
(
call
.
get
(
"
call_price
"
),
call
.
get
(
"
call_price
"
),
base
=
call
[
"
call_price
"
].
get
(
"
base
"
),
base
=
call
[
"
call_price
"
].
get
(
"
base
"
),
quote
=
call
[
"
call_price
"
].
get
(
"
quote
"
),
quote
=
call
[
"
call_price
"
].
get
(
"
quote
"
),
...
...
This diff is collapsed.
Click to expand it.
bitsharesapi/websocket.py
+
5
−
4
View file @
6abe6823
...
@@ -11,7 +11,7 @@ from .exceptions import NumRetriesReached
...
@@ -11,7 +11,7 @@ from .exceptions import NumRetriesReached
from
events
import
Events
from
events
import
Events
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
#
logging.basicConfig(level=logging.DEBUG)
#logging.basicConfig(level=logging.DEBUG)
class
BitSharesWebsocket
(
Events
):
class
BitSharesWebsocket
(
Events
):
...
@@ -131,7 +131,7 @@ class BitSharesWebsocket(Events):
...
@@ -131,7 +131,7 @@ class BitSharesWebsocket(Events):
self
.
urls
=
cycle
([
urls
])
self
.
urls
=
cycle
([
urls
])
# Instanciate Events
# Instanciate Events
Events
.
__init__
(
self
,
*
args
,
**
kwargs
)
Events
.
__init__
(
self
)
self
.
events
=
Events
()
self
.
events
=
Events
()
# Store the objects we are interested in
# Store the objects we are interested in
...
@@ -184,9 +184,11 @@ class BitSharesWebsocket(Events):
...
@@ -184,9 +184,11 @@ class BitSharesWebsocket(Events):
if
self
.
subscription_accounts
and
self
.
on_account
:
if
self
.
subscription_accounts
and
self
.
on_account
:
# Unfortunately, account subscriptions don't have their own
# Unfortunately, account subscriptions don't have their own
# callback number
# callback number
self
.
accounts
=
self
.
get_full_accounts
(
self
.
subscription_accounts
,
True
)
log
.
debug
(
"
Subscribing to accounts %s
"
%
str
(
self
.
subscription_accounts
))
self
.
get_full_accounts
(
self
.
subscription_accounts
,
True
)
if
self
.
subscription_markets
and
self
.
on_market
:
if
self
.
subscription_markets
and
self
.
on_market
:
log
.
debug
(
"
Subscribing to markets %s
"
%
str
(
self
.
subscription_markets
))
for
market
in
self
.
subscription_markets
:
for
market
in
self
.
subscription_markets
:
# Technially, every market could have it's own
# Technially, every market could have it's own
# callback number
# callback number
...
@@ -298,7 +300,6 @@ class BitSharesWebsocket(Events):
...
@@ -298,7 +300,6 @@ class BitSharesWebsocket(Events):
self
.
ws
=
websocket
.
WebSocketApp
(
self
.
ws
=
websocket
.
WebSocketApp
(
self
.
url
,
self
.
url
,
on_message
=
self
.
on_message
,
on_message
=
self
.
on_message
,
# on_data=self.on_message,
on_error
=
self
.
on_error
,
on_error
=
self
.
on_error
,
on_close
=
self
.
on_close
,
on_close
=
self
.
on_close
,
on_open
=
self
.
on_open
on_open
=
self
.
on_open
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment