Beispiel #1
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id',
                        default=None,
                        help='TickTrader Web API Id')
    parser.add_argument('web_api_key',
                        default=None,
                        help='TickTrader Web API Key')
    parser.add_argument('web_api_secret',
                        default=None,
                        help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id,
                                 args.web_api_key, args.web_api_secret)

    # Account positions
    account = client.get_account()
    if account['AccountingType'] == 'Net':
        positions = client.get_all_positions()
        for p in positions:
            print('{0} position: {1} {2}'.format(p['Symbol'], p['LongAmount'],
                                                 p['ShortAmount']))
Beispiel #2
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id',
                        default=None,
                        help='TickTrader Web API Id')
    parser.add_argument('web_api_key',
                        default=None,
                        help='TickTrader Web API Key')
    parser.add_argument('web_api_secret',
                        default=None,
                        help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id,
                                 args.web_api_key, args.web_api_secret)

    # Account trades
    trades = client.get_all_trades()
    for t in trades:
        print('{0} trade with type {1} by symbol {2}: {3}'.format(
            t['Id'], t['Type'], t['Symbol'], t['Amount']))

    trade = client.get_trade(trades[0]['Id'])
    print('{0} trade with type {1} by symbol {2}: {3}'.format(
        trade['Id'], trade['Type'], trade['Symbol'], trade['Amount']))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    iterations = 3
    request = {'TimestampTo':TickTraderWebClient.get_timestamp(), 'RequestDirection':'Backward', 'RequestPageSize':10}

    # Try to get trade history from now to the past. Request is limited to 30 records!
    while iterations > 0:
        report = client.get_trade_history(request)
        for record in report['Records']:
            print('TradeHistory record: Id={0}, TransactionType={1}, TransactionReason={2}, Symbol={3}, TradeId={4}'
                  .format(record.get('Id', ''),
                          record.get('TransactionType', ''),
                          record.get('TransactionReason', ''),
                          record.get('Symbol', ''),
                          record.get('TradeId', '')))
            request['RequestLastId'] = record['Id']
        # Stop for last report
        if report['IsLastReport']:
            break
        iterations -= 1
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    # Account trade session
    trade_session = client.get_trade_session()
    print('Trade session status: {0}'.format(trade_session['SessionStatus']))
Beispiel #5
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address)

    # Public symbols
    symbols = client.get_public_all_symbols()
    for s in symbols:
        print('Symbol: {0}'.format(s['Symbol']))

    symbol = client.get_public_symbol(symbols[0]['Symbol'])
    print("{0} symbol precision: {1}".format(symbol[0]['Symbol'], symbol[0]['Precision']))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address)

    # Public feed ticks
    ticks = client.get_public_all_ticks()
    for t in ticks:
        print('{0} tick: {1} {2}'.format(t['Symbol'], t['BestBid']['Price'], t['BestAsk']['Price']))

    tick = client.get_public_tick(ticks[0]['Symbol'])
    print("{0} tick timestamp: {1}".format(tick[0]['Symbol'], tick[0]['Timestamp']))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address)

    # Public currencies
    currencies = client.get_public_all_currencies()
    for c in currencies:
        print('Currency: {0}'.format(c['Name']))

    currency = client.get_public_currency(currencies[0]['Name'])
    print("{0} currency precision: {1}".format(currency[0]['Name'], currency[0]['Precision']))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address)

    # Public trade session status
    public_trade_session = client.get_public_trade_session()
    print('TickTrader name: {0}'.format(public_trade_session['PlatformName']))
    print('TickTrader company: {0}'.format(public_trade_session['PlatformCompany']))
    print('TickTrader address: {0}'.format(public_trade_session['PlatformAddress']))
    print('TickTrader timezone offset: {0}'.format(public_trade_session['PlatformTimezoneOffset']))
    print('TickTrader session status: {0}'.format(public_trade_session['SessionStatus']))
