addisonlynch / addisonlynch/pyTD

market.get_option_chains returns only one of the strikes when the output is set to df

オープン
#6 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
12
フォーク
12
PR マージ指標
30日以内にマージされた PR はありません

説明

## Summary (include Python version)
python 3.6
In options.py lines 134,139, the code iterates over the strikes, but, always overwrites the value of previous strike. The code is:
```
for strike in out['callExpDateMap'][date]:
ret[date] = (out['callExpDateMap'][date][strike])[0]

```
I.e., you overwrite the ret[dict] in the subsequent iteration. I tried to change the dict entry to an array, i.e.,
```

strikes = []
for strike in out['callExpDateMap'][date]:
strikes.append((out['callExpDateMap'][date][strike])[0])
ret[date] = strikes

```
But, since the length of array is different for different dates, pandas throws an exception:
```

raise ValueError('arrays must all be same length')
ValueError: arrays must all be same length

```
I.e., either you pad the arrays so that all have the same length, or, just get the JSON. For now, I have decided to use the json output.
### Date/time of issue
June 4, 2020

### Expected behavior
have all the strikes in results

### Actual behavior
only one strike per day

Regards,
Behdad

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。