question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue during live trading. Cannot order XXXX on <date> as there is no last price for the security

See original GitHub issue

I’m doing a live trading using pylivetrader 0.5.1 (same issue with 0.5.2) and having these issues happen every day:

[2020-10-05 13:31:01.912238] ERROR: builtins: failed closing position with: Cannot order AAPL on 2020-10-05 13:31:00+00:00 as there is no last price for the security.
[2020-10-05 13:31:01.933311] INFO: pipeline_live.data.alpaca.pricing_loader: chart_range=5
/home/ubuntu/.zipline/data/dailycache/alpaca_chart_5: digest mismatch 38d1c082545877db0a880a8c723ec797 != c4a2fe5faf4363334722824e558a6016, reloading
[2020-10-05 13:31:13.953458] DEBUG: pipeline_live.data.sources.util: fetch: 11.18% completed
[2020-10-05 13:31:14.043624] DEBUG: pipeline_live.data.sources.util: fetch: 20.13% completed
[2020-10-05 13:31:19.523271] DEBUG: pipeline_live.data.sources.util: fetch: 31.32% completed
[2020-10-05 13:31:19.733984] DEBUG: pipeline_live.data.sources.util: fetch: 40.27% completed
[2020-10-05 13:31:24.657859] DEBUG: pipeline_live.data.sources.util: fetch: 51.45% completed
[2020-10-05 13:31:28.247525] DEBUG: pipeline_live.data.sources.util: fetch: 60.40% completed
[2020-10-05 13:31:31.176971] DEBUG: pipeline_live.data.sources.util: fetch: 71.58% completed
[2020-10-05 13:31:32.786441] DEBUG: pipeline_live.data.sources.util: fetch: 80.53% completed
[2020-10-05 13:31:36.671318] DEBUG: pipeline_live.data.sources.util: fetch: 91.05% completed
[2020-10-05 13:31:36.959422] DEBUG: pipeline_live.data.sources.util: fetch: 100.00% completed

I don’t see this issue during paper trading. Issue happens every day with different stocks.

My code:

def initialize(context):
    schedule_function(
        my_rebalance,
        date_rules.every_day(),
        time_rules.market_open()
    )
    my_pipe = make_pipeline()
    attach_pipeline(my_pipe, 'my_pipeline')

def make_pipeline():
   return <some_pipeline>

def my_rebalance(context, data):
    for s in context.portfolio.positions:
        try:
            order_target_percent(s, 0)  // HERE issue happen and I think here we detect the difference and loading the data
        except Exception as e:
            log.error(f"failed closing position with: {e}")

    df = pipeline_output('my_pipeline')
    // buy and sell logic works after data download completes

My understanding that the issue happens here: https://github.com/alpacahq/pylivetrader/blob/779e23f8622376f3685e8de2f387446093402add/pylivetrader/algorithm.py#L833

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:34 (27 by maintainers)

github_iconTop GitHub Comments

1reaction
shlomikushchicommented, Nov 29, 2020

Guys, I have merged #204 (from issue #192) onto the master branch. please do test it and let me know if you still have issues with it.

0reactions
camelpaccommented, May 29, 2021

closing due to lack of activity

Read more comments on GitHub >

github_iconTop Results From Across the Web

TWS API v9.72+: Message Codes
Code TWS message Additional notes 106 Can't transmit order ID: 107 Cannot transmit incomplete order. Order is missing a required field. 114 Relative orders are valid...
Read more >
What are Order Rejections and their Solutions in Alice Blue?
If an MCX order is placed before 09:00 am, the order gets rejected and this error is displayed. 600: Invalid trigger price for...
Read more >
Help for the Transaction Notes Screen - The Stock Market Game
Hot Tip : Transaction Notes is the first place to look when a trade your team entered does not appear in the Account...
Read more >
4210. Margin Requirements | FINRA.org
If there is no closing price, a member may use a reasonable estimate of the market value of the security as of the...
Read more >
Webmaster Frequently Asked Questions - SEC.gov
What is the lag time between the filing acceptance time from the EDGAR Filer System and availability of the documents on sec.gov?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found