Beispiel #9
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    # Account info
    account = client.get_account()
    print('Account Id: {0}'.format(account['Id']))
    print('Account name: {0}'.format(account['Name']))
    print('Account group: {0}'.format(account['Group']))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address)

    # Public feed level2 ticks
    ticks_level2 = client.get_public_all_ticks_level2()
    for t in ticks_level2:
        print('{0} level2 book depth: {1}'.format(t['Symbol'], max(len(t['Bids']), len(t['Asks']))))

    tick_level2 = client.get_public_tick_level2(ticks_level2[0]['Symbol'])
    print("{0} level2 book depth: {1}".format(tick_level2[0]['Symbol'],
                                              max(len(tick_level2[0]['Bids']), len(tick_level2[0]['Asks']))))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address)

    # Public currencies
    currencies = client.get_public_all_currencies()
    for c in currencies:
        print('Currency: {0}'.format(c['Name']))

    currency = client.get_public_currency(currencies[0]['Name'])
    print("{0} currency precision: {1}".format(currency[0]['Name'],
                                               currency[0]['Precision']))
Beispiel #12
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address)

    # Public feed ticks
    ticks = client.get_public_all_ticks()
    for t in ticks:
        print('{0} tick: {1} {2}'.format(t['Symbol'], t['BestBid']['Price'],
                                         t['BestAsk']['Price']))

    tick = client.get_public_tick(ticks[0]['Symbol'])
    print("{0} tick timestamp: {1}".format(tick[0]['Symbol'],
                                           tick[0]['Timestamp']))
Beispiel #13
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    # Account assets
    account = client.get_account()
    if account['AccountingType'] == 'Cash':
        assets = client.get_all_assets()
        for a in assets:
            print('{0} asset: {1}'.format(a['Currency'], a['Amount']))
Beispiel #14
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    # Account positions
    account = client.get_account()
    if account['AccountingType'] == 'Net':
        positions = client.get_all_positions()
        for p in positions:
            print('{0} position: {1} {2}'.format(p['Symbol'], p['LongAmount'], p['ShortAmount']))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    # Account feed ticks
    ticks = client.get_all_ticks()
    for t in ticks:
        print('{0} tick: {1} {2}'.format(t['Symbol'], t['BestBid']['Price'], t['BestAsk']['Price']))

    tick = client.get_tick(ticks[0]['Symbol'])
    print("{0} tick timestamp: {1}".format(tick[0]['Symbol'], tick[0]['Timestamp']))
Beispiel #16
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address)

    # Public feed level2 ticks
    ticks_level2 = client.get_public_all_ticks_level2()
    for t in ticks_level2:
        print('{0} level2 book depth: {1}'.format(
            t['Symbol'], max(len(t['Bids']), len(t['Asks']))))

    tick_level2 = client.get_public_tick_level2(ticks_level2[0]['Symbol'])
    print("{0} level2 book depth: {1}".format(
        tick_level2[0]['Symbol'],
        max(len(tick_level2[0]['Bids']), len(tick_level2[0]['Asks']))))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    # Account symbols
    symbols = client.get_all_symbols()
    for s in symbols:
        print('Symbol: {0}'.format(s['Symbol']))

    symbol = client.get_symbol(symbols[0]['Symbol'])
    print("{0} symbol precision: {1}".format(symbol[0]['Symbol'], symbol[0]['Precision']))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address)

    # Public trade session status
    public_trade_session = client.get_public_trade_session()
    print('TickTrader name: {0}'.format(public_trade_session['PlatformName']))
    print('TickTrader company: {0}'.format(
        public_trade_session['PlatformCompany']))
    print('TickTrader address: {0}'.format(
        public_trade_session['PlatformAddress']))
    print('TickTrader timezone offset: {0}'.format(
        public_trade_session['PlatformTimezoneOffset']))
    print('TickTrader session status: {0}'.format(
        public_trade_session['SessionStatus']))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    # Account feed ticks level2
    ticks_level2 = client.get_all_ticks_level2()
    for t in ticks_level2:
        print('{0} level2 book depth: {1}'.format(t['Symbol'], max(len(t['Bids']), len(t['Asks']))))

    tick_level2 = client.get_tick_level2(ticks_level2[0]['Symbol'])
    print("{0} level2 book depth: {1}".format(tick_level2[0]['Symbol'],
                                              max(len(tick_level2[0]['Bids']), len(tick_level2[0]['Asks']))))
