Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Pettypiece committed Oct 25, 2016
1 parent 64722d6 commit 3a3b4a2
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 6 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,24 @@ entry point alias:
(env)user@host: ~/v20-python-samples$ v20-instrument-candles
```

### Streaming Transactions

### Poll Instrument Candlesticks

The script to poll instrument candlesticks is defined at
`src/instrument/candles_poll.py`. It uses curses to redraw the current candle
while it is being updated, and moves on to the next candle when the current
candle is completed. It can be executed directly or with the provided entry
point alias:

```bash
(env)user@host: ~/v20-python-samples$ python src/instrument/candles_poll.py
(env)user@host: ~/v20-python-samples$ v20-instrument-candles-poll
```


## Orders

### Create Market Order

### Create Market Order

2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
'v20-account-configure = account.configure:main',
'v20-instrument-candles = instrument.candles:main',
'v20-instrument-candles-poll = instrument.candles_poll:main',
'v20-order-list = order.list:main',
'v20-order-market = order.market:main',
]
}
)
Expand Down
36 changes: 36 additions & 0 deletions src/common/arg_helper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
import argparse
import v20.transaction

def instrument(i):
return i.replace("/", "_")
Expand All @@ -13,3 +14,38 @@ def parse(s):
raise argparse.ArgumentTypeError(msg)

return parse

def add_client_order_extensions(parser):
parser.add_argument(
"--client-order-id",
help="The client-provided ID to assign to the Order"
)

parser.add_argument(
"--client-order-tag",
help="The client-provided tag to assign to the Order"
)

parser.add_argument(
"--client-order-comment",
help="The client-provided comment to assign to the Order"
)

def parse_client_order_extensions(args):
if (args.client_order_id is None and
args.client_order_tag is None and
args.client_order_comment is None):
return None

kwargs = {}

if args.client_order_id is not None:
kwargs["id"] = args.client_order_id

if args.client_order_tag is not None:
kwargs["tag"] = args.client_order_tag

if args.client_order_comment is not None:
kwargs["comment"] = args.client_order_comment

return v20.transaction.ClientExtensions(**kwargs)
2 changes: 1 addition & 1 deletion src/common/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ def print_response_transaction(
response.get(transaction_name, expected_status),
title=title
)
print()
print
except:
pass
7 changes: 5 additions & 2 deletions src/instrument/candles_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def render(self):
self.stdscr.refresh()



def main():
curses.wrapper(run)

Expand Down Expand Up @@ -212,7 +211,11 @@ def run(stdscr):
)

printer.render()


#
# Poll for candles updates every second and redraw
# the results
#
while True:
time.sleep(1)

Expand Down
18 changes: 17 additions & 1 deletion src/order/orders_list.py → src/order/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@

import argparse
import common.config
from common.view import print_orders
from view import print_orders


def main():
parser = argparse.ArgumentParser()
common.config.add_argument(parser)

parser.add_argument(
"--summary",
dest="summary",
action="store_true",
help="Print a summary of the orders",
default=True
)

parser.add_argument(
"--details",
dest="summary",
help="Print details of the orders",
action="store_false"
)

args = parser.parse_args()

account_id = args.config.active_account
Expand Down
1 change: 0 additions & 1 deletion src/order/market_order.py

This file was deleted.

0 comments on commit 3a3b4a2

Please sign in to comment.