Beispiel #20
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    # Account trades
    trades = client.get_all_trades()
    for t in trades:
        print('{0} trade with type {1} by symbol {2}: {3}'.format(t['Id'], t['Type'], t['Symbol'], t['Amount']))

    trade = client.get_trade(trades[0]['Id'])
    print('{0} trade with type {1} by symbol {2}: {3}'.format(trade['Id'],
                                                              trade['Type'],
                                                              trade['Symbol'],
                                                              trade['Amount']))
Beispiel #21
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id',
                        default=None,
                        help='TickTrader Web API Id')
    parser.add_argument('web_api_key',
                        default=None,
                        help='TickTrader Web API Key')
    parser.add_argument('web_api_secret',
                        default=None,
                        help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id,
                                 args.web_api_key, args.web_api_secret)

    # Account trade session
    trade_session = client.get_trade_session()
    print('Trade session status: {0}'.format(trade_session['SessionStatus']))
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id', default=None, help='TickTrader Web API Id')
    parser.add_argument('web_api_key', default=None, help='TickTrader Web API Key')
    parser.add_argument('web_api_secret', default=None, help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id, args.web_api_key, args.web_api_secret)

    # Create, modify and cancel limit order
    account = client.get_account()
    if (account['AccountingType'] == 'Gross') or (account['AccountingType'] == 'Net'):

        # Create limit order
        limit = client.create_trade(
            {
                'Type': 'Limit',
                'Side': 'Buy',
                'Symbol': 'EURUSD' if (account['AccountingType'] == 'Gross') else 'EUR/USD',
                'Amount': 10000,
                'Price': 1.0,
                'Comment': 'Buy limit from Web API sample'
            })

        # Modify limit order
        limit = client.modify_trade(
            {
                'Id': limit['Id'],
                'Comment': 'Modified limit from Web API sample'
            })

        # Cancel limit order
        client.cancel_trade(limit['Id'])
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id',
                        default=None,
                        help='TickTrader Web API Id')
    parser.add_argument('web_api_key',
                        default=None,
                        help='TickTrader Web API Key')
    parser.add_argument('web_api_secret',
                        default=None,
                        help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id,
                                 args.web_api_key, args.web_api_secret)

    # Account info
    account = client.get_account()
    print('Account Id: {0}'.format(account['Id']))
    print('Account name: {0}'.format(account['Name']))
    print('Account group: {0}'.format(account['Group']))
Beispiel #24
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id',
                        default=None,
                        help='TickTrader Web API Id')
    parser.add_argument('web_api_key',
                        default=None,
                        help='TickTrader Web API Key')
    parser.add_argument('web_api_secret',
                        default=None,
                        help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id,
                                 args.web_api_key, args.web_api_secret)

    # Account assets
    account = client.get_account()
    if account['AccountingType'] == 'Cash':
        assets = client.get_all_assets()
        for a in assets:
            print('{0} asset: {1}'.format(a['Currency'], a['Amount']))
Beispiel #25
0
def main():
    parser = argparse.ArgumentParser(description='TickTrader Web API sample')
    parser.add_argument('web_api_address', help='TickTrader Web API address')
    parser.add_argument('web_api_id',
                        default=None,
                        help='TickTrader Web API Id')
    parser.add_argument('web_api_key',
                        default=None,
                        help='TickTrader Web API Key')
    parser.add_argument('web_api_secret',
                        default=None,
                        help='TickTrader Web API Secret')
    args = parser.parse_args()

    # Create instance of the TickTrader Web API client
    client = TickTraderWebClient(args.web_api_address, args.web_api_id,
                                 args.web_api_key, args.web_api_secret)

    # Create, modify and cancel limit order
    account = client.get_account()
    if (account['AccountingType'] == 'Gross') or (account['AccountingType']
                                                  == 'Net'):

        # Create limit order
        limit = client.create_trade({
            'Type':
            'Limit',
            'Side':
            'Buy',
            'Symbol':
            'EURUSD' if (account['AccountingType'] == 'Gross') else 'EUR/USD',
            'Amount':
            10000,
            'Price':
            1.0,
            'Comment':
            'Buy limit from Web API sample'
        })

        # Modify limit order
        limit = client.modify_trade({
            'Id':
            limit['Id'],
            'Comment':
            'Modified limit from Web API sample'
        })

        # Cancel limit order
        client.cancel_trade(limit['Id'])